limegrow / ingenico-m2-payments

2 stars 15 forks source link

Order confirmation emails are not sent after status change #28

Open stefliekens opened 2 years ago

stefliekens commented 2 years ago

Since versions above 2.9.0 the order confirmation emails are no longer sent on status change to processing. Below the configured settings: config-settings-ing

During some investigation I found probably the reason why this isn't working. In the Model\Processor class the $orderRepository->save() was removed and replace by a database transaction implementation to save the order and invoice together. But the Magento plugin Plugin/OrderStatePlugin which should trigger the email only listen on the after save action.

Here you can see the changes where I'm talking about.

I've created this patch/solution in my project. The after-save action is still triggered elsewhere during the result/redirect and/or webhook controllers, but I removed the old status check.

--- a/vendor/ingenico/m2-payment/Plugin/OrderStatePlugin.php     2021-10-18 06:54:05.000000000 +0200
+++ b/vendor/ingenico/m2-payment/Plugin/OrderStatePlugin.php     2022-02-02 20:48:35.000000000 +0100
@@ -52,8 +52,7 @@
             if ($this->cnf->getOrderConfirmationEmailMode($storeId) === OrderEmail::STATUS_ONCHANGE) {
                 $targetStatus = $this->cnf->getOrderStatusForConfirmationEmail($storeId);
                 if (!$result->getEmailSent()
-                    && $result->getData('status') == $targetStatus
-                    && $result->getOrigData('status') !== $targetStatus) {
+                    && $result->getData('status') == $targetStatus) {
                     $this->orderNotifier->notify($result);
                 }
             }
olegisk commented 2 years ago

@stefliekens Thank you for your contribution! I made PR https://github.com/limegrow/ingenico-m2-payments/pull/30

akosglue commented 2 years ago

in my case this is never equal $result->getData('status') == $targetStatus

pending_payment vs. processed

what is de rest of your configuration @stefliekens ?

akosglue commented 2 years ago

I applied the mentioned patch, but to no avail. The order confirmation is not sent, the 'afterSave' is fired 2x times but too early it seems. This is my config: any advice?

Screenshot 2022-07-14 at 08 26 25 Screenshot 2022-07-14 at 08 26 16 Screenshot 2022-07-14 at 08 26 07