PHPackages                             faridibin/paystack-php - 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-php

ActiveLibrary[Payment Processing](/categories/payments)

faridibin/paystack-php
======================

A modern, type-safe PHP SDK for Paystack payment processing

v0.3.0(2mo ago)03451MITPHPPHP ^8.1CI passing

Since Dec 8Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (16)Versions (21)Used By (1)

paystack-php
============

[](#paystack-php)

A modern, type-safe PHP SDK for [Paystack](https://paystack.com) payment processing.

Requirements
------------

[](#requirements)

- PHP 8.0+
- Guzzle 7.x

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

[](#installation)

```
composer require faridibin/paystack-php
```

Getting Started
---------------

[](#getting-started)

The `Paystack` client only registers the `health` service by default. Register the services you need before calling them.

```
use Faridibin\Paystack\Paystack;
use Faridibin\Paystack\Services\Payments\Transactions\Transactions;
use Faridibin\Paystack\Services\Payments\Customers;
use Faridibin\Paystack\Contracts\Services\Payments\Transactions\TransactionsInterface;
use Faridibin\Paystack\Contracts\Services\Payments\CustomersInterface;

$paystack = new Paystack(secretKey: 'sk_live_...');

$paystack->registerServices([
    'transactions' => [Transactions::class, TransactionsInterface::class],
    'customers'    => [Customers::class, CustomersInterface::class],
]);

$paystack->transactions()->initialize(amount: 50000, email: 'customer@example.com');
$paystack->customers()->create(['email' => 'customer@example.com', 'first_name' => 'John', 'last_name' => 'Doe']);
```

The alias on the left of each entry is the dynamic method name you'll call on `$paystack`. Pick whatever names you like.

Services
--------

[](#services)

### Payments

[](#payments)

Suggested aliasService class`transactions()``Services\Payments\Transactions\Transactions``splits()``Services\Payments\Transactions\Splits``customers()``Services\Payments\Customers``charge()``Services\Payments\Charge``bulkCharges()``Services\Payments\BulkCharges``refunds()``Services\Payments\Refunds``subaccounts()``Services\Payments\Subaccounts``disputes()``Services\Payments\Disputes``settlements()``Services\Payments\Settlements``paymentRequests()``Services\Payments\PaymentRequests``dedicatedAccount()``Services\Payments\DedicatedAccount``terminal()``Services\Payments\Terminal``applePay()``Services\Payments\ApplePay`### Transfers

[](#transfers)

Suggested aliasService class`transfers()``Services\Transfers\Transfers``recipients()``Services\Transfers\Recipients``control()``Services\Transfers\Control`### Recurring

[](#recurring)

Suggested aliasService class`plans()``Services\Recurring\Plans``subscriptions()``Services\Recurring\Subscriptions`### Commerce

[](#commerce)

Suggested aliasService class`products()``Services\Commerce\Products``paymentPages()``Services\Commerce\PaymentPages`### Other

[](#other)

Suggested aliasService class`integration()``Services\Integration``verification()``Services\Verification``miscellaneous()``Services\Miscellaneous``balance()``Services\Balance``directDebit()``Services\DirectDebit``virtualTerminal()``Services\VirtualTerminal``storefront()``Services\Storefront``order()``Services\Order`Examples
--------

[](#examples)

### Transactions

[](#transactions)

```
// Initialize a transaction
$response = $paystack->transactions()->initialize(amount: 50000, email: 'customer@example.com');
$authUrl  = $response->getData()->authorization_url;

// Verify a transaction
$paystack->transactions()->verify('ref_abc123');

// List transactions
$paystack->transactions()->list(perPage: 20, page: 1);

// Fetch a transaction by id
$paystack->transactions()->fetch('123456789');

// Charge a saved authorization
$paystack->transactions()->chargeAuthorization('AUTH_xxx', amount: 10000, email: 'customer@example.com');

// Partial debit
$paystack->transactions()->partialDebit('AUTH_xxx', amount: 10000, currency: 'NGN', email: 'customer@example.com');
```

### Customers

[](#customers)

```
// Create a customer
$paystack->customers()->create([
    'email'      => 'john@example.com',
    'first_name' => 'John',
    'last_name'  => 'Doe',
    'phone'      => '+2348000000000',
]);

// Fetch a customer
$paystack->customers()->fetch('CUS_xxx');

// Update a customer
$paystack->customers()->update('CUS_xxx', ['first_name' => 'Jane']);

// Validate a customer's identity (e.g. BVN check)
$paystack->customers()->validate('CUS_xxx', [
    'first_name'      => 'John',
    'last_name'       => 'Doe',
    'type'            => 'bank_account',
    'value'           => '0123456789',
    'country'         => 'NG',
    'bvn'             => '12345678901',
    'bank_code'       => '058',
    'account_number'  => '0123456789',
]);

// Whitelist or blacklist a customer
$paystack->customers()->setRiskStatus('CUS_xxx', 'allow');
```

### Transfers

[](#transfers-1)

```
use Faridibin\Paystack\Enums\Currency;

// Initiate a transfer (reference must be unique per request — required for idempotency)
$paystack->transfers()->initiateTransfer(
    amount:    10000,
    recipient: 'RCP_xxx',
    reference: 'pay_invoice_42_2026_04',
    optional:  ['reason' => 'Payment for services'],
);

// Finalize a transfer (when OTP is required)
$paystack->transfers()->finalizeTransfer('TRF_xxx', '123456');

// Bulk transfers
$paystack->transfers()->initiateBulkTransfer(Currency::NGN, [
    ['amount' => 5000, 'recipient' => 'RCP_aaa', 'reference' => 'inv_1', 'reason' => 'Invoice 1'],
    ['amount' => 7500, 'recipient' => 'RCP_bbb', 'reference' => 'inv_2', 'reason' => 'Invoice 2'],
]);

// Verify and fetch
$paystack->transfers()->verifyTransfer('ref_abc123');
$paystack->transfers()->fetchTransfer('TRF_xxx');
```

### Recipients

[](#recipients)

```
use Faridibin\Paystack\Enums\RecipientType;

// Create a single recipient
$paystack->recipients()->createRecipient(
    type:          RecipientType::NUBAN,
    name:          'John Doe',
    accountNumber: '0123456789',
    bankCode:      '058',
);

// Bulk recipients
$paystack->recipients()->createBulkRecipients([
    ['type' => 'nuban', 'name' => 'John Doe',  'account_number' => '0123456789', 'bank_code' => '058'],
    ['type' => 'nuban', 'name' => 'Jane Smith','account_number' => '0987654321', 'bank_code' => '058'],
]);
```

### Plans &amp; Subscriptions

[](#plans--subscriptions)

```
use Faridibin\Paystack\Enums\PlanInterval;

// Create a plan
$paystack->plans()->create('Pro Monthly', amount: 500000, interval: PlanInterval::MONTHLY);

// Subscribe a customer
$paystack->subscriptions()->create('CUS_xxx', 'PLN_xxx');

// Enable / disable a subscription (token is the email_token from the subscription object)
$paystack->subscriptions()->toggle('SUB_xxx', 'tok_xxx', active: true);
$paystack->subscriptions()->toggle('SUB_xxx', 'tok_xxx', active: false);

// Generate or email a card-update link for the subscription
$paystack->subscriptions()->generateUpdateSubscriptionLink('SUB_xxx');
$paystack->subscriptions()->sendUpdateSubscriptionLink('SUB_xxx');
```

### Splits

[](#splits)

```
use Faridibin\Paystack\Enums\SplitType;
use Faridibin\Paystack\Enums\Bearer;
use Faridibin\Paystack\Enums\Currency;

$paystack->splits()->createSplit(
    name:             'Halfsies',
    type:             SplitType::PERCENTAGE,
    currency:         Currency::NGN,
    subaccounts:      [['subaccount' => 'ACCT_xxx', 'share' => 50]],
    bearer:           Bearer::SUB_ACCOUNT,
    bearerSubaccount: 'ACCT_xxx',
);
```

### Storefront

[](#storefront)

```
$paystack->storefront()->create([
    'name'        => 'My Store',
    'slug'        => 'my-store',
    'description' => 'Curated goods',
    'currency'    => 'NGN',
]);

$paystack->storefront()->verifySlug('my-store');
$paystack->storefront()->fetch('1');
$paystack->storefront()->update('1', ['name' => 'My New Store']);
$paystack->storefront()->addProducts('1', ['products' => [10, 20]]);
$paystack->storefront()->publish('1');
$paystack->storefront()->duplicate('1');
$paystack->storefront()->fetchOrders('1');
$paystack->storefront()->listProducts('1');
$paystack->storefront()->delete('1');
```

### Orders

[](#orders)

```
$paystack->order()->create([
    'amount'   => 50000,
    'currency' => 'NGN',
    'items'    => [['product' => 1, 'quantity' => 2]],
]);

$paystack->order()->list(perPage: 20, page: 1);
$paystack->order()->fetch('ORD_xxx');
$paystack->order()->fetchByProduct('123');
$paystack->order()->validate('ORD_xxx');
```

### Miscellaneous

[](#miscellaneous)

```
$paystack->miscellaneous()->listCountries();
$paystack->miscellaneous()->listStates('CA');
$paystack->miscellaneous()->listBanks('nigeria');
```

Webhook Verification
--------------------

[](#webhook-verification)

Use `Webhook::validateSignature()` and `Webhook::isIpWhitelisted()` to authenticate incoming Paystack webhooks:

```
use Faridibin\Paystack\Webhook;
use Faridibin\Paystack\Exceptions\PaystackException;

$payload   = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_PAYSTACK_SIGNATURE'] ?? '';
$ip        = $_SERVER['REMOTE_ADDR'] ?? '';

try {
    Webhook::isIpWhitelisted($ip);
    Webhook::validateSignature($payload, $signature, 'sk_live_...');

    $event = json_decode($payload, true);

    match ($event['event']) {
        'charge.success'   => handleChargeSuccess($event['data']),
        'transfer.success' => handleTransferSuccess($event['data']),
        default            => null,
    };

    http_response_code(200);
} catch (PaystackException $e) {
    http_response_code(403);
}
```

Paystack sends webhooks only from these IP addresses:

- `52.31.139.75`
- `52.49.173.169`
- `52.214.14.220`

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~108 days

Total

19

Last Release

62d ago

PHP version history (2 changes)v0.1PHP ^8.0

v0.3.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/899013446321c5d8185df4d616c40b4a08a81017efd04c4b355df90da09197dd?d=identicon)[faridibin](/maintainers/faridibin)

---

Top Contributors

[![faridibin](https://avatars.githubusercontent.com/u/10797272?v=4)](https://github.com/faridibin "faridibin (152 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/faridibin-paystack-php/health.svg)

```
[![Health](https://phpackages.com/badges/faridibin-paystack-php/health.svg)](https://phpackages.com/packages/faridibin-paystack-php)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.4k](/packages/laravel-framework)[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[bagisto/bagisto

Bagisto Laravel E-Commerce

28.0k175.2k9](/packages/bagisto-bagisto)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.9M535](/packages/pimcore-pimcore)[shetabit/multipay

PHP Payment Gateway Integration Package

298368.9k4](/packages/shetabit-multipay)[imdhemy/google-play-billing

Google Play Billing

491.5M5](/packages/imdhemy-google-play-billing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
