diff --git a/addons/payment_mercado_pago/const.py b/addons/payment_mercado_pago/const.py index 0fa7765d4a4..606a17036a1 100644 --- a/addons/payment_mercado_pago/const.py +++ b/addons/payment_mercado_pago/const.py @@ -65,7 +65,7 @@ TRANSACTION_STATUS_MAPPING = { 'pending': ('pending', 'in_process', 'in_mediation', 'authorized'), 'done': ('approved', 'refunded'), 'canceled': ('cancelled', 'null'), - 'error': ('rejected'), + 'error': ('rejected',), } # Mapping of error states to Mercado Pago error messages. diff --git a/addons/payment_mercado_pago/tests/common.py b/addons/payment_mercado_pago/tests/common.py index f9e675aa29e..323db231810 100644 --- a/addons/payment_mercado_pago/tests/common.py +++ b/addons/payment_mercado_pago/tests/common.py @@ -26,3 +26,6 @@ class MercadoPagoCommon(PaymentCommon): cls.verification_data = { 'status': 'approved', } + cls.verification_data_for_error_state = { + 'status': 404, + } diff --git a/addons/payment_mercado_pago/tests/test_payment_transaction.py b/addons/payment_mercado_pago/tests/test_payment_transaction.py index a92649d4443..513bcdc4acb 100644 --- a/addons/payment_mercado_pago/tests/test_payment_transaction.py +++ b/addons/payment_mercado_pago/tests/test_payment_transaction.py @@ -69,3 +69,15 @@ class TestPaymentTransaction(MercadoPagoCommon, PaymentHttpCommon): ): tx._process_notification_data(self.redirect_notification_data) self.assertEqual(tx.state, 'done') + + @mute_logger('odoo.addons.payment_mercado_pago.models.payment_transaction') + def test_processing_notification_data_rejects_transaction(self): + """ Test that the transaction state is set to 'error' when the notification data indicate a status of + 404 error payment. """ + tx = self._create_transaction(flow='redirect') + with patch( + 'odoo.addons.payment_mercado_pago.models.payment_provider.PaymentProvider' + '._mercado_pago_make_request', return_value=self.verification_data_for_error_state + ): + tx._process_notification_data(self.redirect_notification_data) + self.assertEqual(tx.state, 'error')