forked from 3wordchant/capsul-flask
fix exceptions related to btcpay HTTP calls. better cleanup of expired
btcpay invoices.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import click
|
||||
@ -86,7 +87,16 @@ def clean_up_unresolved_btcpay_invoices():
|
||||
unresolved_btcpay_invoices = get_model().get_unresolved_btcpay_invoices()
|
||||
for unresolved_invoice in unresolved_btcpay_invoices:
|
||||
invoice_id = unresolved_invoice['id']
|
||||
btcpay_invoice = current_app.config['BTCPAY_CLIENT'].get_invoice(invoice_id)
|
||||
btcpay_invoice = None
|
||||
try:
|
||||
btcpay_invoice = current_app.config['BTCPAY_CLIENT'].get_invoice(invoice_id)
|
||||
except:
|
||||
current_app.logger.error(f"""
|
||||
error was thrown when contacting btcpay server for invoice {invoice_id}:
|
||||
{my_exec_info_message(sys.exc_info())}"""
|
||||
)
|
||||
continue
|
||||
|
||||
days = float((datetime.now() - unresolved_invoice['created']).total_seconds())/float(60*60*24)
|
||||
|
||||
if btcpay_invoice['status'] == "complete":
|
||||
@ -102,6 +112,7 @@ def clean_up_unresolved_btcpay_invoices():
|
||||
f"btcpay server invoice status: {btcpay_invoice['status']}"
|
||||
)
|
||||
get_model().btcpay_invoice_resolved(invoice_id, False)
|
||||
get_model().delete_payment_session("btcpay", invoice_id)
|
||||
|
||||
delete_at_account_balance_dollars = -10
|
||||
|
||||
|
Reference in New Issue
Block a user