gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-merchant-demos] 16/18: front-port Dold patch from master


From: gnunet
Subject: [taler-taler-merchant-demos] 16/18: front-port Dold patch from master
Date: Sat, 10 Oct 2020 22:55:50 +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 2fcce2028d4308b56b4a545d587a76d4c51b1f5d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Sep 7 13:36:17 2020 +0200

    front-port Dold patch from master
---
 talermerchantdemos/blog/blog.py | 59 +++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
index af4e95c..1268d6b 100644
--- a/talermerchantdemos/blog/blog.py
+++ b/talermerchantdemos/blog/blog.py
@@ -226,6 +226,7 @@ def article(article_name, lang=None, data=None):
 
     if not session_id:
         session_id = flask.session["session_id"] = str(uuid.uuid4())
+        order_id = None
     ##
     # First-timer; generate order first.
     if not order_id:
@@ -243,41 +244,35 @@ def article(article_name, lang=None, data=None):
         order_resp = backend_post(BACKEND_URL, "private/orders", 
dict(order=order))
         order_id = order_resp["order_id"]
 
-    # We run this code twice, 2nd time in case repurchase detection gave us
-    # a new order_id.
-    for retries in range(0,2):
-        # Ask the backend for the status of the payment
-        pay_status = backend_get(
-            BACKEND_URL, f"private/orders/{order_id}", 
params=dict(session_id=session_id)
-        )
+    # Ask the backend for the status of the payment
+    pay_status = backend_get(
+        BACKEND_URL, f"private/orders/{order_id}", 
params=dict(session_id=session_id)
+    )
 
-        order_status = pay_status.get("order_status")
+    order_status = pay_status.get("order_status")
 
-        if order_status == "paid":
-            refunded = pay_status["refunded"]
-            if refunded:
-                return flask.render_template(
-                    "templates/article_refunded.html",
-                    article_name=article_name,
-                    order_id=order_id,
-                )
-            else:
-                response = render_article(article_name, data, order_id)
-                response.set_cookie("order_id", order_id, 
path=urllib.parse.quote(f"/essay/{article_name}"))
-                response.set_cookie("order_id", order_id, 
path=urllib.parse.quote(f"/{lang}/essay/{article_name}"))
-                return response
+    if order_status == "paid":
+        refunded = pay_status["refunded"]
+         if refunded:
+             return flask.render_template(
+                "templates/article_refunded.html",
+                article_name=article_name,
+                order_id=order_id,
+            )
         else:
-            if "already_paid_order_id" in pay_status:
-                order_id = pay_status.get("already_paid_order_id")
-                print ("Already paid: " + order_id);
-                # retry (but only once)
-                continue
-            else:
-                print ("Not yet paid paid: " + str(pay_status))
-
-
-        # Give up trying, order is unpaid
-        break
+            response = render_article(article_name, data, order_id)
+            response.set_cookie("order_id", order_id, 
path=urllib.parse.quote(f"/essay/{article_name}"))
+            response.set_cookie("order_id", order_id, 
path=urllib.parse.quote(f"/{lang}/essay/{article_name}"))
+            return response
+    else:
+        # Check if the customer came on this page via the
+        # re-purchase detection mechanism
+        ai = pay_status.get("already_paid_order_id")
+        au = pay_status.get("already_paid_fulfillment_url")
+        if ai is not None and au is not None:
+            response = flask.redirect(au)
+            response.set_cookie("order_id", ai, 
path=urllib.parse.quote(f"/essay/{article_name}"))
+            return response
 
     # Redirect the browser to a page where the wallet can
     # run the payment protocol.

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]