Skip to content

Commit

Permalink
Added business connection id and subscription period for createinvoic…
Browse files Browse the repository at this point in the history
…elink
  • Loading branch information
coder2020official committed Nov 17, 2024
1 parent ff6db8b commit c8d8ec7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
15 changes: 13 additions & 2 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5418,7 +5418,9 @@ def create_invoice_link(self,
need_shipping_address: Optional[bool]=None,
send_phone_number_to_provider: Optional[bool]=None,
send_email_to_provider: Optional[bool]=None,
is_flexible: Optional[bool]=None) -> str:
is_flexible: Optional[bool]=None,
subscription_period: Optional[int]=None,
business_connection_id: Optional[str]=None) -> str:

"""
Use this method to create a link for an invoice.
Expand All @@ -5427,6 +5429,9 @@ def create_invoice_link(self,
Telegram documentation:
https://core.telegram.org/bots/api#createinvoicelink
:param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created
:type business_connection_id: :obj:`str`
:param title: Product name, 1-32 characters
:type title: :obj:`str`
Expand All @@ -5449,6 +5454,11 @@ def create_invoice_link(self,
(e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
:type prices: :obj:`list` of :obj:`types.LabeledPrice`
:subscription_period: The number of seconds the subscription will be active for before the next payment.
The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always
be 2592000 (30 days) if specified.
:type subscription_period: :obj:`int`
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
:type max_tip_amount: :obj:`int`
Expand Down Expand Up @@ -5505,7 +5515,8 @@ def create_invoice_link(self,
photo_width=photo_width, photo_height=photo_height, need_name=need_name,
need_phone_number=need_phone_number, need_email=need_email,
need_shipping_address=need_shipping_address, send_phone_number_to_provider=send_phone_number_to_provider,
send_email_to_provider=send_email_to_provider, is_flexible=is_flexible)
send_email_to_provider=send_email_to_provider, is_flexible=is_flexible ,subscription_period=subscription_period,
business_connection_id=business_connection_id)


# noinspection PyShadowingBuiltins
Expand Down
6 changes: 5 additions & 1 deletion telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ def create_invoice_link(token, title, description, payload, provider_token,
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
send_email_to_provider=None, is_flexible=None):
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
method_url = r'createInvoiceLink'
payload = {'title': title, 'description': description, 'payload': payload,
'currency': currency, 'prices': _convert_list_json_serializable(prices)}
Expand Down Expand Up @@ -2004,6 +2004,10 @@ def create_invoice_link(token, title, description, payload, provider_token,
payload['is_flexible'] = is_flexible
if provider_token is not None:
payload['provider_token'] = provider_token
if subscription_period:
payload['subscription_period'] = subscription_period
if business_connection_id:
payload['business_connection_id'] = business_connection_id
return _make_request(token, method_url, params=payload, method='post')


Expand Down
14 changes: 12 additions & 2 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6836,14 +6836,19 @@ async def create_invoice_link(self,
need_shipping_address: Optional[bool]=None,
send_phone_number_to_provider: Optional[bool]=None,
send_email_to_provider: Optional[bool]=None,
is_flexible: Optional[bool]=None) -> str:
is_flexible: Optional[bool]=None,
subscription_period: Optional[int]=None,
business_connection_id: Optional[str]=None) -> str:

"""
Use this method to create a link for an invoice.
Returns the created invoice link as String on success.
Telegram documentation:
https://core.telegram.org/bots/api#createinvoicelink
:param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created
:type business_connection_id: :obj:`str`
:param title: Product name, 1-32 characters
:type title: :obj:`str`
Expand All @@ -6867,6 +6872,11 @@ async def create_invoice_link(self,
(e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
:type prices: :obj:`list` of :obj:`types.LabeledPrice`
:subscription_period: The number of seconds the subscription will be active for before the next payment.
The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always
be 2592000 (30 days) if specified.
:type subscription_period: :obj:`int`
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
:type max_tip_amount: :obj:`int`
Expand Down Expand Up @@ -6921,7 +6931,7 @@ async def create_invoice_link(self,
currency, prices, max_tip_amount, suggested_tip_amounts, provider_data,
photo_url, photo_size, photo_width, photo_height, need_name, need_phone_number,
need_email, need_shipping_address, send_phone_number_to_provider,
send_email_to_provider, is_flexible)
send_email_to_provider, is_flexible, subscription_period=subscription_period, business_connection_id=business_connection_id)
return result

# noinspection PyShadowingBuiltins
Expand Down
6 changes: 5 additions & 1 deletion telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ async def create_invoice_link(token, title, description, payload, provider_token
currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None,
need_email=None, need_shipping_address=None, send_phone_number_to_provider=None,
send_email_to_provider=None, is_flexible=None):
send_email_to_provider=None, is_flexible=None, subscription_period=None, business_connection_id=None):
method_url = r'createInvoiceLink'
payload = {'title': title, 'description': description, 'payload': payload,
'currency': currency, 'prices': await _convert_list_json_serializable(prices)}
Expand Down Expand Up @@ -1986,6 +1986,10 @@ async def create_invoice_link(token, title, description, payload, provider_token
payload['is_flexible'] = is_flexible
if provider_token is not None:
payload['provider_token'] = provider_token
if subscription_period:
payload['subscription_period'] = subscription_period
if business_connection_id:
payload['business_connection_id'] = business_connection_id
return await _process_request(token, method_url, params=payload, method='post')


Expand Down

0 comments on commit c8d8ec7

Please sign in to comment.