lnurlpos working
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
from lnurl import Lnurl, LnurlWithdrawResponse, encode as lnurl_encode # type: ignore
|
||||
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode, ParseResult
|
||||
from lnurl.types import LnurlPayMetadata # type: ignore
|
||||
from lnurl.models import LnurlPaySuccessAction, UrlAction # type: ignore
|
||||
from sqlite3 import Row
|
||||
from typing import NamedTuple, Optional, Dict
|
||||
import shortuuid # type: ignore
|
||||
@@ -26,29 +27,24 @@ class lnurlposs(BaseModel):
|
||||
currency: str
|
||||
timestamp: str
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "lnurlposs":
|
||||
return cls(**dict(row))
|
||||
|
||||
@property
|
||||
def lnurl(self) -> Lnurl:
|
||||
url = url_for("lnurlpos.lnurl_response", pos_id=self.id, _external=True)
|
||||
def lnurl(self, req: Request) -> Lnurl:
|
||||
url = req.url_for("lnurlpos.lnurl_response", pos_id=self.id, _external=True)
|
||||
return lnurl_encode(url)
|
||||
|
||||
@property
|
||||
def lnurlpay_metadata(self) -> LnurlPayMetadata:
|
||||
async def lnurlpay_metadata(self) -> LnurlPayMetadata:
|
||||
return LnurlPayMetadata(json.dumps([["text/plain", self.title]]))
|
||||
|
||||
def success_action(self, paymentid: str, req: Request) -> Optional[Dict]:
|
||||
url = url_for(
|
||||
"lnurlpos.displaypin",
|
||||
paymentid=paymentid,
|
||||
def success_action(
|
||||
self, paymentid: str, req: Request
|
||||
) -> Optional[LnurlPaySuccessAction]:
|
||||
|
||||
return UrlAction(
|
||||
url=req.url_for("lnurlpos.displaypin", paymentid=paymentid),
|
||||
description="Check the attached link",
|
||||
)
|
||||
return {
|
||||
"tag": "url",
|
||||
"description": "Check the attached link",
|
||||
"url": url,
|
||||
}
|
||||
|
||||
|
||||
class lnurlpospayment(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user