0

I'm currently in the process of developing a heavily Recurly integrated platform that Users constantly have the option of adding/editing/removing features that will immediately be reflected in their subscription pricing.

The environment for this project is Laravel 5.1 and attempting to use Recurly's PHP Client to simplify the API integration. In order to get a lot of the Recurly stuff to work, I had to add namespacing to the Recurly PHP Files in order to have them successfully referenced and reference one another inside Laravels Framework. i.e.

<?php

namespace App\Libraries\Recurly;

use DateTime;
use DOMDocument;

abstract class Recurly_Base
{

to all 44 or so class files involved in the 2.5.* version of the Recurly PHP library.

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.

Call to private method Recurly_Base::addLink() from context 'App\Libraries\Recurly\Recurly_Base'

This error is thrown during this block of code

        $user = $request->user();

        $subscription = Recurly_Subscription::get($user->recurly_subscription_code);
        $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(); // <- The offending line

        $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.

  • Did you download it and integrate it yourself, or use composer? – aynber Jul 15 '16 at 17:44
  • Used composer to acquire the package, and then migrated the files to app/Libraries/Recurly, where I added the namespace App\Libraries\Recurly to the head of each class file. – Robert Minnix Jul 15 '16 at 17:52
  • Unless you're heavily adapting the package, you shouldn't need to move it. You can just leave it where it installed and call it as if it were any other included package. If you are adapting the package, I'd recommend creating your own class and extending Recurly. This will help if/when they update their package. – aynber Jul 15 '16 at 17:56
  • The issue there is that the Recurly PHP Client isn't namespaced at all on its own, and they rely on you using include() to include their primary php file that then includes all of the remaining php files of the library. It doesn't meet PSR-4 or even PSR-0 standards, so I had to modify it in able to reference it in the framework. – Robert Minnix Jul 15 '16 at 18:07

0 Answers0