diff options
author | Sebastian <sebasjm@gmail.com> | 2024-02-08 17:45:16 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-02-08 17:45:16 -0300 |
commit | 200b658d3152774345a4dbd6adfb10f62581233a (patch) | |
tree | 30aed86598a6512cf29300110a1ac71185fa113f /talermerchantdemos/httpcommon | |
parent | 0490626fc0f24506eaa78a4fb72d55988ecd903f (diff) | |
download | taler-merchant-demos-200b658d3152774345a4dbd6adfb10f62581233a.tar.gz taler-merchant-demos-200b658d3152774345a4dbd6adfb10f62581233a.tar.bz2 taler-merchant-demos-200b658d3152774345a4dbd6adfb10f62581233a.zip |
fixes #8137
Diffstat (limited to 'talermerchantdemos/httpcommon')
-rw-r--r-- | talermerchantdemos/httpcommon/__init__.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/talermerchantdemos/httpcommon/__init__.py b/talermerchantdemos/httpcommon/__init__.py index 518eb1b..d2238ff 100644 --- a/talermerchantdemos/httpcommon/__init__.py +++ b/talermerchantdemos/httpcommon/__init__.py @@ -1,6 +1,6 @@ import flask import requests -from urllib.parse import urljoin +from urllib.parse import urljoin, urlencode, urlparse, urlunparse from flask import request, url_for from datetime import datetime import time @@ -117,6 +117,21 @@ def get_locale(): return "en" return lang +## +# Construct the payment URL where customer can pay the order +# +# @param backend_url where the backend is located +# @param order_id id of the order already created +# @param session_id session in which the order is going to be paid +# @param token if the order requires a token +# @return the JSON response from the backend, or a error response +# if something unexpected happens. +def backend_payment_url(backend_url, endpoint, session_id, token): + final_url = urljoin(backend_url, endpoint) + query = urlencode({"token":token, "session_id":session_id}) + redirect_url = urlparse(final_url)._replace(query=query) + return urlunparse(redirect_url) + ## # Helper function used inside Jinja2 logic to create a links |