Skip to content

API 7.4 - Invoice changes #4283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/substitutions/global.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@
.. |message_effect_id| replace:: Unique identifier of the message effect to be added to the message; for private chats only.

.. |show_cap_above_med| replace:: :obj:`True`, if the caption must be shown above the message media.

.. |tg_stars| replace:: `Telegram Stars <https://t.me/BotNews/90>`__
67 changes: 42 additions & 25 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4918,7 +4918,7 @@ async def send_invoice(
title: str,
description: str,
payload: str,
provider_token: str,
provider_token: Optional[str], # This arg is now optional as of Bot API 7.4
currency: str,
prices: Sequence["LabeledPrice"],
start_parameter: Optional[str] = None,
Expand Down Expand Up @@ -4973,12 +4973,19 @@ async def send_invoice(
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
displayed to the user, use for your internal processes.
provider_token (:obj:`str`): Payments provider token, obtained via
`@BotFather <https://t.me/BotFather>`_.
`@BotFather <https://t.me/BotFather>`_. Pass an empty string for payments in
|tg_stars|.

.. deprecated:: NEXT.VERSION
As of Bot API 7.4, this parameter is now optional and future versions of the
library will make it optional as well.

currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
<https://core.telegram.org/bots/payments#supported-currencies>`_.
<https://core.telegram.org/bots/payments#supported-currencies>`_. Pass ``XTR`` for
payment in |tg_stars|.
prices (Sequence[:class:`telegram.LabeledPrice`]): Price breakdown, a sequence
of components (e.g. product price, tax, discount, delivery cost, delivery tax,
bonus, etc.).
bonus, etc.). Must contain exactly one item for payment in |tg_stars|.

.. versionchanged:: 20.0
|sequenceargs|
Expand All @@ -4987,7 +4994,7 @@ async def send_invoice(
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the
majority of currencies). Defaults to ``0``.
majority of currencies). Defaults to ``0``. Not supported for payment in |tg_stars|

