Skip to content

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 byTutorial
Telegram Starstelegram_starsA quantity of Stars. One order sends 50 to 100,000 Stars.Your first Telegram Stars order
Telegram Premiumtelegram_premiummonths 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.

Code for Read what you can order
GET /v1/productsSandbox, test key
// 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:

Code for What you should see
What can be ordered in the Sandbox
JSON
200 OKSynthetic sandbox data
{  "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 seeWhat to check
product_unavailableThe product is closed where your key works. Read GET /products and offer only what it lists as available.
product_not_permittedThe key may buy only some products, and the request named another. Use a key allowed to buy it.
invalid_api_keyThe 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 refusedCheck the quantity or months against the product's selection. A value outside it is refused before anything is held.