[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-merchant-demos] 17/18: fix logic to match spec changes of #
From: |
gnunet |
Subject: |
[taler-taler-merchant-demos] 17/18: fix logic to match spec changes of #6616 |
Date: |
Sat, 10 Oct 2020 22:55:51 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository taler-merchant-demos.
commit 58af97724593e6d9cf423035f46da8f88c29526c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Oct 2 21:39:37 2020 +0200
fix logic to match spec changes of #6616
---
talermerchantdemos/blog/blog.py | 43 ++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
index 1268d6b..865605b 100644
--- a/talermerchantdemos/blog/blog.py
+++ b/talermerchantdemos/blog/blog.py
@@ -194,12 +194,31 @@ def render_article(article_name, data, order_id):
order_id=order_id,
)
+##
+# Setup a fresh order with the backend.
+#
+# @param article_name which article the order is for
+# @param lang which language to use
+#
+def post_order(article_name,lang):
+ order = dict(
+ amount=ARTICLE_AMOUNT,
+ extra=dict(article_name=article_name,lang=lang),
+ fulfillment_url=flask.request.base_url,
+ summary="Essay: " + article_name.replace("_", " "),
+ # 10 minutes time for a refund
+ refund_deadline=dict(t_ms=1000 * int(time.time() + 10 * 30)),
+ wire_transfer_deadline=dict(t_ms=1000 * int(time.time() + 15 * 30)),
+ )
+ order_resp = backend_post(BACKEND_URL, "private/orders", dict(order=order))
+ return order_resp
+
##
# Trigger a article purchase. The logic follows the main steps:
#
# 1. Always check if the article was paid already, via the
-# "/check-payment" API from the backend.
+# "/private/orders/$ORDER_ID" API from the backend.
# 2. If so, return the article.
# 3. If not, redirect the browser to a page where the
# wallet will initiate the payment protocol.
@@ -232,16 +251,7 @@ def article(article_name, lang=None, data=None):
if not order_id:
if not lang:
err_abort(403, message="Direct access forbidden")
- order = dict(
- amount=ARTICLE_AMOUNT,
- extra=dict(article_name=article_name,lang=lang),
- fulfillment_url=flask.request.base_url,
- summary="Essay: " + article_name.replace("_", " "),
- # 10 minutes time for a refund
- refund_deadline=dict(t_ms=1000 * int(time.time() + 10 * 30)),
- wire_transfer_deadline=dict(t_ms=1000 * int(time.time() + 15 *
30)),
- )
- order_resp = backend_post(BACKEND_URL, "private/orders",
dict(order=order))
+ order_resp = post_order(article_name,lang)
order_id = order_resp["order_id"]
# Ask the backend for the status of the payment
@@ -250,6 +260,17 @@ def article(article_name, lang=None, data=None):
)
order_status = pay_status.get("order_status")
+ if order_status == "claimed":
+ if not lang:
+ err_abort(403, message="Direct access forbidden")
+ # Order already claimed, must setup fresh order
+ 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)
+ )
+ order_status = pay_status.get("order_status")
+ # This really must be 'unpaid' now...
if order_status == "paid":
refunded = pay_status["refunded"]
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-merchant-demos] 04/18: fixed thing in readme, (continued)
- [taler-taler-merchant-demos] 04/18: fixed thing in readme, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 01/18: Re-Designed blog, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 06/18: removed a br to make it look better, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 11/18: fixed scss complaining, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 10/18: stuff?, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 05/18: language switcher now works, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 07/18: towards supporting language switching, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 15/18: Merge branch 'torsten-redesign' of git+ssh://git.taler.net/taler-merchant-demos into torsten-redesign, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 13/18: gitignore changes: add newline towards eof, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 18/18: merge torsten-redesign branch, implement i18n support, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 17/18: fix logic to match spec changes of #6616,
gnunet <=
- [taler-taler-merchant-demos] 08/18: fix merge issue, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 16/18: front-port Dold patch from master, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 09/18: Moved css to scss (See readme for build instructions), gnunet, 2020/10/10
- [taler-taler-merchant-demos] 12/18: gitignore changes, gnunet, 2020/10/10
- [taler-taler-merchant-demos] 14/18: add logic for repurchase detection, adjusting order_id if provided, gnunet, 2020/10/10