- Project Meta
Develop a Telegram bot that:
Sells subscriptions to a private channel via WayForPay;
Automatically grants access to the channel after successful payment;
Manages subscriptions — removes users after the expiration date, sends reminders for renewal;
Keeps records in Google Sheets;
Can be deployed on a VPS (for example, Ubuntu / Docker).
- Telegram Bot Functionality User:
Upon starting, sees buttons with rates:
1 month (10 UAH)
3 months (25 UAH)
6 months (45 UAH)
Clicks the button → the bot generates a WayForPay link for payment.
After payment, the bot sends an invite link to the channel.
If the user already has an active subscription — the bot shows the status (“Subscription active until: ...”).
Administrator:
Receives notifications about new payments.
Can manually extend / deactivate a user's subscription.
Has the command /list to view active users (optional).
- Subscription Control System
A separate Python script or module:
Runs once a day / or at startup (can add cron later);
Checks subscription expiration dates in Google Sheets;
If the term has expired — removes the user from the channel;
One day before expiration — sends a reminder with a “Renew” button;
If the user renews — updates the date in the table.
- Google Sheets Integration
The table has the following columns:
| telegram_id | order_ref | amount | months | start_date | end_date | status |
status can be: active, expired, refunded
A record is added only if:
the transaction is Approved
such order_ref is not yet in the table
If the user is already in the table — updates end_date (subscription renewal).
- Flask Server (Webhook for WayForPay)
Receives requests from WayForPay after payment;
Checks transactionStatus == "Approved";
If the payment is new:
adds a record to Google Sheets;
creates an invite link to the channel;
sends the link to the user in Telegram;
Ignores transactions with statuses Refunded, Expired, InProcessing;
Has logging of all requests to the console or file (print / logging).
- Additionally
The code should be well-structured: bot_payment.py, webhook_server.py, subscription_checker.py.
All tokens, keys, IDs — placed in a separate file config.py.
- Work Result
Fully functional system:
Telegram bot with payments
WayForPay integration
Connection to Google Sheets
Automatic subscription management
Ready for deployment on VPS