In this episode, we move beyond just sending users to Stripe’s billing portal for subscription management, and actually build the ability to cancel and resume subscriptions directly in our own app. We start by creating two separate partials: one for cancelling a subscription and one for resuming it. Based on the user's subscription status, we show the appropriate option (cancel if it's active, resume if cancelled-but-not-yet-ended).
We set up routes and controller methods to handle both the cancellation and resumption processes, using Laravel Cashier’s handy methods under the hood. You'll see how easy it is to call Stripe to cancel or resume subscriptions from your app, and how to reflect those changes immediately in your UI.
Towards the end, we improve the user experience a bit by displaying when a cancelled subscription will actually end, grabbing the ends_at
field from the database and showing either a date or a "diff for humans" string. We also clean up the template logic so users only see the subscription actions relevant to their current status.
By the end of the episode, you’ll have a complete feature for cancelling and resuming subscriptions right in your app—no more need to rely solely on Stripe’s portal!