PHPackages                             alloys9/mpesa\_rahisi - 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. [API Development](/categories/api)
4. /
5. alloys9/mpesa\_rahisi

ActiveLibrary[API Development](/categories/api)

alloys9/mpesa\_rahisi
=====================

A simple library for integrating with Safaricom's M-Pesa API

621PHP

Since Aug 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Alloys9/mpesa-rahisi)[ Packagist](https://packagist.org/packages/alloys9/mpesa_rahisi)[ RSS](/packages/alloys9-mpesa-rahisi/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

M-PESA rahisi
=============

[](#m-pesa-rahisi)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

**Mpesa Rahisi** provides an easy integration of M-Pesa payment services with your Laravel application, allowing you to process payments, handle transaction callbacks, and manage customer billing through Safaricom's M-Pesa API.

Features
--------

[](#features)

- Seamless M-Pesa integration with Laravel applications.
- Easy-to-use interface for initiating STK push requests.
- Automatically handles M-Pesa callback URLs and updates transactions.
- Configuration options to customize M-Pesa API settings.
- Compatible with Laravel 11.x.

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

[](#installation)

### Step 1: Install the package via Composer

[](#step-1-install-the-package-via-composer)

```
composer require alloys9/mpesa_rahisi:dev-main@dev
```

### Step 2: Run the installation command

[](#step-2-run-the-installation-command)

The next step is to publish the application configurations. Run the following command

```
php artisan mpesa-rahisi:install
```

This command will:

- Replace the config/app.php file
- Copy controllers to app/Http/Controllers
- Copy migrations to database/migrations
- Copy models to app/Models
- Copy views to resources/views
- Append necessary routes to routes/web.php
- Replace the CSRF middleware file

### Step 3: Migrate the database

[](#step-3-migrate-the-database)

Run the following command to migrate the necessary database tables:

```
php artisan migrate
```

### Step 4: Add the following to your .env file to save the variables

[](#step-4-add-the-following-to-your-env-file-to-save-the-variables)

```
MPESA_ENVIRONMENT=
SAFARICOM_PASSKEY=
MPESA_BUSINESS_SHORTCODE=
MPESA_CONSUMER_KEY=
MPESA_CONSUMER_SECRET=
MPESA_INITIATOR_PASSWORD=
MPESA_INITIATOR_NAME=
MPESA_SHORTCODE=

MPESA_CALLBACK_URL="${APP_URL}/payments/stkcallback"

MPESA_TEST_URLPRE="https://sandbox.safaricom.co.ke"

MPESA_TOKEN_URL="${MPESA_TEST_URLPRE}/oauth/v1/generate?grant_type=client_credentials"

MPESA_INITIATE_URL="${MPESA_TEST_URLPRE}/mpesa/stkpush/v1/processrequest"

MPESA_STK_QUERY_URL="${MPESA_TEST_URLPRE}/mpesa/stkpushquery/v1/query"

MPESA_SIMULATE_URL="${MPESA_TEST_URLPRE}/mpesa/c2b/v1/simulate"

MPESA_REGISTER_URL="${MPESA_TEST_URLPRE}/mpesa/c2b/v1/registerurl"

MPESA_CONFIRMATION_URL="${APP_URL}/payments/confirmation"

MPESA_VALIDATION_URL="${APP_URL}/payments/validation"

MPESA_B2C_TIMEOUT_URL="${APP_URL}/payments/b2ctimeout"
MPESA_B2C_RESULT_URL="${APP_URL}/payments/b2cresult"

MPESA_REVERSAL_TIMEOUT_URL="${APP_URL}/payments/reversalResult"
MPESA_REVERSAL_RESULT_URL="${APP_URL}/payments/reversalTimeout"
```

Then you are done! That simple!

### If an error occurs run

[](#if-an-error-occurs-run)

```
php artisan vendor:publish --provider="Alloys9\MpesaRahisi\MpesaRahisiServiceProvider"
```

Then run

```
php artisan mpesa-rahisi:install
```

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

MIT License

Copyright 2024 Alloys Amasakha

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104967102?v=4)[Alloys Amasakha](/maintainers/Alloys9)[@Alloys9](https://github.com/Alloys9)

---

Top Contributors

[![Alloys9](https://avatars.githubusercontent.com/u/104967102?v=4)](https://github.com/Alloys9 "Alloys9 (34 commits)")

---

Tags

apibillinglaravelmpesapaymentsafaricomstkpush

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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