Overview
Paystack is the payment processor used by the Telegram Subscription Manager to accept payments in Nigerian Naira (NGN). This guide covers account setup, API key configuration, and webhook integration.Prerequisites
- A registered business or personal account in Nigeria
- Valid bank account for receiving payments
- Phone number and email for verification
Create Paystack Account
Sign Up
- Go to Paystack
- Click “Sign Up” or “Get Started”
- Choose account type:
- Personal: For individuals
- Business: For registered businesses
- Fill in your details:
- Full name
- Email address
- Phone number
- Password
- Click “Create Account”
Verify Email
- Check your email for verification link
- Click the link to verify your email
- You’ll be redirected to the Paystack dashboard
Complete KYC (Know Your Customer)
To activate your account for live payments:
- Go to Settings → Account
- Complete the required information:
- Business/Personal details
- Bank account information (for receiving settlements)
- Government-issued ID
- Business registration documents (if applicable)
Test mode works immediately without KYC. Complete KYC only when ready for production.
Get API Keys
Navigate to API Settings
- Log in to your Paystack Dashboard
- Click Settings in the sidebar
- Select API Keys & Webhooks
Copy Secret Key
You’ll see two types of keys:Copy the Secret Key for the environment you want (test or live).
- Test Keys
- Live Keys
For Development:
- Test Public Key:
pk_test_...(not needed for this app) - Test Secret Key:
sk_test_...(use this for testing)
- Develop and test locally
- Verify integration without real money
- Use Paystack’s test cards
Test mode payments don’t require KYC completion.
Configure Payment Plans
The Telegram Subscription Manager supports multiple subscription plans defined insrc/lib/config.ts:
src/lib/config.ts
Kobo: Paystack uses kobo (smallest unit of Nigerian currency).
- NGN 1.00 = 100 kobo
- NGN 5,000 = 500,000 kobo
Update Bank Details
Users will see bank details for manual transfers. Update them insrc/lib/config.ts:
src/lib/config.ts
Set Up Webhooks (Optional)
Webhooks allow Paystack to notify your app about payment events in real-time.Webhooks are optional for this bot. The bot primarily uses the
/verify_basic and /verify_premium commands which directly verify payments via the Paystack API.Deploy Your Application
Webhooks require a publicly accessible URL. Deploy to Vercel first:
- Follow the Vercel Deployment Guide
- Note your deployment URL (e.g.,
https://your-app.vercel.app)
Configure Webhook in Paystack
- Go to Settings → API Keys & Webhooks
- Scroll to Webhook URL
- Enter your webhook endpoint:
- Click “Save Changes”
Webhook Events
The app listens for these Paystack events:| Event | Description | Action |
|---|---|---|
charge.success | Payment completed successfully | Verify and process subscription |
charge.failed | Payment failed | Log for monitoring |
refund.processed | Refund completed | Update subscription status |
Test Payments
Before going live, test the payment flow:Test Cards
Paystack provides test cards for different scenarios:- Successful Payment
- Insufficient Funds
- Declined
Card Number:
4084084084084081- CVV: Any 3 digits
- Expiry: Any future date
- PIN:
0000 - OTP:
123456
Testing Workflow
Make Test Payment
- Use Paystack’s test payment page or integrate with your frontend
- Use one of the test card numbers above
- Complete the payment flow
- Note the transaction reference (e.g.,
T123456789)
Test mode transactions appear in your Paystack dashboard but don’t involve real money.
Go Live
When ready to accept real payments:Complete KYC
Ensure your Paystack account is fully verified:
- Business/personal details submitted
- Bank account verified
- Identity documents approved
Update Environment Variables
In Vercel:
- Go to Project Settings → Environment Variables
- Update
PAYSTACK_SECRET_KEYwith your live key - Redeploy your application
.env.local
Payment Verification Flow
Understanding how payments are verified:Verification Checks
The bot performs these checks before granting access:- ✅ Valid reference format: Basic validation
- ✅ Payment exists: Paystack API confirms transaction
- ✅ Payment successful: Status is “success”
- ✅ Correct amount: Matches the plan being verified
- ✅ Reference unused: Not redeemed before
- ✅ Not rate limited: User hasn’t failed too many times
Troubleshooting
Invalid API Key Error
Invalid API Key Error
Error:
"Invalid key"Solutions:- Verify you copied the Secret Key, not Public Key
- Check for extra spaces or quotes in environment variable
- Ensure using correct key for environment (test vs live)
- Verify key starts with
sk_test_orsk_live_
Payment Verification Failing
Payment Verification Failing
Common causes:
-
Wrong reference format:
- Should be alphanumeric
- Check user didn’t add spaces
- Reference is case-sensitive
-
Payment not successful:
- Check status in Paystack dashboard
- User might have abandoned payment
- Payment might have failed
-
Amount mismatch:
- User paid wrong amount
- User used wrong command (e.g., paid NGN 22,000 but used
/verify_basic)
-
Reference already used:
- Check database for existing subscription with that reference
- User trying to reuse old payment
Webhook Not Receiving Events
Webhook Not Receiving Events
Troubleshooting:
-
Verify webhook URL:
Should return 200 status.
-
Check Paystack webhook logs:
- Go to Settings → API Keys & Webhooks
- Scroll to Webhook Logs
- Check delivery status and errors
- Test webhook manually: Use Paystack’s webhook testing tool in dashboard.
- Verify signature validation: Ensure webhook handler validates Paystack signature.
Settlements Not Arriving
Settlements Not Arriving
Check settlement schedule:
- New accounts: T+7 days (7 days after transaction)
- Established accounts: T+2 or T+1 days
- Go to Settings → Account
- Check bank account information
- Ensure account is verified
- Go to Settlements in dashboard
- View pending and completed settlements
- Check for any holds or issues
Security Best Practices
Paystack Fees
Paystack charges per transaction:| Transaction Amount | Fee |
|---|---|
| Local cards | 1.5% capped at NGN 2,000 |
| International cards | 3.9% |
Fees are automatically deducted from settlements. You receive the net amount.
Next Steps
Database Setup
Configure MongoDB and Prisma
Deploy to Vercel
Deploy your complete application