From 5dabdcd5f8a8d99b5f98d667094a0151f5fd80a8 Mon Sep 17 00:00:00 2001 From: pedrambiria 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#107143 X-original-commit: 3dce793ad00b1c0b9f06c705f40e31666db74a06 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Pedram Bi Ria (pebr) --- addons/payment_sips/models/payment_transaction.py | 2 +- addons/payment_sips/tests/common.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/payment_sips/models/payment_transaction.py b/addons/payment_sips/models/payment_transaction.py index 660d3b879eb..416f6a97e39 100644 --- a/addons/payment_sips/models/payment_transaction.py +++ b/addons/payment_sips/models/payment_transaction.py @@ -150,6 +150,6 @@ class PaymentTransaction(models.Model): def _sips_notification_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/common.py b/addons/payment_sips/tests/common.py index 9f7627504ed..b68476dc46e 100644 --- a/addons/payment_sips/tests/common.py +++ b/addons/payment_sips/tests/common.py @@ -27,6 +27,8 @@ class SipsCommon(PaymentCommon): f'|guaranteeIndicator=Y|cardCSCResultCode=4D|panExpiryDate=202201' f'|paymentMeanBrand=VISA|paymentMeanType=CARD|customerIpAddress=111.11.111.11' f'|maskedPan=4100##########00|returnContext={{"reference": "{cls.reference}"}}' + f'|scoreValue=-3.0|scoreColor=GREEN|scoreInfo=A3;N;N#SC;N;TRANS=3:2;CUMUL=4500:250000' + f'|scoreProfile=25_BUSINESS_SCORE_PRE_AUTHORISATION|scoreThreshold=-7;-5' f'|holderAuthentRelegation=N|holderAuthentStatus=3D_SUCCESS' f'|tokenPan=dp528b9xwknujmkw|transactionOrigin=INTERNET|paymentPattern=ONE_SHOT' f'|customerMobilePhone=null|mandateAuthentMethod=null|mandateUsage=null' @@ -37,6 +39,6 @@ class SipsCommon(PaymentCommon): f'|holderAuthentMethod=NOT_SPECIFIED', 'Encode': '', 'InterfaceVersion': 'HP_2.4', - 'Seal': '8a4c1f8b268832600a7bf40ddaa5d487f07d61dea81b8119ab8bab3c8a0861f3', + 'Seal': 'eb2a499e1abd07f0d9361418f109d940d6cb7bcbaf6ef9385c28651956c96514', 'locale': 'en', }