Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] payment_mercado_pago: fix traceback when the payment status is 404 #159649

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/payment_mercado_pago/const.py
Expand Up @@ -65,7 +65,7 @@
'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.
Expand Down
3 changes: 3 additions & 0 deletions addons/payment_mercado_pago/tests/common.py
Expand Up @@ -26,3 +26,6 @@ def setUpClass(cls):
cls.verification_data = {
'status': 'approved',
}
cls.verification_data_for_error_state = {
'status': 404,
}
12 changes: 12 additions & 0 deletions addons/payment_mercado_pago/tests/test_payment_transaction.py
Expand Up @@ -69,3 +69,15 @@ def test_processing_notification_data_confirms_transaction(self):
):
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')