Creating an interface for the user to manage subscriptions
Alright, the preceding recipe made it possible for people to subscribe, but what happens when they want to change the plan or cancel it!
I will cover making an area where they can update or swap out their plan. You can take this much further at the UI level. I am keeping it very simple.
Getting ready
See the preceding recipes, as you really need to have the cashier set up to get this far.
How to do it…
I will make a controller to keep our logic in one controller:
> php artisan make:controller SubscriptionSwapController
Then, I will make the route for this controller:
Now, to add some logic to the repository class called
app/Repositories/SubscribeRepository.php
, the controller uses:Update the previous view for
resources/views/stripe/status.blade.php
:Now, the UI will look like this at
/user/membership
:When you press the button:
That's it! It will swap out memberships for you and make a new invoice.
How it works…
Like I said at the start...