I'm in the process of building a web app where users can buy subscriptions for an online magazine.
The back-end is powered by PHP (Laravel) and the front-end is very light, just HTML/CSS and a little bit of vanilla JavaScript.
I'm curious to know what is the best approach to chain a bunch of actions that need to happen in a row.
For example: the user should be able to select the desired subscription period (1 day, 1 week, 1 month), pay for the subscription using an online payment processor and then have an active subscription in the app and receive an email with an access code.
What I have so far is this:
- User navigates to the subscriptions page and selects the desired period.
- Then gets redirected to the checkout page where he enters contact and billing details.
- If the entered data is valid an order is created in the app and the user gets redirected to the payment page where he can enter credit card details.
- The payment processor makes a request back to the app to inform about the payment status.
So far so good, but here's is where I need some advice. Basically, if the payment is successful I need to update the status of the order, create a new subscription, generate a new access code and send it to the user via email.
Should I create a new Laravel job to handle all this? Should I create separate jobs for each task and then call one job after another? Should I keep it simple and perform all tasks in the controller method that handles the IPN?
Thanks.