PHPackages                             yaphet17/chapa - 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. yaphet17/chapa

ActiveLibrary[Payment Processing](/categories/payments)

yaphet17/chapa
==============

PHP SDK for Chapa payment gateway

v1.0.0(3y ago)23287MITPHPCI passing

Since Aug 23Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/yaphet17/chapa-php)[ Packagist](https://packagist.org/packages/yaphet17/chapa)[ RSS](/packages/yaphet17-chapa/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Chapa-PHP
=========

[](#chapa-php)

[![BUILD](https://github.com/yaphet17/chapa-php/actions/workflows/php.yml/badge.svg)](https://github.com/yaphet17/chapa-php/actions/workflows/php.yml/)[![Latest Stable Version](https://camo.githubusercontent.com/a849d082cb586a616fae138e3cc7a9eae418c4dac8806fb70d70d0f946abf3d9/687474703a2f2f706f7365722e707567782e6f72672f79617068657431372f63686170612f76)](https://packagist.org/packages/yaphet17/chapa) [![Total Downloads](https://camo.githubusercontent.com/5399c98a48f67d63c15cd14742cd8169bb339d7540fcb42f97f3be36b7cffe06/687474703a2f2f706f7365722e707567782e6f72672f79617068657431372f63686170612f646f776e6c6f616473)](https://packagist.org/packages/yaphet17/chapa) [![Latest Unstable Version](https://camo.githubusercontent.com/dd2d0d78e6aa7f3646a8d16b8b7025ff8104f0627591e8cb355e6329507594ad/687474703a2f2f706f7365722e707567782e6f72672f79617068657431372f63686170612f762f756e737461626c65)](https://packagist.org/packages/yaphet17/chapa) [![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Unofficial PHP library for Chapa Payment Gateway.

Description
-----------

[](#description)

Integrating Chapa to your app is simple as it is. So what benefit can you get from using this library? well, here are some of the benefits you can get by using this library.

- Allows you to focus on building your app instead of spending time on making the integration to work.
- It provides utility methods that can save you from writing some lines of codes. For example the library supports data validation out of the box, so that you don't have to manually sanitize users input.
- The library gives you an easy interface to manage any data send to or received from [Chapa API](https://developer.chapa.co/) in an object-oriented approach.

Documentation
-------------

[](#documentation)

Visit official [Chapa's API Documentation](https://developer.chapa.co/docs)

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

[](#installation)

Go to your project directory and install the latest version of the library using following command

```
composer require yaphet17/chapa
```

Usage
-----

[](#usage)

Instantiate a `Chapa` class.

```
$chapa = new Chapa('{your-secrete-key}');
```

Create a `PostData` object that will represent your payment details.`PostData` class uses the [Fluent Interface,](https://martinfowler.com/bliki/FluentInterface.html)so you can be able to chain setter methods.

```
$postData = new PostData();
$postData->amount('100')
    ->currency('ETB')
    ->email('abebe@bikila.com')
    ->firstname('Abebe')
    ->lastname('Bikila')
    ->transactionRef('transaction-ref')
    ->callbackUrl('https://chapa.co')
    ->customizations(
        array(
            'customization[title]' => 'I love e-commerce',
            'customization[description]' => 'It is time to pay'
        )
    );
```

You can also use a utility method provided by the library to generate a unique and convenient transaction reference token. `Util` class provides a method that can generate a token by combining your custom prefix such as company initials (optional), current timestamp and random string.

```
$transactionRef = Util::generateToken('acme'); // generated transaction reference will start with the prefix aceme
```

To initialize a transaction, all you have to do is call `initializa` method in side `Chapa` class. Pass the `PostData` object you created in the above step.

```
$response1 = $chapa->initialize($postData);
```

You can also verify your transaction using `verify` method inside `Chapa` class. This method takes a transaction reference token so that it can uniquely identify a specific transaction.

```
$response2 = $chapa->verify($transactionRef);
```

Both of the above two methods (i.e `initialize` and `verify`) returns an instance of `ReponseData` class. This class will allow you to access the data returned by Chapa API with an OOP approach. It has the same structure as the JSON data returned by Chapa API plus status code and a raw JSON data.

```
$statusCode = $resopnse1->getStatusCode();
$message = $response1->getMessage();
$success = $response1->getStatus();
$data = $response1->getData();
```

For some reason, if you want the raw JSON data you can easily access it using `getRawJSON` method.

```
$json = $response->getRawJson();
```

Below is the full implementation of the above steps.

```
$chapa = new Chapa('{your-secrete-key}');
$transactionRef = Util::generateToken();
$postData = new PostData();
$postData->amount('100')
    ->currency('ETB')
    ->email('abebe@bikila.com')
    ->firstname('test')
    ->lastname('user')
    ->transactionRef($transactionRef)
    ->callbackUrl('https://chapa.co')
    ->customizations(
        array(
            'customization[title]' => 'E-commerce',
            'customization[description]' => 'It is time to pay'
        )
    );

$response1 = $chapa->initialize($postData);
print_r($response1->getMessage());
print_r($response1->getStatus());
print_r($response1->getData());
echo $response->getRawJson();
$response2 = $chapa->verify($transactionRef);
if($response2->getStatusCode() == 200){
    echo 'Payment not verified because ' . $response2->getMessage()['message'];
}
```

Contribution
------------

[](#contribution)

Any sort of contribution to this library is appreciated. Make a PR for minor changes or create an issue for breaking changes.

This open source library is licensed under the terms of the MIT License.

Enjoy.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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

Unknown

Total

1

Last Release

1412d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c30572a97d357c1076479fe96f40056a05890f7f5a4a0078a89f678c8626e59?d=identicon)[yaphet17](/maintainers/yaphet17)

---

Top Contributors

[![yaphet17](https://avatars.githubusercontent.com/u/78301074?v=4)](https://github.com/yaphet17 "yaphet17 (50 commits)")[![natytgn](https://avatars.githubusercontent.com/u/73637938?v=4)](https://github.com/natytgn "natytgn (1 commits)")

---

Tags

chapaethiopiapayment-integrationphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yaphet17-chapa/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k39](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.5M9](/packages/chargebee-chargebee-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[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)
