Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AudunS's avatar

Stripe: Stripe\Customer instance: subscriptions / member function retrieve()

Hello.

I am trying to get Laravel and Stripe up and running. I have choosen to connect the subscription to the account, and not the user, as it fits my model.

'stripe' => [
        'model' => App\Account::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET')
],

I have followed the howto on the Cashier-page. Creating a subscription (this is in Stripe's test-mode) works fine from Tinker, doing this:

\Stripe\Stripe::setApiKey(THE STRIPE API KEY);
\Stripe\Token::create(array("card" => array("number" => "4242424242424242","exp_month" => 1,"exp_year" => 2017,"cvc" => "314")));
$account->newSubscription('foo', 'bar')->create($creditCardToken);

The subscription is saved to the database, and visible in Stripes dashboard.

Then I try to increase the quantity of the subscription, this way:

$account = Account::find(1);
$account->subscription('ACT_USER_MONTH')->incrementQuantity(2);

That gives me these errors:

Stripe Notice: Undefined property of Stripe\Customer instance: subscriptions
Fatal error: Call to a member function retrieve() on null  

I am not familiar enough with Laravel to figure out what I have done wrong.

Any help is appreciated :)

0 likes
0 replies

Please or to participate in this conversation.