summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models/authorize_request.py
diff options
context:
space:
mode:
authorjev-odoo <jev@odoo.com>2019-05-16 06:49:56 +0000
committerNicolas Martinelli <nim@odoo.com>2019-05-20 11:29:08 +0000
commit0a1a950c256c162bb3070d72d2dcdb9e8ab7cf1c (patch)
tree400f326e9392a96ae3d72a587c70f0af1f504671 /addons/payment_authorize/models/authorize_request.py
parentdf4dcc8932e4488bd499e69fbf5a3fd769a9d927 (diff)
[FIX] payment_authorize: no customer profile don't crash transaction
When transaction is approved, if for any reason the `customerProfileId` is missing from the response, the transaction is aborted. It should succeed even if we cannot create a customer profile. opw-1998505 closes odoo/odoo#33501 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/payment_authorize/models/authorize_request.py')
-rw-r--r--addons/payment_authorize/models/authorize_request.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py
index fef82365b71..04291b5d133 100644
--- a/addons/payment_authorize/models/authorize_request.py
+++ b/addons/payment_authorize/models/authorize_request.py
@@ -4,12 +4,14 @@ from urllib2 import urlopen, Request
from StringIO import StringIO
import xml.etree.ElementTree as ET
from uuid import uuid4
+import logging
from odoo import _
from odoo.exceptions import ValidationError, UserError
from odoo import _
XMLNS = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
+_logger = logging.getLogger(__name__)
def strip_ns(xml, ns):
@@ -183,6 +185,12 @@ class AuthorizeAPI():
etree.SubElement(customer, "email").text = partner.email or ''
response = self._authorize_request(root)
res = dict()
+ if not response.find('customerProfileId'):
+ _logger.warning(
+ 'Unable to create customer payment profile, data missing from transaction. Transaction_id: %s - Partner_id: %s'
+ % (transaction_id, partner)
+ )
+ return res
res['profile_id'] = response.find('customerProfileId').text
res['payment_profile_id'] = response.find('customerPaymentProfileIdList/numericString').text
root_profile = self._base_tree('getCustomerPaymentProfileRequest')