From be8cfee3c395fedb39a37d3b9f5f0fd778dbc7d3 Mon Sep 17 00:00:00 2001 From: forest Date: Sat, 16 May 2020 21:24:40 -0500 Subject: [PATCH] add more logs to btcpay webhook --- capsulflask/payment.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/capsulflask/payment.py b/capsulflask/payment.py index 9159d9a..1827d3b 100644 --- a/capsulflask/payment.py +++ b/capsulflask/payment.py @@ -77,11 +77,15 @@ def btcpay_payment(): @bp.route("/btcpay/webhook", methods=("POST",)) def btcpay_webhook(): + current_app.logger.info(f"got btcpay webhook") + # IMPORTANT! there is no signature or credential for the data sent into this webhook :facepalm: # its just a notification, thats all. request_data = json.loads(request.data) invoice_id = request_data['id'] + current_app.logger.info(f"got btcpay webhook with invoice_id={invoice_id}") + # so you better make sure to get the invoice directly from the horses mouth! invoice = current_app.config['BTCPAY_CLIENT'].get_invoice(invoice_id) @@ -90,6 +94,8 @@ def btcpay_webhook(): dollars = invoice['price'] + current_app.logger.info(f"got btcpay webhook with invoice_id={invoice_id}, status={invoice['status']} dollars={dollars}") + if invoice['status'] == "paid" or invoice['status'] == "confirmed" or invoice['status'] == "complete": success_account = get_model().consume_payment_session("btcpay", invoice_id, dollars)