diff --git a/addons/payment_ogone/i18n/payment_ogone.pot b/addons/payment_ogone/i18n/payment_ogone.pot index 452165becf7..6bf2d7ee910 100644 --- a/addons/payment_ogone/i18n/payment_ogone.pot +++ b/addons/payment_ogone/i18n/payment_ogone.pot @@ -136,6 +136,12 @@ msgstr "" msgid "The communication with the API failed." msgstr "" +#. module: payment_ogone +#: code:addons/payment_ogone/models/payment_transaction.py:0 +#, python-format +msgid "The payment has been declined: %s" +msgstr "" + #. module: payment_ogone #: code:addons/payment_ogone/models/payment_transaction.py:0 #, python-format diff --git a/addons/payment_ogone/models/const.py b/addons/payment_ogone/models/const.py index b842dfe2354..cab223f5ad6 100644 --- a/addons/payment_ogone/models/const.py +++ b/addons/payment_ogone/models/const.py @@ -74,4 +74,5 @@ PAYMENT_STATUS_MAPPING = { 'pending': (41, 46, 50, 51, 52, 55, 56, 81, 82, 91, 92, 99), # 46 = 3DS 'done': (5, 8, 9), 'cancel': (1,), + 'declined': (2,), } diff --git a/addons/payment_ogone/models/payment_transaction.py b/addons/payment_ogone/models/payment_transaction.py index 604140947db..fa59f173b60 100644 --- a/addons/payment_ogone/models/payment_transaction.py +++ b/addons/payment_ogone/models/payment_transaction.py @@ -204,6 +204,17 @@ class PaymentTransaction(models.Model): self._set_done() elif payment_status in const.PAYMENT_STATUS_MAPPING['cancel']: self._set_canceled() + elif payment_status in const.PAYMENT_STATUS_MAPPING['declined']: + if data.get("NCERRORPLUS"): + reason = data.get("NCERRORPLUS") + elif data.get("NCERROR"): + reason = "Error code: %s" % data.get("NCERROR") + else: + reason = "Unknown reason" + _logger.info("the payment has been declined: %s.", reason) + self._set_error( + "Ogone: " + _("The payment has been declined: %s", reason) + ) else: # Classify unknown payment statuses as `error` tx state _logger.info( "received data with invalid payment status (%s) for transaction with reference %s",