[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) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2021-03-31 11:46:27 +00:00
parent 199878a569
commit 86b189bfea
@@ -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,