Skip to main content

Modern Telegram Stars payment library with multi-bot support and enhanced security

Project description

NEONPAY - Modern Telegram Stars Payment Library

PyPI version PyPI downloads Python Support License: MIT Build Status Code Quality

Current Version: 2.6.0 - Published on PyPI 🚀

NEONPAY is a modern, universal payment processing library for Telegram bots that makes integrating Telegram Stars payments incredibly simple. With support for all major bot libraries and a clean, intuitive API, you can add payments to your bot in just a few lines of code.

✨ Features

Core Payment Features

  • 🚀 Universal Support - Works with Pyrogram, Aiogram, python-telegram-bot, pyTelegramBotAPI, and raw Bot API
  • 💫 Telegram Stars Integration - Native support for Telegram's XTR currency
  • 🎨 Custom Payment Stages - Create branded payment experiences with custom logos and descriptions
  • 🔧 Simple Setup - Get started with just 2-3 lines of code
  • 📱 Modern Architecture - Built with async/await and type hints
  • 🛡️ Error Handling - Comprehensive error handling and validation
  • 📦 Zero Dependencies - Only requires your chosen bot library

🆕 New in v2.6.0 - Enterprise Features

  • 🌐 Web Analytics Dashboard - Real-time bot performance monitoring via web interface
  • 🔄 Web Sync Interface - Multi-bot synchronization through REST API
  • 📊 Advanced Analytics - Comprehensive payment analytics and reporting
  • 🔔 Notification System - Multi-channel notifications (Email, Telegram, SMS, Webhook)
  • 💾 Backup & Restore - Automated data protection and recovery
  • 📋 Template System - Pre-built bot templates and generators
  • 🔗 Multi-Bot Analytics - Network-wide performance tracking
  • 📈 Event Collection - Centralized event management and processing

🚀 Quick Start

Installation

# Install latest version from PyPI
pip install neonpay

# Or install specific version
pip install neonpay==2.5.0

# Install with optional dependencies
pip install neonpay[all]  # All bot libraries
pip install neonpay[ptb]   # python-telegram-bot only
pip install neonpay[aiogram]  # Aiogram only

📦 Available on PyPI: neonpay 2.5.0

Basic Usage

from neonpay import create_neonpay, PaymentStage

# Works with any bot library - automatic detection!
neonpay = create_neonpay(your_bot_instance)

# Create a payment stage
stage = PaymentStage(
    title="Premium Features",
    description="Unlock all premium features",
    price=100,  # 100 Telegram Stars
    photo_url="https://example.com/logo.png"
)

# Add the payment stage
neonpay.create_payment_stage("premium", stage)

# Send payment to user
await neonpay.send_payment(user_id=12345, stage_id="premium")

# Handle successful payments
@neonpay.on_payment
async def handle_payment(result):
    print(f"Payment received: {result.amount} stars from user {result.user_id}")

📚 Library Support

NEONPAY automatically detects your bot library and creates the appropriate adapter:

Pyrogram

from pyrogram import Client
from neonpay import create_neonpay

app = Client("my_bot", bot_token="YOUR_TOKEN")
neonpay = create_neonpay(app)

Aiogram

from aiogram import Bot, Dispatcher
from neonpay import create_neonpay

bot = Bot(token="YOUR_TOKEN")
dp = Dispatcher()
neonpay = create_neonpay(bot, dp)  # Pass dispatcher for aiogram

python-telegram-bot

from telegram.ext import Application
from neonpay import create_neonpay

application = Application.builder().token("YOUR_TOKEN").build()
neonpay = create_neonpay(application)

pyTelegramBotAPI

import telebot
from neonpay import create_neonpay

bot = telebot.TeleBot("YOUR_TOKEN")
neonpay = create_neonpay(bot)

Raw Bot API

from neonpay import RawAPIAdapter, NeonPayCore

adapter = RawAPIAdapter("YOUR_TOKEN", webhook_url="https://yoursite.com/webhook")
neonpay = NeonPayCore(adapter)

🎯 Advanced Usage

Custom Payment Stages

from neonpay import PaymentStage

# Create detailed payment stage
premium_stage = PaymentStage(
    title="Premium Subscription",
    description="Get access to exclusive features and priority support",
    price=500,  # 500 Telegram Stars
    label="Premium Plan",
    photo_url="https://yoursite.com/premium-logo.png",
    payload={"plan": "premium", "duration": "monthly"}
)

neonpay.create_payment_stage("premium_monthly", premium_stage)

Payment Callbacks

from neonpay import PaymentResult, PaymentStatus

