Paystack Payment Gateway Integration
Paystack is a leading payment gateway focused on Africa, enabling businesses in countries like Nigeria, Ghana, Kenya, and South Africa to accept payments seamlessly. It supports a variety of payment methods, including credit/debit cards, bank accounts, mobile money, USSD, and QR codes, with a modern API designed for developers. Paystack is ideal for businesses looking to process local and international transactions with high success rates and robust fraud protection.
This guide provides a step-by-step process to integrate Paystack into your application, from account creation to live deployment.
Step 1: Log in or Sign Up
- Visit Paystack: Go to Paystack and click Sign Up to create a new account or Log In if you already have one.
- Account Creation: Enter your email, password, and basic business details (e.g., name, country). Paystack supports both individual and business accounts.
- Email Verification: Check your inbox for a verification email from Paystack and click the link to confirm your account.
- Dashboard Access: After verification, log in to access the Paystack Dashboard, where you’ll manage payments, settings, and API keys.
Step 2: Set Up Your Account
Before processing payments, configure your Paystack account:
-
Complete Your Profile:
- In the Paystack Dashboard, go to Settings > Business.
- Provide your business details: legal name, address, phone number, and website URL (optional for test mode).
- For individuals, enter personal details like name and contact information.
-
Business Verification (Required for Live Mode):
- Paystack requires verification to process real payments. Navigate to Settings > Business > KYC.
- Submit documents based on your country (e.g., Nigeria: CAC certificate, bank account details; Ghana: business registration).
- Verification typically takes 1-3 business days. You’ll receive an email once approved.
-
Add a Settlement Bank:
- Go to Settings > Bank Accounts.
- Enter your bank details (e.g., IBAN for international or local account number) for payouts.
- Paystack may send a small test deposit to verify the account.
-
Test Mode: Until verified, you can use Test Mode to simulate transactions without restrictions.
Step 3: Obtain API Credentials
Paystack provides API keys for integration:
- Public Key: Used in client-side code (e.g., checkout forms).
- Secret Key: Used in server-side code for secure API calls.
- Test vs. Live: Test keys (prefixed with
pk_test_
orsk_test_
) are for development; Live keys (prefixed withpk_live_
orsk_live_
) are for production.
How to Get Your Credentials:
- In the Paystack Dashboard, go to Settings > API Keys & Webhooks.
- You’ll see:
- Test Public Key and Test Secret Key: Available immediately for testing.
- Live Public Key and Live Secret Key: Available after business verification.
- Key Security: Keep the Secret Key confidential—never expose it in client-side code. Copy both keys and store them securely.
- Add these to your application’s Admin Panel under System Settings > Payment Gateways > Paystack.
Step 4: Configure Payment Methods
Paystack supports multiple payment channels, which are enabled by default or upon request:
- Go to Settings > Payment Channels in the Paystack Dashboard.
- Available methods include:
- Cards: Visa, MasterCard, Verve (enabled by default).
- Bank Accounts: Direct bank payments (Nigeria-specific).
- Mobile Money: Popular in Ghana and Kenya (request activation if needed).
- USSD: For Nigerian customers (enabled by default).
- QR Codes: For in-person or mobile payments (request activation).
- Contact Paystack support via support@paystack.com to enable additional methods not visible in your dashboard.
- These methods will appear in your checkout flow once integrated.
Step 5: Set Up Webhooks
Webhooks notify your server of payment events (e.g., successful transactions):
- In the Paystack Dashboard, go to Settings > API Keys & Webhooks.
- Scroll to the Webhook URL section and click Edit.
- Webhook URL:
- Enter the URL from your application (e.g.,
https://yourwebsite.com/webhooks/paystack
). - Find this URL in your Admin Panel under Paystack settings.
- Ensure your endpoint accepts POST requests and returns a 200 OK response.
- Enter the URL from your application (e.g.,
- Events: Paystack sends events like
charge.success
(payment completed) orcharge.failed
(payment failed). You don’t need to select events manually—all relevant updates are sent. - Click Save Changes.
- Test Webhook: Use the Send Test Webhook button to verify your endpoint works.
Step 6: Set Up Credentials in Our Dashboard
Integrate Paystack into your application:
- Log in to your application’s Admin Panel.
- Navigate to System Settings > Payment Gateways > Paystack.
- Fill out the configuration form:
-
Detailed Fields:
- Supported Currencies: Select currencies (e.g., NGN, GHS, USD, ZAR) enabled on your Paystack account. Contact Paystack to enable USD or others if needed.
- Active: Toggle “On” to enable Paystack payments.
- Live Mode: Toggle “Off” for testing, “On” for live transactions.
- Public Key: Enter your Test Public Key (e.g.,
pk_test_abc123
) or Live Public Key (e.g.,pk_live_xyz789
). - Secret Key: Enter your Test Secret Key (e.g.,
sk_test_def456
) or Live Secret Key (e.g.,sk_live_ghi789
). - Webhook URL: Copy this URL and paste it into the Paystack Dashboard’s webhook settings.
- Minimum Amount: Set a floor (e.g., ₦100) to avoid small transactions.
- Maximum Amount: Set a ceiling (e.g., ₦1,000,000) based on your needs.
- Fixed Charge: Add a flat fee (e.g., ₦50) per transaction, if applicable.
- Percentage Charge: Add a percentage fee (e.g., 1.5%) on top of Paystack’s fees.
-
Click Submit to save. Your Paystack gateway is now configured.
Step 7: Test the Integration
Test your setup in Test Mode:
- Enable Test Mode:
- In your Admin Panel, ensure Live Mode is off and use the Test Public Key and Test Secret Key.
- In the Paystack Dashboard, confirm you’re using test credentials.
- Simulate Payments:
- Use Paystack’s test cards:
- Success:
408 408 408 408 408 1
, expiry12/25
, CVV408
, PIN1234
. - Failure:
5399 8383 1234 5678
, expiry12/25
, CVV123
.
- Success:
- Test other methods like USSD (
*737#
) or bank transfers with test credentials.
- Use Paystack’s test cards:
- Verify Webhooks:
- Check your server logs for webhook events (e.g.,
charge.success
). - Ensure payment statuses update in your Admin Panel (e.g., “Paid,” “Pending”).
- Check your server logs for webhook events (e.g.,
- Debugging: If issues arise, check the Paystack Dashboard’s Transactions tab for error details (e.g., “Card Declined”).
Step 8: Enable Live Mode
After successful testing:
- Paystack Dashboard:
- Ensure your account is verified and you have the Live Public Key and Live Secret Key.
- Admin Panel:
- Go to System Settings > Payment Gateways > Paystack.
- Toggle Live Mode to “On”.
- Replace the test keys with the Live Public Key and Live Secret Key.
- Save the changes.
- Webhook Confirmation: Verify the webhook URL is still set correctly in the Paystack Dashboard.
Step 9: Go Live
Launch your Paystack integration:
- Start Accepting Payments:
- Customers can now pay using enabled methods at checkout.
- Monitor initial transactions for any issues.
- Live Verification:
- In the Paystack Dashboard, go to Transactions to track payments in real-time.
- Confirm payouts to your bank account (daily or weekly, depending on settings).
- Troubleshooting:
- If payments fail, review error logs in the Paystack Dashboard or contact support@paystack.com.
- Ensure your webhook endpoint remains operational.
Additional Tips
- Paystack Fees: Paystack charges per transaction (e.g., 1.5% + ₦100 for local cards in Nigeria, capped at ₦2000). Check pricing and adjust your charges accordingly.
- Documentation: Explore the Paystack Developer Docs for advanced features like recurring payments or split payments.
- Support: Reach out to Paystack via support@paystack.com or the Dashboard’s live chat for assistance.
Note:
If you encounter any issues or need further help, our support team is available. Contact us at softivus@gmail.com or through the Admin Panel. Let’s get your Paystack integration up and running smoothly!