forked from 3wordchant/capsul-flask
better error handling when the btcpay server goes down
This commit is contained in:
@ -58,14 +58,19 @@ def btcpay_payment():
|
||||
dollars = result[1]
|
||||
|
||||
if len(errors) == 0:
|
||||
invoice = current_app.config['BTCPAY_CLIENT'].create_invoice(dict(
|
||||
price=float(dollars),
|
||||
currency="USD",
|
||||
itemDesc="Capsul Cloud Compute",
|
||||
transactionSpeed="high",
|
||||
redirectURL=f"{current_app.config['BASE_URL']}/console/account-balance",
|
||||
notificationURL=f"{current_app.config['BASE_URL']}/payment/btcpay/webhook"
|
||||
))
|
||||
try:
|
||||
invoice = current_app.config['BTCPAY_CLIENT'].create_invoice(dict(
|
||||
price=float(dollars),
|
||||
currency="USD",
|
||||
itemDesc="Capsul Cloud Compute",
|
||||
transactionSpeed="high",
|
||||
redirectURL=f"{current_app.config['BASE_URL']}/console/account-balance",
|
||||
notificationURL=f"{current_app.config['BASE_URL']}/payment/btcpay/webhook"
|
||||
))
|
||||
except:
|
||||
current_app.logger.error(f"An error occurred while attempting to reach BTCPay Server: {my_exec_info_message(sys.exc_info())}")
|
||||
flash("An error occurred while attempting to reach BTCPay Server.")
|
||||
return redirect(url_for("console.account_balance"))
|
||||
|
||||
current_app.logger.info(f"created btcpay invoice: {invoice}")
|
||||
|
||||
|
Reference in New Issue
Block a user