In this episode, we dive into what happens when a customer’s subscription payment fails and how to handle the resulting "past due" status in your Laravel app using Cashier and Stripe.
First, we simulate a failed payment by using a special test card in the Stripe dashboard, showing how the subscription status in your database changes to "past due". We also walk through how, by default, your Laravel app might immediately restrict access for users whose payment fails—which isn’t always the best user experience!
To address this, we update our app to keep past due subscriptions active for a grace period. This gives customers a chance to resolve their payment issue before losing access. We show exactly how to enable this in your service provider code.
Next, we improve the user experience by adding a notification in the app’s UI whenever a payment failure occurs. Users get a prompt to update their card details, linked directly to the appropriate page (or the subscription portal), making it easy for them to fix the problem.
Finally, we test things end-to-end: once the payment is resolved, Stripe and Cashier will update the user’s subscription status automatically, and our UI banner disappears. Throughout the episode, we highlight best practices for balancing access control with a friendly recovery process for failing payments.