From 4e5a355f7c2978a6f705e6ca36abdfc51636acfc Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 29 Mar 2021 15:10:13 +0000 Subject: [FIX] payment{,_stripe},sale: special character in reference Special character in reference (eg. '#' character in invoice sequence) might cause error for payment acquirer. For example with stripe we get the error on: {'error': {'code': 'url_invalid', 'doc_url': 'https://stripe.com/docs/error-codes/url-invalid', 'message': 'Not a valid URL', 'param': 'success_url', 'type': 'invalid_request_error'}} Or an error because prepare_tx_url is broken. With this changeset, when a payment reference is used inside an url, we quote it. opw-2479658 note: also uses url_quote_plus in payment.link.wizard()._generate_link since this is what is expected by werkzeug (previously + characters became spaces). closes odoo/odoo#68577 X-original-commit: 47645c2f170d5a7c09ae80d4e0de6c3a821f7b36 Signed-off-by: Nicolas Lempereur (nle) --- addons/payment_stripe/models/payment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/payment_stripe') diff --git a/addons/payment_stripe/models/payment.py b/addons/payment_stripe/models/payment.py index 53ac5f5682a..d09a6977c1c 100644 --- a/addons/payment_stripe/models/payment.py +++ b/addons/payment_stripe/models/payment.py @@ -58,8 +58,8 @@ class PaymentAcquirerStripe(models.Model): 'line_items[][quantity]': 1, 'line_items[][name]': tx_values['reference'], 'client_reference_id': tx_values['reference'], - 'success_url': urls.url_join(base_url, StripeController._success_url) + '?reference=%s' % tx_values['reference'], - 'cancel_url': urls.url_join(base_url, StripeController._cancel_url) + '?reference=%s' % tx_values['reference'], + 'success_url': urls.url_join(base_url, StripeController._success_url) + '?reference=%s' % urls.url_quote_plus(tx_values['reference']), + 'cancel_url': urls.url_join(base_url, StripeController._cancel_url) + '?reference=%s' % urls.url_quote_plus(tx_values['reference']), 'payment_intent_data[description]': tx_values['reference'], 'customer_email': tx_values.get('partner_email') or tx_values.get('billing_partner_email'), } -- cgit v1.2.3