Installation
Requirements
- PHP >= 8.1
- Laravel >= 11.0
Install via Composer
You can install the package via composer:
composer require turndale/paystackService 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:
php artisan install:paystackThis 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_URLis set by default unless Paystack change their api url - The
PAYSTACK_WEBHOOK_PATHshould be a path not full url and in testing mode Recommended to use webhook.site as recommended on the Webhook Page. - The
PAYSTACK_CALLBACK_URLcan 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 & Webhookswill be used.
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.phpDefault 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
currencyin 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:
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:
# 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.220The 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
<script src="https://js.paystack.co/v2/inline.js"></script>npm install @paystack/inline-jsyarn add @paystack/inline-jsIf you used NPM or Yarn, ensure you import the library as shown below:
import PaystackPop from "@paystack/inline-js";