parent
c2399cf9aa
commit
17c79cd044
7 changed files with 26 additions and 10 deletions
2
Makefile
2
Makefile
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
all: format check requirements.txt
|
all: format check requirements.txt
|
||||||
|
|
||||||
format: prettier black
|
format: black
|
||||||
|
|
||||||
check: mypy checkprettier checkblack
|
check: mypy checkprettier checkblack
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,12 @@ tpos_ext: APIRouter = APIRouter(prefix="/tpos", tags=["TPoS"])
|
||||||
def tpos_renderer():
|
def tpos_renderer():
|
||||||
return template_renderer(["lnbits/extensions/tpos/templates"])
|
return template_renderer(["lnbits/extensions/tpos/templates"])
|
||||||
|
|
||||||
|
|
||||||
from .tasks import wait_for_paid_invoices
|
from .tasks import wait_for_paid_invoices
|
||||||
from .views_api import * # noqa
|
from .views_api import * # noqa
|
||||||
from .views import * # noqa
|
from .views import * # noqa
|
||||||
|
|
||||||
|
|
||||||
def tpos_start():
|
def tpos_start():
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,14 @@ async def create_tpos(wallet_id: str, data: CreateTposData) -> TPoS:
|
||||||
INSERT INTO tpos.tposs (id, wallet, name, currency, tip_options, tip_wallet)
|
INSERT INTO tpos.tposs (id, wallet, name, currency, tip_options, tip_wallet)
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(tpos_id, wallet_id, data.name, data.currency, data.tip_options, data.tip_wallet),
|
(
|
||||||
|
tpos_id,
|
||||||
|
wallet_id,
|
||||||
|
data.name,
|
||||||
|
data.currency,
|
||||||
|
data.tip_options,
|
||||||
|
data.tip_wallet,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
tpos = await get_tpos(tpos_id)
|
tpos = await get_tpos(tpos_id)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ async def m001_initial(db):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def m002_addtip_wallet(db):
|
async def m002_addtip_wallet(db):
|
||||||
"""
|
"""
|
||||||
Add tips to tposs table
|
Add tips to tposs table
|
||||||
|
|
@ -23,6 +24,7 @@ async def m002_addtip_wallet(db):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def m003_addtip_options(db):
|
async def m003_addtip_options(db):
|
||||||
"""
|
"""
|
||||||
Add tips to tposs table
|
Add tips to tposs table
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||||
tipAmount = payment.extra.get("tipAmount")
|
tipAmount = payment.extra.get("tipAmount")
|
||||||
|
|
||||||
if tipAmount is None:
|
if tipAmount is None:
|
||||||
#no tip amount
|
# no tip amount
|
||||||
return
|
return
|
||||||
|
|
||||||
tipAmount = tipAmount * 1000
|
tipAmount = tipAmount * 1000
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ async def tpos(request: Request, tpos_id):
|
||||||
"tpos/tpos.html", {"request": request, "tpos": tpos}
|
"tpos/tpos.html", {"request": request, "tpos": tpos}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@tpos_ext.get("/manifest/{tpos_id}.webmanifest")
|
@tpos_ext.get("/manifest/{tpos_id}.webmanifest")
|
||||||
async def manifest(tpos_id: str):
|
async def manifest(tpos_id: str):
|
||||||
tpos = await get_tpos(tpos_id)
|
tpos = await get_tpos(tpos_id)
|
||||||
|
|
@ -48,10 +49,12 @@ async def manifest(tpos_id: str):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"short_name": LNBITS_SITE_TITLE,
|
"short_name": LNBITS_SITE_TITLE,
|
||||||
"name": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
"name": tpos.name + " - " + LNBITS_SITE_TITLE,
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": LNBITS_CUSTOM_LOGO if LNBITS_CUSTOM_LOGO else "https://cdn.jsdelivr.net/gh/lnbits/lnbits@0.3.0/docs/logos/lnbits.png",
|
"src": LNBITS_CUSTOM_LOGO
|
||||||
|
if LNBITS_CUSTOM_LOGO
|
||||||
|
else "https://cdn.jsdelivr.net/gh/lnbits/lnbits@0.3.0/docs/logos/lnbits.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "900x900",
|
"sizes": "900x900",
|
||||||
}
|
}
|
||||||
|
|
@ -64,9 +67,9 @@ async def manifest(tpos_id: str):
|
||||||
"theme_color": "#1F2234",
|
"theme_color": "#1F2234",
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"name": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
"name": tpos.name + " - " + LNBITS_SITE_TITLE,
|
||||||
"short_name": tpos.name,
|
"short_name": tpos.name,
|
||||||
"description": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
"description": tpos.name + " - " + LNBITS_SITE_TITLE,
|
||||||
"url": "/tpos/" + tpos_id,
|
"url": "/tpos/" + tpos_id,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ async def api_tpos_delete(
|
||||||
|
|
||||||
|
|
||||||
@tpos_ext.post("/api/v1/tposs/{tpos_id}/invoices", status_code=HTTPStatus.CREATED)
|
@tpos_ext.post("/api/v1/tposs/{tpos_id}/invoices", status_code=HTTPStatus.CREATED)
|
||||||
async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tipAmount: int = None, tpos_id: str = None):
|
async def api_tpos_create_invoice(
|
||||||
|
amount: int = Query(..., ge=1), tipAmount: int = None, tpos_id: str = None
|
||||||
|
):
|
||||||
tpos = await get_tpos(tpos_id)
|
tpos = await get_tpos(tpos_id)
|
||||||
|
|
||||||
if not tpos:
|
if not tpos:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue