Gift Card API for Telegram Bots
Short Answer
A gift card API works in a Telegram bot exactly as it does in a web store β the difference is only the delivery channel. The bot accepts a product selection and payment, calls the supplier's order creation endpoint, receives the code, and sends it to the user in the chat. No web interface required. The key implementation steps are: product menu, payment trigger, API call, code delivery via sendMessage, and error handling.
Definition: A gift card API for Telegram bots is a supplier's REST API that the bot's backend calls to create gift card orders and receive codes, which the bot then delivers to the customer within the Telegram conversation.
Key takeaway: The gift card API is channel-agnostic. Whether you call it from a web store backend or a Telegram bot backend makes no difference to the API. The only bot-specific implementation is replacing the email/order-page delivery with a bot.sendMessage() call.
Who This Guide Is For
- Telegram bot developers adding gift card sales to their bot
- Bot operators who already sell top-ups and want to add gift card codes
- Developers evaluating whether a Telegram bot is a viable gift card storefront
Gift Card vs. Top-Up in a Telegram Bot
| Factor | Gift Card (Code) | Top-Up (Direct to Account) |
|---|---|---|
| Customer input needed | None | Player ID (mandatory) |
| Delivery | Code string in message | Account credit confirmation |
| Refund risk | Code can be misused; moderate risk | Non-reversible; low risk |
| Integration complexity | Lower | Higher (player ID validation) |
| Product examples | Steam, PSN, Xbox, Google Play | PUBG UC, Robux, ML Diamonds |
For a first implementation, gift card codes are simpler. Top-up integration requires the additional player ID validation step.
Full Bot Flow for Gift Card Delivery
/start
β Bot: "Select a product category"
[Gaming] [Retail] [Mobile]
[Gaming]
β Bot: "Select a product"
[Steam $10] [Steam $20] [PSN $10] [Xbox $15]
[Steam $20]
β Bot: "Steam $20 (US) β $21.99. Pay now?"
[Pay with Stars] [Pay with Crypto]
[Pay with Stars β Telegram payment]
β Telegram native payment flow
β On successful_payment event:
Bot calls supplier API: POST /orders { sku: "steam-20-usd", qty: 1 }
Receives: { code: "XXXXX-YYYYY-ZZZZZ" }
Bot.sendMessage: "Your Steam code: XXXXX-YYYYY-ZZZZZ
Redeem at: store.steampowered.com"
Payment Integration for Gift Card Bots
| Method | Telegram Integration | Fee Range | Friction |
|---|---|---|---|
| Telegram Stars | Native, via Payments API | ~30% cut | Very low |
| Crypto (TON, USDT) | External wallet link or @wallet bot | 1β2% | Low |
| Stripe payment link | Redirect to browser | 2.5β3.5% | Medium |
Telegram Stars note: Telegram takes approximately 30% of Stars payments. For a $10 product, your effective revenue from a Stars payment is ~$7. This requires a higher retail price or higher wholesale discount to maintain margin. Model carefully before enabling Stars as your only payment method.
Code Delivery Message Format
When sending the code to the user, always include:
β
Order complete
Product: Steam Gift Card $20 (US Region)
Code: XXXXX-YYYYY-ZZZZZ
Redeem at: store.steampowered.com/account/redeemwalletcode
Region: US Steam accounts only
Need help? /support
Format the code in a monospace block so it is easy to copy:
`XXXXX-YYYYY-ZZZZZ`
Telegram renders text between backticks in monospace, which is copy-friendly on mobile.
Error Handling
| Error | Cause | Bot Response |
|---|---|---|
| API call fails | Network or supplier error | "Order processing β please wait. If not delivered within 2 minutes, contact /support" |
API returns failed |
Out of stock or supplier issue | "Delivery failed. You have not been charged. Contact /support" |
| Code field empty | Supplier-side issue | Treat as failure; do not deliver |
| Payment confirmed but API fails | Race condition | Log order; retry once; alert ops if retry fails |
Never send an empty code or a placeholder to the user. If the API returns an error, handle it gracefully.
Logging Orders
For every completed gift card order in your bot, log:
- Telegram user ID (not username β IDs are stable; usernames can change)
- Product SKU
- Supplier order ID
- Code (hashed, not plain text in your database)
- Timestamp
- Payment confirmation ID
This log is required for dispute resolution: if a user claims they did not receive a code, you check your log.
Checklist
- Product catalog set up in bot (with region-explicit naming)
- Payment method integrated and tested
- Payment event handler: trigger API call only on confirmed payment
- Supplier API order creation call with error handling
- Code delivery via sendMessage with full instructions
- Code in monospace format for easy copying
- /support command with contact info
- Transaction logging per order
- Balance monitoring with alert
- Refund policy communicated (/terms or in /start message)
