mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-05 14:54:51 +00:00
pyrofork: Update send_invoice doc
also add support for non-iterable prices Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
f030f00e9d
commit
e0e5bdb2cd
1 changed files with 24 additions and 6 deletions
|
|
@ -27,7 +27,7 @@ class SendInvoice:
|
||||||
title: str,
|
title: str,
|
||||||
description: str,
|
description: str,
|
||||||
currency: str,
|
currency: str,
|
||||||
prices: List["types.LabeledPrice"],
|
prices: Union["types.LabeledPrice", List["types.LabeledPrice"]],
|
||||||
provider: str = None,
|
provider: str = None,
|
||||||
provider_data: str = None,
|
provider_data: str = None,
|
||||||
payload: str = None,
|
payload: str = None,
|
||||||
|
|
@ -60,8 +60,10 @@ class SendInvoice:
|
||||||
Three-letter ISO 4217 currency code.
|
Three-letter ISO 4217 currency code.
|
||||||
`XTR` for Telegram Stars.
|
`XTR` for Telegram Stars.
|
||||||
|
|
||||||
prices (List of :obj:`~pyrogram.types.LabeledPrice`):
|
prices (:obj:`~pyrogram.types.LabeledPrice` | List of :obj:`~pyrogram.types.LabeledPrice`):
|
||||||
Price with label.
|
Price with label.
|
||||||
|
If you add multiple prices, the prices will be added up.
|
||||||
|
For stars invoice you can only have one item.
|
||||||
|
|
||||||
provider (``str``, *optional*):
|
provider (``str``, *optional*):
|
||||||
Payment provider.
|
Payment provider.
|
||||||
|
|
@ -113,13 +115,27 @@ class SendInvoice:
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# USD
|
# USD (single prices)
|
||||||
app.send_invoice(
|
app.send_invoice(
|
||||||
chat_id,
|
chat_id,
|
||||||
title="Product Name",
|
title="Product Name",
|
||||||
description="Product Description",
|
description="Product Description",
|
||||||
currency="USD",
|
currency="USD",
|
||||||
prices=[types.LabeledPrice("Product", 1000)],
|
prices=types.LabeledPrice("Product", 1000),
|
||||||
|
provider="Stripe_provider_codes",
|
||||||
|
provider_data="{}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# USD (multiple prices)
|
||||||
|
app.send_invoice(
|
||||||
|
chat_id,
|
||||||
|
title="Product Name",
|
||||||
|
description="Product Description",
|
||||||
|
currency="USD",
|
||||||
|
prices=[
|
||||||
|
types.LabeledPrice("Product 1", 1000),
|
||||||
|
types.LabeledPrice("Product 2", 2000)
|
||||||
|
],
|
||||||
provider="Stripe_provider_codes",
|
provider="Stripe_provider_codes",
|
||||||
provider_data="{}"
|
provider_data="{}"
|
||||||
)
|
)
|
||||||
|
|
@ -130,10 +146,12 @@ class SendInvoice:
|
||||||
title="Product Name",
|
title="Product Name",
|
||||||
description="Product Description",
|
description="Product Description",
|
||||||
currency="XTR",
|
currency="XTR",
|
||||||
prices=[types.LabeledPrice("Product", 1000)]
|
prices=types.LabeledPrice("Product", 1000)
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
is_iterable = not isinstance(prices, types.LabeledPrice)
|
||||||
|
|
||||||
if reply_markup is not None:
|
if reply_markup is not None:
|
||||||
has_buy_button = False
|
has_buy_button = False
|
||||||
for i in reply_markup.inline_keyboard:
|
for i in reply_markup.inline_keyboard:
|
||||||
|
|
@ -170,7 +188,7 @@ class SendInvoice:
|
||||||
description=description,
|
description=description,
|
||||||
invoice=raw.types.Invoice(
|
invoice=raw.types.Invoice(
|
||||||
currency=currency,
|
currency=currency,
|
||||||
prices=[price.write() for price in prices]
|
prices=[price.write() for price in prices] if is_iterable else [prices.write()]
|
||||||
),
|
),
|
||||||
payload=encoded_payload,
|
payload=encoded_payload,
|
||||||
provider=provider,
|
provider=provider,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue