From af41ab8010f31b3c75a7864db16b0e1f99e5a2f1 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 11 May 2018 09:14:07 +0200 Subject: [PATCH] [FIX] payment_adyen: bytes/str comparison When returning from the Adyen payment website, SHA signature check fails because of an inconsistent bytes vs string comparison. This is due to `base64.b64encode` returning bytes in P3. opw-1841103 --- addons/payment_adyen/models/payment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/payment_adyen/models/payment.py b/addons/payment_adyen/models/payment.py index 3b15e51d44f..c28093f826f 100644 --- a/addons/payment_adyen/models/payment.py +++ b/addons/payment_adyen/models/payment.py @@ -14,6 +14,7 @@ from werkzeug import urls from odoo import api, fields, models, tools, _ from odoo.addons.payment.models.payment_acquirer import ValidationError from odoo.addons.payment_adyen.controllers.main import AdyenController +from odoo.tools.pycompat import to_native _logger = logging.getLogger(__name__) @@ -192,7 +193,7 @@ class TxAdyen(models.Model): shasign_check = tx.acquirer_id._adyen_generate_merchant_sig_sha256('out', data) else: shasign_check = tx.acquirer_id._adyen_generate_merchant_sig('out', data) - if shasign_check != data.get('merchantSig'): + if to_native(shasign_check) != to_native(data.get('merchantSig')): error_msg = _('Adyen: invalid merchantSig, received %s, computed %s') % (data.get('merchantSig'), shasign_check) _logger.warning(error_msg) raise ValidationError(error_msg)