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)