A feature-rich Telegram bot for selling digital products.
- Binance Pay - USDT cryptocurrency payments with automatic verification
- Bank Transfer - Vietnamese bank transfers via SePay API integration
- Automatic Payment Detection - Monitors and confirms deposits automatically
- QR Code Support - Displays QR codes for easy payment
- Balance (USDT/VND) - Primary currency from deposits
- Credits (🪙) - Bonus currency from referrals and events
- Flexible Payment - Users can pay with either Balance or Credits
- Smart Pricing - Products can have separate pricing for each currency
- Referral Codes - Unique codes for each user
- Instant Bonuses - Configurable rewards for referrer and referee
- Minimum Deposit Option - Set minimum deposit requirement for bonus eligibility
- Tracking - View referral statistics and earnings
- Stock Management - Track available and sold items
- Dual Pricing - Set prices in both Balance and Credits
- Auto-delivery - Instant delivery of account credentials after purchase
- Product Visibility - Enable/disable products as needed
- 3 Languages - Vietnamese, English, Chinese
- User Preferences - Each user can select their preferred language
- Fully Translated - All messages and UI elements localized
- User Management - View all users, balances, and credits
- Order Tracking - Monitor all orders in real-time
- Revenue Analytics - Track Balance revenue and Credits usage
- Manual Adjustments - Add/remove balance or credits for users
- Broadcast Messages - Send announcements to all users (in their language)
- Event System - Create promotional events with bonus credits
- Product CRUD - Full product management interface
- Purchase History - Users can view their order history with timestamps
- Transaction Logs - Complete audit trail of all transactions
- Atomic Operations - Prevents race conditions and double-spending
- Deposit Expiration - Configurable timeout for pending deposits (default 15 min)
- Error Handling - Robust error handling with user-friendly messages
- SQLite Database - Fast, reliable, embedded database
- Node.js v16 or higher
- Telegram Bot Token (from @BotFather)
- Binance Pay account (for crypto payments)
- SePay account (for Vietnamese bank transfers)
git clone <repository-url>
cd bot_binance_paynpm installCopy .env.example to .env:
cp .env.example .envEdit .env with your credentials:
# Bot Configuration
BOT_TOKEN=your_telegram_bot_token_from_botfather
BOT_USERNAME=your_bot_username
SHOP_NAME=Your Shop Name
# Admin Configuration
ADMIN_IDS=123456789,987654321
ADMIN_USER_NAME=your_admin_username
# Binance Pay Configuration
BINANCE_API_KEY=your_binance_api_key
BINANCE_SECRET_KEY=your_binance_secret_key
BINANCE_PAY_ID=your_binance_pay_id
# Bank Transfer (SePay) Configuration
SEPAY_API_KEY=your_sepay_api_key
BANK_ACCOUNT=your_bank_account_number
BANK_NAME=Vietcombank
BANK_OWNER=NGUYEN VAN A
BANK_BIN=970436
# Referral Configuration
REFERRER_BONUS=1
REFEREE_BONUS=0.5
MIN_DEPOSIT_FOR_BONUS=5
DEPOSIT_EXPIRES_MINUTES=15Place your Binance Pay QR code image at:
public/bnc_qr.png
npm startFor development with auto-reload:
npm run devbot_binance_pay/
├── src/
│ ├── bot.js # Main entry point
│ ├── config.js # Configuration loader
│ ├── database/
│ │ ├── index.js # Database initialization
│ │ └── models/ # Data models
│ │ ├── user.js # User model
│ │ ├── product.js # Product model
│ │ ├── order.js # Order model
│ │ └── transaction.js # Transaction model
│ ├── handlers/
│ │ ├── commands.js # /start, /balance commands
│ │ ├── callbacks.js # Button click handlers
│ │ ├── messages.js # Text message handlers
│ │ └── admin.js # Admin commands & UI
│ ├── services/
│ │ ├── wallet.js # Balance & credits operations
│ │ ├── referral.js # Referral system logic
│ │ ├── events.js # Event system (bonuses)
│ │ └── payment/
│ │ ├── index.js # Payment orchestration
│ │ ├── binance.js # Binance Pay integration
│ │ └── sepay.js # SePay bank transfer
│ ├── utils/
│ │ ├── helpers.js # Helper functions
│ │ └── keyboard.js # Keyboard builders
│ └── locales/
│ ├── index.js # i18n loader
│ ├── vi.js # Vietnamese
│ ├── en.js # English
│ └── zh.js # Chinese
├── data/
│ └── shop.db # SQLite database (auto-created)
├── public/
│ └── bnc_qr.png # Binance QR code
├── .env # Environment config (git-ignored)
├── .env.example # Example configuration
└── package.json # Dependencies
/start- Start bot and show main menu/balance- View balance, credits, and statistics/referral- View referral code and earnings/history- View purchase history/lang- Change language
/users- List all users with balances/orders- View recent orders/revenue- View revenue analytics/addbalance [user_id] [amount]- Add balance to user/addcredits [user_id] [amount]- Add credits to user/broadcast- Send message to all users/addevent [type] [amount] [code] [name]- Create bonus event/clear- Clear chat messages/products- Manage products (via inline menu)
- Add/edit products
- Set dual pricing (Balance + Credits)
- Manage stock (add/view inventory)
- Enable/disable products
- View sales statistics
- User selects deposit method (Binance Pay or Bank Transfer)
- User chooses amount or enters custom amount
- Bot generates payment instructions with QR code
- Bot monitors payment status automatically
- Upon confirmation, balance is credited and user notified
- Referral bonuses processed if applicable
- User browses products
- Selects quantity and payment method (Balance or Credits)
- Bot verifies sufficient funds
- Bot atomically reserves stock
- Bot processes payment
- Account credentials delivered instantly
- Admin notified of purchase
- Transaction logged
- Atomic Operations - Prevents double-spending and race conditions
- Transaction Logs - Complete audit trail
- Admin Authentication - Commands restricted to authorized admins
- Input Validation - All user inputs sanitized
- Error Recovery - Automatic refunds on failed orders
- id, first_name, username, language
- balance, credits
- balance_spent, credits_spent
- referral_code, referred_by
- created_at
- id, name, description
- price (Balance price)
- credits_price, credits_enabled
- is_active
- created_at
- id, user_id, product_id
- quantity, unit_price, total_price
- payment_method, payment_code
- status, chat_id
- created_at, completed_at
- id, user_id, type
- amount, currency
- payment_method, reference_id
- status, note
- created_at
- id, user_id, amount, currency
- payment_method, payment_code
- status, expires_at
- created_at
- id, product_id, account_data
- status (available/sold/reserved)
- order_id, reserved_at, sold_at
- id, code, name, type
- reward_amount, reward_type
- max_per_user, is_active
- created_at
Add new languages by creating a file in src/locales/:
// src/locales/es.js
module.exports = {
// Main Menu
shop_btn: '🛍️ Tienda',
balance_btn: '💰 Saldo',
// ... more translations
};Register in src/locales/index.js:
const es = require('./es');
const languages = { vi, en, zh, es };REFERRER_BONUS- Credits given to referrer (default: 1)REFEREE_BONUS- Credits given to referee (default: 0.5)MIN_DEPOSIT_FOR_BONUS- Minimum deposit to unlock bonus (default: 5)- Set to
0for instant bonus on referral code entry
- Set to
DEPOSIT_EXPIRES_MINUTES- Timeout for pending deposits (default: 15)
- Set
BANK_ENABLED=falseto disable bank transfers - Leave Binance or SePay credentials empty to disable respective methods
The bot tracks:
- Total revenue (Balance + Credits usage)
- Revenue split by payment method
- Total orders and completion rate
- Stock availability and sold items
- User registration trends
- Referral conversion rates
- Check BOT_TOKEN is correct
- Verify bot has privacy mode disabled in BotFather
- Check Node.js process is running
- Verify API credentials are correct
- Check payment polling interval (30 seconds default)
- Review logs for API errors
- Database is loaded into memory at startup
- External DB edits require bot restart
- Use admin commands for live updates
- All numbers automatically format without unnecessary decimals
2.00displays as22.50displays as2.5
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
ISC License - See LICENSE file for details
DIYEPH
- node-telegram-bot-api
- sql.js
- Binance Pay API
- SePay API
For issues and questions:
- Open an issue on GitHub
- Contact admin via Telegram
- Keep
.envfile secure and never commit it - Backup
data/shop.dbregularly - Test in a staging environment before production
- Monitor bot performance and API rate limits
- Database changes require bot restart to take effect