From 760b4a5c14079fe31c3eb6497c392255ea48654b Mon Sep 17 00:00:00 2001 From: Parth Gajjar Date: Mon, 30 May 2022 10:17:48 +0000 Subject: [PATCH] [FIX] payment_mollie: mollie shows 404 page when only one payment method is active Mollie supports multiple payments methods, these payment methods can be enabled/disabled from the mollie dashboard. When you activate only one payment method from mollie dashboard, you will get 404 page instead of payment page. This commit will fix that issue by providing necessary query parameters in url. closes odoo/odoo#92637 X-original-commit: 500be5b85d99ee4fa9590c18d3795977fbf48c4f Signed-off-by: Antoine Vandevenne (anv) --- addons/payment_mollie/models/payment_transaction.py | 9 ++++++++- addons/payment_mollie/views/payment_mollie_templates.xml | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/payment_mollie/models/payment_transaction.py b/addons/payment_mollie/models/payment_transaction.py index 3ce46f89c7d..2571f18eaa9 100644 --- a/addons/payment_mollie/models/payment_transaction.py +++ b/addons/payment_mollie/models/payment_transaction.py @@ -38,7 +38,14 @@ class PaymentTransaction(models.Model): # The acquirer reference is set now to allow fetching the payment status after redirection self.acquirer_reference = payment_data.get('id') - return {'api_url': payment_data['_links']['checkout']['href']} + # Extract the checkout URL from the payment data and add it with its query parameters to the + # rendering values. Passing the query parameters separately is necessary to prevent them + # from being stripped off when redirecting the user to the checkout URL, which can happen + # when only one payment method is enabled on Mollie and query parameters are provided. + checkout_url = payment_data['_links']['checkout']['href'] + parsed_url = urls.url_parse(checkout_url) + url_params = urls.url_decode(parsed_url.query) + return {'api_url': checkout_url, 'url_params': url_params} def _mollie_prepare_payment_request_payload(self): """ Create the payload for the payment request based on the transaction values. diff --git a/addons/payment_mollie/views/payment_mollie_templates.xml b/addons/payment_mollie/views/payment_mollie_templates.xml index 1ae04addbdc..990cd0a6514 100644 --- a/addons/payment_mollie/views/payment_mollie_templates.xml +++ b/addons/payment_mollie/views/payment_mollie_templates.xml @@ -3,7 +3,11 @@