mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-02 08:58:33 +02:00
fix: LNbits backend wallet
This commit is contained in:
parent
5fe64d324d
commit
ab190454f4
@ -1,7 +1,9 @@
|
||||
from requests import get, post
|
||||
from os import getenv
|
||||
from requests import get, post
|
||||
|
||||
from .base import InvoiceResponse, PaymentResponse, PaymentStatus, Wallet
|
||||
|
||||
|
||||
class LnbitsWallet(Wallet):
|
||||
|
||||
def __init__(self):
|
||||
@ -22,6 +24,7 @@ class LnbitsWallet(Wallet):
|
||||
checking_id, payment_request = data["checking_id"], data["payment_request"]
|
||||
else:
|
||||
error_message = r.json()["message"]
|
||||
|
||||
return InvoiceResponse(ok, checking_id, payment_request, error_message)
|
||||
|
||||
def pay_invoice(self, bolt11: str) -> PaymentResponse:
|
||||
@ -37,12 +40,21 @@ class LnbitsWallet(Wallet):
|
||||
checking_id = data["checking_id"]
|
||||
else:
|
||||
error_message = r.json()["message"]
|
||||
return InvoiceResponse(ok, checking_id, fee_msat, error_message)
|
||||
|
||||
return PaymentResponse(ok, checking_id, fee_msat, error_message)
|
||||
|
||||
def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
||||
r = get(url=f"{self.endpoint}/api/v1/payments/{checking_id}", headers=self.auth_invoice)
|
||||
return PaymentStatus(r['paid'])
|
||||
|
||||
if not r.ok:
|
||||
return PaymentStatus(None)
|
||||
|
||||
return PaymentStatus(r.json()['paid'])
|
||||
|
||||
def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
||||
r = get(url=f"{self.endpoint}/api/v1/payments/{checking_id}", headers=self.auth_invoice)
|
||||
return PaymentStatus(r['paid'])
|
||||
|
||||
if not r.ok:
|
||||
return PaymentStatus(None)
|
||||
|
||||
return PaymentStatus(r.json()['paid'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user