TelegramPayment
The TelegramPayment
action allows you to set up payments in Telegram.
telegramPayment
type in $response.replies
instead.Parameters
Parameter | Type | Description | Comments | Required |
---|---|---|---|---|
providerToken | String | Payment system token | You need to obtain a unique token for each payment system in Telegram. | Yes |
startParameter | Boolean | Allow clients to forward payment links to other clients | true — other clients can pay for the service or goods using this link. false — other clients cannot pay for the service or goods using this link. They will be transferred to the chat with the bot. | Yes |
paymentTitle | String | Service or goods title | Use no more than 32 characters. | Yes |
description | String | Service or goods description | Use no more than 255 characters. | Yes |
imageUrl | String | Image URL | You can attach your service or goods image to the invoice. | No |
amount | String | Service or goods price | Telegram sets limits for each currency on the minimum and maximum entered amount. The amount should contain 12 digits or less. | Yes |
currency | String | Currency | Three-letter currency code according to ISO 4217. You can only specify currencies that Telegram and your payment system support. | Yes |
invoicePayload | String | Arbitral invoice details | The details will not be shown in the chat. Only the payment system owner will see them. | Yes |
precheckoutEnabled | Boolean | Check the goods availability before checkout | true — before checkout, the bot will send requests to the service URL specified in precheckoutUrl . If the goods are out of stock and the service returns a response with an HTTP code other than 2xx , the bot will go to errorState . false — the bot will not check the goods availability before checkout. | No |
precheckoutUrl | String | URL of the service which returns information on whether the requested goods are in stock | — | No |
okState | String | The state the dialog will switch to if the payment is successful | — | No |
errorState | String | The state the dialog will switch to if the parameters are filled incorrectly | The bot will go to this state if, for example, the specified token is invalid or the price is less than the minimum allowed amount. | No |
catchAllState | String | The state the dialog will switch to if the client fails to pay and sends an arbitrary message to the bot | — | No |
Payment system token
To receive payments from clients, you need to obtain a unique token of the payment system and specify it in the tag parameters. Create a bot in Telegram before obtaining a token. Follow the steps described in the Telegram as an inbound channel article and return to this one.
- Open Telegram and enter
BotFather
in the search bar. - Send the
/mybots
command to BotFather. - Choose your bot and select Payments.
- Choose a payment system from the list.
- Choose one of the payment methods:
- Test for testing the payment system.
- Live for setting up a real payment system integration.
- You will be redirected to a chatbot for the selected payment system. Start the chatbot.
- Follow all the steps the chatbot asks for.
- Return to the chat with BotFather.
- In the last message from BotFather, you will see a list of connected payment systems and tokens for each of them. Copy the token for the selected payment system.
- Paste the token in the
providerToken
parameter.
Price limits
Telegram sets limits on the minimum and maximum entered amount for each currency. The minimum and maximum amount for each of the currencies roughly correspond to the limit of 1–10,000 USD. For each currency except USD, these limits depend on exchange rates and may change over time.
You can find approximate values of the minimum and maximum amount for each supported currency in the Telegram documentation.
How to use
state: TelegramPayment
intent!: /Purchase pass
TelegramPayment:
providerToken = {{$secrets.get("providerToken")}}
startParameter = true
paymentTitle = Her
description = Aurora Theater, December 25, 12 PM
imageUrl = https://upload.wikimedia.org/wikipedia/en/4/44/Her2013Poster.jpg
amount = 15
currency = USD
invoicePayload = Bolshaya Zelenina str. 24, lit. A, 197110, Russian Federation
okState = /TelegramPayment/PaymentSuccessful
errorState = /TelegramPayment/PaymentFailed
catchAllState = /TelegramPayment/CatchAll
state: PaymentSuccessful
a: The payment was successful. We have sent your ticket to your email address. See you at Conversations!
go!: /SendTickets
state: PaymentFailed
a: The payment failed due to a technical error. Please contact us at client@just-ai.com to buy tickets.
state: CatchAll
a: The payment was declined. Please check if you have entered the correct card details and try again.
go!: /TelegramPayment
When the client switches to the TelegramPayment
state, the following message will appear in the chat: