summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-10-01 18:48:43 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-10-01 18:48:59 +0200
commit6f61622484c1133023a92913a71c56a7a715c944 (patch)
treec3827cb5923c7a216cff8a96f907d3e613a2e634
parenta6c9acc30a22654ca2570cd7105021719e255742 (diff)
downloadblog-6f61622484c1133023a92913a71c56a7a715c944.tar.gz
blog-6f61622484c1133023a92913a71c56a7a715c944.tar.bz2
blog-6f61622484c1133023a92913a71c56a7a715c944.zip
new instances API
-rw-r--r--talerblog/blog/blog.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index b6f0f30..c5effe3 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -39,11 +39,12 @@ app.secret_key = base64.b64encode(os.urandom(64)).decode('utf-8')
LOGGER = logging.getLogger(__name__)
TC = TalerConfig.from_env()
-BACKEND_URL = TC["frontends"]["backend"].value_string(required=True)
+BACKEND_BASE_URL = TC["frontends"]["backend"].value_string(required=True)
CURRENCY = TC["taler"]["currency"].value_string(required=True)
APIKEY = TC["frontends"]["backend_apikey"].value_string(required=True)
INSTANCE = TC["blog"]["instance"].value_string(required=True)
ARTICLE_AMOUNT = CURRENCY + ":0.5"
+BACKEND_URL = urljoin(BACKEND_BASE_URL, f"instances/{INSTANCE}/")
app.config.from_object(__name__)
@@ -177,7 +178,7 @@ except ImportError:
@app.route("/confirm-refund/<order_id>", methods=["GET"])
def confirm_refund(order_id):
# Here we don't care about the session ID
- pay_params = dict(instance=INSTANCE, order_id=order_id)
+ pay_params = dict(order_id=order_id)
pay_status = backend_get("check-payment", pay_params)
if not pay_status.get("paid"):
err_abort(
@@ -214,7 +215,6 @@ def refund(order_id):
dict(error="Aborting refund: article not payed")
), 401
refund_spec = dict(
- instance=INSTANCE,
order_id=order_id,
reason="Demo reimbursement",
refund=ARTICLE_AMOUNT
@@ -291,9 +291,7 @@ def get_qrcode_svg(data):
# to check if the payment has been completed via the QR code.
@app.route("/check-status/<order_id>/<session_id>")
def check_status(order_id, session_id):
- pay_params = dict(
- instance=INSTANCE, order_id=order_id, session_id=session_id
- )
+ pay_params = dict(order_id=order_id, session_id=session_id)
pay_status = backend_get("check-payment", pay_params)
return flask.jsonify(paid=pay_status["paid"])
@@ -341,7 +339,6 @@ def article(article_name, data=None):
amount=ARTICLE_AMOUNT,
extra=dict(article_name=article_name),
fulfillment_url=flask.request.base_url,
- instance=INSTANCE,
summary="Essay: " + article_name.replace("_", " ")
)
order_resp = backend_post("order", dict(order=order))
@@ -354,9 +351,7 @@ def article(article_name, data=None):
##
# Prepare data for the upcoming payment check.
- pay_params = dict(
- instance=INSTANCE, order_id=order_id, session_id=session_id
- )
+ pay_params = dict(order_id=order_id, session_id=session_id)
pay_status = backend_get("check-payment", pay_params)