Skip to content
Back to blog

Telegram Stars Invoice Builder: createInvoiceLink Payloads

3 min read
Telegram Stars Invoice Builder: createInvoiceLink Payloads

Telegram payments have two shapes that look almost identical in the API and behave nothing alike. One is a Telegram Stars invoice — the in-app currency, settled by Telegram, no payment provider involved. The other is a traditional card invoice routed through a provider you connected in BotFather. Both go through the same method, createInvoiceLink, with roughly twenty parameters, and most of the time lost to that method is lost to one of them.

The amount is not the price

amount is always an integer in the currency's smallest unit. That single sentence hides three different behaviours:

Currencyamount: 250 charges
USD, EUR, RUB, GBP…$2.50 — two decimal places
JPY¥250 — zero decimal places
XTR (Stars)250 ⭐ — no minor unit

The USD case is the one everybody learns first, and it is exactly why the other two go wrong. Copying a working USD integration to a Japanese storefront and multiplying by 100 "because that is how it works" charges a hundred times too much. Going the other way for Stars — dividing by 100 to get "2.50 stars" — produces an invoice for 2 stars, or a validation error, depending on where the rounding lands.

Telegram publishes an exponent per currency. Every currency in the common set uses two decimal places except JPY, which uses none. A tool that renders the total in the currency's real units makes the mistake visible before a buyer ever sees it, instead of leaving it to be inferred from an integer.

What the builder does

Telegram Stars Invoice Builder composes a createInvoiceLink payload in either mode and checks it as you type:

  • Stars (XTR) and card payment are separate tabs, so the fields that do not exist in a mode are absent rather than greyed out.
  • A per-currency exponent table drives the live total, so 250 reads as ⭐ 250, $2.50 or ¥250 depending on what you actually selected.
  • The payload field counts UTF-8 bytes, not characters.
  • A Decode tab takes the parameters back apart and cross-checks them.
  • Export to cURL, Node.js, Python and PHP.

Everything runs in the browser. The provider token is only interpolated into the snippet on screen; nothing is sent anywhere.

Stars and card are not a toggle

The differences are structural, not cosmetic. A Stars invoice:

  • uses currency: "XTR",
  • carries no provider_token — Telegram settles it,
  • must contain exactly one item in prices,
  • supports none of the billing-detail flags: no max_tip_amount, no need_name, need_phone_number, need_email or need_shipping_address, no send_*_to_provider, no is_flexible.

A card invoice requires a provider_token from @BotFather → Payments, may list several price lines, and may use all of those flags. is_flexible in particular means the final price depends on the shipping address, so the bot must answer shipping_query — and it is independent of max_tip_amount, which is a separate feature that works with or without it.

Sending a Stars invoice with a leftover provider_token, or a card invoice without one, is the most common way to get a 400 back from a payload that looks perfectly reasonable. Both directions are checked here, in the builder and in the decoder.

The payload is bytes

payload is your own opaque string. Telegram never displays it and hands it straight back on pre_checkout_query and successful_payment, which makes it the natural place to put an order id or a subscription key. Its limit is 1–128 bytes.

Bytes, not characters. UTF-8 spends two bytes on each Cyrillic letter and up to four on an emoji, so a 65-character Russian payload is 130 bytes and gets rejected by an API call that a .length <= 128 check said was fine. The counter here measures the encoded length.

What cannot be decoded

createInvoiceLink returns a URL of the form https://t.me/$…. It is an opaque handle: the invoice lives on Telegram's servers and nothing about it can be read out of the string in a browser. The same is true of a bare invoice_payload — it is whatever bytes your own bot chose.

So the Decode tab works on the parameters you send, not on the link you get back, and says so rather than pretending to parse something that carries no data. Paste the JSON, or a whole cURL, Node, Python or PHP snippet containing it, and it comes back as a field table with the total rendered in real units and every rule re-checked.

Workflow

  1. Pick Stars (XTR) or Card payment.
  2. Fill in title, description and payload — watch the byte counter, not the character count.
  3. Add price lines and read the live total in the units it will charge.
  4. Clear any blocking validation notes.
  5. Copy the snippet for your language, call createInvoiceLink, and send the returned link to the buyer.
  6. Handle pre_checkout_query within ten seconds, then successful_payment, matching on the payload you set in step 2.

Frequently asked questions

What does amount mean in a Telegram invoice?

Always an integer in the currency's smallest unit. For USD or EUR that means amount 100 is 1.00, not 100. For zero-decimal currencies such as JPY there is no smaller unit, so amount 250 is 250 yen. For Telegram Stars there is no smaller unit either, so amount 250 is 250 stars.

Do I need a provider_token for Telegram Stars?

No. Stars payments are settled by Telegram itself, so a Stars invoice uses currency XTR and carries no provider token at all. A provider_token from BotFather is only needed for traditional card currencies.

Why is my invoice_payload rejected even though it looks short?

The limit is 1 to 128 bytes, not characters. UTF-8 spends two bytes per Cyrillic character and up to four per emoji, so a payload that passes a naive length check can still exceed the byte limit.

Can a Stars invoice have several price lines?

No. An invoice priced in Telegram Stars must contain exactly one item in prices. Traditional card invoices may list several.

Can I decode the https://t.me/$ link that createInvoiceLink returns?

No. That link is an opaque server-side handle with no client-readable contents. What can be inspected is the set of parameters you sent to createInvoiceLink.

Does tipping work with Telegram Stars?

No. max_tip_amount and suggested_tip_amounts are not supported for payments in Telegram Stars, along with name, phone, email and shipping address collection and is_flexible.

Author

Fullstack Engineer

In commercial development since 2011 — over 15 years. Author of two SaaS products, TeleGo.io and LingvoHabit.com. The articles here come out of real client and product work.