PHPackages                             flaircore/mpesa - 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. flaircore/mpesa

ActiveLibrary

flaircore/mpesa
===============

Contains a php library that helps php developer intergrate their app(s) with safaricom mpesa (Daraja) api

1.2.3(6y ago)3172MITPHPPHP &gt;=7.2.0

Since Feb 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/flaircore/php-mpesa)[ Packagist](https://packagist.org/packages/flaircore/mpesa)[ RSS](/packages/flaircore-mpesa/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

**INTRODUCTION**

Why/Because: lets you save and retrieve your app credentials from either a database or on a .env file.

This library focuses on making it easier for php developers to integrate mpesa payment system into their app, especially if you're using a cms or a framework that let's you save/update your configs from the database.

**INSTALLATION**

Make sure you have composer installed, then in the root of your project directory run `composer require flaircore/mpesa`

[Mpesa Online Payment Example](https://github.com/flaircore/php-mpesa/wiki/Home:)

**MAKING REQUESTS**

```
    # set the variables needed first (maybe)
    // access token

    $passKey = 'Your Pass key';
    $consumerKey = 'Your Consurer Key';
    $consumerSecret = 'Your Consumer Secret';

    $mpesaConfigs = new \Flaircore\Mpesa\MpesaConfigs();
    $mpesaConfigs->setConsumerKey($consumerKey);
    $mpesaConfigs->setConsumerSecret($consumerSecret);
    $mpesaConfigs->setPassKey($passKey);
    $mpesaConfigs->setEnviroment('sandbox'); #sandbox or live;

    $mpesaItem = new \Flaircore\Mpesa\MpesaItem($mpesaConfigs);
    $mpesaItem->setBusinessShortCode('Your Bs shortcode');
    $mpesaItem->setTransactionType('CustomerPayBillOnline');
    $mpesaItem->setAmount('Amount in KSH');
    $mpesaItem->setPartyA('PartyA'); #2547******00
    $mpesaItem->setPartyB($mpesaItem->getBusinessShortCode());
    $mpesaItem->setPhoneNumber('2547******00');
    $mpesaItem->setCallBackURL('call back url string where to receive the response');
    $mpesaItem->setAccountReference('Product Title');
    $mpesaItem->setTransactionDesc('maybe Product EntityID 111');

    $mpesaRequest = new \Flaircore\Mpesa\Requests\stkPush($mpesaConfigs, $mpesaItem);#pass the mpesaConfigs and mpesaItem in that order

    #var_dump($mpesaRequest->mpesaSTKPush());die;
    $mpesaRequest->mpesaSTKPush();#send the request

```

**PREREQUISITES**PHP 7.2 or above, also curl and json ext must be enabled.

**Contributing**Seeking co-contributers to make this library whole and better please check the todo.php in this directory

**Credits**Inspired by `https://github.com/bnjunge/MPESA-API-Tutorial`

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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 ~76 days

Recently: every ~94 days

Total

6

Last Release

2268d ago

PHP version history (2 changes)1.0PHP &gt;=7.1.0

1.2.3PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1a880b9d8bad96075a11e6d17c62430c1c9033398119c8d83e71e37ae69074?d=identicon)[Nicholas Babu](/maintainers/Nicholas%20Babu)

![](https://www.gravatar.com/avatar/3d2d9023762c58b29ce40d9cb2369b117258ee560926b491dd114c310b32150b?d=identicon)[Flaircore](/maintainers/Flaircore)

---

Top Contributors

[![Nickbahson](https://avatars.githubusercontent.com/u/22325357?v=4)](https://github.com/Nickbahson "Nickbahson (20 commits)")

### Embed Badge

![Health badge](/badges/flaircore-mpesa/health.svg)

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

PHPackages © 2026

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