From aee95865bb6e4e0a0a3b0baa34ea8e4f1ec065d2 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 12 Feb 2020 21:00:29 +0000 Subject: [PATCH] [IMP] payment_authorize: log API responses Makes debugging possible without having to run the db locally and manually adding _loggers everywhere. Parts of the error are logged already, leading to messages like: ...payment_authorize.models.payment: The transaction was unsuccessful Unfortunately they don't show the reason. The entire response is something like: {'messages': {'message': [{'code': 'E00027', 'text': 'The transaction was unsuccessful.'}], 'resultCode': 'Error'}, 'transactionResponse': {'SupplementalDataQualificationIndicator': 0, 'accountNumber': '', 'accountType': '', 'authCode': '', 'avsResultCode': 'P', 'cavvResultCode': '', 'cvvResultCode': '', 'errors': [{'errorCode': '5', 'errorText': 'A valid amount is ' 'required.'}], 'refTransID': '', 'responseCode': '3', 'testRequest': '0', 'transHash': '', 'transHashSha2': '', 'transId': '0'}} Since we log the full request above, let's also log the full response. PS. this was present before but was lost with 26f3d8465d3c6f1da80c186. opw-2188889 closes odoo/odoo#45259 X-original-commit: d269bba3b9f4f4fa567a2a7084396bdf08422fa4 Signed-off-by: Nicolas Martinelli (nim) --- addons/payment_authorize/models/authorize_request.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index 80b9e4bdbf2..dce188477ba 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -44,6 +44,7 @@ class AuthorizeAPI(): resp = requests.post(self.url, json.dumps(data)) resp.raise_for_status() resp = json.loads(resp.content) + _logger.info("_authorize_request: Received response:\n%s", resp) messages = resp.get('messages') if messages and messages.get('resultCode') == 'Error': return {