1
votes

I'm using Laravel's Cashier to handle my subscription plans on Laravel 5.1. Every time I change the user's card with

$user->updateCard($stripeToken);

a new customer is generated on Stripe, with a new card, new id but same e-mail, when in reality it should just update a customer's card. I've looked in the documentation but didn't find what could be wrong. Could someone help?

1
Any updates on this?Marcel Gruber
my problem was actually kinda stupid, I was submitting for another route.. the accepted solution should work.sigmawf

1 Answers

2
votes

The only thing I could see that might be a possible problem is that you might be calling the method on the wrong instance. Maybe you need to do something like this?

$user->subscription()->updateCard($stripeToken);

Also, make sure that the $user object you're calling it on is the user you are expecting.

Here is what my method looks like when the user updates their CC details.

protected function updateCreditCard($creditCardToken){
    $company = Auth::user()->company;
    // subscription() is a StripeGateway object.
    $company->subscription()->updateCard($creditCardToken);
}