Sylius APIv2: Event sylius.order.post_complete is not triggered after order checkout completion

Hi Sylius people :slight_smile:

I complete some order via the new Sylius APIv2 /api/v2/shop/orders/{tokenValue}/complete and I do get the default Order confirmation mail. But I would like to send an additional mail for some admin person and have added a separate Event Listener which listens to the event “sylius.order.post_complete” as documented here:

But this listener is never called. If I do a checkout via the default Shop UI the listener gets called, but not if I complete the checkout via the Sylius APIv2.

Do I miss some more configuration? Or could this be some bug or is this the intended way to work, that the “sylius.order.post_complete” event won’t be triggered via the new API call?

Thanks for help!

Ahh found some solution: I have seen that the ApiBundle uses a Symfony Messenger OrderCompleted message which can be handled by some custom handler according to Symfony docs here:

But Sylius Sylius\Bundle\ApiBundle\EventHandler\OrderCompletedHandler is marked as experimental, so I’m not sure how stable this approach is :slight_smile:

Some answers by “diimpp” in Slack:

Every file of new ApiBundle is marked as experimental, point is not a runtime stability, but files are subject to change without backward comparability promise

This event is probably triggered via this route configuration[…]/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml , which exists in ShopBundle and ApiBundle provides alternate parallel solution, so it has it’s own event

It might be nice to have the same event, but it’s different and it’s not a bug