Laravel Cashier: Creating new subscription on customer that already exists
I'm on Laravel 5.2, using Laravel Cashier to process and manage subscriptions to our platform. Here's what happened.
- A user's credit card expired and they forgot
- Stripe attempted the standard "3 retries" before totally failing
- All retries failed, and Stripe ends up deleting the
sub_*subscription record permanently - The user wants to resume their subscription
The trouble here is, when you evaluate $user->subscribed('main'), it will return false now for this subscription because this record has been deleted at Stripe. This means that you can't resume a subscription with $user->subscription('main')->resume(). A new subscription (sub_*) record needs to be created altogether.
As a workaround in my admin panel, I'm using this piece of code to process the creation of a brand-new subscription for a totally canceled/failed subscription (they have a valid CC on file under their still-active cus_* Stripe record):
if ( $action == 'resume' && ! $user->subscribed('main'))
{
$user->newSubscription('main', 'monthly')->create();
flash()->success('A brand new subscription has been created for this user. Their subscription has been resumed.');
}
When this piece of code was executed, this user was resubscribed, charged, with an invoice generated, but a "Whoops, look like something went wrong" error occurred:
LogicException: Unable to resume subscription that is not within grace period.
How can I fix/bypass this, when a valid cus_* record exists when creating a new subscription?
Please or to participate in this conversation.