From b1c81a65729a3f6c6b1b11df6d3edd5ff6503be3 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Thu, 16 Apr 2020 08:33:21 +0000 Subject: [FIX] payment_authorize: display errors to customers Set the transaction to the state 'error' when Authorize.net responds with that status, as it will display a message to the customer to detail the problem. opw-2231276 X-original-commit: 005607fce4a22394a9f67cc4eaa52f8bf89780f0 --- addons/payment_authorize/models/authorize_request.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/payment_authorize/models/authorize_request.py') diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index 4d28aed0396..2b810f1a21d 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -226,11 +226,15 @@ class AuthorizeAPI(): 'x_response_reason_text': response.get('err_msg') } - return { + result = { 'x_response_code': response.get('transactionResponse', {}).get('responseCode'), 'x_trans_id': response.get('transactionResponse', {}).get('transId'), 'x_type': 'auth_capture' } + errors = response.get('transactionResponse', {}).get('errors') + if errors: + result['x_response_reason_text'] = '\n'.join([e.get('errorText') for e in errors]) + return result def authorize(self, token, amount, reference): """Authorize a payment for the given amount. -- cgit v1.2.3