From e7c20a11fac21ab485b17feec81d0887be4cf5eb Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 29 Aug 2019 19:09:02 +0200 Subject: url-based payments --- talerdonations/donations/donations.py | 26 +++++++- .../donations/templates/request_payment.html | 69 ++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 talerdonations/donations/templates/request_payment.html (limited to 'talerdonations/donations') diff --git a/talerdonations/donations/donations.py b/talerdonations/donations/donations.py index 220fbb7..06c6617 100644 --- a/talerdonations/donations/donations.py +++ b/talerdonations/donations/donations.py @@ -245,6 +245,16 @@ def donate(): ) +## +# This endpoint is used by the payment request page +# to check if the payment has been completed via the QR code. +@app.route("/check-status/") +def check_status(order_id, session_id): + pay_params = dict( instance=INSTANCE, order_id=order_id) + pay_status = backend_get("check-payment", pay_params) + return flask.jsonify(paid=pay_status["paid"]) + + ## # Serve the fulfillment page. # @@ -260,7 +270,21 @@ def fulfillment(receiver): pay_status = backend_get("check-payment", pay_params) if pay_status.get("payment_redirect_url"): - return flask.redirect(pay_status["payment_redirect_url"]) + taler_pay_uri = pay_status["taler_pay_uri"] + qrcode_svg = get_qrcode_svg(taler_pay_uri) + check_status_url_enc = urllib.parse.quote( + flask.url_for("check_status", order_id=order_id) + ) + content = flask.render_template( + "templates/request_payment.html", + article_name=article_name, + taler_pay_uri=taler_pay_uri, + qrcode_svg=qrcode_svg, + check_status_url_enc=check_status_url_enc + ) + headers = {"Taler": taler_pay_uri} + resp = flask.Response(content, status=402, headers=headers) + return resp if pay_status.get("paid"): extra = pay_status["contract_terms"]["extra"] diff --git a/talerdonations/donations/templates/request_payment.html b/talerdonations/donations/templates/request_payment.html new file mode 100644 index 0000000..6e050d0 --- /dev/null +++ b/talerdonations/donations/templates/request_payment.html @@ -0,0 +1,69 @@ +{% extends "templates/base.html" %} + + +{% block meta %} + +{% endblock meta %} + + +{% block scripts %} + +{% endblock scripts %} + + +{% block main %} + +

Payment Required

+ +
+

+ Looks like your browser doesn't support GNU Taler payments. You can try + installing a wallet browser extension. +

+
+ +
+ +

+ You can use this QR code to pay with your mobile wallet: +

+ + {{ qrcode_svg | safe }} + +

+ Click this link to open your system's Taler wallet if it exists. +

+ +
+ +{% endblock main %} -- cgit v1.2.3