PHPackages                             matscode/paystack - 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. matscode/paystack

ActiveLibrary[Payment Processing](/categories/payments)

matscode/paystack
=================

This package is for communicating with PAYSTACK API

v1.10.1(1y ago)1719.7k↓35%9GPL-3.0-onlyPHP

Since Jun 27Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (8)Used By (0)

matscode/paystack-php
=====================

[](#matscodepaystack-php)

This currently repository development has been discontinued. Development of `v2.0.0` and above has now moved to [matscode/paystack-php-sdk](https://github.com/matscode/paystack-php-sdk) with new improved structure, documentation, demo and overall dev experience.

#### TODO - RoadMap

[](#todo---roadmap)

- `Use GuzzleHttp`
- `Customers`
- `Plans`
- `Subscription`
- `Transfers`
- `Charges`
- `others...`

###### This package is for communicating with PAYSTACK RESTful API. [Paystack](https://paystack.com/)

[](#this-package-is-for-communicating-with-paystack-restful-api-paystack)

Having other resource point available on PAYSTACK API, Resources like;

- Transaction
- Customers
- Plans
- Subscription
- Transfers
- Charges
- and many more

Just to name a few, it is only the Transaction Resource that is made available currently in this package. Development is ongoing while releases are Stable. Incase you find a BUG/Security Issue, Please, do be kind to open an issue or email [matscode at Gmail dot Com](mailto://matscode@gmail.com).
**PS**: This library also works for you if you use paystack inline. You just have to use the `verify()` method, passing in your transaction `$reference|$token|$id` is compulsory.

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

[](#requirements)

- Curl

Install
-------

[](#install)

### Via Composer

[](#via-composer)

```
$ composer require matscode/paystack
```

If you use a Framework, check your documentation for how vendor packages are autoloaded else Add this to the top of your source file;

```
require_once __DIR__ . "/vendor/autoload.php";
```

Making Transactions/Recieving Payment
-------------------------------------

[](#making-transactionsrecieving-payment)

### Starting Up Paystack Transaction

[](#starting-up-paystack-transaction)

```
use Matscode\Paystack\Transaction;
use Matscode\Paystack\Utility\Debug; // for Debugging purpose
use Matscode\Paystack\Utility\Http;

$secretKey = 'sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

// creating the transaction object
$Transaction = new Transaction( $secretKey );
```

### Initializing Transaction

[](#initializing-transaction)

Set data/payload/requestBody to post with initialize request. Minimum required data are email and amount.

```
// Set data to post using array
$data =
[
    'email'  => 'customer@email.com',
    'amount' => 500000 // amount is treated in kobo using this method
];
$response = $Transaction->initialize($data);
```

OR

```
// Set data to post using this method
$response =
        $Transaction
            ->setCallbackUrl('http://michaelakanji.com') // to override/set callback_url, it can also be set on your dashboard
            ->setEmail( 'matscode@gmail.com' )
            ->setAmount( 75000 ) // amount is treated in Naira while using this method
            ->setMetadata(['custom_field1' => 'value1', 'custom_field2' => 'value2'])
            ->initialize();
```

If you want to get the 200OK raw Object as it is sent by Paystack, Set the 2nd argument of the `initialize()` to `true`, example below

```
// Set data to post using this method
$response =
        $Transaction
            ->setEmail( 'matscode@gmail.com' )
            ->setAmount( 75000 ) // amount is treated in Naira while using this method
            ->initialize([], true);
```

Now do a redirect to payment page (using authorization\_url)
NOTE: Recommended to Debug `$response` or check if authorizationUrl is set, and save your Transaction reference code. useful to verify Transaction status

```
// recommend to save Transaction reference in database and do a redirect
$reference = $response->reference;
// redirect
Http::redirect($response->authorizationUrl);
```

Using a Framework? It is recommended you use the reverse routing/redirection functions provided by your Framework

### Verifying Transaction

[](#verifying-transaction)

This part would live in your callback file i.e `callback.php` or `whatsoever_you_name.php`
It is also imperative that you create Transaction Obj once more.
This method would return the Transaction Obj but `false` if saved `$reference` is not passed in as argument and also cant be guessed. Using `verify()` would require you do a manual check on the response Obj

```
$response = $Transaction->verify();
// Debuging the $response
Debug::print_r( $response);
```

OR

```
// This method does the check for you and return `(bool) true|false`
$response = $Transaction->isSuccessful();
```

The two methods above try to guess your Transaction `$reference` but it is highly recommended you pass the Transaction `$reference` as an argument on the method as follows

```
// This method does the check for you and return `(bool) true|false`
$response = $Transaction->isSuccessful($reference);
```

Moreso, you can also compare if amount paid by customer is the amount expected. This method only works after calling `verify()` or `isSuccessful()` in the same script. It is recommended to do this if you use paystack inline to initialize the transaction.

```
$amountExpected = 5000; // amount must be in kobo
// returns `(bool) true|false`
$Transaction->amountEquals($amountExpected);
```

Now you can process Customer Valuable.

You might wanna save Transaction `$authorizationCode` for the current customer subsequent Transaction but not a nessecity. It would only counts to future updates of this package or if you choose to extend the package.

```
// returns Auth_xxxxxxx
$response = $Transaction->authorizationCode($reference); // can also guess Transaction $reference
```

Hire Me
-------

[](#hire-me)

I am available on contract if you need help integrating paystack into your Business Website or something.
Contact me via my email above - [michaelakanji.com](http://michaelakanji.com)

Contributions
-------------

[](#contributions)

If you seem to understand the architecture, you are welcome to fork and pull else you can wait a bit more till when i provide convention documentation.

Licence
-------

[](#licence)

GNU GPLV3

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 90.3% 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 ~516 days

Recently: every ~646 days

Total

6

Last Release

662d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b99414173a8cb184b6fe4ef735060b4b625ff632c837cff052788dd254dedfef?d=identicon)[matscode](/maintainers/matscode)

---

Top Contributors

[![matscode](https://avatars.githubusercontent.com/u/8417404?v=4)](https://github.com/matscode "matscode (28 commits)")[![AmirMehrabi](https://avatars.githubusercontent.com/u/3878847?v=4)](https://github.com/AmirMehrabi "AmirMehrabi (3 commits)")

---

Tags

payment-gatewaypayment-integrationpayment-processingpaystackpaystack-apipaystack-librarypaystack-phppaystack-sdkpaystack-wrapperphptransactionphppaymentpaystack

### Embed Badge

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

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

###  Alternatives

[yandex-money/yandex-money-sdk-php

Yandex.Money API SDK for PHP

105167.4k2](/packages/yandex-money-yandex-money-sdk-php)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[digikraaft/laravel-paystack-webhooks

Handle Paystack webhooks in a Laravel application

177.5k1](/packages/digikraaft-laravel-paystack-webhooks)

PHPackages © 2026

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