Telegram accepts payments in such a way that the m

Telegram accepts payments in such a way that the messenger itself does not store money and does not charge a transaction fee. It acts as a secure interface between your bot, the buyer, and the payment gateway.

Below is a detailed look at what types of payments are available and how to technically launch a payment.

1. What payments can I accept?

All payments in Telegram are divided into two main categories:fiat (ordinary money)Anddomestic currency (Telegram Stars).

Fiat money and payment providers

You can sell physical goods, subscriptions, or digital content for rubles, hryvnias, dollars, euros, and other currencies. Telegram is integrated with many international and local providers:

  • Global:Stripe, ECOMMPAY.

  • Ukraine:LiqPay, Portmone, Tranzzo.

  • Kazakhstan CISSMARTGLOCAL

  • UZ:Payme, Click.

  • Cryptocurrency:Cryptomus.

When paying with fiat, users out of the box workApple PayAndGoogle Payif they are supported by the selected acquiring provider.

Telegram Stars

This is Telegram's internal digital currency.

  • What you need:According to the rules of Apple and Google, the purchase of anydigital goods(e-books, courses, access to closed channels, subscriptions in bots and Telegram Mini Apps) inside the apps on iOS and Android should go through their payment systems. Telegram Stars were created just for this purpose.

  • How does it work?The user buys "Stars" inside Telegram through the App Store/Google Play, and then spends them in your bot. You, as a developer, can withdraw these Stars to TON cryptocurrency through the Fragment platform or use them to pay for advertising.

2. How to set up payment (Step-by-step algorithm)

The process consists of setting up communication with the payment system in a special bot from Telegram and writing code for processing transactions.

Step 1: Get the provider token from @BotFather

  1. Open@BotFatherin Telegram and enter the command/mybots.

  2. Select your bot from the list and go toBot Settings -> Payments.

  3. Select the payment provider you want (ex.LiqPay, StripeorYuKassa) from the list. To develop, select the option markedTestsuch asStripe Test) to test payment with virtual cards.

  4. You will be redirected to the bot of the selected payment system for authorization (you will need an account/merchant in this system).

  5. After successful binding@BotFatherwill give youProvider Token(long line). Save it to your project configuration file. (Env.).

Important:If you are setting up payment viaTelegram Stars, you do not need to receive the provider's token. Instead of a token, an empty string is passed in the code"", and the code is indicated as the currencyXTR.

Step 2: Technical implementation in the bot code

From the point of view of the Telegram Bot API, the entire payment process consists of three key stages. Let's consider the architecture using the example of code logic (in Python/aiogram or Node.js):

1. Invoicing (sendInvoice)

When a user clicks the "Buy" button, your bot should send them a special invoice message using thesendInvoice.

Python
# Example of parameters for the sendInvoice method (Python-style)
awaitbot.send_invoice(
    chat_id=message.chat.idTitle="Intermission 5""Premium monthly subscription"Description"Access to the closed B2B functionality of the bot",
    payload="user_id_12345_package_premium", # Your internal label to checkprovider_token="YOUR_TOKEN_OF_BOTFATHER",  # For Stars, leave an empty string ""currencyUAH,                           # Or "XTR" for Telegram Starsprices=[
        LabeledPrice(label="Subscription"amount25000) # Amount in minimum units (25,000 kopecks = 250 UAH)
    ]
)

2. Checking the availability of goods (PreCheckoutQuery)

As soon as the user enters the card details and clicks "Pay", Telegram sends your bot a requestPreCheckoutQuery.

  • Time limit:Your server should respond to this request within10 Seconds, or the transaction will be canceled.

  • Why you shouldHere you check the database whether the product is still in stock or whether the price is still relevant.

Python
# pre_checkout_query handler
@dp.pre_checkout_query_handler(LambdaQuery:True)
ASYNC def process_pre_checkout_query(pre_checkout_query: PreCheckoutQuery):
    # Check the balances in the database, if everything is ok:
    awaitbot.answer_pre_checkout_query(pre_checkout_query.idOKTrue)
    # If there is no product: ok=False, error_message="Product is out"

3. Successful payment (SuccessfulPayment)

If the provider successfully debited the money, the bot receives the final update with the type of contentsuccessful_payment. At this point, you are required to give the user a product or activate a subscription.

Python
# Successful Payment Processor
@dp.message_handler(content_types=ContentTypes.SUCCESSFUL_PAYMENT)
ASYNC def success_payment(message: Message):payload = message.successful_payment.invoice_payload# Payment completed! Accruing balance / issuing access to a private channel
    awaitmessage.answer("Thank you for your payment! Your access has been activated.")

Checklist before launching into production

  • [ ] Testing:First, be sure to link the provider's test token to the@BotFatherand spend the entire payment cycle using test cards (their numbers are provided by the payment gateway itself in its documentation).

  • [ ] Fiat Limitations:Make sure that your legal status (individual entrepreneur/sole proprietor or legal entity) allows you to connect the selected gateway.

  • [ ] App Store/Google Play rule:If you sell files, information products, or subscriptions inside the bot, do it through Telegram Stars. (currency="XTR"), otherwise the bot may be blocked on mobile platforms. For physical goods (food delivery, merch), feel free to use the standard fiat.