Skip to content

Commit d1cb9f6

Browse files
authored
fix: v1 update, make withdraw post (#105)
* make withdraw post * add id repo and version to config.json
1 parent d42e1d1 commit d1cb9f6

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

config.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2+
"id": "tpos",
3+
"version": "1.0.0",
24
"name": "TPoS",
5+
"repo": "https://github.com/lnbits/tpos",
36
"short_description": "A shareable PoS terminal!",
47
"tile": "/tpos/static/image/tpos.png",
58
"min_lnbits_version": "1.0.0",

models.py

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from pydantic import BaseModel, Field, validator
77

88

9+
class CreateWithdrawPay(BaseModel):
10+
pay_link: str
11+
12+
913
class CreateTposInvoice(BaseModel):
1014
amount: int = Query(..., ge=1)
1115
memo: Optional[str] = Query(None)

static/js/tpos.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,12 @@ window.app = Vue.createApp({
570570
}
571571
LNbits.api
572572
.request(
573-
'GET',
574-
`/tpos/api/v1/atm/withdraw/${this.atmToken}/${this.sat}/pay?payLink=${payLink}`
573+
'POST',
574+
`/tpos/api/v1/atm/withdraw/${this.atmToken}/${this.sat}/pay`,
575+
null,
576+
{
577+
pay_link: payLink
578+
}
575579
)
576580
.then(res => {
577581
if (!res.data.success) {

templates/tpos/dialogs.html

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
target="_blank"
1414
rel="noopener noreferrer"
1515
>
16-
<q-responsive :ratio="1" class="q-mx-xl q-mb-md">
17-
<lnbits-qrcode
18-
:value="'lightning:' + invoiceDialog.data.payment_request.toUpperCase()"
19-
:options="{width: 800}"
20-
class="rounded-borders"
21-
></lnbits-qrcode>
22-
</q-responsive>
16+
<lnbits-qrcode
17+
:value="'lightning:' + invoiceDialog.data.payment_request.toUpperCase()"
18+
class="rounded-borders"
19+
></lnbits-qrcode>
2320
<q-tooltip>Pay in wallet</q-tooltip>
2421
</a>
2522
<div class="text-center">
@@ -111,7 +108,6 @@ <h5 class="q-mt-none q-mb-sm">
111108
<q-responsive :ratio="1" class="q-mx-xl q-mb-md">
112109
<lnbits-qrcode
113110
value="{{ request.url }}"
114-
:options="{width: 800}"
115111
class="rounded-borders"
116112
></lnbits-qrcode>
117113
</q-responsive>

views_api.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
CreateTposData,
3434
CreateTposInvoice,
3535
CreateUpdateItemData,
36+
CreateWithdrawPay,
3637
LnurlCharge,
3738
PayLnurlWData,
3839
Tpos,
@@ -237,15 +238,15 @@ async def api_tpos_atm_pin_check(tpos_id: str, atmpin: int) -> LnurlCharge:
237238
return token
238239

239240

240-
@tpos_api_router.get(
241+
@tpos_api_router.post(
241242
"/api/v1/atm/withdraw/{k1}/{amount}/pay", status_code=HTTPStatus.OK
242243
)
243244
async def api_tpos_atm_pay(
244-
request: Request, k1: str, amount: int, pay_link: str = Query(...)
245+
request: Request, k1: str, amount: int, data: CreateWithdrawPay
245246
):
246247
try:
247248
# get the payment_request from the lnurl
248-
pay_link = pay_link.replace("lnurlp://", "https://")
249+
pay_link = data.pay_link.replace("lnurlp://", "https://")
249250
async with httpx.AsyncClient() as client:
250251
headers = {"user-agent": "lnbits/tpos"}
251252
r = await client.get(pay_link, follow_redirects=True, headers=headers)
@@ -258,10 +259,10 @@ async def api_tpos_atm_pay(
258259
if resp["tag"] != "payRequest":
259260
return {"success": False, "detail": "Wrong tag type"}
260261

261-
if amount < resp["minSendable"]:
262+
if amount < int(resp["minSendable"]):
262263
return {"success": False, "detail": "Amount too low"}
263264

264-
if amount > resp["maxSendable"]:
265+
if amount > int(resp["maxSendable"]):
265266
return {"success": False, "detail": "Amount too high"}
266267

267268
cb_res = await client.get(

0 commit comments

Comments
 (0)