Skip to content

Commit

Permalink
[MERGE] forward port branch saas-14 up to 0601b21
Browse files Browse the repository at this point in the history
  • Loading branch information
beledouxdenis committed May 21, 2019
2 parents 68b7f2a + 0601b21 commit b1e1c78
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion addons/payment/models/payment_acquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def create(self, values):

# custom create
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))

# Default value of reference is
Expand Down
8 changes: 8 additions & 0 deletions addons/payment_authorize/models/authorize_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
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):
Expand Down Expand Up @@ -183,6 +185,12 @@ def create_customer_profile_from_tx(self, partner, transaction_id):
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')
Expand Down
17 changes: 9 additions & 8 deletions addons/payment_authorize/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,15 @@ def _authorize_form_validate(self, data):
(self.type == 'form_save' or self.acquirer_id.save_token == 'always'):
transaction = AuthorizeAPI(self.acquirer_id)
res = transaction.create_customer_profile_from_tx(self.partner_id, self.acquirer_reference)
token_id = self.env['payment.token'].create({
'authorize_profile': res.get('profile_id'),
'name': res.get('name'),
'acquirer_ref': res.get('payment_profile_id'),
'acquirer_id': self.acquirer_id.id,
'partner_id': self.partner_id.id,
})
self.payment_token_id = token_id
if res:
token_id = self.env['payment.token'].create({
'authorize_profile': res.get('profile_id'),
'name': res.get('name'),
'acquirer_ref': res.get('payment_profile_id'),
'acquirer_id': self.acquirer_id.id,
'partner_id': self.partner_id.id,
})
self.payment_token_id = token_id
return True
elif status_code == self._authorize_pending_tx_status:
self.write({
Expand Down

0 comments on commit b1e1c78

Please sign in to comment.