summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-08-27 01:05:15 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-08-27 01:05:15 +0200
commitc0657b7fc92ce330b3cbda249114f37fb995c915 (patch)
treeb15cea8223ee2feb19ab1e0d3eb0eeeca5f3e28b
parent1776133224171568374b04d7e46556dae00da3c2 (diff)
downloadblog-c0657b7fc92ce330b3cbda249114f37fb995c915.tar.gz
blog-c0657b7fc92ce330b3cbda249114f37fb995c915.tar.bz2
blog-c0657b7fc92ce330b3cbda249114f37fb995c915.zip
check status via API
-rw-r--r--talerblog/blog/blog.py2
-rw-r--r--talerblog/blog/templates/request_payment.html37
2 files changed, 38 insertions, 1 deletions
diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index 7162119..9c4f8ad 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -337,6 +337,8 @@ def article(article_name, data=None):
# run the payment protocol.
taler_pay_uri = pay_status["taler_pay_uri"]
qrcode_svg = get_qrcode_svg(taler_pay_uri)
+ check_status_url = flask.url_for(
+ "check_status", order_id=order_id, session_id=session_id)
content = flask.render_template("templates/request_payment.html",
article_name=article_name,
taler_pay_uri=taler_pay_uri,
diff --git a/talerblog/blog/templates/request_payment.html b/talerblog/blog/templates/request_payment.html
index c30b847..6c14456 100644
--- a/talerblog/blog/templates/request_payment.html
+++ b/talerblog/blog/templates/request_payment.html
@@ -1,7 +1,42 @@
{% extends "templates/base.html" %}
+
+
{% block meta %}
-<meta http-equiv="refresh" content="1">
+<noscript>
+ <meta http-equiv="refresh" content="1">
+</noscript>
{% endblock meta %}
+
+
+{% block scripts %}
+<script>
+ let checkUrl = decodeURIComponent("{{ check_status_url_enc }}");
+ let delayMs = 500;
+ function check() {
+ let req = new XMLHttpRequest();
+ req.onreadystatechange = function () {
+ if (req.readyState === XMLHttpRequest.DONE && req.status === 200) {
+ if (req.status === 200) {
+ let resp = JSON.parse(req.responseText);
+ if (resp.paid) {
+ document.location.reload(true);
+ }
+ }
+ setTimeout(check, delayMs);
+ }
+ };
+ req.onerror = function () {
+ setTimeout(check, delayMs);
+ }
+ req.open("GET", checkUrl);
+ req.send();
+ }
+
+ setTimeout(check, delayMs);
+</script>
+{% endblock scripts %}
+
+
{% block main %}
<h1>Payment Required</h1>