summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-04-04 12:22:29 +0000
committerNicolas Lempereur <nle@odoo.com>2019-04-04 12:46:00 +0000
commit95c9227cb327912645e855767ed0e4daed6cadd5 (patch)
treeb7b62523223eecedda263102289a25eb5106888b /addons/payment_authorize/models
parentfde76dd9b8f88b322f73a09bf5758b7c3ef28975 (diff)
[FIX] payment_authorize: >1m partner ok transaction
When creating a customer profile in Authorize.Net we specify a field merchantCustomerId that is composed of: ODOO-{partner-id}-{8-random-characters} But the limit of this field is of 20 characters: https://developer.authorize.net/api/reference/index.html#payment-transactions So if we have 1 million partner, we may have eg. a partner 1000005 that would result in an ID `ODOO-1000005-af123c5b` that is too long and results in an error. With this changeset, the generated ID is truncated to 20 characters so this should theorically be alright for up to 9.99*10^15 partners (the postgres limit for an integer is 2.15*10^9 so this should be safe enough). opw-1962422 closes #32423 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/payment_authorize/models')
-rw-r--r--addons/payment_authorize/models/authorize_request.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py
index bca2164dac1..79d0a7589c5 100644
--- a/addons/payment_authorize/models/authorize_request.py
+++ b/addons/payment_authorize/models/authorize_request.py
@@ -148,7 +148,8 @@ class AuthorizeAPI():
"""
root = self._base_tree('createCustomerProfileRequest')
profile = etree.SubElement(root, "profile")
- etree.SubElement(profile, "merchantCustomerId").text = 'ODOO-%s-%s' % (partner.id, uuid4().hex[:8])
+ # merchantCustomerId is ODOO-{partner.id}-{random hex string} truncated to maximum 20 characters
+ etree.SubElement(profile, "merchantCustomerId").text = ('ODOO-%s-%s' % (partner.id, uuid4().hex[:8]))[:20]
etree.SubElement(profile, "email").text = partner.email or ''
payment_profile = etree.SubElement(profile, "paymentProfiles")
etree.SubElement(payment_profile, "customerType").text = 'business' if partner.is_company else 'individual'
@@ -220,7 +221,8 @@ class AuthorizeAPI():
root = self._base_tree('createCustomerProfileFromTransactionRequest')
etree.SubElement(root, "transId").text = transaction_id
customer = etree.SubElement(root, "customer")
- etree.SubElement(customer, "merchantCustomerId").text = 'ODOO-%s-%s' % (partner.id, uuid4().hex[:8])
+ # merchantCustomerId is ODOO-{partner.id}-{random hex string} truncated to maximum 20 characters
+ etree.SubElement(customer, "merchantCustomerId").text = ('ODOO-%s-%s' % (partner.id, uuid4().hex[:8]))[:20]
etree.SubElement(customer, "email").text = partner.email or ''
response = self._authorize_request(root)
res = dict()