PaymentApi
This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.
Do not edit it by hand - run composer spec:build instead.
Invoices, checkout, refunds, and the Telegram Stars balance.
Mixed into Telegram through Methods. Every method is named exactly as the Bot API names it, takes exactly the fields the Bot API documents (use named arguments for the optional ones), and resolves with the hydrated result.
Tags
Table of Contents
Methods
- answerPreCheckoutQuery() : PromiseInterface<string|int, bool>
- Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
- answerShippingQuery() : PromiseInterface<string|int, bool>
- If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
- createInvoiceLink() : PromiseInterface<string|int, string>
- Use this method to create a link for an invoice. Returns the created invoice link as String on success.
- editUserStarSubscription() : PromiseInterface<string|int, bool>
- Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars.
- getMyStarBalance() : PromiseInterface<string|int, StarAmount>
- A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
- getStarTransactions() : PromiseInterface<string|int, StarTransactions>
- Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
- refundStarPayment() : PromiseInterface<string|int, bool>
- Refunds a successful payment in Telegram Stars. Returns True on success.
- sendInvoice() : PromiseInterface<string|int, Message>
- Use this method to send invoices. On success, the sent Message is returned.
Methods
answerPreCheckoutQuery()
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
public
answerPreCheckoutQuery(string $pre_checkout_query_id, bool $ok[, string|null $error_message = null ]) : PromiseInterface<string|int, bool>
Parameters
- $pre_checkout_query_id : string
-
Unique identifier for the query to be answered
- $ok : bool
-
Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
- $error_message : string|null = null
-
Optional. Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
Tags
Return values
PromiseInterface<string|int, bool>answerShippingQuery()
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
public
answerShippingQuery(string $shipping_query_id, bool $ok[, array<int, ShippingOption|array<string|int, mixed>>|null $shipping_options = null ][, string|null $error_message = null ]) : PromiseInterface<string|int, bool>
Parameters
- $shipping_query_id : string
-
Unique identifier for the query to be answered
- $ok : bool
-
Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
- $shipping_options : array<int, ShippingOption|array<string|int, mixed>>|null = null
-
Optional. Required if ok is True. A JSON-serialized Array of available shipping options.
- $error_message : string|null = null
-
Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable"). Telegram will display this message to the user.
Tags
Return values
PromiseInterface<string|int, bool>createInvoiceLink()
Use this method to create a link for an invoice. Returns the created invoice link as String on success.
public
createInvoiceLink(string $title, string $description, string $payload, string $currency, array<int, LabeledPrice|array<string|int, mixed>> $prices[, string|null $business_connection_id = null ][, string|null $provider_token = null ][, int|null $subscription_period = null ][, int|null $max_tip_amount = null ][, array<int, int>|null $suggested_tip_amounts = null ][, string|null $provider_data = null ][, string|null $photo_url = null ][, int|null $photo_size = null ][, int|null $photo_width = null ][, int|null $photo_height = null ][, bool|null $need_name = null ][, bool|null $need_phone_number = null ][, bool|null $need_email = null ][, bool|null $need_shipping_address = null ][, bool|null $send_phone_number_to_provider = null ][, bool|null $send_email_to_provider = null ][, bool|null $is_flexible = null ]) : PromiseInterface<string|int, string>
Parameters
- $title : string
-
Product name, 1-32 characters
- $description : string
-
Product description, 1-255 characters
- $payload : string
-
Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
- $currency : string
-
Three-letter ISO 4217 currency code, see more on currencies. Pass "XTR" for payments in Telegram Stars.
- $prices : array<int, LabeledPrice|array<string|int, mixed>>
-
Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
- $business_connection_id : string|null = null
-
Optional. Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only.
- $provider_token : string|null = null
-
Optional. Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
- $subscription_period : int|null = null
-
Optional. 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. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars.
- $max_tip_amount : int|null = null
-
Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
- $suggested_tip_amounts : array<int, int>|null = null
-
Optional. A JSON-serialized Array of suggested amounts of tips 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 positive, passed in a strictly increased order and must not exceed max_tip_amount.
- $provider_data : string|null = null
-
Optional. 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.
- $photo_url : string|null = null
-
Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
- $photo_size : int|null = null
-
Optional. Photo size in bytes
- $photo_width : int|null = null
-
Optional. Photo width
- $photo_height : int|null = null
-
Optional. Photo height
- $need_name : bool|null = null
-
Optional. Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
- $need_phone_number : bool|null = null
-
Optional. Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
- $need_email : bool|null = null
-
Optional. Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
- $need_shipping_address : bool|null = null
-
Optional. Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
- $send_phone_number_to_provider : bool|null = null
-
Optional. Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
- $send_email_to_provider : bool|null = null
-
Optional. Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
- $is_flexible : bool|null = null
-
Optional. Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
Tags
Return values
PromiseInterface<string|int, string>editUserStarSubscription()
Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars.
public
editUserStarSubscription(int $user_id, string $telegram_payment_charge_id, bool $is_canceled) : PromiseInterface<string|int, bool>
Returns True on success.
Parameters
- $user_id : int
-
Identifier of the user whose subscription will be edited
- $telegram_payment_charge_id : string
-
Telegram payment identifier for the subscription
- $is_canceled : bool
-
Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.
Tags
Return values
PromiseInterface<string|int, bool>getMyStarBalance()
A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
public
getMyStarBalance() : PromiseInterface<string|int, StarAmount>
Tags
Return values
PromiseInterface<string|int, StarAmount>getStarTransactions()
Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
public
getStarTransactions([int|null $offset = null ][, int|null $limit = null ]) : PromiseInterface<string|int, StarTransactions>
Parameters
- $offset : int|null = null
-
Optional. Number of transactions to skip in the response
- $limit : int|null = null
-
Optional. The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.
Tags
Return values
PromiseInterface<string|int, StarTransactions>refundStarPayment()
Refunds a successful payment in Telegram Stars. Returns True on success.
public
refundStarPayment(int $user_id, string $telegram_payment_charge_id) : PromiseInterface<string|int, bool>
Parameters
- $user_id : int
-
Identifier of the user whose payment will be refunded
- $telegram_payment_charge_id : string
-
Telegram payment identifier
Tags
Return values
PromiseInterface<string|int, bool>sendInvoice()
Use this method to send invoices. On success, the sent Message is returned.
public
sendInvoice(int|string $chat_id, string $title, string $description, string $payload, string $currency, array<int, LabeledPrice|array<string|int, mixed>> $prices[, int|null $message_thread_id = null ][, int|null $direct_messages_topic_id = null ][, string|null $provider_token = null ][, int|null $max_tip_amount = null ][, array<int, int>|null $suggested_tip_amounts = null ][, string|null $start_parameter = null ][, string|null $provider_data = null ][, string|null $photo_url = null ][, int|null $photo_size = null ][, int|null $photo_width = null ][, int|null $photo_height = null ][, bool|null $need_name = null ][, bool|null $need_phone_number = null ][, bool|null $need_email = null ][, bool|null $need_shipping_address = null ][, bool|null $send_phone_number_to_provider = null ][, bool|null $send_email_to_provider = null ][, bool|null $is_flexible = null ][, bool|null $disable_notification = null ][, bool|null $protect_content = null ][, bool|null $allow_paid_broadcast = null ][, string|null $message_effect_id = null ][, SuggestedPostParameters|array<string|int, mixed>|null $suggested_post_parameters = null ][, ReplyParameters|array<string|int, mixed>|null $reply_parameters = null ][, InlineKeyboardMarkup|array<string|int, mixed>|null $reply_markup = null ]) : PromiseInterface<string|int, Message>
Parameters
- $chat_id : int|string
-
Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
- $title : string
-
Product name, 1-32 characters
- $description : string
-
Product description, 1-255 characters
- $payload : string
-
Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
- $currency : string
-
Three-letter ISO 4217 currency code, see more on currencies. Pass "XTR" for payments in Telegram Stars.
- $prices : array<int, LabeledPrice|array<string|int, mixed>>
-
Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
- $message_thread_id : int|null = null
-
Optional. Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only
- $direct_messages_topic_id : int|null = null
-
Optional. Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat
- $provider_token : string|null = null
-
Optional. Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
- $max_tip_amount : int|null = null
-
Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
- $suggested_tip_amounts : array<int, int>|null = null
-
Optional. A JSON-serialized Array of suggested amounts of tips 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 positive, passed in a strictly increased order and must not exceed max_tip_amount.
- $start_parameter : string|null = null
-
Optional. Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter.
- $provider_data : string|null = null
-
Optional. 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.
- $photo_url : string|null = null
-
Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
- $photo_size : int|null = null
-
Optional. Photo size in bytes
- $photo_width : int|null = null
-
Optional. Photo width
- $photo_height : int|null = null
-
Optional. Photo height
- $need_name : bool|null = null
-
Optional. Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
- $need_phone_number : bool|null = null
-
Optional. Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
- $need_email : bool|null = null
-
Optional. Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
- $need_shipping_address : bool|null = null
-
Optional. Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
- $send_phone_number_to_provider : bool|null = null
-
Optional. Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
- $send_email_to_provider : bool|null = null
-
Optional. Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
- $is_flexible : bool|null = null
-
Optional. Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
- $disable_notification : bool|null = null
-
Optional. Sends the message silently. Users will receive a notification with no sound.
- $protect_content : bool|null = null
-
Optional. Protects the contents of the sent message from forwarding and saving
- $allow_paid_broadcast : bool|null = null
-
Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance.
- $message_effect_id : string|null = null
-
Optional. Unique identifier of the message effect to be added to the message; for private chats only
- $suggested_post_parameters : SuggestedPostParameters|array<string|int, mixed>|null = null
-
Optional. A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.
- $reply_parameters : ReplyParameters|array<string|int, mixed>|null = null
-
Optional. Description of the message to reply to
- $reply_markup : InlineKeyboardMarkup|array<string|int, mixed>|null = null
-
Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.