Why Telegram Is a Powerful Sales Channel for Digital Goods
In many markets โ Russia, Ukraine, India, Southeast Asia โ Telegram is the primary communication platform. Users trust bots for purchases, especially for digital goods where physical delivery is not involved. A well-built Telegram shop bot can outperform a traditional website in conversion, especially for repeat buyers.
This guide shows how to build a production-ready Telegram bot that sells Google Play Gift Cards with instant delivery, powered by the FoxReload wholesale API.
Architecture
User โ Telegram Bot (python-telegram-bot)
โ
Your Backend Server
โ
FoxReload API (wholesale supply)
โ
Payment Provider (Telegram Payments / Stripe / CryptoBot)
Step 1 โ Create Your Bot and Get a Token
- Open Telegram and message @BotFather
- Send
/newbotand follow the prompts - Save the bot token:
1234567890:ABCDefGhIjklMnOPQrsTUVwxyz
Set up your environment:
export TELEGRAM_BOT_TOKEN="your_bot_token"
export FOXRELOAD_API_KEY="your_foxreload_key"
export PAYMENT_TOKEN="your_payment_provider_token"
Step 2 โ Set Up the Bot Framework
from telegram.ext import (
Application, CommandHandler, CallbackQueryHandler,
PreCheckoutQueryHandler, MessageHandler, filters
)
app = Application.builder().token(os.environ["TELEGRAM_BOT_TOKEN"]).build()
app.add_handler(CommandHandler("start", start_handler))
app.add_handler(CommandHandler("catalog", catalog_handler))
app.add_handler(CallbackQueryHandler(button_handler))
app.add_handler(PreCheckoutQueryHandler(precheckout_handler))
app.add_handler(MessageHandler(filters.SUCCESSFUL_PAYMENT, payment_handler))
app.run_polling()
Step 3 โ Build the Catalog Menu
When a user sends /catalog, show Google Play denominations as inline buttons:
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
import requests
async def catalog_handler(update, context):
products = get_google_play_products()
keyboard = []
for p in products:
label = f"Google Play ${p['face_value']} โ ${p['retail_price']}"
keyboard.append([
InlineKeyboardButton(label, callback_data=f"buy:{p['id']}")
])
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(
"๐ฎ Google Play Gift Cards\nChoose a denomination:",
reply_markup=reply_markup
)
def get_google_play_products():
r = requests.get(
"https://api.foxreload.com/api/v1/catalog",
headers={"Authorization": f"Bearer {os.environ['FOXRELOAD_API_KEY']}"},
params={"category": "google-play", "in_stock": "true"}
)
products = r.json()["products"]
# Apply 15% margin
for p in products:
p["retail_price"] = round(p["wholesale_price"] * 1.15, 2)
return products
Step 4 โ Handle the Buy Button
When a user taps a denomination, send a payment invoice:
async def button_handler(update, context):
query = update.callback_query
await query.answer()
if query.data.startswith("buy:"):
product_id = query.data.split(":")[1]
product = get_product_by_id(product_id)
await context.bot.send_invoice(
chat_id=query.message.chat_id,
title=product["name"],
description=f"Instant delivery โข {product['region']} region",
payload=f"order:{product_id}:{query.from_user.id}",
provider_token=os.environ["PAYMENT_TOKEN"],
currency="USD",
prices=[
LabeledPrice(
label=product["name"],
amount=int(product["retail_price"] * 100) # cents
)
],
need_email=True,
send_email_to_provider=True
)
Step 5 โ Validate the Pre-Checkout Query
Telegram sends a pre-checkout query before charging the user. Validate stock availability here:
async def precheckout_handler(update, context):
query = update.pre_checkout_query
payload_parts = query.invoice_payload.split(":")
product_id = payload_parts[1]
# Check stock before confirming payment
if is_in_stock(product_id):
await query.answer(ok=True)
else:
await query.answer(
ok=False,
error_message="Sorry, this item just went out of stock. Please try another denomination."
)
Step 6 โ Fulfill the Order After Successful Payment
async def payment_handler(update, context):
payment = update.message.successful_payment
payload_parts = payment.invoice_payload.split(":")
product_id = payload_parts[1]
user_id = payload_parts[2]
charge_id = payment.provider_payment_charge_id
try:
# Place wholesale order
order_response = requests.post(
"https://api.foxreload.com/api/v1/orders",
headers={
"Authorization": f"Bearer {os.environ['FOXRELOAD_API_KEY']}",
"Idempotency-Key": charge_id
},
json={
"product_id": product_id,
"quantity": 1,
"external_order_id": charge_id
}
)
order_data = order_response.json()
code = order_data["codes"][0]["code"]
# Deliver code to user
await update.message.reply_text(
f"โ
*Payment confirmed!*\n\n"
f"Your Google Play Gift Card code:\n\n"
f"`{code}`\n\n"
f"_(tap to copy)_\n\n"
f"*How to redeem:*\n"
f"1. Open Google Play\n"
f"2. Tap profile โ Payments โ Redeem gift code\n"
f"3. Enter the code above",
parse_mode="Markdown"
)
except Exception as e:
# Refund on failure
await context.bot.refund_star_payment(user_id, charge_id)
await update.message.reply_text(
"Sorry, fulfillment failed. Your payment has been refunded automatically."
)
Step 7 โ Add an Order History Command
async def orders_handler(update, context):
user_id = update.effective_user.id
orders = db.get_user_orders(user_id, limit=10)
if not orders:
await update.message.reply_text("You have no previous orders.")
return
lines = ["*Your recent orders:*\n"]
for o in orders:
lines.append(f"โข {o['product_name']} โ `{o['code']}` ({o['date']})")
await update.message.reply_text("\n".join(lines), parse_mode="Markdown")
Bot Command Menu
Register commands with BotFather for a polished UX:
/start - Welcome message and menu
/catalog - Browse Google Play Gift Cards
/orders - View your order history
/support - Contact support
/help - How to use this bot
Production Considerations
- Rate limiting: add per-user rate limiting to prevent abuse
- Language detection: respond in the user's Telegram language
- Logging: log every order with
user_id,charge_id, andfox_order_id - Monitoring: alert on fulfillment failures > 1% of orders
- Payment tokens: test with Stripe test tokens before going live
See Also
- How to implement instant delivery for Google Play Gift Cards
- How to connect Google Play Gift Cards to your shop via API
- How to set up webhooks for digital code delivery
Launch your Telegram gift card bot. Connect to FoxReload wholesale supply and start selling Google Play Gift Cards directly in Telegram โ no website required.

