Choose Stars or Premium
The two products you can order, what each is bought by, and the tutorial that takes each to a delivered Sandbox order.
Sandbox: test money only. No request moves real money.
Choose what to sell first. Both products are delivered to a Telegram username, paid from your balance and ordered with the same request. They differ in one field.
The two products
| Product | `product` | Bought by | Tutorial |
|---|---|---|---|
| Telegram Stars | telegram_stars | A quantity of Stars. One order sends 50 to 100,000 Stars. | Your first Telegram Stars order |
| Telegram Premium | telegram_premium | months of Premium: 3, 6 or 12. | Your first Telegram Premium order |
Telegram Stars. Availability: Available. Live and verified in production.
Telegram Premium. Availability: Available. Live and verified in production. In Live, Premium is sold to a workspace allowed to buy it. GET /products with your Live key lists it with available true when yours is; until then an order for it is refused and nothing is held.
Read what you can order
GET /products is the server's own list. Offer a product only when it is listed with available true, and read its bounds from selection instead of writing them into your code: a min, a max and a step for Stars, the months allowed for Premium. They are provisional until they are confirmed.
Read it when your service starts, and again when an order is refused for its product. A client that reads the catalogue needs no change when a product opens.
// npm install axiosimport axios from 'axios';try { const { status, data: products } = await axios. get( 'https:// sandbox-api. nasfampay. com/ v1/ products', { headers: { Authorization: `Bearer ${process. env. NASFAM_ SANDBOX_ KEY}`, }, }, ); console. log( status, products);} catch ( error) { if ( !axios. isAxiosError( error) || !error. response) throw error; const problem = error. response. data; throw new Error( `${problem. status} ${problem. code}: ${problem. title} ( request ${problem. request_ id})`);}Pick your tutorial
Each tutorial takes one product from a key to a delivered Sandbox order on one page: the lookup, the confirmation, the order, tracking, safe retries and the webhook handler.
- Your first Telegram Stars order: One Telegram Stars order from your key to delivery: look the recipient up, confirm, order, track, retry safely and handle the webhook.
- Your first Telegram Premium order: One Telegram Premium order from your key to delivery: look the recipient up, confirm, order, track, retry safely and handle the webhook.
The Sandbox steps cover the same ground one part at a time, for either product, starting with Add test funds.
What you should see
GET /products answers 200 with the products your key can order, each with its selection. This is the Sandbox's list:
{ "data": [ { "id": "telegram_ stars", "name": "Telegram Stars", "status": "sandbox", "provisional": true, "available": true, "selection": { "type": "quantity", "min": 50, "max": 100000, "step": 50 }, "recipient": { "type": "telegram_ username" } } ], "has_ more": false, "next_ cursor": null}If it fails
| What you see | What to check |
|---|---|
product_unavailable | The product is closed where your key works. Read GET /products and offer only what it lists as available. |
product_not_permitted | The key may buy only some products, and the request named another. Use a key allowed to buy it. |
invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header is Bearer followed by the whole key. |
| The product is listed, and an order for it is refused | Check the quantity or months against the product's selection. A value outside it is refused before anything is held. |
Related guides
- Telegram Stars: the product, its bounds and its advanced flow.
- Telegram Premium: the product, and what happens when the account already has Premium.
- List products: every field of the catalogue.
