[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-blog] branch master updated: further simplify blog
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-blog] branch master updated: further simplify blog |
Date: |
Wed, 10 Jan 2018 00:32:55 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository blog.
The following commit(s) were added to refs/heads/master by this push:
new 41c1a7b further simplify blog
41c1a7b is described below
commit 41c1a7b7ecb0ebc775e52ce9c61b05920fd4edf9
Author: Florian Dold <address@hidden>
AuthorDate: Wed Jan 10 00:32:48 2018 +0100
further simplify blog
---
talerblog/blog/blog.py | 65 ++++++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 39 deletions(-)
diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index 4b4e08e..98af38d 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -94,42 +94,6 @@ def refund():
flask.abort(500)
address@hidden("/generate-contract", methods=["GET"])
-def generate_contract():
- article_name = expect_parameter("article_name")
- pretty_name = article_name.replace("_", " ")
- order = dict(
- summary=pretty_name,
- nonce=flask.request.args.get("nonce"),
- amount=ARTICLE_AMOUNT,
- max_fee=dict(value=1, fraction=0, currency=CURRENCY),
- products=[
- dict(
- description="Essay: " + pretty_name,
- quantity=1,
- product_id=0,
- price=ARTICLE_AMOUNT,
- ),
- ],
- fulfillment_url=make_url("/essay/" + quote(article_name)),
- pay_url=make_url("/pay"),
- merchant=dict(
- instance=INSTANCE,
- address="nowhere",
- name="Kudos Inc.",
- jurisdiction="none",
- ),
- extra=dict(article_name=article_name),
- )
- resp = requests.post(urljoin(BACKEND_URL, "proposal"),
- json=dict(order=order))
- if resp.status_code != 200:
- return backend_error(resp)
- proposal_resp = resp.json()
- return flask.jsonify(**proposal_resp)
-
-
-
@app.route("/essay/<name>")
@app.route("/essay/<name>/data/<data>")
def article(name, data=None):
@@ -141,12 +105,35 @@ def article(name, data=None):
if not session_id:
session_id = flask.session["uid"] = uuid.uuid4()
+ # Check if this request already has an order id.
+ # If not, create a new order.
+ order_id = flask.request.args.get("order_id")
+ if not order_id:
+ pretty_name = article_name.replace("_", " ")
+ order = dict(
+ summary=pretty_name,
+ fulfillment_url=make_url("/essay/" + quote(article_name)),
+ amount=ARTICLE_AMOUNT,
+ )
+ resp = requests.post(urljoin(BACKEND_URL, "proposal"),
+ json=dict(order=order))
+ if resp.status_code != 200:
+ return backend_error(resp)
+ proposal_resp = resp.json()
+ order_id = proposal_resp["order_id"]
+
+ session_sig = flask.request.args.get("session_id")
+
+ if order_id and not session_sig:
+ # If there was an order_id but no session_sig, either the user played
+ # around with the URL or the wallet is old/broken.
+ return "Bad request", 400
+
pay_params = dict(
- contract_url=make_url("/generate-contract", ("article_name", name)),
instance=INSTANCE,
- order_id=flask.request.args.get("order_id"),
+ order_id=order_id,
session_id=session_id,
- session_sig=flask.request.args.get("session_sig"),
+ session_sig=session_sig,
)
resp = requests.get(urljoin(BACKEND_URL, "check-payment"),
params=pay_params)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-blog] branch master updated: further simplify blog,
gnunet <=