Skip to content

Python-based Telegram bot template built with the aiogram library, featuring a web app webhook powered by aiohttp and integrated with Paypalrestsdk for payment processing. The bot leverages a PostgreSQL database, utilizing SQLAlchemy as its engine for efficient query handling.

License

Notifications You must be signed in to change notification settings

joludyaster/aiogram-paypal-bot-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 █████╗ ██╗ ██████╗ ██████╗ ██████╗ ████████╗
██╔══██╗██║██╔═══██╗██╔══██╗██╔══██╗╚══██╔══╝
███████║██║██║   ██║██████╔╝██████╔╝   ██║   
██╔══██║██║██║   ██║██╔═══╝ ██╔══██╗   ██║   
██║  ██║██║╚██████╔╝██║     ██████╔╝   ██║   
╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═╝     ╚═════╝    ╚═╝   
-----------------------------------------------
Telegram bot template with aiogram, aiohttp, Paypalrestsdk, SQLAlchemy, and PostgreSQL.

AIOPBT - is a Python-based Telegram bot template built with the aiogram library, featuring a web app webhook powered by aiohttp and integrated with Paypalrestsdk for payment processing. The bot leverages a PostgreSQL database, utilizing SQLAlchemy as its engine for efficient query handling.

Technologies used

  1. Aiogram
  2. Aiohttp
  3. Paypalrestsdk
  4. PostgreSQL
  5. SQLAlchemy

Bot structure

...
├── bot
    ├── data
        ├── __init__.py
        ├── config.py
    ├── handlers
        ├── users
            ├── __init__.py
            ├── start.py
        ├── __init__.py
    ├── keyboard
        ├── default_keyboard
            ├── __init__.py
            ├── default_keyboard.py
        ├── inline_keyboard
            ├── __init__.py
            ├── inline_keyboard.py
        ├── __init__.py
    ├── middlewares
        ├── __init__.py
        ├── middlewares.py
    ├── paypal
        ├── __init__.py
        ├── paypal.py
    ├── services
        ├── __init__.py
        ├── broadcast.py
        ├── send_message.py
    ├── __init__.py
    ├── __main__.py

├── database
    ├── commands
        ├── __init__.py
        ├── base.py
        ├── receipts.py
        ├── requests.py
        ├── users.py
    ├── models
        ├── __init__.py
        ├── base.py
        ├── receipts.py
        ├── users.py
    ├── __init__.py
    ├── setup.py
├── .env.dist

How to run?

Application requires Python 3.10+ installed on your local machine to support all features.

Create virtual environment to install all needed dependencies:

Manually:

python -m venv .venv

Or you can use your IDE to install it automatically as for example PyCharm does.

Install all needed dependencies:

pip install -r requirements.txt

Change .env settings:

DB_HOST=your_database_host
POSTGRES_PASSWORD=your_database_password
POSTGRES_USER=your_database_username
POSTGRES_DB=your_database_table
DB_PORT=5432
ADMINS=list_of_admin_ids

BOT_TOKEN=bot_token
USE_REDIS=False

# Paypal credentials
PAYPAL_MODE=sandbox
PAYPAL_CLIENT_ID=your_paypal_client_id
PAYPAL_CLIENT_SECRET=your_paypal_client_secret

# Web server settings
WEB_SERVER_HOST=your_webhook_host
WEB_SERVER_PORT=your_webhook_port
WEB_SECRET=your_webhook_secret
BASE_WEBHOOK_URL=your_webhook_url

How to get PayPal credentials?

  1. Open Paypal Developer page and register with your usual PayPal credentials.
  2. Go to Dashboard
  3. Scroll down and press Sandbox accounts
  4. Create a new personal and business (by default you will have them both already created)
  5. Navigate to Apps & Credentials
  6. Click on your default app and copy Client ID and Secret key

How to get webhook details?

If you don't have your own webhook server, you can use Ngrok.

  1. Install Ngrok on your local machine.
  2. Type ngrok http 8080

Port can be different, depending on your allowed ports by your network.

  1. Copy the address and paste it in the .env.dist file with the rest of the details.
WEB_SERVER_HOST=127.0.0.1
WEB_SERVER_PORT=8080
WEB_SECRET=secret
BASE_WEBHOOK_URL=https://....ngrok-free.app

Lastly, just run __main.py__ file.

About

Python-based Telegram bot template built with the aiogram library, featuring a web app webhook powered by aiohttp and integrated with Paypalrestsdk for payment processing. The bot leverages a PostgreSQL database, utilizing SQLAlchemy as its engine for efficient query handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages