summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-06-08 13:43:11 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-06-11 08:11:39 +0200
commite9b21c37f4989c96113390fc84b900d0c480fac4 (patch)
tree6c75d1c3e1e8f399268ad1fcd3aa65faa82ec0aa /addons/payment_authorize/models
parent3adeb46cdd4997ffba4f46fde2645c7235da48e9 (diff)
[FIX] payment_authorize: state code
According to Authorize.net documentation, the state code should only be used for United States. For the other countries, use the state name instead. opw-1854278
Diffstat (limited to 'addons/payment_authorize/models')
-rw-r--r--addons/payment_authorize/models/payment.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py
index 4efeabd54e3..cd35782a506 100644
--- a/addons/payment_authorize/models/payment.py
+++ b/addons/payment_authorize/models/payment.py
@@ -59,6 +59,15 @@ class PaymentAcquirerAuthorize(models.Model):
@api.multi
def authorize_form_generate_values(self, values):
self.ensure_one()
+ # State code is only supported in US, use state name by default
+ # See https://developer.authorize.net/api/reference/
+ state = values['partner_state'].name if values.get('partner_state') else ''
+ if values.get('partner_country') and values.get('partner_country') == self.env.ref('base.us', False):
+ state = values['partner_state'].code if values.get('partner_state') else ''
+ billing_state = values['billing_partner_state'].name if values.get('billing_partner_state') else ''
+ if values.get('billing_partner_country') and values.get('billing_partner_country') == self.env.ref('base.us', False):
+ billing_state = values['billing_partner_state'].code if values.get('billing_partner_state') else ''
+
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
authorize_tx_values = dict(values)
temp_authorize_tx_values = {
@@ -83,7 +92,7 @@ class PaymentAcquirerAuthorize(models.Model):
'first_name': values.get('partner_first_name'),
'last_name': values.get('partner_last_name'),
'phone': values.get('partner_phone'),
- 'state': values.get('partner_state') and values['partner_state'].code or '',
+ 'state': state,
'billing_address': values.get('billing_partner_address'),
'billing_city': values.get('billing_partner_city'),
'billing_country': values.get('billing_partner_country') and values.get('billing_partner_country').name or '',
@@ -92,7 +101,7 @@ class PaymentAcquirerAuthorize(models.Model):
'billing_first_name': values.get('billing_partner_first_name'),
'billing_last_name': values.get('billing_partner_last_name'),
'billing_phone': values.get('billing_partner_phone'),
- 'billing_state': values.get('billing_partner_state') and values['billing_partner_state'].code or '',
+ 'billing_state': billing_state,
}
temp_authorize_tx_values['returndata'] = authorize_tx_values.pop('return_url', '')
temp_authorize_tx_values['x_fp_hash'] = self._authorize_generate_hashing(temp_authorize_tx_values)