From 4a636582a4a044d5bd8ac1cc286ccf4b5cda80ea Mon Sep 17 00:00:00 2001 From: mafo-odoo Date: Tue, 4 Oct 2022 06:55:09 +0000 Subject: [PATCH] [FIX] payment_payulatam: cancel transaction can be set to done Steps to reproduce: A) Share a payment link and pay with PayU Latam (you'll be redirected to their checkout page) B) Make sure that your first payment attempt with Pay U Latam fails (they provide the cards info to simulate successful and failed payments) C) After the first failed attempt, stay on the same checkout page and do a second attempt (this time a successful attempt) D) Click on 'Go back to the website of the shop' (still on the checkout page). Current behavior: Odoo will show 'Your payment has been canceled' Expected behvavior: Odoo will show 'Your payment has been confirmed' Explanation: After the first payment failure payulatam calls the webhook to cancel the transaction but after it lets the user the possibilty to retry the same payment again and if the payment succeed it calls the webhook again to confirm the transaction but it can not as the transaction is already in a canceled state. To prevent this issue we allow the payulatam webhook to set the transaction from canceled to done by adding canceled in the allowed states of _set_done() opw-2994527 closes odoo/odoo#103066 X-original-commit: 162b4a4fb958b8568a2d99625934b9b4f4dfa103 Signed-off-by: Antoine Vandevenne (anv) --- addons/payment/models/payment_transaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/payment/models/payment_transaction.py b/addons/payment/models/payment_transaction.py index 80d7ba7af29..da240e56c09 100644 --- a/addons/payment/models/payment_transaction.py +++ b/addons/payment/models/payment_transaction.py @@ -666,7 +666,7 @@ class PaymentTransaction(models.Model): :return: The updated transactions. :rtype: recordset of `payment.transaction` """ - allowed_states = ('draft', 'pending', 'authorized', 'error') + allowed_states = ('draft', 'pending', 'authorized', 'error', 'cancel') # 'cancel' for Payulatam target_state = 'done' txs_to_process = self._update_state(allowed_states, target_state, state_message) txs_to_process._log_received_message()