commit 3adc612ed53b1ab602849d95a189c30382138122
parent f8b8cce3a19ecf6963ae01eee8940ff7b9e607cd
Author: Iván Ávalos <avalos@disroot.org>
Date: Wed, 30 Jul 2025 17:47:09 +0200
contract v1 demo
Diffstat:
1 file changed, 39 insertions(+), 9 deletions(-)
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
@@ -73,6 +73,9 @@ ARTICLE_AMOUNT = CURRENCY + ":0.5"
BACKEND_URL = config["frontend-demo-blog"]["backend_url"].value_string(required=True)
APIKEY = config["frontend-demo-blog"]["backend_apikey"].value_string(required=True)
+SUBSCRIPTION_AMOUNT = CURRENCY + ":10"
+SUBSCRIPTION_SLUG_PREFIX = "blog_abo_"
+
BABEL_TRANSLATION_DIRECTORIES = "../translations"
app.config.from_object(__name__)
@@ -328,17 +331,44 @@ def render_article(article_name, lang, data, order_id, refundable):
def post_order(article_name, article_url, session_id, lang):
article_info = ARTICLES[lang].get(article_name)
summary = f"Essay: {article_info.title}"
- order = dict(
- amount=ARTICLE_AMOUNT,
- extra=dict(article_name=article_name),
- fulfillment_url=article_url,
- public_reorder_url=article_url,
- summary=summary,
- session_id=session_id,
+ order = {
+ "version": 1,
+ "extra": { "article_name": article_name },
+ "fulfillment_url": article_url,
+ "public_reorder_url": article_url,
+ "summary": summary,
+ "session_id": session_id,
+ "choices": [
+ # regular price
+ { "amount": ARTICLE_AMOUNT },
+
+ # buy monthly abo
+ {
+ "amount": SUBSCRIPTION_AMOUNT,
+ "outputs": [{
+ "type": "token",
+ "token_family_slug": SUBSCRIPTION_SLUG_PREFIX + lang,
+ }],
+ },
+
+ # access with monthly abo
+ {
+ "amount": CURRENCY + ":0",
+ "inputs": [{
+ "type": "token",
+ "token_family_slug": SUBSCRIPTION_SLUG_PREFIX + lang,
+ }],
+ "outputs": [{
+ "type": "token",
+ "token_family_slug": SUBSCRIPTION_SLUG_PREFIX + lang,
+ }],
+ },
+ ],
+
# FIXME: add support for i18n of summary!
# 10 minutes time for a refund
- wire_transfer_deadline=dict(t_s=int(time.time() + 15 * 30)),
- )
+ "wire_transfer_deadline": { "t_s": int(time.time() + 15 * 30) },
+ }
order_resp = backend_post(
BACKEND_URL,
"private/orders",