From 7594a959c7c913e7d988f545548b792ee4688e0b Mon Sep 17 00:00:00 2001 From: pedrambiria <pebr@odoo.com> Date: Wed, 30 Nov 2022 15:43:47 +0000 Subject: [PATCH] [FIX] payment_sips: accept scoreInfo in payment response After a payment is processed by SIPS, a data object is posted back to Odoo. The data has a `ScoreInfo` element that has more than one `=` characters (e.g. `scoreInfo=A3;N;N#SC;N;TRANS=3:2;CUMUL=4500:250000`) This causes the method `_sips_data_to_object` to break, because there will be too many values to unpack. To fix this, we should limit the data split to 2 values. This is the same method used by SIPS to process data as well. (See: https://github.com/worldline/Sips-International-non-FR-PHPlibrary/blob/master/lib/Sips/PaymentResponse.php#L73) opw-3071315 closes odoo/odoo#106919 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> --- addons/payment_sips/models/payment_transaction.py | 2 +- addons/payment_sips/tests/test_sips.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/payment_sips/models/payment_transaction.py b/addons/payment_sips/models/payment_transaction.py index 139c2e7e1bca..ff005e9f5ca5 100644 --- a/addons/payment_sips/models/payment_transaction.py +++ b/addons/payment_sips/models/payment_transaction.py @@ -163,6 +163,6 @@ class PaymentTransaction(models.Model): def _sips_data_to_object(self, data): res = {} for element in data.split('|'): - key, value = element.split('=') + key, value = element.split('=', 1) res[key] = value return res diff --git a/addons/payment_sips/tests/test_sips.py b/addons/payment_sips/tests/test_sips.py index f9ae40d4ee4a..b423483b4610 100644 --- a/addons/payment_sips/tests/test_sips.py +++ b/addons/payment_sips/tests/test_sips.py @@ -75,8 +75,9 @@ class SipsTest(SipsCommon): 'paymentMeanBrand=IDEAL|paymentMeanType=CREDIT_TRANSFER|' 'customerIpAddress=127.0.0.1|returnContext={"return_url": ' '"/payment/process", "reference": ' - '"SO100x1"}|holderAuthentRelegation=N|holderAuthentStatus=|' - 'transactionOrigin=INTERNET|paymentPattern=ONE_SHOT|customerMobilePhone=null|' + '"SO100x1"}|scoreValue=-3.0|scoreColor=GREEN|scoreInfo=A3;N;N#SC;N;TRANS=3:2;CUMUL=4500:250000|' + 'scoreProfile=25_BUSINESS_SCORE_PRE_AUTHORISATION|scoreThreshold=-7;-5|holderAuthentRelegation=N|' + 'holderAuthentStatus=|transactionOrigin=INTERNET|paymentPattern=ONE_SHOT|customerMobilePhone=null|' 'mandateAuthentMethod=null|mandateUsage=null|transactionActors=null|' 'mandateId=null|captureLimitDate=20200408|dccStatus=null|dccResponseCode=null|' 'dccAmount=null|dccCurrencyCode=null|dccExchangeRate=null|' @@ -109,7 +110,9 @@ class SipsTest(SipsCommon): 'transactionDateTime=2020-04-08T06:24:08+02:00|transactionReference=SO100x2|' 'keyVersion=1|amount=31400|customerIpAddress=127.0.0.1|returnContext={"return_url": ' '"/payment/process", "reference": ' - '"SO100x2"}|paymentPattern=ONE_SHOT|customerMobilePhone=null|mandateAuthentMethod=null|' + '"SO100x2"}|scoreValue=-3.0|scoreColor=GREEN|scoreInfo=A3;N;N#SC;N;TRANS=3:2;CUMUL=4500:250000|' + 'scoreProfile=25_BUSINESS_SCORE_PRE_AUTHORISATION|scoreThreshold=-7;-5' + '|paymentPattern=ONE_SHOT|customerMobilePhone=null|mandateAuthentMethod=null|' 'mandateUsage=null|transactionActors=null|mandateId=null|captureLimitDate=null|' 'dccStatus=null|dccResponseCode=null|dccAmount=null|dccCurrencyCode=null|' 'dccExchangeRate=null|dccExchangeRateValidity=null|dccProvider=null|' -- GitLab