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

bigblueboss's avatar

Stripe Updating Subscriptions Not Working

I got the part where I charge people. But when I try to update subscription to yearly, there seems to be a problem. Can someone help me please?

In routes.php I have: Route::get('upgrade', function() { Auth::user()->subscription('yearly')->swap(); return "upgraded!"; });

The error screen shows: FatalErrorException in Customer.php line 87:Call to undefined method Stripe_Object::save()

0 likes
6 replies
bigblueboss's avatar

---For More information---

A similar problem occurs when I try to cancel.

I've been trying to follow each line of code (doing dd() and seeing where the error occurs) and everything works right up until the middle of the code block of the "create" method within StripeGateway.php.

    $this->billable->setStripeSubscription(
        $customer->updateSubscription($this->buildPayload())->id
    );

I believe the updateSubscription method is coming from Customer.php, where it has the following code: public function updateSubscription($params = null) { if (is_null($this->subscription)) { return $this->createSubscription($params); } else { return $this->saveSubscription($params); } }

protected function saveSubscription($params)
{
    foreach ($params as $key => $value) {
        $this->subscription->{$key} = $value;
    }
    $this->subscription->save();
    return $this->subscription;
}

I think the problem that I have is in the second last line: $this->subscription->save(); If I try to dd($this->subscription) before the second last line, I get the following object: Stripe_Object {#220 ▼ #_apiKey: "sk_test_mbybwIzoLf5Imnt6Kh0jkOT7" #_values: array:19 [▶] #_unsavedValues: Stripe_Util_Set {#221 ▶} #_transientValues: Stripe_Util_Set {#222 ▶} #_retrieveOptions: [] }

So it clearly has access to the Stripe_Object. But when I try to run save() on $this->subscription, I get the error: Call to undefined method Stripe_Object::save()

So I have a few questions. I believe the error is telling me that it's looking for the save() method within Stripe_Object or any other class it extends and cannot find this method, so it cannot run it. Am I correct about this?

If I am correct, then where does the save() method come from? Is this a helper from Eloquent? If so, what would i have to extend or use and in which file?

Lastly, where is this saving happening? To my understanding, the updateSubscription method is attempting to save the new change from monthly to yearly within Stripe, and then the rest of the function originally set out by swap() will also save the changes inside our own database under "stripe_plan" column?

Would really appreciate it if anyone might be able to go through this in detail or study the material together with me.

bigblueboss's avatar
bigblueboss
OP
Best Answer
Level 4

I have the issue fixed. I maybe have forgotten to properly composer update and composer dump-autoload. For some reason laravel cashier 3.0 doesn't want to work with stripe/stripe-php 2.1, I required ~1.9 instead and i believe it decided to install 1.8 on its own. Everything working now.

bigblueboss's avatar

@blackbird I had actually started off going about it looking into stripe first. It pointed me towards stripe 2.1, and then I found out about laravel cashier. Somewhere along the way, perhaps I didn't composer dump-autoload properly.

Please or to participate in this conversation.