From 5b8f1e41496cb37e4bb9d4924a82d7dfb1418e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 26 Nov 2019 22:16:00 +0100 Subject: [PATCH] Add __href__ and is_secure, host and http_host to url module This ease the composition of URL pointing to Tryton route. issue8767 review264461005 --- payment.py | 6 +++--- payment.xml | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/payment.py b/payment.py index 6c4bec4f7c..8cfc0a5b85 100644 --- a/payment.py +++ b/payment.py @@ -21,7 +21,7 @@ from trytond.report import Report, get_email from trytond.rpc import RPC from trytond.sendmail import sendmail_transactional from trytond.transaction import Transaction -from trytond.url import HOSTNAME +from trytond.url import http_host from trytond.wizard import Wizard, StateAction from trytond.modules.account_payment.exceptions import ( @@ -99,7 +99,7 @@ class CheckoutMixin: Checkout = pool.get('account.payment.stripe.checkout', type='wizard') action = Checkout.checkout.get_action() return action['url'] % { - 'hostname': HOSTNAME, + 'http_host': http_host(), 'database': database, 'model': self.__class__.__name__, 'id': self.stripe_checkout_id, @@ -773,7 +773,7 @@ class Account(ModelSQL, ModelView): 'identifier': self.webhook_identifier, 'database_name': Transaction().database.name, } - return 'https://' + HOSTNAME + ( + return http_host() + ( urllib.parse.quote( '/%(database_name)s/account_payment_stripe' '/webhook/%(identifier)s' diff --git a/payment.xml b/payment.xml index 3457c903eb..cc13647cda 100644 --- a/payment.xml +++ b/payment.xml @@ -224,11 +224,10 @@ this repository contains the full copyright notices and license terms. --> minutes - - + Stripe Checkout - https://%(hostname)s:8000/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s + %(http_host)s/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s