laravel-paystack-subscription icon indicating copy to clipboard operation
laravel-paystack-subscription copied to clipboard

Error after subsciption created

Open PaulChase opened this issue 3 years ago • 1 comments
trafficstars

I passed the authorization code to the create method instead of transaction ID. the subscription was created successfully in my paystack dashbaord, but I keep getting this error

Attempt to read property "authorization_code" on int

here is my code after verifying a transction

$paymentData = paystack()->getPaymentData();

        if ($paymentData['data']['status'] !== 'success') {
            return redirect()->route('dashboard')->with('flash.banner', 'sorry your transaction was not successfull');
        }

        $authorizationCode = $paymentData['data']['authorization']['authorization_code'];

        auth()->user()->update([
            'paystack_authorization' => $authorizationCode
        ]);

        auth()->user()->newSubscription('premium', 'PLN_abcdedfghi')->create(null, auth()->user()->paystack_authorization);

        return redirect()->route('dashboard')->with('flash.banner', 'Congrats, You are now a premium user');

PaulChase avatar Sep 29 '22 11:09 PaulChase

Hi, @PaulChase thanks for pointing this out. It seems some responses from Paystack may have changed. I will look into this.

timoladoyinbo avatar Sep 29 '22 12:09 timoladoyinbo