# Telegram

## How to connect the payment system&#x20;

### Payment system is built into Telegram.&#x20;

In order to make payments inside the messenger, you need:&#x20;

* connect payment system to bot in botfather bot&#x20;
* go to the desired bot settings and in the menu select Payments&#x20;
* following instructions to connect an accessible payment system and copy the issued token

&#x20;                                           ![](/files/1PhZiQDP4PjOrrnX1v6g)<br>

![](/files/v4W6UofD9bLhVEvPf9zp)

## How to Invoice a Client&#x20;

To send invoice to telegram use method&#x20;

tg\_send\_invoice(provider\_token, platform\_id, title, description, currency, prices, photo\_url, payload, protect\_content, disable\_notification, need\_name, phone\_number, need\_email, reply\_to\_message\_id, reply\_markup, reply\_id) - the required parameters are highlighted in bold&#x20;

**provider\_token** - token received in Botfather, after connecting the payment system&#x20;

**platform\_id** - recipient - identifier of user, group or channel&#x20;

**title** - item title, 1-32 characters

**description** - description of goods, 1-255 characters&#x20;

**currency** - payment currency (RUB, USD, UAH and so on <https://core.telegram.org/bots/payments#supported-currencies>) &#x20;

**payload** - the first part of the coin about payment, by default tg\_payment&#x20;

**prices** - price breakdown (description below)&#x20;

**photo\_url** - link to product picture&#x20;

**disable\_notification** - 1 - send with notification, 0 - without notification

**protect\_content** - 1 copy and screenshot protection, 0 - unprotected&#x20;

**need\_name** - 1 if you need a full username to complete the order, 0 - without asking for a name&#x20;

**need\_phone\_number** - 1 if you require a user’s phone number to complete the order, 0 - without a request number&#x20;

**need\_email** - 1 if you require an email address of the user to complete the order, 0 - without a mail request&#x20;

**reply\_to\_message\_id** - the message id to which we respond, '' is not the answer&#x20;

**reply\_markup** - keyboard, the first button should be a button with pay type

If one of the parameters need\_name, need\_phone\_number or need\_email is specified, the user will request the data before paying and save it to the client variables if the payment is successful. In the screenshot below the request for all data input:

**prices** - an array of arrays with data on the cost of goods and additional services (delivery, packaging, etc.). Displayed on the payment page. The amount shall be indicated either by an integer of 125 or by a fraction through point 120.25 For example: \[\["goods", 2000], \["VAT", 20.75], \["packaging", 100]

## Callback on payment&#x20;

After successful payment in the chat with the user will come a colbeck as follows:&#x20;

**phone\_best 4737685 2120.75 UAH 1955518436**&#x20;

where phone\_best - payload - from the request for creation of invoice 473737685 - a chat id, to which originally was sent invoice 2120.75 - the full amount of payment UAH - currency 1955518436 - payment id in the merchant system

Also, if you requested a name, phone and/or email, the client will write down the variables:&#x20;

**tg\_payment\_name, tg\_payment\_phone** and **tg\_payment\_email**

{% hint style="info" %}
In case of success, the kolbek will be sent to the user’s personal messages. To do this, the client and the bot must cooperate before payment (the client must be subscribed to the bot)!
{% endhint %}

{% hint style="info" %}
After receiving the hook about payment, the payment will be automatically confirmed, by answerPreCheckoutQuery <https://core.telegram.org/bots/api#answerprecheckoutquery> . &#x20;
{% endhint %}

## Examples&#x20;

`prices = [["product", 2000], ["NDS", 20.75], ["package", 100]]` \
`result = tg_send_invoice('632593626:TEST:sandbox_i38014109763', platform_id, 'phoneW-200', 'Best Model on the Market', 'UAH', prices, 'https://images11.popmeh.ru/cropped.jpg', 'phone_best', 0, 0, 1, 0, 1)`

![](/files/ViN43roVKMVQIugmhEBu)

### Example with minimum parameter sets

`prices = [["an amazing product", 20000]] result = tg_send_invoice('632593626:TEST:sandbox_i38014109763', platform_id, 'The best bot ever!',`` `<mark style="color:purple;">`'An amazing course! Be the best!'`</mark>`, 'UAH', prices)`

![](/files/Xv4s74VETFlaFavwGY0k)

### Example with a Keyboard&#x20;

`prices = [["product", 2000], ["NDS", 20.75], ["package", 100]] result = tg_send_invoice('632593626:TEST:sandbox_i38014109763', platform_id, 'Phone W-200', 'BEst Model on the Market', 'UAH', prices, 'https://helpix.ru/news/200405/181746/gf200_2.jpg', 'phone_best', 0, 0, 1, 1, 1, '', '{"inline_keyboard": [[{"text":"Pay", "pay":"True"}], [{"text":"One more button", "callback_data": "One more button"}]]}')`

![](/files/PgjDPMxTWUqcdIEMz7rK)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/integrations/payment/telegram.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
