A clean, production-ready donation system integrated with Paystack payment gateway.
- One-page donation form with quick-select amount buttons
- Paystack payment popup / redirect flow
- Server-side payment verification
- Webhook support for reliable payment confirmation
- Recent donors feed (auto-refreshes every 30s)
- Mobile-responsive design
| Layer | Technology |
|---|---|
| Backend | Node.js + Express |
| Payment | Paystack |
| Frontend | Vanilla HTML / CSS / JS |
npm installcp .env.example .envEdit .env and fill in your Paystack keys:
PAYSTACK_SECRET_KEY=sk_test_xxxxx
PAYSTACK_PUBLIC_KEY=pk_test_xxxxx
BASE_URL=http://localhost:3000
Get your keys from the Paystack Dashboard.
# Development (auto-reload)
npm run dev
# Production
npm startOpen http://localhost:3000 in your browser.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/donate/initialize |
Start a Paystack transaction |
| GET | /api/donate/verify |
Verify payment after redirect |
| POST | /api/webhook/paystack |
Paystack server-to-server webhook |
| GET | /api/donations |
List recent completed donations (public) |
{
"name": "Jane Doe",
"email": "jane@example.com",
"amount": 1000,
"message": "Keep up the good work!"
}Returns { authorization_url, reference } — redirect the user to authorization_url.
- Go to Paystack Dashboard → Settings → API Keys & Webhooks
- Set webhook URL to:
https://yourdomain.com/api/webhook/paystack - Paystack will send
charge.successevents for confirmed payments.
- Replace the in-memory
donationsarray with a real database (PostgreSQL, MongoDB, etc.) - Always keep
PAYSTACK_SECRET_KEYserver-side — never expose it to the browser - Use HTTPS in production
- Set
BASE_URLto your actual domain for correct callback redirects

