From f5da2dc9bdb9727a94f38e7dbf8472366dfcc329 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 10 Jul 2023 14:07:02 -0300 Subject: set the new order id in the cookie after recreating from refund --- talermerchantdemos/blog/blog.py | 19 +++++++++++++++++-- .../templates/blog-article-refunded.html.j2 | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py index 493ffac..f787f0c 100644 --- 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 index 3b0d765..4252adb 100644 --- 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.") }} - + {{ - gettext("Click here to it again.") + gettext("Click here to pay it again.") }}

-- cgit v1.2.3