diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-11-20 18:56:01 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-11-20 18:56:01 +0100 |
| commit | f0a1bc81eb65fd570da2f1fc70e1eba4202a5246 (patch) | |
| tree | 11c62fc24b18d352ebe5a19a4336b7f2ef087727 /addons/payment_authorize | |
| parent | 0bf7ab45119e7b441dd071118b2dfa4db9e3b90d (diff) | |
| parent | f4a54d7f664b03c3c692f114b59cb814603e848c (diff) | |
[MERGE] forward port branch 10.0 up to f4a54d7f664
Diffstat (limited to 'addons/payment_authorize')
| -rw-r--r-- | addons/payment_authorize/models/authorize_request.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index 1ae0e71b6ed..6e0987b2de6 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from lxml import etree, objectify +import logging from urllib2 import urlopen, Request from StringIO import StringIO import xml.etree.ElementTree as ET @@ -11,6 +12,8 @@ from odoo import _ XMLNS = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' +_logger = logging.getLogger(__name__) + def strip_ns(xml, ns): """Strip the provided name from tag names. @@ -58,11 +61,13 @@ class AuthorizeAPI(): :param etree._Element data: etree data to process """ - data = etree.tostring(data, xml_declaration=True, encoding='utf-8') - request = Request(self.url, data) + data_tree = etree.tostring(data, xml_declaration=True, encoding='utf-8') + request = Request(self.url, data_tree) request.add_header('Content-Type', 'text/xml') + _logger.debug('Authorize.net request sent: \n%s', etree.tostring(data, pretty_print=True)) response = urlopen(request).read() response = strip_ns(response, XMLNS) + _logger.debug('Authorize.net response: \n%s', etree.tostring(response, pretty_print=True)) if response.find('messages/resultCode').text == 'Error': messages = map(lambda m: m.text, response.findall('messages/message/text')) raise ValidationError(_('Authorize.net Error Message(s):\n %s') % '\n'.join(messages)) |
