Payment in Telegram bots with Stars

Mihail GokMihail Gok
3 min read

Pavel Durov recently announced payment in bots with a new Telegram Stars currency in his Telegram channel. Now all digital goods in bots must be bought and sold via this currency. If your goods are not digital, you can leave payment via regular payments.

This is a forced measure due to Apple's terms and conditions: in-app purchases sold in the AppStore must earn Apple a 30% commission on each payment. To avoid unprintable words, we will not evaluate Apple's behaviour.

In case your bot will not use Telegram Stars to sell digital apps - it will be blocked, at least for users from the AppStore.

Well, since we are not given a choice - let's see how to use it.

Payments via Telegram Stars

For the demonstration, I'm using python code with the Aiogram 3.0 library.

First we need to create a digital item - this is easy, it's just like before:


one = types.LabeledPrice(label='Одна покупка', amount=1)

The label is the description of the item and the amount is the value - the number of stars you get for it. The Telegram Stars rate is pegged to the dollar at a ratio of about 1 to 50, but that's when you buy it. After taking out Apple's 30% commission and Telegram's 4-5% commission, you get ~65% of the value. This is worth keeping in mind when quoting prices.

Course Table:

After creating the product, we create the payment:


await bot.send_invoice(
    msg.chat.id,
    title="Заголовок покупки ",
    description="Подробное описание покупки ",
    provider_token="",
    currency="XTR",
    photo_url="ссылка на фото",
    photo_width=3600,
    photo_height=2338,
    photo_size=262000,
    is_flexible=False,
    prices=[one],
    start_parameter="one-more",
    payload="one-more"
)

As you can see, provider_token here is an empty string, so it is necessary, as the provider in this case is Telegram itself and we don't need to get any token.

As a currency we specify "XTR" - this is the name of Telegram Stars and put our goods in the prices array.

You can find the full example code on GitVerse and GitHub. And see the example in the bot.

Withdrawing Telegram Stars into real money

Telegram's official website says the following:

Developers can receive an equivalent of 0.013 USD worth of rewards for each Telegram Star.

Telegram determines the monetary value it assigns to Stars in its sole discretion, and this value has no connection, direct or implied, to the historical, present, or anticipated future purchase cost of Stars in any particular region. You acknowledge that both the Star purchase cost and the monetary value Telegram assigns to them for the purposes of rewards may fluctuate over time, based on current market conditions, economic considerations and other factors. We do not anticipate frequent changes to the monetary value assigned to Stars for the purpose of issuing rewards.

<...>

For technical reasons, Stars in your balance may not become available for advertising credits or rewards for up to 21 days after their receipt.

<...>

Telegram currently outsources the processing of rewards to Fragment, a platform owned and operated by Fragment Corp. You understand and agree that your engagement with Fragment is further subject to the Fragment Terms of Service and Privacy Policy.

Withdrawal is available in the bot settings as an ad buy or via cryptocurrency (but only from 1000 stars):

Conclusions

Strangely enough, this currency has advantages:
Since it is inbuilt and owned by Telegram itself - no need for a payment provider in the form of any other banks. You don't need special verification and long registration.

But there are disadvantages too:

  • You'll have to raise the cost of goods for users by at least 30% to get the money you used to.

  • If you don't upgrade to those weird and scary stars - your bot could get blocked. There have already been precedents.

My website

Generate Icons

0
Subscribe to my newsletter

Read articles from Mihail Gok directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mihail Gok
Mihail Gok

Frontend Developer, Publisher, Coder