mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-22 15:57:28 +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:
|
||||
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]:
|
||||
await db.execute(
|
||||
"UPDATE shops SET wordlist = ? WHERE id = ?", (wordlist, shop),
|
||||
"UPDATE shops SET wordlist = ? WHERE id = ?",
|
||||
(wordlist, 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(
|
||||
"""
|
||||
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(
|
||||
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:
|
||||
await db.execute(
|
||||
"""
|
||||
|
@@ -8,20 +8,35 @@
|
||||
<q-card-section>
|
||||
<ol>
|
||||
<li>Register items.</li>
|
||||
<li>Print QR codes and paste them on your store, your menu, somewhere, somehow.</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>
|
||||
<li>
|
||||
Print QR codes and paste them on your store, your menu, somewhere,
|
||||
somehow.
|
||||
</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>
|
||||
<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>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
Powered by LNURL-pay.
|
||||
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.
|
||||
</p>
|
||||
<p>Powered by LNURL-pay.</p>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
@@ -51,8 +66,8 @@
|
||||
}}/offlineshop/api/v1/offlineshop/items -H "Content-Type:
|
||||
application/json" -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -d
|
||||
'{"name": <string>, "description": <string>, "image":
|
||||
<data-uri string>, "price": <integer>, "unit": <"sat" or
|
||||
"USD">}'
|
||||
<data-uri string>, "price": <integer>, "unit": <"sat"
|
||||
or "USD">}'
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
@@ -74,7 +89,10 @@
|
||||
</h5>
|
||||
<code
|
||||
>{"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>
|
||||
<code
|
||||
|
@@ -24,7 +24,14 @@ async def api_shop_from_wallet():
|
||||
|
||||
try:
|
||||
return (
|
||||
jsonify({**shop._asdict(), **{"items": [item.values() for item in items],},}),
|
||||
jsonify(
|
||||
{
|
||||
**shop._asdict(),
|
||||
**{
|
||||
"items": [item.values() for item in items],
|
||||
},
|
||||
}
|
||||
),
|
||||
HTTPStatus.OK,
|
||||
)
|
||||
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)
|
||||
if item_id == None:
|
||||
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
|
||||
else:
|
||||
@@ -77,7 +89,9 @@ async def api_delete_item(item_id):
|
||||
@offlineshop_ext.route("/api/v1/offlineshop/wordlist", methods=["PUT"])
|
||||
@api_check_wallet_key("invoice")
|
||||
@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():
|
||||
wordlist = g.data["wordlist"].split("\n") if g.data["wordlist"] else None
|
||||
|
Reference in New Issue
Block a user