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

raphadko's avatar

Cashier generating multiple customers with the same email

I'm using cashier for my subscription plans. Every time I change the user's card with $user->updateCard($stripeToken); a new customer is generated on Stripe, with a new card but same e-mail, when in reality it should just update a customer's card. What could I be doing wrong?

0 likes
7 replies
raphadko's avatar

This appears to be a coded bug in cashier. All my settings appear right.. Can anyone help?

theUnforgiven's avatar

Have you referred to docs?

Also show us your code and we can try and help.

raphadko's avatar

Code is pretty simple, just a basic credit card update;

$user = \Auth::user();
$stripeToken = \Input::get('stripeToken');
$user->updateCard($stripeToken);
return 'ok';
1 like
braxton's avatar

Can you maybe post the updateCard() function here?

raphadko's avatar

Sure, from cashier's billable class:

public function updateCard($token)
{
    return $this->subscription()->updateCard($token);
}

And from Cashier's StripeGateway:

public function updateCard($token)
{
    $customer = $this->getStripeCustomer();

    $card = $customer->sources->create(['source' => $token]);

    $customer->default_source = $card->id;

    $customer->save();

    $this->billable
         ->setLastFourCardDigits($this->getLastFourCardDigits($this->getStripeCustomer()))
         ->saveBillableInstance();
}
raphadko's avatar

Ok, the error was that ajax was submitting the request to another route. After 2 days searching for this, I feel stupid. :(

theUnforgiven's avatar

Always something simple you've over looked, I do that on a regular basis, don't worry about it, just see it as a learning curve :)

1 like

Please or to participate in this conversation.