diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-28 15:36:23 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-28 15:52:00 +0200 |
| commit | cffd147cfd4767f57dc6deeb0a956361904e1b1b (patch) | |
| tree | 8a5990635ca60e0f34fc59462ed694847714db5b /addons/payment_authorize/models | |
| parent | e9350993ca0b81df17308766d7e26d458bc39520 (diff) | |
| parent | a20a31486cd0b99755f8e6c27281ac6ba4758b7a (diff) | |
[MERGE] forward port branch 11.0 up to a20a31486cd
Diffstat (limited to 'addons/payment_authorize/models')
| -rw-r--r-- | addons/payment_authorize/models/authorize_request.py | 6 | ||||
| -rw-r--r-- | addons/payment_authorize/models/payment.py | 21 |
2 files changed, 17 insertions, 10 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index d9b87437577..109cf455f6d 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -224,6 +224,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') diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py index cf55effdd12..0c95a444c64 100644 --- a/addons/payment_authorize/models/payment.py +++ b/addons/payment_authorize/models/payment.py @@ -240,17 +240,18 @@ class TxAuthorize(models.Model): (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 - if self.payment_token_id: - self.payment_token_id.verified = True + if self.payment_token_id: + self.payment_token_id.verified = True return True elif status_code == self._authorize_pending_tx_status: self.write({ |
