mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-19 07:35:19 +00:00
Make provider_token Argument Optional (#4689)
This commit is contained in:
@@ -61,9 +61,9 @@ async def start_with_shipping_callback(update: Update, context: ContextTypes.DEF
|
||||
title,
|
||||
description,
|
||||
payload,
|
||||
PAYMENT_PROVIDER_TOKEN,
|
||||
currency,
|
||||
prices,
|
||||
provider_token=PAYMENT_PROVIDER_TOKEN,
|
||||
need_name=True,
|
||||
need_phone_number=True,
|
||||
need_email=True,
|
||||
@@ -90,7 +90,13 @@ async def start_without_shipping_callback(
|
||||
# optionally pass need_name=True, need_phone_number=True,
|
||||
# need_email=True, need_shipping_address=True, is_flexible=True
|
||||
await context.bot.send_invoice(
|
||||
chat_id, title, description, payload, PAYMENT_PROVIDER_TOKEN, currency, prices
|
||||
chat_id,
|
||||
title,
|
||||
description,
|
||||
payload,
|
||||
currency,
|
||||
prices,
|
||||
provider_token=PAYMENT_PROVIDER_TOKEN,
|
||||
)
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -5177,9 +5177,9 @@ class Bot(TelegramObject, contextlib.AbstractAsyncContextManager["Bot"]):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str], # This arg is now optional as of Bot API 7.4
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
start_parameter: Optional[str] = None,
|
||||
photo_url: Optional[str] = None,
|
||||
photo_size: Optional[int] = None,
|
||||
@@ -5232,13 +5232,13 @@ class Bot(TelegramObject, contextlib.AbstractAsyncContextManager["Bot"]):
|
||||
:tg-const:`telegram.Invoice.MIN_PAYLOAD_LENGTH`-
|
||||
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
|
||||
displayed to the user, use it for your internal processes.
|
||||
provider_token (:obj:`str`): Payments provider token, obtained via
|
||||
provider_token (:obj:`str`, optional): Payments provider token, obtained via
|
||||
`@BotFather <https://t.me/BotFather>`_. Pass an empty string for payments in
|
||||
|tg_stars|.
|
||||
|
||||
.. deprecated:: 21.3
|
||||
As of Bot API 7.4, this parameter is now optional and future versions of the
|
||||
library will make it optional as well.
|
||||
.. versionchanged:: NEXT.VERSION
|
||||
Bot API 7.4 made this parameter is optional and this is now reflected in the
|
||||
function signature.
|
||||
|
||||
currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
|
||||
<https://core.telegram.org/bots/payments#supported-currencies>`_. Pass ``XTR`` for
|
||||
@@ -8252,9 +8252,9 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str], # This arg is now optional as of Bot API 7.4
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
max_tip_amount: Optional[int] = None,
|
||||
suggested_tip_amounts: Optional[Sequence[int]] = None,
|
||||
provider_data: Optional[Union[str, object]] = None,
|
||||
@@ -8296,13 +8296,13 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
||||
:tg-const:`telegram.Invoice.MIN_PAYLOAD_LENGTH`-
|
||||
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be
|
||||
displayed to the user, use it for your internal processes.
|
||||
provider_token (:obj:`str`): Payments provider token, obtained via
|
||||
provider_token (:obj:`str`, optional): Payments provider token, obtained via
|
||||
`@BotFather <https://t.me/BotFather>`_. Pass an empty string for payments in
|
||||
|tg_stars|.
|
||||
|
||||
.. deprecated:: 21.3
|
||||
As of Bot API 7.4, this parameter is now optional and future versions of the
|
||||
library will make it optional as well.
|
||||
.. versionchanged:: NEXT.VERSION
|
||||
Bot API 7.4 made this parameter is optional and this is now reflected in the
|
||||
function signature.
|
||||
|
||||
currency (:obj:`str`): Three-letter ISO 4217 currency code, see `more on currencies
|
||||
<https://core.telegram.org/bots/payments#supported-currencies>`_. Pass ``XTR`` for
|
||||
|
||||
+1
-1
@@ -1576,9 +1576,9 @@ class _ChatBase(TelegramObject):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str],
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
start_parameter: Optional[str] = None,
|
||||
photo_url: Optional[str] = None,
|
||||
photo_size: Optional[int] = None,
|
||||
|
||||
@@ -35,9 +35,11 @@ class InputInvoiceMessageContent(InputMessageContent):
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`title`, :attr:`description`, :attr:`payload`,
|
||||
:attr:`provider_token`, :attr:`currency` and :attr:`prices` are equal.
|
||||
:attr:`currency` and :attr:`prices` are equal.
|
||||
|
||||
.. versionadded:: 13.5
|
||||
.. versionchanged:: NEXT.VERSION
|
||||
:attr:`provider_token` is no longer considered for equality comparison.
|
||||
|
||||
Args:
|
||||
title (:obj:`str`): Product name. :tg-const:`telegram.Invoice.MIN_TITLE_LENGTH`-
|
||||
@@ -49,13 +51,13 @@ class InputInvoiceMessageContent(InputMessageContent):
|
||||
:tg-const:`telegram.Invoice.MIN_PAYLOAD_LENGTH`-
|
||||
:tg-const:`telegram.Invoice.MAX_PAYLOAD_LENGTH` bytes. This will not be displayed
|
||||
to the user, use it for your internal processes.
|
||||
provider_token (:obj:`str`): Payment provider token, obtained via
|
||||
provider_token (:obj:`str`, optional): Payment provider token, obtained via
|
||||
`@Botfather <https://t.me/Botfather>`_. Pass an empty string for payments in
|
||||
|tg_stars|.
|
||||
|
||||
.. deprecated:: 21.3
|
||||
As of Bot API 7.4, this parameter is now optional and future versions of the
|
||||
library will make it optional as well.
|
||||
.. versionchanged:: NEXT.VERSION
|
||||
Bot API 7.4 made this parameter is optional and this is now reflected in the
|
||||
class signature.
|
||||
currency (:obj:`str`): Three-letter ISO 4217 currency code, see more on
|
||||
`currencies <https://core.telegram.org/bots/payments#supported-currencies>`_.
|
||||
Pass ``XTR`` for payments in |tg_stars|.
|
||||
@@ -199,9 +201,9 @@ class InputInvoiceMessageContent(InputMessageContent):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str], # This arg is now optional since Bot API 7.4
|
||||
currency: str,
|
||||
prices: Sequence[LabeledPrice],
|
||||
provider_token: Optional[str] = None,
|
||||
max_tip_amount: Optional[int] = None,
|
||||
suggested_tip_amounts: Optional[Sequence[int]] = None,
|
||||
provider_data: Optional[str] = None,
|
||||
@@ -225,10 +227,10 @@ class InputInvoiceMessageContent(InputMessageContent):
|
||||
self.title: str = title
|
||||
self.description: str = description
|
||||
self.payload: str = payload
|
||||
self.provider_token: Optional[str] = provider_token
|
||||
self.currency: str = currency
|
||||
self.prices: tuple[LabeledPrice, ...] = parse_sequence_arg(prices)
|
||||
# Optionals
|
||||
self.provider_token: Optional[str] = provider_token
|
||||
self.max_tip_amount: Optional[int] = max_tip_amount
|
||||
self.suggested_tip_amounts: tuple[int, ...] = parse_sequence_arg(suggested_tip_amounts)
|
||||
self.provider_data: Optional[str] = provider_data
|
||||
@@ -248,7 +250,6 @@ class InputInvoiceMessageContent(InputMessageContent):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
self.provider_token,
|
||||
self.currency,
|
||||
self.prices,
|
||||
)
|
||||
|
||||
@@ -3382,9 +3382,9 @@ class Message(MaybeInaccessibleMessage):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str],
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
start_parameter: Optional[str] = None,
|
||||
photo_url: Optional[str] = None,
|
||||
photo_size: Optional[int] = None,
|
||||
|
||||
+1
-1
@@ -1018,9 +1018,9 @@ class User(TelegramObject):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str],
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
start_parameter: Optional[str] = None,
|
||||
photo_url: Optional[str] = None,
|
||||
photo_size: Optional[int] = None,
|
||||
|
||||
@@ -1195,9 +1195,9 @@ class ExtBot(Bot, Generic[RLARGS]):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str],
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
max_tip_amount: Optional[int] = None,
|
||||
suggested_tip_amounts: Optional[Sequence[int]] = None,
|
||||
provider_data: Optional[Union[str, object]] = None,
|
||||
@@ -2768,9 +2768,9 @@ class ExtBot(Bot, Generic[RLARGS]):
|
||||
title: str,
|
||||
description: str,
|
||||
payload: str,
|
||||
provider_token: Optional[str],
|
||||
currency: str,
|
||||
prices: Sequence["LabeledPrice"],
|
||||
provider_token: Optional[str] = None,
|
||||
start_parameter: Optional[str] = None,
|
||||
photo_url: Optional[str] = None,
|
||||
photo_size: Optional[int] = None,
|
||||
|
||||
@@ -282,10 +282,10 @@ class TestInputInvoiceMessageContentWithoutRequest(InputInvoiceMessageContentTes
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
self.provider_token,
|
||||
self.currency,
|
||||
# the first prices amount & the second lebal changed
|
||||
[LabeledPrice("label1", 24), LabeledPrice("label22", 314)],
|
||||
self.provider_token,
|
||||
)
|
||||
d = InputInvoiceMessageContent(
|
||||
self.title,
|
||||
|
||||
@@ -269,9 +269,9 @@ class TestInvoiceWithRequest(InvoiceTestBase):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
provider_token,
|
||||
self.currency,
|
||||
self.prices,
|
||||
provider_token,
|
||||
**kwargs,
|
||||
)
|
||||
for kwargs in ({}, {"protect_content": False})
|
||||
@@ -301,7 +301,6 @@ class TestInvoiceWithRequest(InvoiceTestBase):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
"", # using tg stars
|
||||
"XTR",
|
||||
[self.prices[0]],
|
||||
allow_sending_without_reply=custom,
|
||||
@@ -315,9 +314,9 @@ class TestInvoiceWithRequest(InvoiceTestBase):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
provider_token,
|
||||
self.currency,
|
||||
self.prices,
|
||||
provider_token,
|
||||
reply_to_message_id=reply_to_message.message_id,
|
||||
)
|
||||
assert message.reply_to_message is None
|
||||
@@ -328,9 +327,9 @@ class TestInvoiceWithRequest(InvoiceTestBase):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
provider_token,
|
||||
self.currency,
|
||||
self.prices,
|
||||
provider_token,
|
||||
reply_to_message_id=reply_to_message.message_id,
|
||||
)
|
||||
|
||||
@@ -340,9 +339,9 @@ class TestInvoiceWithRequest(InvoiceTestBase):
|
||||
self.title,
|
||||
self.description,
|
||||
self.payload,
|
||||
provider_token,
|
||||
self.currency,
|
||||
self.prices,
|
||||
provider_token=provider_token,
|
||||
max_tip_amount=self.max_tip_amount,
|
||||
suggested_tip_amounts=self.suggested_tip_amounts,
|
||||
start_parameter=self.start_parameter,
|
||||
|
||||
+1
-1
@@ -610,9 +610,9 @@ class TestChatWithoutRequest(ChatTestBase):
|
||||
"title",
|
||||
"description",
|
||||
"payload",
|
||||
"provider_token",
|
||||
"currency",
|
||||
"prices",
|
||||
"provider_token",
|
||||
)
|
||||
|
||||
async def test_instance_method_send_location(self, monkeypatch, chat):
|
||||
|
||||
@@ -2216,9 +2216,9 @@ class TestMessageWithoutRequest(MessageTestBase):
|
||||
"title",
|
||||
"description",
|
||||
"payload",
|
||||
"provider_token",
|
||||
"currency",
|
||||
"prices",
|
||||
"provider_token",
|
||||
)
|
||||
await self.check_quote_parsing(
|
||||
message,
|
||||
|
||||
@@ -206,9 +206,7 @@ def ignored_param_requirements(object_name: str) -> set[str]:
|
||||
|
||||
|
||||
# Arguments that are optional arguments for now for backwards compatibility
|
||||
BACKWARDS_COMPAT_KWARGS: dict[str, set[str]] = {
|
||||
"send_invoice|create_invoice_link|InputInvoiceMessageContent": {"provider_token"},
|
||||
}
|
||||
BACKWARDS_COMPAT_KWARGS: dict[str, set[str]] = {}
|
||||
|
||||
|
||||
def backwards_compat_kwargs(object_name: str) -> set[str]:
|
||||
|
||||
+1
-1
@@ -343,9 +343,9 @@ class TestUserWithoutRequest(UserTestBase):
|
||||
"title",
|
||||
"description",
|
||||
"payload",
|
||||
"provider_token",
|
||||
"currency",
|
||||
"prices",
|
||||
"provider_token",
|
||||
)
|
||||
|
||||
async def test_instance_method_send_location(self, monkeypatch, user):
|
||||
|
||||
Reference in New Issue
Block a user