'Symfony - Dispatch event and listen in controller when route requested
I don't know if it's a good practice or what ever, but I would like to dispatch an event when an order is created, then I wish catch this event inside a controller to update the order.
I explain:
user is in checkout page then he's redirected to Stripe for the payment. On success/cancel, Stripe will redirect user on subscription_cancel or subscription_success page.
I could add the order id in the url to fetch the order after Stripe redirection. But if I dispatch an event, can I subscribe in subscribtion_cancel/subscription_success method ? With something like $event->getOrder()
With this way, I don't add the order id in the url and it's a bit more secure because the user cannot play with the url. If his order has for id : 10, the url will be subscription/success/14
, but with an event, ciao order_id !
But maybe there's a other way to do that without event ?
Thanks for help 👌😊
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|