[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-blog] branch master updated: qrcode support
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-blog] branch master updated: qrcode support |
Date: |
Sat, 24 Aug 2019 12:50:43 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository blog.
The following commit(s) were added to refs/heads/master by this push:
new b13964c qrcode support
b13964c is described below
commit b13964c84195df8535bc1740da50e96450c6d888
Author: Florian Dold <address@hidden>
AuthorDate: Sat Aug 24 12:50:36 2019 +0200
qrcode support
---
talerblog/blog/blog.py | 29 +++++++++++++++++++++++----
talerblog/blog/templates/request_payment.html | 3 +++
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index 6f09852..e35dd0e 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -17,14 +17,17 @@
# @author Marcello Stanisci
# @brief Implementation of a Taler-compatible blog.
-from urllib.parse import urljoin, quote
+from urllib.parse import urljoin, quote, urlencode
import logging
import os
import traceback
import uuid
+import qrcode
+import qrcode.image.svg
import base64
import requests
import flask
+import lxml.etree
from cachelib import UWSGICache, SimpleCache
from talerblog.talerconfig import TalerConfig
from ..blog.content import ARTICLES, get_article_file, get_image_file
@@ -224,6 +227,10 @@ def render_article(article_name, data, order_id):
article_name=article_name,
order_id=order_id)
+def get_qrcode_svg(data):
+ factory = qrcode.image.svg.SvgImage
+ img = qrcode.make(data, image_factory=factory)
+ return lxml.etree.tostring(img.get_image())
##
# Trigger a article purchase. The logic follows the main steps:
@@ -281,10 +288,16 @@ def article(article_name, data=None):
order_id = order_resp["order_id"]
##
+ # The resource URL uniquely identifies the Web resource that
+ # the customer is paying for, and is used to detect that an
+ # article has already been puchased when the cookie was lost.
+ resource_url = flask.request.base_url
+
+ ##
# Prepare data for the upcoming payment check.
pay_params = dict(instance=INSTANCE,
order_id=order_id,
- resource_url=flask.request.base_url,
+ resource_url=resource_url,
session_id=session_id,
session_sig=session_sig)
@@ -316,9 +329,17 @@ def article(article_name, data=None):
# Redirect the browser to a page where the wallet can
# run the payment protocol.
contract_url = pay_status["contract_url"]
- headers = {"X-Taler-Contract-Url": contract_url}
+ headers = {
+ "X-Taler-Contract-Url": contract_url,
+ "X-Taler-Session-Url": session_id,
+ "X-Taler-Resource-Url": resource_url,
+ }
+
+ qrcode_data = "talerpay:" + urlencode(contract_url) + ";" + session_id
+ qrcode_svg = get_qrcode_svg(qrcode_data)
content = flask.render_template("templates/request_payment.html",
- article_name=article_name)
+ article_name=article_name,
+ qrcode_svg=qrcode_svg)
resp = flask.Response(content, status=402, headers=headers)
return resp
diff --git a/talerblog/blog/templates/request_payment.html
b/talerblog/blog/templates/request_payment.html
index d1ae48d..2fcf8db 100644
--- a/talerblog/blog/templates/request_payment.html
+++ b/talerblog/blog/templates/request_payment.html
@@ -8,5 +8,8 @@
</p>
Use this QR code to pay with your module wallet:
+
+ {{ qrcode_svg | safe }}
+
</div>
{% endblock main %}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-blog] branch master updated: qrcode support,
gnunet <=