A comprehensive Telegram bot integrated with Django that manages Stripe(sandbox) connected accounts. Users can create Stripe accounts, verify their identity, check balances, and manage two revenue flows: receiving payments (Get Paid) or paying for a subscription.
-
Account Management
- Create Stripe connected accounts via Telegram
- One-time verification links for account verification
- Account status tracking in MySQL database
- Real-time balance checks
-
Two Transaction Types
- Get Paid: Users request payouts (max $500 USD) from platform to their connected account
- Subscription: Users pay for subscription plans (tier options available)
-
Multi-Currency Support
- Real-time currency conversion via exchange-rate-api.com
- Automatic conversion between user and platform currencies
- Support for USD, EUR, CHF
-
Stripe Integration
- Direct Stripe API integration via custom service layer
- Connected account onboarding and verification
- Real-time balance retrieval and management
- PaymentLinks for subscription payments
- Test mode support with test cards
| Django Project
| |- Custom Command: python manage.py runbot
| |- Custom API (stores account info)
| |- Stripe Services App (Stripe API logic)
| `- MySQL Database (profile models, verification status)
|
|- Telegram Bot (aiogram 3.x)
| |- FSM States (Sign-in, Get Paid, Subscription flows)
| |- Command Handlers (/start)
| |- Callback Handlers (account selection, payment confirmation)
| `- Message Handlers (multi-step forms)
|
|- External APIs
| |- Stripe API (payments, accounts, transfers)
| `- exchange-rate-api.com (currency conversion)
|
`- Integration Flow
|- User signs in via Telegram
|- Bot queries Custom API for account verification status
|- Currency conversion via exchange-rate-api
`- Stripe operations (transfers, payment links)
- Bot Framework: aiogram 3.x (async)
- Backend: Django + Python async/await
- Database: MySQL (account tracking)
- Payment Processing: Stripe API
- Currency Conversion: exchange-rate-api.com
- State Management: aiogram FSM (Finite State Machine)
- HTTP Client: aiohttp (async requests)
- Python 3.9+
- Django 4.0+
- MySQL 8.0+
- Stripe account (test/live)
- Telegram Bot Token
- exchange-rate-api.com API Key
- Clone the repository
git clone https://github.com/askawa/stripe_bot_api.git- Install dependencies
pip install -r requirements.txt- Configure environment variables
# .env
TELEGRAM_BOT_TOKEN=your_bot_token
STRIPE_SECRET_API_KEY=sk_test_...
PLATFORM_ACC_ID=acct_...
EXCHANGE_API_KEY=your_api_key
DJANGO_SECRET_KEY=your_secret_key
# MySQL
DB_ENGINE=django.db.backends.mysql
DB_NAME=financelog_db
DB_USER=django_user
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=3306- Run Django migrations
python manage.py makemigrations
python manage.py migrate- Start the Telegram bot and Custom API
python manage.py runbot
python manage.py runserver-
Start the bot
- Click
/startin drop-down menu in Telegram
- Click
-
Sign Up
- Click
No, I have notoption and follow instructions - It will require currency, email, confirmation
- Click
-
Sign In
- Enter email associated with Stripe account
- Bot retrieves your connected account
-
Choose Flow
- Get Paid: Request payout (with currency conversion)
- Subscription: Pay for subscription plan
-
Complete Transaction
- Get Paid: Confirm payout details
- Subscription: Click PaymentLink and pay with test card
Your Django API stores and manages:
- Account Information: Connected account details and Stripe IDs
- Verification Status: Account verification capability tracking
- User Metadata
- Account creation and retrieval
- Verification status updates
project/
|- manage.py
|- bot/
| |- management/
| | `- commands/
| | `- runbot.py (Bot startup command)
| `- finance_bot.py
|
|- services/
| `- stripe_services.py (All Stripe API logic)
|
|- api/ (Custom API)
| |- models.py
| |- serializers.py
| |- urls.py
| `- views.py
`- requirements.txt
- Connected Account Creation: Express account onboarding
- Identity Verification: One-time verification links via onboarding forms
- Fetching Connected Accounts
- Balance Checks: Real-time balance retrieval
- Transfers: Platform to connected accounts (Get Paid flow)
- PaymentLinks: Hosted payment forms (Subscription flow)
- Price Objects: Reusable price definitions for subscription plans
- Uses exchange-rate-api.com for real-time conversion rates
- Supports USD, EUR, GBP, CHF, and more
- Automatic conversion displayed to users before confirmation
- Rates checked before each transaction
The bot includes try/except blocks with detailed error messages:
- Insufficient balance checks
- Stripe API errors with user-friendly messages
- State management error recovery
- Create feature branch
- Make changes
- Test with Stripe test cards
- Submit pull request
MIT License
For issues or questions:
- Check Stripe documentation: https://docs.stripe.com
- Review aiogram docs: https://docs.aiogram.dev
- Open an issue in the repository
Last Updated: May 2026