Connecting Crypto Pay API to Telegram Bot: A Complete Guide for Beginners
Next step
Open the bot or continue inside this section.
Article -> plan in AI
Paste this article URL into any AI and get an implementation plan for your project.
Read this article: https://vibecode.morecil.ru/en/oplaty-i-podpiski/podklychenie-crypto-pay/
Work in my current project context.
Create an implementation plan for this stack:
1) what to change
2) which files to edit
3) risks and typical mistakes
4) how to verify everything works
If there are options, provide "quick" and "production-ready". How to use
- Copy this prompt and send it to your AI chat.
- Attach your project or open the repository folder in the AI tool.
- Ask for file-level changes, risks, and a quick verification checklist.
Crypto Pay is the official payment system from @CryptoBot (send.tg), which allows any Telegram bot or web service to accept payment in cryptocurrency without intermediaries and with minimal fees. You create an invoice through the API, send a link to the user, they pay directly in the Crypto Bot application – and you instantly get money on the balance of your application.
Supported assets (mainnet 2026): USDT, TON, BTC, ETH, LTC, BNB, TRX, USDC (and test JET on testnet).
You can accept one-time payments, time access payment (subscriptions through your bot’s logic), send checks and even transfer coins back to users.
1. Obtaining an API token (test and combat)
Test environment (recommended to start with):
- Open the bot @CryptoTestnetBot.
- Write
/payor click Crypto Pay. - Click Create App → Enter the name (e.g., “MyTestBot”) → get a
12345:ABCdef...token. - Save the token – it will only work on
https://testnet-pay.crypt.bot/api/.
** Combat environment:**
- Open @CryptoBot.
- Go to Crypto Pay > Create App.
- Get a token (it is different from the test one).
- Basic URL:
https://pay.crypt.bot/api/.
Important: The token is transmitted only under the heading Crypto-Pay-API-Token. Never publish it in public repository code!
2. How to Test Without Risk
- In testnet, all payments are simulated. You can “pay” the bill in the test bot.
- The balance is replenished with JET test coins (and others) through the CryptoTestnetBot menu.
- All methods and response formats are completely identical to production.
- After the tests, simply change the URL and token – the code remains the same.
3. Main method: creation of a single account (createInvoice)
POST https://pay.crypt.bot/api/createInvoice (or testnet)
Minimum parameters (JSON):
{
"asset": "USDT,"
"amount": "9.99,"
"Description": "Premium access for 30 days"
"payload": "user 123 order 456", // your internal ID
"expires in": 3600 // 1 hour for payment
}
Full list of parameters (all real as of February 2026):
currency_type: "crypto" (default) or "fiat" (then amount in USD/EUR/RUB, etc.)accepted_assets: "USDT,TON,BTC" (if fiat)hidden_message: text that the user will see after paymentpaid_btn_name+paid_btn_url: button after payment (“Open bot”, “Return”, etc.)allow_comments,allow_anonymousswap_to: autoexchange in USDT/TON after payment (new product 2025)
The answer is:
invoice_idXXbot_invoice_url– the main link for paymentmini_app_invoice_url,web_app_invoice_url(for Mini Apps)
Example of sending a link to a user in a bot (aiogram 3.x):
await message.answer(
"Оплатите доступ:",
reply_markup=InlineKeyboardMarkup(inline_keyboard=[[
InlineKeyboardButton(text="Оплатить 9.99 USDT", url=invoice.bot_invoice_url)
]])
)
4. How to accept subscriptions (recurrent payments)
Crypto Pay ** does not have built-in recurring profiles** (like Stripe), but this is easily implemented on the bot side:
** Option 1 (most popular):**
- The user chooses a subscription (1 month / 3 months / year).
- The bot creates invoice for the corresponding amount.
- When paying (webhook) write to the database:
user_id,expires_at = now + 30 дней. - 3 days before the end, send a reminder + a new invoice.
- Repeat automatically.
Variant 2: CreateCheck – the user activates the check himself, convenient for “subscription renewal with one click”.
** Option 3:** For closed channels, use the built-in Crypto Bot subscriptions (a separate section in help.send.tg), but for bots, only custom logic.
5. Receiving payment notifications (Webhooks is a must!)
In your App settings (at @CryptoBot → My Apps → your app → Webhooks), specify the URL of the https://yourdomain.com/crypto-webhook view.
When paying, Crypto Bot makes POST to your URL with the heading Crypto-Pay-Api-Signature (HMAC-SHA256 from the body + your token as a key).
Example of signature verification (Python):
import hmac, hashlib, json
def verify_webhook(data: bytes, signature: str, token: str) -> bool:
expected = hmac.new(token.encode(), data, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
The body will always have update_type: "invoice_paid" + full Invoice object (with paid_asset, paid_amount, payload, etc.).
6. Useful complementary techniques
getMe– check the tokengetBalance- current balance of the application for all assetsgetInvoices- list of all accounts (with status=active/paid/expired filters)deleteInvoice- delete unpaid invoicegetCurrencies– current list of currencies and minimum amountsgetExchangeRatesCoursestransfer– send coins to the user (must be included in Security)createCheck/getChecks- one-time gift checksgetStats- application statistics (new 2024)
7. Commissions and withdrawals (real data 2026)
The commission depends on the turnover in the last 30 days:
- 0–10,000 USD – 3%
- 10,000-50,000 - 2%
- 50,000–100,000 – 1%
100,000 to 0.5% or lower (individually)
Output to any TON/USDT/BTC wallet, etc. – instantly, without additional Crypto Pay fees (network only).
8. Prompts for AI (ChatGPT / Claude / Grok) to connect everything yourself
If you already have a token and a wallet, just copy the prompt:
Prompt 1 (full integration on aiogram 3.x + FastAPI webhook):
Write the full working code of the Telegram bot in Python 3.11 + aiogram 3.x + FastAPI for webhook.
Use the Crypto Pay API (token: [MAKE THEY]).
Functional:
- /pay command creates invoice for 5 USDT with payload = user id
- Sends a button from bot invoice url
Webhook /crypto webhook checks signature, adds 30 days of subscription to SQLite
The /status command shows the end date of the subscription
- All with error processing, logging, comments.
Use the testnet first.
Prompt 2 (backend + Flask only):**
Create a Flask application that:
1. When GET /create?user=123&amount=9.99 creates invoice through the Crypto Pay API and returns JSON from the url.
2. Has endpoint /webhook, checks HMAC, saves payment to PostgreSQL.
The token and the URL are constants. Add Docker-compose.
Prompt 3 (Node.js + Telegraf):
Write Crypto Pay integration into Telegraf bot (Node.js). Creating an invoice, sending a button, processing webhook with signature verification.
9. Safety and best practices
- Enable IP-allowlist in the App (Security) settings.
- Never store a token in client code.
- For production, use HTTPS + webhook signature verification.
- Store payload with user id + order id.
- Do backup checks through
getInvoicesevery 5-10 minutes.
Conclusion
Crypto Pay is the easiest and most reliable way to accept crypto in a Telegram bot in 2026. Everything works within the Telegram ecosystem, without redirects to third-party sites, with instant notifications and zero commissions at high turnover.
Official documentation (always relevant):