1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1231 from vnagornyy/master

Added tip for invoice
This commit is contained in:
Badiboy 2021-07-15 09:23:10 +03:00 committed by GitHub
commit 2b1db1f1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -1983,7 +1983,8 @@ class TeleBot:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
provider_data: Optional[str]=None,
timeout: Optional[int]=None,
allow_sending_without_reply: Optional[bool]=None) -> types.Message:
allow_sending_without_reply: Optional[bool]=None,
max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[list]=None) -> types.Message:
"""
Sends invoice
:param chat_id: Unique identifier for the target private chat
@ -2018,6 +2019,10 @@ class TeleBot:
A detailed description of required fields should be provided by the payment provider.
:param timeout:
:param allow_sending_without_reply:
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest
units of the currency. At most 4 suggested tip amounts can be specified. The suggested tip
amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
:return:
"""
result = apihelper.send_invoice(
@ -2025,7 +2030,8 @@ class TeleBot:
currency, prices, start_parameter, 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, disable_notification,
reply_to_message_id, reply_markup, provider_data, timeout, allow_sending_without_reply)
reply_to_message_id, reply_markup, provider_data, timeout, allow_sending_without_reply,
max_tip_amount, suggested_tip_amounts)
return types.Message.de_json(result)
def send_poll(

View File

@ -1258,7 +1258,7 @@ def send_invoice(
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,
disable_notification=None, reply_to_message_id=None, reply_markup=None, provider_data=None,
timeout=None, allow_sending_without_reply=None):
timeout=None, allow_sending_without_reply=None,max_tip_amount=None, suggested_tip_amounts=None):
"""
Use this method to send invoices. On success, the sent Message is returned.
:param token: Bot's token (you don't need to fill this)
@ -1287,6 +1287,9 @@ def send_invoice(
:param provider_data: A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
:param timeout:
:param allow_sending_without_reply:
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency.
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
:return:
"""
method_url = r'sendInvoice'
@ -1327,6 +1330,10 @@ def send_invoice(
payload['timeout'] = timeout
if allow_sending_without_reply is not None:
payload['allow_sending_without_reply'] = allow_sending_without_reply
if max_tip_amount is not None:
payload['max_tip_amount'] = max_tip_amount
if suggested_tip_amounts is not None:
payload['suggested_tip_amounts'] = json.dumps(suggested_tip_amounts)
return _make_request(token, method_url, params=payload)