mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-25 19:36:15 +02:00
prettier and black stuff.
This commit is contained in:
@@ -286,7 +286,11 @@ async def create_payment(
|
|||||||
|
|
||||||
async def update_payment_status(checking_id: str, pending: bool) -> None:
|
async def update_payment_status(checking_id: str, pending: bool) -> None:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"UPDATE apipayments SET pending = ? WHERE checking_id = ?", (int(pending), checking_id,),
|
"UPDATE apipayments SET pending = ? WHERE checking_id = ?",
|
||||||
|
(
|
||||||
|
int(pending),
|
||||||
|
checking_id,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -34,12 +34,20 @@ async def get_or_create_shop_by_wallet(wallet: str) -> Optional[Shop]:
|
|||||||
|
|
||||||
async def set_wordlist(shop: int, wordlist: str) -> Optional[Shop]:
|
async def set_wordlist(shop: int, wordlist: str) -> Optional[Shop]:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"UPDATE shops SET wordlist = ? WHERE id = ?", (wordlist, shop),
|
"UPDATE shops SET wordlist = ? WHERE id = ?",
|
||||||
|
(wordlist, shop),
|
||||||
)
|
)
|
||||||
return await get_shop(shop)
|
return await get_shop(shop)
|
||||||
|
|
||||||
|
|
||||||
async def add_item(shop: int, name: str, description: str, image: Optional[str], price: int, unit: str,) -> int:
|
async def add_item(
|
||||||
|
shop: int,
|
||||||
|
name: str,
|
||||||
|
description: str,
|
||||||
|
image: Optional[str],
|
||||||
|
price: int,
|
||||||
|
unit: str,
|
||||||
|
) -> int:
|
||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO items (shop, name, description, image, price, unit)
|
INSERT INTO items (shop, name, description, image, price, unit)
|
||||||
@@ -51,7 +59,13 @@ async def add_item(shop: int, name: str, description: str, image: Optional[str],
|
|||||||
|
|
||||||
|
|
||||||
async def update_item(
|
async def update_item(
|
||||||
shop: int, item_id: int, name: str, description: str, image: Optional[str], price: int, unit: str,
|
shop: int,
|
||||||
|
item_id: int,
|
||||||
|
name: str,
|
||||||
|
description: str,
|
||||||
|
image: Optional[str],
|
||||||
|
price: int,
|
||||||
|
unit: str,
|
||||||
) -> int:
|
) -> int:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
|
@@ -8,20 +8,35 @@
|
|||||||
<q-card-section>
|
<q-card-section>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Register items.</li>
|
<li>Register items.</li>
|
||||||
<li>Print QR codes and paste them on your store, your menu, somewhere, somehow.</li>
|
<li>
|
||||||
<li>Clients scan the QR codes and get information about the items plus the price on their phones directly (they must have internet)</li>
|
Print QR codes and paste them on your store, your menu, somewhere,
|
||||||
<li>Once they decide to pay, they'll get an invoice on their phones automatically</li>
|
somehow.
|
||||||
<li>When the payment is confirmed, a confirmation code will be issued for them.</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
Clients scan the QR codes and get information about the items plus the
|
||||||
|
price on their phones directly (they must have internet)
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Once they decide to pay, they'll get an invoice on their phones
|
||||||
|
automatically
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
When the payment is confirmed, a confirmation code will be issued for
|
||||||
|
them.
|
||||||
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p>
|
<p>
|
||||||
The confirmation codes are words from a predefined sequential word list. Each new payment bumps the words sequence by 1. So you can check the confirmation codes manually by just looking at them.
|
The confirmation codes are words from a predefined sequential word list.
|
||||||
|
Each new payment bumps the words sequence by 1. So you can check the
|
||||||
|
confirmation codes manually by just looking at them.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
For example, if your wordlist is <code>[apple, banana, coconut]</code> the first purchase will be <code>apple</code>, the second <code>banana</code> and so on. When it gets to the end it starts from the beginning again.
|
For example, if your wordlist is
|
||||||
</p>
|
<code>[apple, banana, coconut]</code> the first purchase will be
|
||||||
<p>
|
<code>apple</code>, the second <code>banana</code> and so on. When it
|
||||||
Powered by LNURL-pay.
|
gets to the end it starts from the beginning again.
|
||||||
</p>
|
</p>
|
||||||
|
<p>Powered by LNURL-pay.</p>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
@@ -51,8 +66,8 @@
|
|||||||
}}/offlineshop/api/v1/offlineshop/items -H "Content-Type:
|
}}/offlineshop/api/v1/offlineshop/items -H "Content-Type:
|
||||||
application/json" -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -d
|
application/json" -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -d
|
||||||
'{"name": <string>, "description": <string>, "image":
|
'{"name": <string>, "description": <string>, "image":
|
||||||
<data-uri string>, "price": <integer>, "unit": <"sat" or
|
<data-uri string>, "price": <integer>, "unit": <"sat"
|
||||||
"USD">}'
|
or "USD">}'
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
@@ -74,7 +89,10 @@
|
|||||||
</h5>
|
</h5>
|
||||||
<code
|
<code
|
||||||
>{"id": <integer>, "wallet": <string>, "wordlist":
|
>{"id": <integer>, "wallet": <string>, "wordlist":
|
||||||
<string>, "items": [{"id": <integer>, "name": <string>, "description": <string>, "image": <string>, "enabled": <boolean>, "price": <integer>, "unit": <string>, "lnurl": <string>}, ...]}</code
|
<string>, "items": [{"id": <integer>, "name":
|
||||||
|
<string>, "description": <string>, "image":
|
||||||
|
<string>, "enabled": <boolean>, "price": <integer>,
|
||||||
|
"unit": <string>, "lnurl": <string>}, ...]}<</code
|
||||||
>
|
>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
|
@@ -24,7 +24,14 @@ async def api_shop_from_wallet():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
jsonify({**shop._asdict(), **{"items": [item.values() for item in items],},}),
|
jsonify(
|
||||||
|
{
|
||||||
|
**shop._asdict(),
|
||||||
|
**{
|
||||||
|
"items": [item.values() for item in items],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
HTTPStatus.OK,
|
HTTPStatus.OK,
|
||||||
)
|
)
|
||||||
except LnurlInvalidUrl:
|
except LnurlInvalidUrl:
|
||||||
@@ -50,7 +57,12 @@ async def api_add_or_update_item(item_id=None):
|
|||||||
shop = await get_or_create_shop_by_wallet(g.wallet.id)
|
shop = await get_or_create_shop_by_wallet(g.wallet.id)
|
||||||
if item_id == None:
|
if item_id == None:
|
||||||
await add_item(
|
await add_item(
|
||||||
shop.id, g.data["name"], g.data["description"], g.data.get("image"), g.data["price"], g.data["unit"],
|
shop.id,
|
||||||
|
g.data["name"],
|
||||||
|
g.data["description"],
|
||||||
|
g.data.get("image"),
|
||||||
|
g.data["price"],
|
||||||
|
g.data["unit"],
|
||||||
)
|
)
|
||||||
return "", HTTPStatus.CREATED
|
return "", HTTPStatus.CREATED
|
||||||
else:
|
else:
|
||||||
@@ -77,7 +89,9 @@ async def api_delete_item(item_id):
|
|||||||
@offlineshop_ext.route("/api/v1/offlineshop/wordlist", methods=["PUT"])
|
@offlineshop_ext.route("/api/v1/offlineshop/wordlist", methods=["PUT"])
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
@api_validate_post_request(
|
@api_validate_post_request(
|
||||||
schema={"wordlist": {"type": "string", "empty": True, "nullable": True, "required": True},}
|
schema={
|
||||||
|
"wordlist": {"type": "string", "empty": True, "nullable": True, "required": True},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
async def api_set_wordlist():
|
async def api_set_wordlist():
|
||||||
wordlist = g.data["wordlist"].split("\n") if g.data["wordlist"] else None
|
wordlist = g.data["wordlist"].split("\n") if g.data["wordlist"] else None
|
||||||
|
Reference in New Issue
Block a user