Download the PHP package botnetdobbs/laravel-mpesa-sdk without Composer

On this page you can find all versions of the php package botnetdobbs/laravel-mpesa-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-mpesa-sdk

Laravel M-Pesa Integration Package

Laravel package for integrating with Safaricom"s M-Pesa payment gateway. Supports STK Push, B2C, B2B, balance queries, transaction status checks, and payment reversals.

For the most current API documentation and updates, always refer to the Safaricom Developer Portal.

Requirements

Laravel Version
Laravel 10.x
Laravel 11.x

Installation

Install the package via Composer:

Publish the configuration file:

Configuration

Add the following variables to your .env file:

More can be added as per the config file below.

Configuration Options

The published config file (config/mpesa.php) contains the following options:

For the cerfiticate, Download under M-Pesa API Certificates.

Usage

STK Push (Lipa Na M-Pesa Online)

STK Push (check the status of a Lipa Na M-Pesa Online Payment.)

B2C Payment (Business to Customer)

B2B Payment (Business to Business)

B2B parameter naming convention is camelCase instead of PascalCase like the other endpoints on the Safaricom Developer Portal. Retained as is

C2B Register (Customer to Business)

C2B Simulate Payment (Sandbox Environment Only)

Account Balance Query

Transaction Status Query

Transaction Reversal

Response Handling

All methods return a standard Response with the following methods:

Example Usage

Error Handling

The package throws MpesaException for various error scenarios:

Callback Handling

The package provides callback handling system for processing M-Pesa payment notifications.

Setup Callback Routes

Register the callback routes in your routes/api.php:

Create Callback Controller

Create a controller to handle M-Pesa callbacks:

You can use the provided CallbackProcessor which wraps the callback data in a TransactionResult object as shown below, or you can handle the raw data directly.

Available Callback Methods

Each callback type provides specific methods to access the payment data:

Common Methods Available in All Callbacks

The CallbackResponder provides two methods:

Response Format: All responses are returned as JSON with the appropriate Content-Type header.

Success Response:

Failed Response:

For Contributors

This package includes comprehensive testing capabilities:

Running Tests

Run all tests

Coverage Reports

Generate HTML coverage report:

Then open coverage/index.html in your browser.

Code Quality

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-mpesa-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/http Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package botnetdobbs/laravel-mpesa-sdk contains the following files

Loading the files please wait ....