duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
147 stars 41 forks source link

Fix: Gateway not included in order when listening to `OrderPaid` event #817

Closed duncanmcclean closed 1 year ago

duncanmcclean commented 1 year ago

This pull request fixes an issue where the gateway wasn't being included in the $order parameter of the OrderPaid event which was happening due to a timing issue.

The OrderPaid event is dispatched by the BaseGateway@markOrderAsPaid method.

However, the gateway was only set in the Manager@purchase method & was run based on if the purchase method in the gateway returned as being successful.

This meant that developers who wanted to include the gateway name in their order paid notifications weren't able to do so as they couldn't tell which gateway was used.

This PR sets the order's gateway in the BaseGateway@markOrderAsPaid method before the event is dispatched, this means it's available for those who need it.

It's worth noting any of the 'gateway data' won't be available in the event because we can't get that until the payment method has ran.

github-actions[bot] commented 1 year ago

Released as part of v4.5.4.