summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models/authorize_request.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-03 14:05:48 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-03 14:05:48 +0100
commit55b810dc70cccb23144986d54fd28bb5f91f2b1b (patch)
treea83dda56dac7f02be26f6821dea5b2f1926ea7b0 /addons/payment_authorize/models/authorize_request.py
parent8bc7cebd9c19ae8f77378d115a8401d7b7de56b0 (diff)
parent726b91b9fbc994c6b2f2cb45e36d4c224497f11b (diff)
[MERGE] forward port branch saas-11.1 up to 726b91b9fbc
Diffstat (limited to 'addons/payment_authorize/models/authorize_request.py')
-rw-r--r--addons/payment_authorize/models/authorize_request.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py
index c6a912de5d2..18c535aedcd 100644
--- a/addons/payment_authorize/models/authorize_request.py
+++ b/addons/payment_authorize/models/authorize_request.py
@@ -165,6 +165,22 @@ class AuthorizeAPI():
etree.SubElement(creditCard, "cardCode").text = card_code
etree.SubElement(root, "validationMode").text = 'liveMode'
response = self._authorize_request(root)
+
+ # If the user didn't set up authorize.net properly then the response
+ # won't contain stuff like customerProfileId and accessing text
+ # will raise a NoneType has no text attribute
+ msg = response.find('messages')
+ if msg is not None:
+ rc = msg.find('resultCode')
+ if rc is not None and rc.text == 'Error':
+ err = msg.find('message')
+ err_code = err.find('code').text
+ err_msg = err.find('text').text
+ raise UserError(
+ "Authorize.net Error:\nCode: %s\nMessage: %s"
+ % (err_code, err_msg)
+ )
+
res = dict()
res['profile_id'] = response.find('customerProfileId').text
res['payment_profile_id'] = response.find('customerPaymentProfileIdList/numericString').text