summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--talersurvey/survey/survey.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index 2cabaec..f4e7824 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -81,23 +81,17 @@ def pick():
def survey():
if flask.request.method == "GET":
return flask.render_template("templates/index.html", merchant_currency=CURRENCY)
- success = False
- amount = Amount(CURRENCY, 1)
- if flask.request.method == "POST":
- r = requests.post(urljoin(BACKEND_URL, 'tip-authorize'),
- json=dict(pickup_url=urljoin(flask.request.base_url, "/pick"),
- amount=amount.dump(),
- instance="default",
- justification="Payment methods survey"))
- if 200 != r.status_code:
- return backend_error(r)
- else:
- success = True
+ tip_spec = dict(pickup_url=urljoin(flask.request.base_url, "/pick"),
+ amount=Amount(CURRENCY, 1).dump(),
+ instance="default",
+ justification="Payment methods survey")
+ r = requests.post(urljoin(BACKEND_URL, 'tip-authorize'), json=tip_spec)
+ if 200 != r.status_code:
+ return backend_error(r)
- response = flask.make_response(flask.render_template(
- "templates/wait.html",
- success=success),
- 402)
- response.headers["X-Taler-Tip"] = json.dumps(r.json())
+ response = flask.make_response(
+ flask.render_template("templates/wait.html", success=True),
+ 402)
+ response.headers["X-Taler-Tip"] = r.json()["tip_token"]
return response