Files
odoo_source/addons/website_payment/models
Mehdi Outagant (MOU) 3b569aed65 [FIX] website_payment: fix Stripe payment base URL configuration
Steps to reproduce:

- Configure a non-ASCII custom domain (Punycode encoded) on a database
(e.g. `test-môu.com` <> `xn--test-mu-y0a.com`).
- Setup test API keys on a Stripe account ("Publishable" & "Secret").
- Install and activate the Stripe payment acquirer (in "Test Mode").
- Go to the Stripe Odoo config (Invoicing > Payment Acquirers > Stripe).
- Configure Stripe API keys and click on the button to "GENERATE YOUR
WEBHOOK" > traceback: `Invalid URL: Non-ASCII characters in URLs must
be percent-encoded in order for the URL to be valid`.
The same error occurs in every interaction with the Stripe API.

The `get_base_url()` refactoring (exactly [1]) introduced a way to get
the most suited URL for a record in the following order:

`record.website_id` > `record.company_id.website_id` > The ICP:
`web.base.url`.

For payment acquirers, and to handle multi-website scenarios, the code
uses the base URL: `httprequest.url_root` which explains why the error
occurs even when the domain name is configured in punycode.

The goal of this commit is to fix this behavior by correctly encoding
the returned base URL.

[1] https://github.com/odoo/odoo/commit/92175d3341b576676a550c60db7c759f71cb17ea

opw-3619608

closes odoo/odoo#149947

X-original-commit: ffb19d0481f623c969266b14dce2b78127ec2391
Signed-off-by: Valentin Chevalier <vcr@odoo.com>
2024-01-18 23:10:29 +00:00
..