mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 50 forks source link

Many invoices with 0 amount for the same order after successful payment #605

Closed ijozwiak closed 1 year ago

ijozwiak commented 1 year ago

Description When I set in the configuration moment that the invoice should be created on the webhook with status=authorized,

image

image

orders have one invoice correct and many with price of 0 euro.

In logs, I can find many entries with the same status=authorized.

it causes because of many webhook responses with the same mollie_transaction_id and the same status=authorized

It can be related to this line: https://github.com/mollie/magento2/blob/master/Model/Client/Orders/Processors/SuccessfulPayment.php#L166

There is no verification if the invoice exists there we have only check if the status is authorized and invoice moment is set on the same step/point and that's all

Used versions

Expected behavior Only one invoice should be created, when payment is successful.

Actual behavior Orders have one invoice correct and many with price of 0 euro.

Screenshots image

Similar issue https://github.com/mollie/magento2/issues/604

Frank-Magmodules commented 1 year ago

HI @ijozwiak , based on our investigation, this issue also appears to be related to the webhook firing faster than before, which results in an update before the order is saved into Magento and seems to created extra order lines as result. 

To address this, we have implemented a solution that involves appending an encrypted order ID to the webhook URL. This will serve as a fallback in situations where the transaction ID is not found in Magento.

In such cases, we will compare the order ID from the metadata in the loaded transaction on the Mollie side and set the transaction ID to the order to process the webhook. This will ensure that the order is properly processed and any necessary actions are taken. This solution is now available within our new [2.22.0](https://github.com/mollie/magento2/releases/tag/v2.22.0) release.

We understand the importance of timely and accurate order processing and appreciate your patience as we work to resolve this issue. Please let us know if you have any further questions or concerns.

We are closing this issue now but please feel free to reopen the issue if this still occurs.