summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-03-08 15:08:16 +0100
committerChristophe Simonis <chs@odoo.com>2019-03-08 15:08:16 +0100
commitecd8c023b7c58809438e462a43bc2dd405afa122 (patch)
tree774139f96f755637fdac1e701599023e85b339af /addons/payment_authorize/models
parentdb50050ed3241a0facee5ec8351f93c11c9b7138 (diff)
parente5f93b83c6828deac166f0691ac9fffe843471e2 (diff)
[MERGE] forward port branch 11.0 up to e5f93b83c68
Diffstat (limited to 'addons/payment_authorize/models')
-rw-r--r--addons/payment_authorize/models/payment.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py
index 89aa33aa249..cf55effdd12 100644
--- a/addons/payment_authorize/models/payment.py
+++ b/addons/payment_authorize/models/payment.py
@@ -6,6 +6,7 @@ from datetime import datetime
import hashlib
import hmac
import logging
+import string
import time
from odoo import _, api, fields, models
@@ -53,8 +54,16 @@ class PaymentAcquirerAuthorize(models.Model):
values['x_fp_sequence'],
values['x_fp_timestamp'],
values['x_amount'],
- values['x_currency_code']])
- return hmac.new(values['x_trans_key'].encode('utf-8'), data.encode('utf-8'), hashlib.md5).hexdigest()
+ values['x_currency_code']]).encode('utf-8')
+
+ # [BACKWARD COMPATIBILITY] Check that the merchant did update his transaction
+ # key to signature key (end of MD5 support from Authorize.net)
+ # The signature key is now '128-character hexadecimal format', while the
+ # transaction key was only 16-character.
+ if len(values['x_trans_key']) == 128:
+ return hmac.new(values['x_trans_key'].decode("hex").encode('utf-8'), data, hashlib.sha512).hexdigest().upper()
+ else:
+ return hmac.new(values['x_trans_key'].encode('utf-8'), data, hashlib.md5).hexdigest()
@api.multi
def authorize_form_generate_values(self, values):
@@ -182,7 +191,7 @@ class TxAuthorize(models.Model):
def _authorize_form_get_tx_from_data(self, data):
""" Given a data dict coming from authorize, verify it and find the related
transaction record. """
- reference, trans_id, fingerprint = data.get('x_invoice_num'), data.get('x_trans_id'), data.get('x_MD5_Hash')
+ reference, trans_id, fingerprint = data.get('x_invoice_num'), data.get('x_trans_id'), data.get('x_SHA2_Hash') or data.get('x_MD5_Hash')
if not reference or not trans_id or not fingerprint:
error_msg = _('Authorize: received data with missing reference (%s) or trans_id (%s) or fingerprint (%s)') % (reference, trans_id, fingerprint)
_logger.info(error_msg)