Fixed payment checking
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/lnurlpos -d '{"title":
|
||||
>curl -X POST {{ request.base_url }}api/v1/lnurlpos -d '{"title":
|
||||
<string>, "message":<string>, "currency":
|
||||
<integer>}' -H "Content-type: application/json" -H "X-Api-Key:
|
||||
{{user.wallets[0].adminkey }}"
|
||||
@@ -70,7 +70,7 @@
|
||||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X POST {{ request.url_root
|
||||
>curl -X POST {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -d ''{"title": <string>,
|
||||
"message":<string>, "currency": <integer>} -H
|
||||
"Content-type: application/json" -H "X-Api-Key:
|
||||
@@ -98,7 +98,7 @@
|
||||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root
|
||||
>curl -X GET {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].inkey }}"
|
||||
</code>
|
||||
@@ -122,7 +122,7 @@
|
||||
<code>[<lnurlpos_object>, ...]</code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/lnurlposs -H "X-Api-Key:
|
||||
>curl -X GET {{ request.base_url }}api/v1/lnurlposs -H "X-Api-Key:
|
||||
{{ user.wallets[0].inkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
@@ -147,7 +147,7 @@
|
||||
<code></code>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root
|
||||
>curl -X DELETE {{ request.base_url
|
||||
}}api/v1/lnurlpos/<lnurlpos_id> -H "X-Api-Key: {{
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
|
||||
@@ -9,6 +9,7 @@ from lnbits.core.crud import get_standalone_payment
|
||||
import hashlib
|
||||
from lnbits.core.services import check_invoice_status
|
||||
from lnbits.core.crud import update_payment_status
|
||||
from lnbits.core.views.api import api_payment
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.exceptions import HTTPException
|
||||
@@ -44,17 +45,13 @@ async def displaypin(request: Request, paymentid: str = Query(None)):
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="lnurlpos not found."
|
||||
)
|
||||
|
||||
status = await check_invoice_status(pos.wallet, lnurlpospayment.payhash)
|
||||
|
||||
is_paid = not status.pending
|
||||
if not is_paid:
|
||||
status = await api_payment(lnurlpospayment.payhash)
|
||||
if status["paid"]:
|
||||
await update_payment_status(checking_id=lnurlpospayment.payhash, pending=True)
|
||||
return lnurlpos_renderer().TemplateResponse(
|
||||
"lnurlpos/error.html",
|
||||
{"request": request, "pin": "filler", "not_paid": True},
|
||||
"lnurlpos/paid.html", {"request": request, "pin": lnurlpospayment.pin}
|
||||
)
|
||||
|
||||
await update_payment_status(checking_id=lnurlpospayment.payhash, pending=True)
|
||||
return lnurlpos_renderer().TemplateResponse(
|
||||
"lnurlpos/paid.html", {"request": request, "pin": lnurlpospayment.pin}
|
||||
"lnurlpos/error.html",
|
||||
{"request": request, "pin": "filler", "not_paid": True},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user