Payments via Telegram
You can also receive payments using Telegram bots.
You should begin with the following steps:
- Create your Telegram bot.
- Connect your Telegram bot to Bank 131.
- Set up your Telegram bot and start receiving payments.
How to Create your Telegram Bot
- In a Telegram app, start chatting with @BotFather by sending
/start
and then/newbot
.
- Specify your bot's name. This is how the bot will be displayed in the customer's list of Telegram chats.
- Specify your bot's username. This must be a unique yet self-explanatory username, which customers can easily identify among others in Telegram. Note that a bot's username must end with "bot".
In the exapmle below, Bank 131 is the bot's name and Bank_131_bot is the bot's username.
- Once you confirmed your bot's username, BotFather will provide you with a token to manage your bot that looks like an alphanumeric line. This is the key to your bot, so store it in a safe place and never share with anyone including Bank 131 or Telegram Help & Support officers.
- Once you got your token, your bot is ready. You can customize its userpic and add a brief description using the Settings section.
How to Connect your Telegram Bot to Bank 131
- Send
/mybots
to BotFather to obtain the list of bots you created and click your desired bot's name.
- In the menu click Bot Settings.
- In the next menu, click Payments.
- In the list of payment providers, select Банк 131.
Once you clicked Банк 131, you will start chatting with Bank 131 bot in a separate window.
The Bank 131 Test allows to try out making payments safely on a test environment, while Bank 131 Live is used to make real payments.
Click Start. In the chat dialog, Bank 131 will confirm acceptance of your account and ask you to provide a confirmation code — type "qwerty" in reply.
Click Start. In the chat dialog, Bank 131 will confirm acceptance of your account and ask you to provide a confirmation code, the one that was provided to you by a Bank's manager earlier. If you don't have the code, contact us at partners@131.ru.
Note that a confirmation code is NOT your bot token to manage your bot. Never share your token with anyone including Bank 131 or Telegram Help & Support officers.
How to Set up your Telegram Bot and Start Receiving Payments
The settings below are provided for bots that use Telegram API. For bots created via other services, refer to the appropriate API description.
Invoice
Call the sendinvoice method to send invoices to your customers. The call must contain parameters for the item's price, name and its brief description, the payload
parameter and, finally, provider_token
— the token to manage your Telegram bot.
{
"chat_id": 0000000,
"title": "TestTitle",
"description": "TestDescription",
"payload": "TestPayload",
"provider_token": "0987654321:TEST",
"currency": "RUB",
"start_parameter": "test",
"prices": [{
"label": "руб",
"amount": 4500
}],
}
If you provide data for fiscalization, add the following parameters into the request:
need_email
and/orneed_phone_number
, if you require customer's email and/or phone number.send_email_to_provider
, if you are going to provide your customer's email to Bank 131.send_phone_number_to_provider
, if you are going to provide your customer's phone number to Bank 131.provider_data
containingreceipt
object.
"need_email": true,
"need_phone_number": true,
"send_email_to_provider": true,
"send_phone_number_to_provider": true,
"provider_data": {
"receipt": {
"items": [
{
"description": "My item",
"quantity": "1.00",
"amount": {
"value": "200.00",
"currency": "RUB"
},
"vat_code": "1"
}
]}
}
Depending on your bot's settings, if you obtained your customers's email and/or phone number earlier, the example may look like:
"send_email_to_provider": true,
"send_phone_number_to_provider": true,
"provider_data": {
"receipt": {
"email": "customer@example.com",
"items": [
{
"description": "My item",
"quantity": "1.00",
"amount": {
"value": "200.00",
"currency": "RUB"
},
"vat_code": "1"
}
]}
}
If you require your a customer's shipping address, use the ShippingQuery
method. When the customer provides an address, you should send the answerShippingQuery
method containing shipping methods and shipping prices in return.
Payment Confirmation
When the customer confirmed the payment, Telegram will send you a webhook containing the PreCheckoutQuery
object. In return, you should call the answerPreCheckoutQuery
method within 10 seconds.
Successful Payment
When you succeed with the payment, you will receive two confirmations: a webhook containing the SuccessfulPayment
object from Telegram and an email from Bank 131.
You can also set up your bot to take an action on receiving the payment confirmations and provide a customer with a service (upload a digital content, etc.).
The payment confirmation sent by Telegram contains the SuccessfulPayment
object with the provider_payment_charge_id
parameter as the ID for the transaction. Collect this ID for future references.