One customer received 2 orders, while paid only once #1398
Closed
matks
started this conversation in
Bug reports
Replies: 1 comment
|
Hello We have published a new version v5.2.0 which should strongly mitigate the race condition issue thanks to a fix on API side. There is still things to improve on module side but the mitigation should be very efficient I believe. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I copy here the report I got because I think it's interesting
We were reported that one customer received 2 orders, while paid only once. basically 2 orders shared same payment transaction.
The issue is related to ps_checkout module and happening when there is a lot of cart_rules rules in the order. Potentially due to this something is lagging
Issue Duplicate Orders with Same Transaction ID in ps_checkout Module
We have observed cases where two separate PrestaShop orders are created for the same PayPal transaction ID multiple time
One Example:
Both rows share the same transaction_id = ...
This results in customers got two orders while only paying once.
we detail checked the code of module and we found:
PayPal webhooks are not guaranteed to be sent once.
If response is slow (e.g., due to heavy cart rules slowing down getOrderTotal()), PayPal retries the same event.
Missing idempotency check
ps_checkout calls validateOrder() without checking if transaction_id/cart already exists.
modules/ps_checkout/controller/front/webhook.php
The webhook controller (Ps_CheckoutWebhookModuleFrontController) just passes the payload to a WebhookHandler.
modules/ps_checkout/classes/ValidateOrder.php
Then eventually ValidateOrder::validateOrder() calls:
This is where duplicates can happen because:
Nothing checks if $response['body']'id' already exists in ps_order_payment.
Nothing checks if $payload['cartId'] already has an order.
This allows multiple valid PrestaShop orders to be created for the same payment.
All reactions