[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant-frontends] branch master updated: /refund l
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant-frontends] branch master updated: /refund logic (mocked button) |
Date: |
Wed, 21 Jun 2017 15:17:09 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant-frontends.
The following commit(s) were added to refs/heads/master by this push:
new b631289 /refund logic (mocked button)
b631289 is described below
commit b631289d47806cb00d4ea4a8de2133e39f0eb6a4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Jun 21 15:17:08 2017 +0200
/refund logic (mocked button)
---
talerfrontends/blog/blog.py | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/talerfrontends/blog/blog.py b/talerfrontends/blog/blog.py
index 35fd073..94bd361 100644
--- a/talerfrontends/blog/blog.py
+++ b/talerfrontends/blog/blog.py
@@ -75,6 +75,37 @@ def index():
def javascript_licensing():
return flask.render_template("templates/javascript.html")
+# Triggers the refund by serving /refund/test?order_id=XY.
+# Will be triggered by a "refund button".
address@hidden("/refund/test", methods=["GET, POST"])
+def refund():
+ # If POST, will fetch this value from the state
+ order_id = expect_parameter("order_id")
+ if request.method == "POST":
+ r = requests.post(urljoin(BACKEND_URL, "refund"),
+ json=dict(order_id=order_id,
+ refund=dict(value=1, fraction=0,
currency=CURRENCY),
+ reason="Demo reimbursement",
+ instance=INSTANCE))
+ else:
+ r = requests.get(urljoin(BACKEND_URL, "refund"),
params=dict(order_id=order_id,
+
instance=INSTANCE))
+ # This (and the double if-else) will disappear once #5090 is solved.
+ if r.status_code != 200:
+ logger.error("Backend error: status code: " + str(r.status_code))
+ try:
+ return flask.jsonify(r.json()), r.status_code
+ except json.decoder.JSONDecodeError:
+ logger.error("Backend error (NO JSON returned): status code: " +
str(r.status_code))
+ return flask.jsonify(dict(error="Backend died, no JSON got from
it")), 502
+
+ if request.method == "POST":
+ response = flask.make_response()
+ response.headers["X-Taler-Refund-Url"] = make_url("/refund",
("order_id", order_id))
+ return response
+ else:
+ return flask.jsonify(r.json()), r.status_code
+
@app.route("/generate-contract", methods=["GET"])
def generate_contract():
@@ -101,7 +132,7 @@ def generate_contract():
),
extra=dict(article_name=article_name),
)
- r = requests.post(urljoin(BACKEND_URL, 'proposal'), json=dict(order=order))
+ r = requests.post(urljoin(BACKEND_URL, "proposal"), json=dict(order=order))
if r.status_code != 200:
try:
return flask.jsonify(r.json()), r.status_code
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant-frontends] branch master updated: /refund logic (mocked button),
gnunet <=