diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-30 14:13:23 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-30 14:13:23 +0200 |
commit | 095aa94e9adfaf1c60260839782c741b40b10e8f (patch) | |
tree | 1ba8d032243b31cdb6e5b330f7aedab4f80bb5e2 /talersurvey/survey/survey.py | |
parent | 6de49f0edac241b3435c460d737ea89f2bb87bc7 (diff) | |
download | survey-095aa94e9adfaf1c60260839782c741b40b10e8f.tar.gz survey-095aa94e9adfaf1c60260839782c741b40b10e8f.tar.bz2 survey-095aa94e9adfaf1c60260839782c741b40b10e8f.zip |
mobile tipping
Diffstat (limited to 'talersurvey/survey/survey.py')
-rw-r--r-- | talersurvey/survey/survey.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py index 1c6b8aa..e64de96 100644 --- a/talersurvey/survey/survey.py +++ b/talersurvey/survey/survey.py @@ -199,6 +199,12 @@ def survey_stats(): return flask.render_template("templates/survey_stats.html", stats=stats) +def get_qrcode_svg(data): + factory = qrcode.image.svg.SvgImage + img = qrcode.make(data, image_factory=factory) + return lxml.etree.tostring(img.get_image()).decode("utf-8") + + ## # Tell the backend to 'authorize' a tip; this means that # the backend will allocate a certain amount to be later @@ -215,10 +221,18 @@ def submit_survey(): instance="default", justification="Payment methods survey" ) - resp = backend_post("tip-authorize", tip_spec) - - if resp.get("tip_redirect_url"): - return flask.redirect(resp["tip_redirect_url"]) + backend_resp = backend_post("tip-authorize", tip_spec) + + taler_tip_uri = backend_resp.get("taler_tip_uri") + if taler_tip_uri: + qrcode_svg = get_qrcode_svg(taler_tip_uri) + content = flask.render_tempate( + "templates/show_tip.html", + qrcode_svg=qrcode_svg, + taler_tip_uri=taler_tip_uri, + ) + headers = {"Taler", taler_tip_uri} + return flask.Response(content, status=402, headers) err_abort( 500, message="Tipping failed, unexpected backend response", json=resp |