In this episode, we build out the billing area of our app where users can manage their subscriptions. First, we set up a new set of routes for subscription management, making sure they’re protected so only logged-in users can access them. Then, we create a view to show subscription info, using partials to keep the code nice and organized.
For users without an active subscription, we display a friendly "Choose a plan" button so they can pick one. Then, when a user is subscribed, we want them to have an easy way to manage their subscription (like canceling or updating their payment info). The main focus is adding a "Manage your subscription" button that sends the user right over to the Stripe billing portal.
To make this work, we hook up a controller method that uses Laravel Cashier’s built-in way to create a secure Stripe billing portal session. We pass in a URL so Stripe knows where to send users when they’re done. After a quick detour to enable the portal in our Stripe account, everything clicks into place – users can view their plan, change payment info, or download invoices, and when they’re finished, they’re sent back to our app. This gives our users a straightforward, secure place to handle all their billing needs, while saving us lots of coding and compliance headaches.