Skip to content

Installation

Requirements

  • PHP >= 8.1
  • Laravel >= 11.0

Install via Composer

You can install the package via composer:

bash
composer require turndale/paystack

Service Provider

Since this package is targeted at Laravel 11+, the PaystackServiceProvider is automatically discovered. You do not need to manually add it to your application's provider list.

Run the installation command

Run the following command to publish the configuration file:

bash
php artisan install:paystack

This command publishes the paystack.php file into your config directory.

Configuration

After publishing the configuration file, you should add your Paystack keys to your .env file:

  • The PAYSTACK_URL is set by default unless Paystack change their api url
  • The PAYSTACK_WEBHOOK_PATH should be a path not full url and in testing mode Recommended to use webhook.site as recommended on the Webhook Page.
  • The PAYSTACK_CALLBACK_URL can be set here to be added to requests globally that requires and you can always override it in the $payload.
  • If callback_url is not provided the one set in your Paystack Dashboard API Keys & Webhooks will be used.
env
PAYSTACK_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxx
PAYSTACK_PUBLIC_KEY=pk_test_xxxxxxxxxxxxxxxxxxxx
# PAYSTACK_CALLBACK_URL=https://your-website.com/paystack/callback
# PAYSTACK_URL=https://api.paystack.co // default is already set in config/paystack.php

Default Currency

The default currency for transactions is determined by your Paystack Dashboard Settings (under Settings > Preferences).

  • The package automatically uses this default currency for all requests unless you explicitly specify a different currency in your payload.
  • Ensure your dashboard currency matches your expected application currency (e.g., GHS, NGN, ZAR, USD).

Next Steps

If you prefer to publish the configuration file manually:

bash
php artisan vendor:publish --tag="paystack-config"

Add these IP if these have change on Paystack Docs page keys and configuration to your .env file:

env
# Optional: Webhook Whitelisted IPs
# PAYSTACK_WHITE_LISTED_IP_1=52.31.139.75
# PAYSTACK_WHITE_LISTED_IP_2=52.49.173.169
# PAYSTACK_WHITE_LISTED_IP_3=52.214.14.220

The IP addresses listed in the configuration are optional and default to the ones currently used by Paystack. You can verify the current list of IPs at Paystack Webhook Documentation.

If the IPs differ, you can add them to your .env file or update the default values in the config/paystack.php file.

Frontend Setup (Optional)

To accept payments using the Paystack Popup, you need to include the Javascript library in your frontend. If CDN, your main layout

Install via CDN, NPM or Yarn

html
<script src="https://js.paystack.co/v2/inline.js"></script>
bash
npm install @paystack/inline-js
bash
yarn add @paystack/inline-js

If you used NPM or Yarn, ensure you import the library as shown below:

javascript
import PaystackPop from "@paystack/inline-js";

Released under the MIT License.