// Array with meta tag data $metaData = array( "" => array( "title" => "Online Payment System | Connecting Payment Systems and Banks Without Fees.", "description" => "Tegro.money offers advantageous tariff plans for online acquiring with a variety of payment acceptance methods. Register and start accepting payments today!", "keywords" => "tegro, online cash register, internet acquiring, payment acceptance, fund withdrawal, acquiring, card payment, online payment, online payment through internet, tegro.money" ), "referral-program" => array( "title" => "Referral Program | Online Payment System - Tegro.Money", "description" => "Invite acquaintances and friends – earn a percentage of their turnover. A unique opportunity for additional income from invited users.", "keywords" => "tegro, online cash register, internet acquiring, partnership, referral" ), "security" => array( "title" => "Security | Online Payment System - Tegro.Money", "description" => "We use PCI DSS security standard, SSL protocol, Verified by Visa and MasterCard SecureCode security systems.", "keywords" => "" ), "pricing" => array( "title" => "Tariffs | Online Payment System - Tegro.Money", "description" => "Payments for your customers will become simpler and more accessible, and more profitable for you.", "keywords" => "" ), "coupons" => array( "title" => "Discounts and Coupons | Online Payment System - Tegro.Money", "description" => "Payments for your customers will become simpler and more accessible, and more profitable for you.", "keywords" => "" ), "advantages" => array( "title" => "Our Advantages | Online Payment System - Tegro.Money", "description" => "Utilize all the features of Tegro.money service.", "keywords" => "" ), "policy" => array( "title" => "Personal Data Processing Policy | Tegro.Money", "description" => "Tegro.Money prioritizes compliance with and protection of its clients' interests.", "keywords" => "" ), "offer" => array( "title" => "Public Offer for Agreement on Use of Tegro.Money Service", "description" => "Agreement on Use of Tegro.Money Service", "keywords" => "" ), "contacts" => array( "title" => "Contacts | About Tegro.Money Company", "description" => "We are a modern IT company that provides services for electronic payments on the internet and beyond.", "keywords" => "" ), "docs/en/" => array( "title" => "Documentation and API | Tegro.Money", "description" => "Tegro.money API allows you to accept payments, process refunds, check transaction statuses, and much more. To use the API, you'll need to have a store in our system.", "keywords" => "" ) ); // Get the current page's name $current_page = basename($_SERVER['REQUEST_URI'], ""); // Check if there's data for the current page in the $metaData array if (array_key_exists($current_page, $metaData)) { $title = $metaData[$current_page]["title"]; $description = $metaData[$current_page]["description"]; $keywords = $metaData[$current_page]["keywords"]; } else { // If data is absent, set default values $title = "Online Payment System"; $description = "Tegro.money offers advantageous tariff plans for online acquiring with a variety of payment acceptance methods."; $keywords = "tegro, online cash register, internet acquiring, payment acceptance, fund withdrawal, acquiring, card payment, online payment, online payment through internet, tegro.money"; } ?>

Telegram bot that accepts payments

A prompt for Cursor / Claude Code. A ready-to-use Telegram bot on Node.js (grammY) with a /buy command — the bot hands out a payment link, Tegro.Money sends a webhook, and the bot tells the user the payment went through.

Prompt

Build a Telegram bot on Node.js + TypeScript + grammY + Fastify.

Structure:
- bot.ts — the grammY bot: /start, /buy commands.
- server.ts — Fastify, two routes: POST /tegro-notify (the webhook from Tegro) and /health.
- index.ts — starts bot.start() + server.listen().

/buy logic:
1. Ask the user what they want to buy (for the demo — a fixed product "Channel access for 500 ₽").
2. Create an order in Tegro.Money:
   POST https://tegro.money/api/createOrder/
   Body: {
     shop_id: process.env.TEGRO_SHOP_ID,
     nonce: crypto.randomUUID(),
     currency: "RUB",
     amount: 500,
     order_id: crypto.randomUUID(),
     description: "Channel access",
     notify_url: process.env.BASE_URL + "/tegro-notify"
   }
   Header: Authorization: Bearer <HMAC-SHA256(body, TEGRO_API_KEY) hex>
   IMPORTANT: the signature is computed over the SAME JSON body you send (after JSON.stringify).
3. Take data.url from the response — send the user an Inline Keyboard "Pay" button with that link.
4. Store a {tegroOrderHash → telegramUserId} mapping in a Map (or Redis/SQLite, if the project has one).

/tegro-notify webhook logic:
1. Tegro sends a form-urlencoded POST.
2. Verify the signature per the docs at https://tegro.money/docs/en/payments/notify/
3. If order_id is found in our Map and status=1 (paid) — send the user a Telegram message
   "Payment received! Adding you to the channel..." and an invite link to the private channel.
4. Return "OK" with status 200.

Extras:
- ENV: TELEGRAM_BOT_TOKEN, TEGRO_SHOP_ID, TEGRO_API_KEY, BASE_URL, CHANNEL_INVITE_LINK
- package.json scripts: dev (tsx watch), start (node dist), build (tsc)
- README.md with the list of ENV vars and instructions:
  * /buy from the user -> a Tegro link
  * After payment — the user gets a channel invite
  * For local development BASE_URL = ngrok URL

Don't use node-telegram-bot-api — it's outdated. Use grammY.

After it's generated

  1. Create a bot via @BotFather — get your TELEGRAM_BOT_TOKEN.
  2. Register a shop in your merchant cabinet — grab TEGRO_SHOP_ID + TEGRO_API_KEY.
  3. Run ngrok to test the webhook (ngrok http 3000).
  4. Set notify_url = https://<ngrok>/tegro-notify in the shop settings.
  5. Enable the shop's test mode — try it out with no real charges.

Related