Skip to content

Commit

Permalink
[FIX] payment_mercado_pago: fix traceback when the payment status is 404
Browse files Browse the repository at this point in the history
This traceback arises when the payment status is 404

A comma at the end is forgotten while creating a tuple with single
record, which leads to a typeerror traceback.

Error:- "TypeError: 'in <string>' requires string as left operand, not int"

https://github.com/odoo/odoo/blob/7e3267fc69324a3c98d36983705a50420b5143f9/addons/payment_mercado_pago/const.py#L35-L39

sentry-5103720097

closes #159609

X-original-commit: 9094afe
Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
  • Loading branch information
alsh-odoo committed Mar 28, 2024
1 parent e323e3a commit b33480a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/payment_mercado_pago/const.py
Expand Up @@ -36,7 +36,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')

0 comments on commit b33480a

Please sign in to comment.