commit f5da2dc9bdb9727a94f38e7dbf8472366dfcc329
parent c07742666ac10f972be94f3b46a5a4a609f1ba06
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 10 Jul 2023 14:07:02 -0300
set the new order id in the cookie after recreating from refund
Diffstat:
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
@@ -459,16 +459,31 @@ def article(article_name, lang=None, data=None):
#If the order is refunded show the status, unless the user is already aware
#and notified using the query parameter to create a new order
- if pay_status["refunded"]:
+ if order_status == "paid" and pay_status.get("refunded"):
if new_if_refunded == "yes":
order_resp = post_order(article_name, lang)
order_id = order_resp["order_id"]
pay_status = backend_get(
BACKEND_URL,
f"private/orders/{order_id}",
- params=dict(session_id=session_id),
auth_token=APIKEY,
)
+ # Order ID is fresh, thus setting the cookies now, and
+ # redirecting the client to the cookie support check.
+ redirect_url = pay_status["order_status_url"]
+ response = flask.redirect(redirect_url)
+ response.set_cookie(
+ "order_id",
+ order_id,
+ path=urllib.parse.quote(url_for ('index') + f"essay/{article_name}")
+ )
+ response.set_cookie(
+ "order_id",
+ order_id,
+ path=urllib.parse.quote(url_for ('index') + f"{lang}/essay/{article_name}")
+ )
+ return response
+
else:
return flask.render_template(
"blog-article-refunded.html.j2",
diff --git a/talermerchantdemos/templates/blog-article-refunded.html.j2 b/talermerchantdemos/templates/blog-article-refunded.html.j2
@@ -13,9 +13,9 @@
{{
gettext("You will not be able to read the article until you pay for it again.")
}}
-<a href="{{ url_for('article', lang=article_lang, article_name=article_name) }}" class="articleTitle">
+<a href="{{ url_for('article', lang=article_lang, article_name=article_name) }}?new_if_refunded=yes" class="articleTitle">
{{
- gettext("Click here to it again.")
+ gettext("Click here to pay it again.")
}}
</a>
</p>