[FIX] payment_ogone: better error reason when payment is declined
Before this revision, when a payment was declined, for instance because the authorization is declined by the bank, or the credit card amount limit is exceeded, the error was marked as "Received data with invalid payment status: 2" which is not very meaningful for the users. This revision aims to set the reason why the payment was declined with the meaningful error from ogone. closes odoo/odoo#80742 X-original-commit: 758f94a173379ba7bd22813b2050e3a6f98210a9 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,),
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user