I am using Laravel 5.3 with Cashier. If a customer updates their card details, how can I check if there is a pending invoice and ask Stripe to re-attempt the charge on the new card? At the moment, I have set the settings for attempts in Stripe dashboard. But from what I understand, Stripe does not automatically attempt to charge the customer if they updated their card details and it waits for the next attempt date to try again. Thats why I want to manually attempt to charge the customer on pending invoice as soon as they update their card. I read the Cashier documentation and Github page but this case is not covered there.
$user->updateCard($token);
// Next charge customer if there is a pending invoice
Can someone help me out please.
After testing and talking with Stripe support, I found out the problem with the current
updateCard()
method used in Laravel Cashier.With the current
updateCard()
method, the card is added to the sources list and then sets the new card as thedefault_source
. the result of this method has 2 outcomes:Multiple cards gets added to the list although the recent one is set as
default_source
When updating the card using this method, if there are any unpaid invoices (i.e. invoices in
past_due
state), they are not automatically charged.In order for stripe to re-attempt charging customer on all invoices in
past_due
state, thesource
parameter needs to be passed. So I have created a new method something like this:I have created a Pull request for this addition. Since editing the
Billable
file directly for any changes is not a good idea, if this doesnt get added to Cashier, then you can use the following in the Controller file to do it directly from there: