[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 26f3d8465d.

opw-2188889

closes odoo/odoo#45259

X-original-commit: d269bba3b9f4f4fa567a2a7084396bdf08422fa4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Joren Van Onder
2020-02-13 08:16:01 +00:00
parent d6db3bc5ef
commit aee95865bb
@@ -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 {