diff --git a/capsulflask/__init__.py b/capsulflask/__init__.py index 151df92..28ab7d6 100644 --- a/capsulflask/__init__.py +++ b/capsulflask/__init__.py @@ -143,7 +143,7 @@ else: app.config['HTTP_CLIENT'] = MyHTTPClient(timeout_seconds=int(app.config['INTERNAL_HTTP_TIMEOUT_SECONDS'])) if app.config['BTCPAY_URL'] != "": - try_reconnnect_btcpay() + try_reconnnect_btcpay(app) # only start the scheduler and attempt to migrate the database if we are running the app. # otherwise we are running a CLI command. diff --git a/capsulflask/payment.py b/capsulflask/payment.py index 796709e..1e2d2fc 100644 --- a/capsulflask/payment.py +++ b/capsulflask/payment.py @@ -1,4 +1,5 @@ import stripe +import requests import json import time import decimal @@ -58,7 +59,7 @@ def btcpay_payment(): flash("BTCPay is not enabled on this server") return redirect(url_for("console.account_balance")) elif 'BTCPAY_CLIENT' not in current_app.config: - if not try_reconnnect_btcpay(): + if not try_reconnnect_btcpay(current_app): flash("can't contact the BTCPay server right now") return redirect(url_for("console.account_balance")) @@ -100,7 +101,7 @@ def btcpay_payment(): def poll_btcpay_session(invoice_id): if 'BTCPAY_CLIENT' not in current_app.config: - if not try_reconnnect_btcpay(): + if not try_reconnnect_btcpay(current_app): return [503, "can't contact btcpay server"] invoice = None @@ -139,17 +140,17 @@ def poll_btcpay_session(invoice_id): return [200, "ok"] -def try_reconnnect_btcpay(): +def try_reconnnect_btcpay(app): try: - response = requests.get(current_app.config['BTCPAY_URL']) + response = requests.get(app.config['BTCPAY_URL']) if response.status_code == 200: - current_app.config['BTCPAY_CLIENT'] = btcpay.Client(api_uri=current_app.config['BTCPAY_URL'], pem=current_app.config['BTCPAY_PRIVATE_KEY']) + app.config['BTCPAY_CLIENT'] = btcpay.Client(api_uri=app.config['BTCPAY_URL'], pem=app.config['BTCPAY_PRIVATE_KEY']) return True else: - current_app.logger.warn(f"Can't reach BTCPAY_URL {current_app.config['BTCPAY_URL']}: Response status code: {response.status_code}. Capsul will work fine except cryptocurrency payments will not work.") + app.logger.warn(f"Can't reach BTCPAY_URL {app.config['BTCPAY_URL']}: Response status code: {response.status_code}. Capsul will work fine except cryptocurrency payments will not work.") return False except: - current_app.logger.warn("unable to create btcpay client. Capsul will work fine except cryptocurrency payments will not work. The error was: " + my_exec_info_message(sys.exc_info())) + app.logger.warn("unable to create btcpay client. Capsul will work fine except cryptocurrency payments will not work. The error was: " + my_exec_info_message(sys.exc_info())) return False diff --git a/capsulflask/static/style.css b/capsulflask/static/style.css index f10468a..9de8767 100644 --- a/capsulflask/static/style.css +++ b/capsulflask/static/style.css @@ -53,9 +53,6 @@ a:hover, a:active, a:visited { .error { color: rgb(173, 74, 8); font-weight: bold; - border: 1px dashed rgb(173, 74, 8); - border-radius: 0.5em; - padding: 1em; } .disabled { diff --git a/capsulflask/templates/account-balance.html b/capsulflask/templates/account-balance.html index 5e2076f..75ce760 100644 --- a/capsulflask/templates/account-balance.html +++ b/capsulflask/templates/account-balance.html @@ -52,7 +52,11 @@ {% else %}
  • Add funds with Bitcoin/Litecoin/Monero (btcpay) - ERROR: the BTCPay server cannot be reached +
  • {% endif %}