PHPackages                             faridibin/paystack-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. faridibin/paystack-laravel

ActiveLibrary[Payment Processing](/categories/payments)

faridibin/paystack-laravel
==========================

A Laravel wrapper for faridibin/paystack-php with first-class Laravel features including facades, config files, database migrations, and webhook handling. Provides seamless integration of Paystack payment processing in Laravel applications.

v0.1.20(6mo ago)0240MITPHPPHP ^8.0

Since Dec 10Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/faridibin/paystack-laravel)[ Packagist](https://packagist.org/packages/faridibin/paystack-laravel)[ RSS](/packages/faridibin-paystack-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Paystack Laravel
================

[](#paystack-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b2fef016f089749fd3d02ebba66afd41f57e928643c01aa869cdaaa408ffac8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66617269646962696e2f706179737461636b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/faridibin/paystack-laravel)[![Total Downloads](https://camo.githubusercontent.com/0d74ad3f5a8eb17901473f8e7b59892ddc90477c278d3463fcbd94836e9061a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66617269646962696e2f706179737461636b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/faridibin/paystack-laravel)[![License](https://camo.githubusercontent.com/fcfceffb2d8e8f3702260e460f1e4e6325375b3361c15f4280d98f22408dbd7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f66617269646962696e2f706179737461636b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/faridibin/paystack-laravel)

A comprehensive Laravel wrapper for [faridibin/paystack-php](https://github.com/faridibin/paystack-php) with first-class Laravel features including facades, config files, webhook handling, and event dispatching. Provides seamless integration of Paystack payment processing in Laravel applications.

Features
--------

[](#features)

- 🚀 **Laravel Integration** - Native Laravel service provider with auto-discovery
- 🎭 **Facade Support** - Clean, expressive API using Laravel facades
- ⚙️ **Configuration Management** - Publishable config files with environment variable support
- 🔗 **Webhook Handling** - Built-in webhook controller with signature validation
- 📡 **Event System** - Laravel events for all webhook activities
- 🛡️ **Security** - Automatic webhook signature validation middleware
- 🎯 **Service Selection** - Enable only the Paystack services you need
- 🧪 **Testing Ready** - Comprehensive test suite with Pest PHP

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require faridibin/paystack-laravel
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

The package will automatically register itself with Laravel's service container. No manual registration required!

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize the package settings:

```
php artisan vendor:publish --tag=paystack-config
```

This will create a `config/paystack.php` file in your application.

### Publish Views (Optional)

[](#publish-views-optional)

If you want to customize the transaction views:

```
php artisan vendor:publish --provider="Faridibin\PaystackLaravel\PaystackServiceProvider"
```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

Add your Paystack credentials to your `.env` file:

```
PAYSTACK_SECRET_KEY=sk_test_your_secret_key_here
PAYSTACK_CURRENCY=NGN
```

### Service Configuration

[](#service-configuration)

The package allows you to enable only the Paystack services you need. Edit `config/paystack.php`:

```
'services' => [
    PaystackServices::commerce([
        'products' => true,
        'paymentPages' => true,
    ]),
    PaystackServices::payments([
        'transactions' => true,
        'customers' => true,
        'refunds' => true,
        // ... other payment services
    ]),
    PaystackServices::recurring([
        'plans' => true,
        'subscriptions' => true,
    ]),
    PaystackServices::transfers([
        'transfers' => true,
        'recipients' => true,
        'control' => true,
    ]),
    PaystackServices::integration(),
    PaystackServices::verification(),
    PaystackServices::miscellaneous(),
],
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

The package provides a convenient facade for accessing Paystack services:

```
use Faridibin\PaystackLaravel\Facades\Paystack;

// Initialize a transaction
$transaction = Paystack::transactions()->initialize(
    email: 'customer@example.com',
    amount: 50000,
    optional: ['currency' => 'NGN']
);

// Verify a transaction
$verification = Paystack::transactions()->verify('transaction_reference');

// Create a customer
$customer = Paystack::customers()->create([
    'email' => 'customer@example.com',
    'first_name' => 'John',
    'last_name' => 'Doe',
]);

// Create a plan
$plan = Paystack::plans()->create([
    'name' => 'Monthly Subscription',
    'amount' => 10000, // ₦100.00
    'interval' => 'monthly',
]);
```

### Available Services

[](#available-services)

The facade provides access to all Paystack services:

#### Commerce Services

[](#commerce-services)

- `Paystack::products()` - Product management
- `Paystack::paymentPages()` - Payment page management

#### Payment Services

[](#payment-services)

- `Paystack::transactions()` - Transaction management
- `Paystack::customers()` - Customer management
- `Paystack::splits()` - Transaction splits
- `Paystack::charge()` - Direct charges
- `Paystack::refunds()` - Refund management
- `Paystack::disputes()` - Dispute handling
- `Paystack::settlements()` - Settlement information
- `Paystack::subaccounts()` - Subaccount management
- `Paystack::bulkCharges()` - Bulk charging
- `Paystack::paymentRequests()` - Payment requests
- `Paystack::terminal()` - Terminal management
- `Paystack::applepay()` - Apple Pay integration

#### Recurring Services

[](#recurring-services)

- `Paystack::plans()` - Subscription plans
- `Paystack::subscriptions()` - Subscription management

#### Transfer Services

[](#transfer-services)

- `Paystack::transfers()` - Transfer management
- `Paystack::recipients()` - Transfer recipients
- `Paystack::control()` - Transfer controls

#### Other Services

[](#other-services)

- `Paystack::integration()` - Integration utilities
- `Paystack::verification()` - Identity verification
- `Paystack::miscellaneous()` - Miscellaneous utilities

Webhook Handling
----------------

[](#webhook-handling)

The package provides built-in webhook handling with automatic signature validation.

### Webhook Endpoint

[](#webhook-endpoint)

The package automatically registers a webhook endpoint at:

```
POST /paystack/webhook

```

### Webhook Events

[](#webhook-events)

All webhook events are automatically dispatched as Laravel events:

```
use Faridibin\PaystackLaravel\Events\WebhookReceived;
use Faridibin\PaystackLaravel\Events\WebhookHandled;

// Listen for any webhook
Event::listen(WebhookReceived::class, function (WebhookReceived $event) {
    // $event->event - The webhook event type
    // $event->data - The webhook payload
});

// Listen for successful webhook processing
Event::listen(WebhookHandled::class, function (WebhookHandled $event) {
    // Webhook was successfully processed
});
```

### Specific Webhook Events

[](#specific-webhook-events)

The package also dispatches specific events for each webhook type:

```
use Faridibin\PaystackLaravel\Events\ChargeSuccessEvent;
use Faridibin\PaystackLaravel\Events\SubscriptionCreatedEvent;

Event::listen(ChargeSuccessEvent::class, function (ChargeSuccessEvent $event) {
    // Handle successful charge
});

Event::listen(SubscriptionCreatedEvent::class, function (SubscriptionCreatedEvent $event) {
    // Handle new subscription
});
```

### Custom Webhook Handling

[](#custom-webhook-handling)

You can extend the webhook controller to add custom handling:

```
