Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Update Subscriptions using 2.5.* in Laravel 5.1 #253

Closed
ram651 opened this issue Jul 15, 2016 · 4 comments
Closed

Unable to Update Subscriptions using 2.5.* in Laravel 5.1 #253

ram651 opened this issue Jul 15, 2016 · 4 comments
Labels
V2 V2 Client

Comments

@ram651
Copy link

ram651 commented Jul 15, 2016

I am trying to update Subscriptions dynamically using the Recurly PHP Library under the Laravel 5.1 Framework. Since the library isn't designed with PSR-4 in mind, I had to add namespacing to the tops of each of the library files in order to reference them appropriately.

I believe that this might affect the behavior of the library, but as you can see in the below error, the context that the private method is being called from is the context of the Class itself the private method belongs to.

Error thrown:

FatalErrorException in base.php line 311:
Call to private method Recurly_Base::addLink() from context 'App\Libraries\Recurly\Recurly_Base'

This is an example of the modifications I made to the class files included in the Recurly PHP Client.

<?php    
    namespace App\Libraries\Recurly;

    use DateTime;
    use DOMDocument;

    abstract class Recurly_Base
    {

I can successfully use the library to generate subscriptions, but any time I try to update those subscriptions, I get this FatalErrorException thrown by PHP, and thrown by the same class I exampled above.

                        $user = $request->user();

            $subscription = Recurly_Subscription::get($user->recurly_subscription_code);// <- The offending line
            $subscription->plan_code = '<plan_code>';

            $user->subscription_pricing = $user->subscription_pricing + $newItemPrice;
            $user->updated_at = $user->freshTimestamp();


            $subscription->unit_amount_in_cents =  $user->subscription_pricing;

            $subscription->updateImmediately(); 

            $user->save();

It seems that for some reason, the Recurly_Base class cannot access it's own private method addLink.

I attempted to resolve the issue by weakening the Visibility of all Recurly_Base methods and values so that the 'private'-ness of addLink wouldn't matter, but the FatalErrorException was still thrown.

@cyruscollier
Copy link

I'm sure the authors of this library will add namespacing at some point, but why would you need to alter the library with namespaces to be compatible with Laravel? Using the standard Autoloading via Composer should allow you access to the Recurly classes directly or through the Laravel DI container.

@ram651
Copy link
Author

ram651 commented Jul 25, 2016

There were issues with the heavy dependencies between classes and some
private methods, as I described above.

There is a PSR4-compliant version of the library, that someone made a pull
request for, that I pulled down and have been using successfully since then.

On Jul 25, 2016 8:35 AM, "Cyrus Collier" notifications@github.com wrote:

I'm sure the authors of this library will add namespacing at some point,
but why would you need to alter the library with namespaces to be
compatible with Laravel? Using the standard Autoloading via Composer should
allow you access to the Recurly classes directly or through the Laravel DI
container.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#253 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIZ5Ii3BFWYMa2D2UjYwbXz8dZn9ywA3ks5qZNe2gaJpZM4JN2VF
.

@ram651 ram651 closed this as completed Jul 25, 2016
@drewish
Copy link

drewish commented Aug 1, 2016

i just noticed https://packagist.org/packages/digital-canvas/recurly-client-laravel i'm not sure if it's up to date or what though.

@ram651
Copy link
Author

ram651 commented Aug 1, 2016

That package was implemented for Laravel 4.1/4.2 whereas my project is in
Laravel 5.1, the LTS that modified how classes/packages are namespaced and
referenced from within the framework. Unfortunately, I had hoped that
package would have worked, but did not.

On Aug 1, 2016 12:12 PM, "andrew morton" notifications@github.com wrote:

i just noticed
https://packagist.org/packages/digital-canvas/recurly-client-laravel i'm
not sure if it's up to date or what though.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#253 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIZ5Il5JLKCIk668MjFz5zFnvfPrS6C2ks5qbkUMgaJpZM4JN2VF
.

@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

4 participants