# 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

1. Visit Paystack: Go to Paystack and click Sign Up to create a new account or Log In if you already have one.
2. Account Creation: Enter your email, password, and basic business details (e.g., name, country). Paystack supports both individual and business accounts.
3. Email Verification: Check your inbox for a verification email from Paystack and click the link to confirm your account.
4. 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:

1. 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.

1. 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.

1. 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.

1. 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_` or `sk_test_`) are for development; Live keys (prefixed with `pk_live_` or `sk_live_`) are for production.

##### How to Get Your Credentials:

1. In the Paystack Dashboard, go to Settings > API Keys & Webhooks.
2. 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.

1. Key Security: Keep the Secret Key confidential—never expose it in client-side code. Copy both keys and store them securely.
2. 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:

1. Go to Settings > Payment Channels in the Paystack Dashboard.
2. 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).

1. Contact Paystack support via support@paystack.com to enable additional methods not visible in your dashboard.
2. 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):

1. In the Paystack Dashboard, go to Settings > API Keys & Webhooks.
2. Scroll to the Webhook URL section and click Edit.
3. 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.

1. Events: Paystack sends events like `charge.success` (payment completed) or `charge.failed` (payment failed). You don’t need to select events manually—all relevant updates are sent.
2. Click Save Changes.
3. 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:

1. Log in to your application’s Admin Panel.
2. Navigate to System Settings > Payment Gateways > Paystack.

1. Fill out the configuration form:

1. 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.

1. Click Submit to save. Your Paystack gateway is now configured.

### Step 7: Test the Integration

Test your setup in Test Mode:

1. 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.

1. Simulate Payments:

- Use Paystack’s test cards:
- Success: `408 408 408 408 408 1`, expiry `12/25`, CVV `408`, PIN `1234`.
- Failure: `5399 8383 1234 5678`, expiry `12/25`, CVV `123`.
- Test other methods like USSD (`*737#`) or bank transfers with test credentials.

1. 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”).

1. 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:

1. Paystack Dashboard:

- Ensure your account is verified and you have the Live Public Key and Live Secret Key.

1. 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.

1. Webhook Confirmation: Verify the webhook URL is still set correctly in the Paystack Dashboard.

### Step 9: Go Live

Launch your Paystack integration:

1. Start Accepting Payments:

- Customers can now pay using enabled methods at checkout.
- Monitor initial transactions for any issues.

1. 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).

1. 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!