diff --git a/addons/payment_mercado_pago/i18n/payment_mercado_pago.pot b/addons/payment_mercado_pago/i18n/payment_mercado_pago.pot index c7df332741a..f0afaddb5ae 100644 --- a/addons/payment_mercado_pago/i18n/payment_mercado_pago.pot +++ b/addons/payment_mercado_pago/i18n/payment_mercado_pago.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 17.0\n" +"Project-Id-Version: Odoo Server 17.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-26 21:56+0000\n" -"PO-Revision-Date: 2023-10-26 21:56+0000\n" +"POT-Creation-Date: 2024-02-06 13:57+0000\n" +"PO-Revision-Date: 2024-02-06 13:57+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -147,6 +147,15 @@ msgid "" "information: '%s' (code %s)" msgstr "" +#. module: payment_mercado_pago +#. odoo-python +#: code:addons/payment_mercado_pago/models/payment_provider.py:0 +#, python-format +msgid "" +"The communication with the API failed. The response is empty. Please verify " +"your access token." +msgstr "" + #. module: payment_mercado_pago #: model:ir.model.fields,help:payment_mercado_pago.field_payment_provider__code msgid "The technical code of this payment provider." diff --git a/addons/payment_mercado_pago/models/payment_provider.py b/addons/payment_mercado_pago/models/payment_provider.py index d3697e3fb57..c72ed5e68fe 100644 --- a/addons/payment_mercado_pago/models/payment_provider.py +++ b/addons/payment_mercado_pago/models/payment_provider.py @@ -65,13 +65,19 @@ class PaymentProvider(models.Model): _logger.exception( "Invalid API request at %s with data:\n%s", url, pprint.pformat(payload), ) - response_content = response.json() - error_code = response_content.get('error') - error_message = response_content.get('message') - raise ValidationError("Mercado Pago: " + _( - "The communication with the API failed. Mercado Pago gave us the following " - "information: '%s' (code %s)", error_message, error_code - )) + try: + response_content = response.json() + error_code = response_content.get('error') + error_message = response_content.get('message') + raise ValidationError("Mercado Pago: " + _( + "The communication with the API failed. Mercado Pago gave us the" + " following information: '%s' (code %s)", error_message, error_code + )) + except ValueError: # The response can be empty when the access token is wrong. + raise ValidationError("Mercado Pago: " + _( + "The communication with the API failed. The response is empty. Please" + " verify your access token." + )) except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): _logger.exception("Unable to reach endpoint at %s", url) raise ValidationError(