A simple demo on how to accept payments with Paystack in a Next.js app, verify transactions server-side, and show real-time payment status to users with flash messages.
- Paystack Inline payment integration (test mode)
- Server-side transaction verification with Paystack API
- Flash messages for payment success, failure, or pending status
- Easy to adapt for production/live keys
git clone https://github.com/YOUR-USERNAME/paystack-demo.git
cd paystack-demonpm installCreate a .env.local file in the project root:
NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY=pk_test_xxxxxxxxxxxxxxxxxxxxx
PAYSTACK_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxx- Get your keys from your Paystack dashboard.
- Use test keys for local development!
npm run devOpen http://localhost:3000 in your browser.
- Enter your email, name, and amount (minimum ₦100).
- Click "Pay with Paystack".
- Use Paystack test card to complete payment:
- Card number:
4084 0840 8408 4081 - Expiry: Any future date (e.g., 12/30)
- CVV:
408 - PIN:
1234 - OTP:
123456
- Card number:
- You’ll see a success, failure, or pending flash message after verification.
- Swap your test keys for live keys in
.env.local. - Update your Paystack dashboard settings for allowed IPs/webhooks if needed.
MIT
- Paystack Documentation
- Next.js