Skip to content

Connecting Telegram Stars payment using aiogram 3.x with the possibility of a refund.

License

Notifications You must be signed in to change notification settings

bohd4nx/tg-stars-payment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐️ Telegram Stars Payment Bot

Complete Telegram bot for Stars payments and refunds using aiogram 3.x

Features

  • Payment processing via Telegram Stars with invoice generation
  • Refund functionality with detailed error handling and validation
  • Balance cheking for bot's Stars balance
  • Error management with user-friendly messages
  • Clean architecture with modular design

Commands

Command Description
/start Create and send Stars payment invoice
/refund <user_id> <transaction_id> Process payment refund with validation
/balance Display bot's current Stars balance

Setup

  1. Clone and install:

    git clone https://github.com/bohd4nx/tg-stars-payment.git
    cd tg-stars-payment
    pip install -r requirements.txt
  2. Configure bot:

    # config.py
    API_TOKEN = "your_bot_token_here"  # From @BotFather
    STARS_AMOUNT = 1                   # Payment amount (1-100000 stars)
  3. Run bot:

    python main.py

Error Handling

The bot includes comprehensive error handling for common scenarios:

  • CHARGE_ALREADY_REFUNDED - Payment already refunded
  • CHARGE_NOT_FOUND - Transaction not found
  • REFUND_FAILED - Insufficient bot balance or Telegram error
  • Invalid commands - Proper format guidance

Built with ❤️ by Bohdan

About

Connecting Telegram Stars payment using aiogram 3.x with the possibility of a refund.

Topics

Resources

License

Stars

Watchers

Forks

Languages