-
- Downloads
[FIX] payment_stripe: add idempotency key to prevent multiple payments
Video 1 (Issue): https://drive.google.com/file/d/1oXYcDJgaT9gmhkjE08yJlXwIL1qPwS1Y/view?usp=sharing Issue: When using the register payment with a token with any of the payment acquirers, if there is a concurrent access error during the reconciliation process, the payment intent is sent multiple times to the acquirer, making the card charged multiple times. Steps to reproduce: -Have a V14 database (only tested this version) with sale_mmanagement, payment_stripe and invoicing -Configure Stripe with your public and secret key (2FA is now enforced for Stripe accounts, therefore, we don't have a generic test account anymore. You have to create your own.It is quite fast and easy to do) -Have a portal user PU with an already registered payment token PT -Go to Invoicing -Create a new invoice I: -Customer PU -Add anything in invoice lines -Confirm I -Register a payment for I: -Journal: Stripe -Saved Payment token: PT AT THIS STEP, YOU MUST ENSURE A CONCURRENT ACCESS ERROR WILL RAISE DURING THE RECONCILIATION -Create Payment Log analysis: A first payment intent is sent to Stripe. The card is charged and Stripe answers that all went as expected. We try to process the payment, but a concurrent access error occurs. A retry is done. A payment intent is sent again to Stripe, The card is charged AGAIN and Stripe answers that all went as expected. We try to process the payment, but a concurrent access error occurs. For each retry, the intent is sent and the card is charged. If the first retry succeeds, then Odoo can finish the process. There will be only 1 payment transaction on Odoo's side (others have been rollbacked) but there will be 3 on Stripe's side and the card will be charged 3 times. This PR mitigate this behaviour. It doesn't address the root cause but by adding the idempotency key to the headers with the hash of the transaction reference and the database UUID, we prevent mutliple payments to happen. OPW-2662964 closes odoo/odoo#101243 Signed-off-by:Antoine Vandevenne (anv) <anv@odoo.com>
Please register or sign in to comment