From 86b189bfea47f95a145e88c680d04bd440faea72 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 29 Mar 2021 15:10:13 +0000 Subject: [PATCH] [FIX] payment_stripe: special character in reference Special character in reference (eg. '#' character in invoice sequence) might cause error after payment not showing it was successful. With this changeset, when a payment reference is used inside an url, we quote it. opw-2479658 closes odoo/odoo#68585 X-original-commit: 47645c2f170d5a7c09ae80d4e0de6c3a821f7b36 Signed-off-by: Nicolas Lempereur (nle) --- addons/payment_stripe/models/payment_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/payment_stripe/models/payment_transaction.py b/addons/payment_stripe/models/payment_transaction.py index 4e4bbeb1292..c3a53e78076 100644 --- a/addons/payment_stripe/models/payment_transaction.py +++ b/addons/payment_stripe/models/payment_transaction.py @@ -91,7 +91,7 @@ class PaymentTransaction(models.Model): base_url = self.acquirer_id._get_base_url() if self.operation == 'online_redirect': return_url = f'{urls.url_join(base_url, StripeController._checkout_return_url)}' \ - f'?reference={self.reference}' + f'?reference={urls.url_quote_plus(self.reference)}' # Specify a future usage for the payment intent to: # 1. attach the payment method to the created customer # 2. trigger a 3DS check if one if required, while the customer is still present @@ -116,7 +116,7 @@ class PaymentTransaction(models.Model): else: # 'validation' # {CHECKOUT_SESSION_ID} is a template filled by Stripe when the Session is created return_url = f'{urls.url_join(base_url, StripeController._validation_return_url)}' \ - f'?reference={self.reference}&checkout_session_id={{CHECKOUT_SESSION_ID}}' + f'?reference={urls.url_quote_plus(self.reference)}&checkout_session_id={{CHECKOUT_SESSION_ID}}' checkout_session = self.acquirer_id._stripe_make_request( 'checkout/sessions', payload={ **common_session_values,