This commit is contained in:
benarc 2024-02-01 17:18:55 +00:00
parent 66d44f95fb
commit 2cac36be17
12 changed files with 272 additions and 311 deletions

View file

@ -29,6 +29,7 @@ async def wait_for_paid_invoices():
# do somethhing when an invoice related top this extension is paid
async def on_invoice_paid(payment: Payment) -> None:
logger.debug("payment received for myextension extension")
if payment.extra.get("tag") != "MyExtension":
@ -42,20 +43,18 @@ async def on_invoice_paid(payment: Payment) -> None:
total = myextension.total - payment.amount
else:
total = myextension.total + payment.amount
data_to_update = {
"total": total
}
data_to_update = {"total": total}
await update_myextension(myextension_id=myextension_id, **data_to_update)
# here we could send some data to a websocket on wss://<your-lnbits>/api/v1/ws/<myextension_id>
# and then listen to it on the frontend, which we do with index.html connectWebocket()
some_payment_data = {
"name": myextension.name,
"amount": payment.amount,
"fee": payment.fee,
"checking_id": payment.checking_id
"checking_id": payment.checking_id,
}
await websocketUpdater(myextension_id, str(some_payment_data))