fix: pass charge param as JSON

This commit is contained in:
Vlad Stan
2022-07-06 11:35:11 +03:00
parent 6c63d3000f
commit d93b199735
2 changed files with 12 additions and 9 deletions

View File

@@ -226,6 +226,7 @@
mixins: [windowMixin], mixins: [windowMixin],
data() { data() {
return { return {
charge: JSON.parse('{{charge | tojson}}'),
newProgress: 0.4, newProgress: 0.4,
counter: 1, counter: 1,
newTimeLeft: '', newTimeLeft: '',
@@ -246,7 +247,7 @@
startPaymentNotifier() { startPaymentNotifier() {
this.cancelListener() this.cancelListener()
this.cancelListener = LNbits.event.onInvoicePaid( this.cancelListener = LNbits.events.onInvoicePaid(
this.wallet, this.wallet,
payment => { payment => {
this.checkBalance() this.checkBalance()
@@ -258,7 +259,7 @@
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
'/satspay/api/v1/charges/balance/{{ charge.id }}', `/satspay/api/v1/charges/balance/${this.charge.id}`,
'filla' 'filla'
) )
.then(function (response) { .then(function (response) {
@@ -316,12 +317,13 @@
} }
}, },
created: function () { created: function () {
console.log('{{ charge.onchainaddress }}' == 'None') console.log('### charge ', this.charge)
if ('{{ charge.lnbitswallet }}' == 'None') { this.lnbtc = !!this.charge.lnbitswallet
this.lnbtc = false this.onbtc = !!this.charge.onchainwallet
this.onbtc = true
} // empty for onchain
this.wallet.inkey = '{{ wallet_inkey }}' this.wallet.inkey = '{{ wallet_inkey }}'
this.getTheTime() this.getTheTime()
this.getThePercentage() this.getThePercentage()
var timerCount = this.timerCount var timerCount = this.timerCount

View File

@@ -24,14 +24,15 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
@satspay_ext.get("/{charge_id}", response_class=HTMLResponse) @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) charge = await get_charge(charge_id)
if not charge: if not charge:
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Charge link does not exist." status_code=HTTPStatus.NOT_FOUND, detail="Charge link does not exist."
) )
wallet = await get_wallet(charge.lnbitswallet) wallet = await get_wallet(charge.lnbitswallet)
inkey = wallet.inkey if wallet else None
return satspay_renderer().TemplateResponse( return satspay_renderer().TemplateResponse(
"satspay/display.html", "satspay/display.html",
{"request": request, "charge": charge, "wallet_key": wallet.inkey}, {"request": request, "charge": charge.dict(), "wallet_inkey": inkey},
) )