I'm using Symfony EventDispatcher
in my project.
There is a trade/pay system in my project, user can create an order
, the order's status is unpaied
, when user paid the order by paypal, paypal will trigger a trade finish hook
, my project's PayNotifyController
will receive the hook.
So the question is, should I dispatch pay.success
event when I receive the hook, or after update the order's status to paid
?
pseudo code:
public function hookAction() {
$event->dispatch('pay.success');
}
then add a event subscriber to update the order's status to paid
.
or
public function hookAction() {
set_order_paid();
$event->dispatch('pay.success');
}