.. versionadded:: 13.5
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
Expand Down Expand Up @@ -5020,19 +5027,20 @@ async def send_invoice(
photo_width (:obj:`int`, optional): Photo width.
photo_height (:obj:`int`, optional): Photo height.
need_name (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's full
name to complete the order.
name to complete the order. Ignored for payments in |tg_stars|.
need_phone_number (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's
phone number to complete the order.
phone number to complete the order. Ignored for payments in |tg_stars|.
need_email (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's email
to complete the order.
to complete the order. Ignored for payments in |tg_stars|.
need_shipping_address (:obj:`bool`, optional): Pass :obj:`True`, if you require the
user's shipping address to complete the order.
user's shipping address to complete the order. Ignored for payments in
|tg_stars|.
send_phone_number_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's
phone number should be sent to provider.
phone number should be sent to provider. Ignored for payments in |tg_stars|.
send_email_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's email
address should be sent to provider.
address should be sent to provider. Ignored for payments in |tg_stars|.
is_flexible (:obj:`bool`, optional): Pass :obj:`True`, if the final price depends on
the shipping method.
the shipping method. Ignored for payments in |tg_stars|.
disable_notification (:obj:`bool`, optional): |disable_notification|
protect_content (:obj:`bool`, optional): |protect_content|

Expand Down Expand Up @@ -7859,7 +7867,7 @@ async def create_invoice_link(
title: str,
description: str,
payload: str,
provider_token: str,
provider_token: Optional[str], # This arg is now optional as of Bot API 7.4
currency: str,
prices: Sequence["LabeledPrice"],
max_tip_amount: Optional[int] = None,
Expand Down Expand Up @@ -7898,12 +7906,19 @@ async def create_invoice_link(
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
displayed to the user, use for your internal processes.
provider_token (:obj:`str`): Payments provider token, obtained via
`@BotFather <https://t.me/BotFather>`_.
`@BotFather <https://t.me/BotFather>`_. Pass an empty string for payments in
|tg_stars|.

.. deprecated:: NEXT.VERSION
As of Bot API 7.4, this parameter is now optional and future versions of the
library will make it optional as well.

currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
<https://core.telegram.org/bots/payments#supported-currencies>`_.
<https://core.telegram.org/bots/payments#supported-currencies>`_. Pass ``XTR`` for
payments in |tg_stars|.
prices (Sequence[:class:`telegram.LabeledPrice`)]: Price breakdown, a sequence
of components (e.g. product price, tax, discount, delivery cost, delivery tax,
bonus, etc.).
bonus, etc.). Must contain exactly one item for payments in |tg_stars|.

.. versionchanged:: 20.0
|sequenceargs|
Expand All @@ -7912,7 +7927,8 @@ async def create_invoice_link(
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the
majority of currencies). Defaults to ``0``.
majority of currencies). Defaults to ``0``. Not supported for payments in
|tg_stars|.
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
Expand All @@ -7931,19 +7947,20 @@ async def create_invoice_link(
photo_width (:obj:`int`, optional): Photo width.
photo_height (:obj:`int`, optional): Photo height.
need_name (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's full
name to complete the order.
name to complete the order. Ignored for payments in |tg_stars|.
need_phone_number (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's
phone number to complete the order.
phone number to complete the order. Ignored for payments in |tg_stars|.
need_email (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's email
address to complete the order.
address to complete the order. Ignored for payments in |tg_stars|.
need_shipping_address (:obj:`bool`, optional): Pass :obj:`True`, if you require the
user's shipping address to complete the order.
user's shipping address to complete the order. Ignored for payments in
|tg_stars|.
send_phone_number_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's
phone number should be sent to provider.
phone number should be sent to provider. Ignored for payments in |tg_stars|.
send_email_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's email
address should be sent to provider.
address should be sent to provider. Ignored for payments in |tg_stars|.
is_flexible (:obj:`bool`, optional): Pass :obj:`True`, if the final price depends on
the shipping method.
the shipping method. Ignored for payments in |tg_stars|.

Returns:
:class:`str`: On success, the created invoice link is returned.
Expand Down Expand Up @@ -9022,7 +9039,7 @@ async def refund_star_payment(
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: Optional[JSONDict] = None,
) -> bool:
"""Refunds a successful payment in `Telegram Stars <https://t.me/BotNews/90>`.
"""Refunds a successful payment in |tg_stars|.

.. versionadded:: NEXT.VERSION

Expand Down
2 changes: 1 addition & 1 deletion telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ async def send_invoice(
title: str,
description: str,
payload: str,
provider_token: str,
provider_token: Optional[str],
currency: str,
prices: Sequence["LabeledPrice"],
start_parameter: Optional[str] = None,
Expand Down
67 changes: 38 additions & 29 deletions telegram/_inline/inputinvoicemessagecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ class InputInvoiceMessageContent(InputMessageContent):
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be displayed
to the user, use for your internal processes.
provider_token (:obj:`str`): Payment provider token, obtained via
`@Botfather <https://t.me/Botfather>`_.
`@Botfather <https://t.me/Botfather>`_. Pass an empty string for payments in
|tg_stars|.

.. deprecated:: NEXT.VERSION
As of Bot API 7.4, this parameter is now optional and future versions of the
library will make it optional as well.
currency (:obj:`str`): Three-letter ISO 4217 currency code, see more on
`currencies <https://core.telegram.org/bots/payments#supported-currencies>`_
`currencies <https://core.telegram.org/bots/payments#supported-currencies>`_.
Pass ``XTR`` for payments in |tg_stars|.
prices (Sequence[:class:`telegram.LabeledPrice`]): Price breakdown, a list of
components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus,
etc.)
etc.). Must contain exactly one item for payments in |tg_stars|.

.. versionchanged:: 20.0
|sequenceclassargs|
Expand All @@ -64,7 +70,8 @@ class InputInvoiceMessageContent(InputMessageContent):
maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the majority
of currencies). Defaults to ``0``.
of currencies). Defaults to ``0``. Defaults to ``0``. Not supported for payments in
|tg_stars|.
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of suggested
amounts of tip in the *smallest* units of the currency (integer, **not** float/double).
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be
Expand All @@ -85,20 +92,20 @@ class InputInvoiceMessageContent(InputMessageContent):
photo_size (:obj:`int`, optional): Photo size.
photo_width (:obj:`int`, optional): Photo width.
photo_height (:obj:`int`, optional): Photo height.
need_name (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's full name to
complete the order.
need_name (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's full
name to complete the order. Ignored for payments in |tg_stars|.
need_phone_number (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's
phone number to complete the order
phone number to complete the order. Ignored for payments in |tg_stars|.
need_email (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's email
address to complete the order.
need_shipping_address (:obj:`bool`, optional): Pass :obj:`True`, if you require the user's
shipping address to complete the order
send_phone_number_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's phone
number should be sent to provider.
send_email_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's email address
should be sent to provider.
is_flexible (:obj:`bool`, optional): Pass :obj:`True`, if the final price depends on the
shipping method.
address to complete the order. Ignored for payments in |tg_stars|.
need_shipping_address (:obj:`bool`, optional): Pass :obj:`True`, if you require the
user's shipping address to complete the order. Ignored for payments in |tg_stars|
send_phone_number_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's
phone number should be sent to provider. Ignored for payments in |tg_stars|.
send_email_to_provider (:obj:`bool`, optional): Pass :obj:`True`, if user's email
address should be sent to provider. Ignored for payments in |tg_stars|.
is_flexible (:obj:`bool`, optional): Pass :obj:`True`, if the final price depends on
the shipping method. Ignored for payments in |tg_stars|.

Attributes:
title (:obj:`str`): Product name. :tg-const:`telegram.Invoice.MIN_TITLE_LENGTH`-
Expand All @@ -111,12 +118,14 @@ class InputInvoiceMessageContent(InputMessageContent):
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be displayed
to the user, use for your internal processes.
provider_token (:obj:`str`): Payment provider token, obtained via
`@Botfather <https://t.me/Botfather>`_.
`@Botfather <https://t.me/Botfather>`_. Pass an empty string for payments in `Telegram
Stars <https://t.me/BotNews/90>`_.
currency (:obj:`str`): Three-letter ISO 4217 currency code, see more on
`currencies <https://core.telegram.org/bots/payments#supported-currencies>`_
`currencies <https://core.telegram.org/bots/payments#supported-currencies>`_.
Pass ``XTR`` for payments in |tg_stars|.
prices (Tuple[:class:`telegram.LabeledPrice`]): Price breakdown, a list of
components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus,
etc.)
etc.). Must contain exactly one item for payments in |tg_stars|.

.. versionchanged:: 20.0
|tupleclassattrs|
Expand All @@ -126,7 +135,7 @@ class InputInvoiceMessageContent(InputMessageContent):
maximum tip of US$ 1.45 ``max_tip_amount`` is ``145``. See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the majority
of currencies). Defaults to ``0``.
of currencies). Defaults to ``0``. Not supported for payments in |tg_stars|.
suggested_tip_amounts (Tuple[:obj:`int`]): Optional. An array of suggested
amounts of tip in the *smallest* units of the currency (integer, **not** float/double).
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be
Expand All @@ -146,19 +155,19 @@ class InputInvoiceMessageContent(InputMessageContent):
photo_width (:obj:`int`): Optional. Photo width.
photo_height (:obj:`int`): Optional. Photo height.
need_name (:obj:`bool`): Optional. Pass :obj:`True`, if you require the user's full name to
complete the order.
complete the order. Ignored for payments in |tg_stars|.
need_phone_number (:obj:`bool`): Optional. Pass :obj:`True`, if you require the user's
phone number to complete the order
phone number to complete the order. Ignored for payments in |tg_stars|.
need_email (:obj:`bool`): Optional. Pass :obj:`True`, if you require the user's email
address to complete the order.
address to complete the order. Ignored for payments in |tg_stars|.
need_shipping_address (:obj:`bool`): Optional. Pass :obj:`True`, if you require the user's
shipping address to complete the order
shipping address to complete the order. Ignored for payments in |tg_stars|.
send_phone_number_to_provider (:obj:`bool`): Optional. Pass :obj:`True`, if user's phone
number should be sent to provider.
number should be sent to provider. Ignored for payments in |tg_stars|.
send_email_to_provider (:obj:`bool`): Optional. Pass :obj:`True`, if user's email address
should be sent to provider.
should be sent to provider. Ignored for payments in |tg_stars|.
is_flexible (:obj:`bool`): Optional. Pass :obj:`True`, if the final price depends on the
shipping method.
shipping method. Ignored for payments in |tg_stars|.

"""

Expand Down Expand Up @@ -190,7 +199,7 @@ def __init__(
title: str,
description: str,
payload: str,
provider_token: str,
provider_token: Optional[str], # This arg is now optional since Bot API 7.4
currency: str,
prices: Sequence[LabeledPrice],
max_tip_amount: Optional[int] = None,
Expand All @@ -216,7 +225,7 @@ def __init__(
self.title: str = title
self.description: str = description
self.payload: str = payload
self.provider_token: str = provider_token
self.provider_token: Optional[str] = provider_token
self.currency: str = currency
self.prices: Tuple[LabeledPrice, ...] = parse_sequence_arg(prices)
# Optionals
Expand Down
2 changes: 1 addition & 1 deletion telegram/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3256,7 +3256,7 @@ async def reply_invoice(
title: str,
description: str,
payload: str,
provider_token: str,
provider_token: Optional[str],
currency: str,
prices: Sequence["LabeledPrice"],
start_parameter: Optional[str] = None,
Expand Down
6 changes: 4 additions & 2 deletions telegram/_payment/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Invoice(TelegramObject):
description (:obj:`str`): Product description.
start_parameter (:obj:`str`): Unique bot deep-linking parameter that can be used to
generate this invoice.
currency (:obj:`str`): Three-letter ISO 4217 currency code.
currency (:obj:`str`): Three-letter ISO 4217 currency code, or ``XTR`` for payments in
|tg_stars|.
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer, not
float/double). For example, for a price of US$ 1.45 pass ``amount = 145``. See the
``exp`` parameter in
Expand All @@ -50,7 +51,8 @@ class Invoice(TelegramObject):
description (:obj:`str`): Product description.
start_parameter (:obj:`str`): Unique bot deep-linking parameter that can be used to
generate this invoice.
currency (:obj:`str`): Three-letter ISO 4217 currency code.
currency (:obj:`str`): Three-letter ISO 4217 currency code, or ``XTR`` for payments in
|tg_stars|.
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer, not
float/double). For example, for a price of US$ 1.45 ``amount`` is ``145``. See the
``exp`` parameter in
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy