From 4ab99cfc91ca2be9aedd9f1099ab9585375fe78d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 23 Aug 2019 18:55:08 +0200 Subject: render 402 page ourselves --- talerblog/blog/blog.py | 10 +++++++--- talerblog/blog/static/web-common | 2 +- talerblog/blog/templates/fallback.html | 28 --------------------------- talerblog/blog/templates/request_payment.html | 16 +++++++++++++++ 4 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 talerblog/blog/templates/fallback.html create mode 100644 talerblog/blog/templates/request_payment.html diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py index 860a3a9..4cf242b 100644 --- a/talerblog/blog/blog.py +++ b/talerblog/blog/blog.py @@ -25,7 +25,7 @@ import uuid import base64 import requests import flask -from werkzeug.contrib.cache import UWSGICache, SimpleCache +from cachelib import UWSGICache, SimpleCache from talerblog.talerconfig import TalerConfig from ..blog.content import ARTICLES, get_article_file, get_image_file @@ -315,8 +315,12 @@ def article(article_name, data=None): ## # Redirect the browser to a page where the wallet can # run the payment protocol. - if pay_status.get("payment_redirect_url"): - return flask.redirect(pay_status["payment_redirect_url"]) + contract_url = pay_status["contract_url"] + headers = {"X-Taler-Contract": contract_url} + content = flask.render_template("templates/request_payment.html", + article_name=article_name) + resp = flask.Response(content, status=402, headers=headers) + return resp # no pay_redirect but article not paid, this should never happen! err_abort(500, message="Internal error, invariant failed", json=pay_status) diff --git a/talerblog/blog/static/web-common b/talerblog/blog/static/web-common index e9554ba..72b28c3 160000 --- a/talerblog/blog/static/web-common +++ b/talerblog/blog/static/web-common @@ -1 +1 @@ -Subproject commit e9554baf0f3f880d656284ef5e9089bbd8313464 +Subproject commit 72b28c3201f2a2cdd3e88b3916f722e050895998 diff --git a/talerblog/blog/templates/fallback.html b/talerblog/blog/templates/fallback.html deleted file mode 100644 index 8dc426b..0000000 --- a/talerblog/blog/templates/fallback.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "templates/base.html" %} -{% block main %} - -

-Payment is being processed. If nothing happens, please click here. -

- -
-

- Oops, it looks like you don't have a Taler wallet installed. Why don't you enter - all your credit card details before reading the article? You can also - use GNU Taler to complete the purchase at any time. -

- -
- First name

- Family name

- Age

- Nationality

- Gender
Male - CC number

- Female
-
-
- -
-
-{% endblock main %} diff --git a/talerblog/blog/templates/request_payment.html b/talerblog/blog/templates/request_payment.html new file mode 100644 index 0000000..827caf1 --- /dev/null +++ b/talerblog/blog/templates/request_payment.html @@ -0,0 +1,16 @@ +{% extends "templates/base.html" %} +{% block main %} + +

+Payment is being processed. If nothing happens, please click here. +

+ +
+

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

+ + Use this QR code to pay with your module wallet: +
+{% endblock main %} -- cgit v1.2.3