diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-23 18:55:08 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-23 18:55:08 +0200 |
commit | 4ab99cfc91ca2be9aedd9f1099ab9585375fe78d (patch) | |
tree | 89004884dca3b0cc21af6672f260a39eb891d48f | |
parent | 08ac2799b04a6326c26d1c22f784270f6bad7f44 (diff) | |
download | blog-4ab99cfc91ca2be9aedd9f1099ab9585375fe78d.tar.gz blog-4ab99cfc91ca2be9aedd9f1099ab9585375fe78d.tar.bz2 blog-4ab99cfc91ca2be9aedd9f1099ab9585375fe78d.zip |
render 402 page ourselves
-rw-r--r-- | talerblog/blog/blog.py | 10 | ||||
m--------- | talerblog/blog/static/web-common | 0 | ||||
-rw-r--r-- | talerblog/blog/templates/fallback.html | 28 | ||||
-rw-r--r-- | talerblog/blog/templates/request_payment.html | 16 |
4 files changed, 23 insertions, 31 deletions
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 -Subproject e9554baf0f3f880d656284ef5e9089bbd831346 +Subproject 72b28c3201f2a2cdd3e88b3916f722e05089599 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 %} - -<p class="taler-installed-show"> -Payment is being processed. If nothing happens, please <a href="{{ request.path }}">click here</a>. -</p> - -<div id="ccfakeform" class="taler-installed-hide"> - <p> - 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? <em>You can also - use GNU Taler to complete the purchase at any time.</em> - </p> - - <form> - First name<br> <input type="text"><br> - Family name<br> <input type="text"><br> - Age<br> <input type="text"><br> - Nationality<br> <input type="text"><br> - Gender<br> <input type="radio" name"gender">Male</input> - CC number<br> <input type="text"><br> - <input type="radio" name="gender">Female<br> - </form> - <form method="get" action="/cc-payment/{{ article_name }}"> - <input type="submit"></input> - </form> -</div> -{% 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 %} + +<p class="taler-installed-show"> +Payment is being processed. If nothing happens, please <a href="{{ request.path }}">click here</a>. +</p> + +<div id="ccfakeform" class="taler-installed-hide"> + <p> + Looks like your browser doesn't support GNU Taler payments. You can try + installing browser extension wallet. + </p> + + Use this QR code to pay with your module wallet: +</div> +{% endblock main %} |