[MERGE] forward port branch saas-14 up to 0601b21bb5

This commit is contained in:
Denis Ledoux
2019-05-21 15:27:22 +02:00
3 changed files with 18 additions and 9 deletions
+1 -1
View File
@@ -498,7 +498,7 @@ class PaymentTransaction(models.Model):
# custom create # custom create
custom_method_name = '%s_create' % acquirer.provider custom_method_name = '%s_create' % acquirer.provider
if hasattr(acquirer, custom_method_name): if hasattr(self, custom_method_name):
values.update(getattr(self, custom_method_name)(values)) values.update(getattr(self, custom_method_name)(values))
# Default value of reference is # Default value of reference is
@@ -4,12 +4,14 @@ from urllib2 import urlopen, Request
from StringIO import StringIO from StringIO import StringIO
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from uuid import uuid4 from uuid import uuid4
import logging
from odoo import _ from odoo import _
from odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError
from odoo import _ from odoo import _
XMLNS = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' XMLNS = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
_logger = logging.getLogger(__name__)
def strip_ns(xml, ns): def strip_ns(xml, ns):
@@ -183,6 +185,12 @@ class AuthorizeAPI():
etree.SubElement(customer, "email").text = partner.email or '' etree.SubElement(customer, "email").text = partner.email or ''
response = self._authorize_request(root) response = self._authorize_request(root)
res = dict() 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['profile_id'] = response.find('customerProfileId').text
res['payment_profile_id'] = response.find('customerPaymentProfileIdList/numericString').text res['payment_profile_id'] = response.find('customerPaymentProfileIdList/numericString').text
root_profile = self._base_tree('getCustomerPaymentProfileRequest') root_profile = self._base_tree('getCustomerPaymentProfileRequest')
+9 -8
View File
@@ -230,14 +230,15 @@ class TxAuthorize(models.Model):
(self.type == 'form_save' or self.acquirer_id.save_token == 'always'): (self.type == 'form_save' or self.acquirer_id.save_token == 'always'):
transaction = AuthorizeAPI(self.acquirer_id) transaction = AuthorizeAPI(self.acquirer_id)
res = transaction.create_customer_profile_from_tx(self.partner_id, self.acquirer_reference) res = transaction.create_customer_profile_from_tx(self.partner_id, self.acquirer_reference)
token_id = self.env['payment.token'].create({ if res:
'authorize_profile': res.get('profile_id'), token_id = self.env['payment.token'].create({
'name': res.get('name'), 'authorize_profile': res.get('profile_id'),
'acquirer_ref': res.get('payment_profile_id'), 'name': res.get('name'),
'acquirer_id': self.acquirer_id.id, 'acquirer_ref': res.get('payment_profile_id'),
'partner_id': self.partner_id.id, 'acquirer_id': self.acquirer_id.id,
}) 'partner_id': self.partner_id.id,
self.payment_token_id = token_id })
self.payment_token_id = token_id
return True return True
elif status_code == self._authorize_pending_tx_status: elif status_code == self._authorize_pending_tx_status:
self.write({ self.write({