@neonpay.on_payment
async def handle_payment(result: PaymentResult):
    if result.status == PaymentStatus.COMPLETED:
        # Grant premium access
        user_id = result.user_id
        amount = result.amount
        metadata = result.metadata
        
        print(f"User {user_id} paid {amount} stars")
        print(f"Plan: {metadata.get('plan')}")
        
        # Your business logic here
        await grant_premium_access(user_id, metadata.get('plan'))

Multiple Payment Stages

# Create multiple payment options
stages = {
    "basic": PaymentStage("Basic Plan", "Essential features", 100),
    "premium": PaymentStage("Premium Plan", "All features + support", 300),
    "enterprise": PaymentStage("Enterprise", "Custom solutions", 1000)
}

for stage_id, stage in stages.items():
    neonpay.create_payment_stage(stage_id, stage)

# Send different payments based on user choice
await neonpay.send_payment(user_id, "premium")

🔧 Configuration

Error Handling

from neonpay import NeonPayError, PaymentError

try:
    await neonpay.send_payment(user_id, "nonexistent_stage")
except PaymentError as e:
    print(f"Payment error: {e}")
except NeonPayError as e:
    print(f"NEONPAY error: {e}")

Logging

import logging

# Enable NEONPAY logging
logging.getLogger("neonpay").setLevel(logging.INFO)

🆕 New Features in v2.6.0

Web Analytics Dashboard

from neonpay import MultiBotAnalyticsManager, run_analytics_server

# Initialize analytics
analytics = MultiBotAnalyticsManager()

# Start web dashboard
await run_analytics_server(analytics, host="localhost", port=8081)
# Access dashboard at http://localhost:8081

Notification System

from neonpay import NotificationManager, NotificationConfig

# Configure notifications
config = NotificationConfig(
    telegram_bot_token="YOUR_ADMIN_BOT_TOKEN",
    telegram_admin_chat_id="YOUR_CHAT_ID"
)

notifications = NotificationManager(config)
await notifications.send_notification(message)

Backup System

from neonpay import BackupManager, BackupConfig

# Setup automated backups
backup_config = BackupConfig(
    backup_type=BackupType.JSON,
    schedule="daily"
)

backup_manager = BackupManager(backup_config)
await backup_manager.create_backup()

Template System

from neonpay import TemplateManager

# Generate bot from template
templates = TemplateManager()
await templates.generate_template("digital_store", output_file="my_bot.py")

Multi-Bot Sync

from neonpay import MultiBotSyncManager

# Sync multiple bots
sync_manager = MultiBotSyncManager()
await sync_manager.sync_bots([bot1, bot2, bot3])

📖 Documentation

🤝 Examples

Check out the examples directory for complete working examples:

Core Payment Examples

🆕 New Feature Examples (v2.6.0)

🛠️ Development Tools

The project includes automated scripts in .github/scripts/:

  • Cleanup: python .github/scripts/cleanup.py - Remove cache files
  • Version Update: python .github/scripts/update_readme_version.py - Update README version
  • PyPI Check: python .github/scripts/check_pypi_version.py - Check PyPI version

🛠️ Requirements

  • Python 3.9+
  • One of the supported bot libraries:
    • pyrogram>=2.0.106 for Pyrogram
    • aiogram>=3.0.0 for Aiogram
    • python-telegram-bot>=20.0 for python-telegram-bot
    • pyTelegramBotAPI>=4.0.0 for pyTelegramBotAPI
    • aiohttp>=3.8.0 for Raw API (optional)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

⭐ Star History

If you find NEONPAY useful, please consider giving it a star on GitHub!


Made with ❤️ by Abbas Sultanov

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neonpay-2.6.0.tar.gz (169.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neonpay-2.6.0-py3-none-any.whl (96.9 kB view details)

Uploaded Python 3

File details

Details for the file neonpay-2.6.0.tar.gz.

File metadata

  • Download URL: neonpay-2.6.0.tar.gz
  • Upload date:
  • Size: 169.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for neonpay-2.6.0.tar.gz
Algorithm Hash digest
SHA256 864cebdd7ea25e200caa64e63945eb25059d8342cdff7d62d3596672cfde3ffd
MD5 a0b94016c6df6447f13bb252948f959a
BLAKE2b-256 c3134f075838a7b55ec8e6b89192b5889926a8a3557799363c3abf22f0a3b5db

See more details on using hashes here.

File details

Details for the file neonpay-2.6.0-py3-none-any.whl.

File metadata

  • Download URL: neonpay-2.6.0-py3-none-any.whl
  • Upload date:
  • Size: 96.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for neonpay-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58bfc6b145e11b263cd1b4a463d4425da999b5357f21357f23d70c2ef794cb6
MD5 745a380996f5a463dcc4b284b4dd31e1
BLAKE2b-256 3309152a718273ba5619e38933a81e3336c0ac2e5a55723484ca56d1f5b395c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page