A Laravel package for the Vodacom M-Pesa Mozambique Open API, providing C2B, B2C, B2B, reversal and transaction status operations.
# M-Pesa Laravel
A Laravel package for the Vodacom M-Pesa Mocambique Open API. It
provides a small, well tested surface for Customer to Business (C2B),
Business to Customer (B2C), Business to Business (B2B), transaction
reversal, transaction status query and customer name lookup
operations.
This package is not affiliated with or endorsed by Vodacom Mocambique.
It is an independent, open source client built against the public
M-Pesa developer portal documentation and the conventions shared by
the wider Mocambique M-Pesa SDK community.
> **Status: alpha.** The public API is still settling and may change
> between `0.x` releases without a major version bump. Pin an exact
> version in production and read `CHANGELOG.md` before upgrading.
## Contents
- Requirements
- Installation
- Getting your credentials
- Configuration
- Usage
- Handling the response
- Error handling
- Response codes
- Asynchronous callbacks
- Hosts and ports
- Testing your integration
- Testing this package
- Security
- Contributing
- License
- References
## Requirements
- PHP 8.2 or higher
- Laravel 10, 11, 12 or 13
- The `openssl` PHP extension, used to build the request bearer token
## Installation
Install the package with Composer. No stable release exists yet, so
pin the current alpha version explicitly:
```bash
composer require kelvinc/mpesa-laravel:0.1.0-alpha
```
Once a `1.0.0` release is tagged, a plain
`composer require kelvinc/mpesa-laravel` will resolve to it without
any extra flags.
Laravel's package discovery registers the service provider and the
`Mpesa` facade automatically. Publish the configuration file if you
want to customise anything beyond your credentials:
```bash
php artisan vendor:publish --tag=mpesa-config
```
This creates `config/mpesa.php` in your application.
## Getting your credentials
Register an account on the M-Pesa developer portal
and create an application to obtain:
- An API key
- A public key, used to encrypt the API key into a bearer token
- …