From d93b1997357ae3da602a281e43e570fa2bdd2996 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 6 Jul 2022 11:35:11 +0300 Subject: [PATCH] fix: pass `charge` param as JSON --- .../satspay/templates/satspay/display.html | 16 +++++++++------- lnbits/extensions/satspay/views.py | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lnbits/extensions/satspay/templates/satspay/display.html b/lnbits/extensions/satspay/templates/satspay/display.html index 8c577fbe..680e5fbe 100644 --- a/lnbits/extensions/satspay/templates/satspay/display.html +++ b/lnbits/extensions/satspay/templates/satspay/display.html @@ -226,6 +226,7 @@ mixins: [windowMixin], data() { return { + charge: JSON.parse('{{charge | tojson}}'), newProgress: 0.4, counter: 1, newTimeLeft: '', @@ -246,7 +247,7 @@ startPaymentNotifier() { this.cancelListener() - this.cancelListener = LNbits.event.onInvoicePaid( + this.cancelListener = LNbits.events.onInvoicePaid( this.wallet, payment => { this.checkBalance() @@ -258,7 +259,7 @@ LNbits.api .request( 'GET', - '/satspay/api/v1/charges/balance/{{ charge.id }}', + `/satspay/api/v1/charges/balance/${this.charge.id}`, 'filla' ) .then(function (response) { @@ -316,12 +317,13 @@ } }, created: function () { - console.log('{{ charge.onchainaddress }}' == 'None') - if ('{{ charge.lnbitswallet }}' == 'None') { - this.lnbtc = false - this.onbtc = true - } + console.log('### charge ', this.charge) + this.lnbtc = !!this.charge.lnbitswallet + this.onbtc = !!this.charge.onchainwallet + + // empty for onchain this.wallet.inkey = '{{ wallet_inkey }}' + this.getTheTime() this.getThePercentage() var timerCount = this.timerCount diff --git a/lnbits/extensions/satspay/views.py b/lnbits/extensions/satspay/views.py index d33d5c17..67dfe1a0 100644 --- a/lnbits/extensions/satspay/views.py +++ b/lnbits/extensions/satspay/views.py @@ -24,14 +24,15 @@ async def index(request: Request, user: User = Depends(check_user_exists)): @satspay_ext.get("/{charge_id}", response_class=HTMLResponse) -async def display(request: Request, charge_id): +async def display(request: Request, charge_id: str): charge = await get_charge(charge_id) if not charge: raise HTTPException( status_code=HTTPStatus.NOT_FOUND, detail="Charge link does not exist." ) wallet = await get_wallet(charge.lnbitswallet) + inkey = wallet.inkey if wallet else None return satspay_renderer().TemplateResponse( "satspay/display.html", - {"request": request, "charge": charge, "wallet_key": wallet.inkey}, + {"request": request, "charge": charge.dict(), "wallet_inkey": inkey}, )