Download the PHP package breviam/mpesa-sdk without Composer
On this page you can find all versions of the php package breviam/mpesa-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download breviam/mpesa-sdk
More information about breviam/mpesa-sdk
Files in breviam/mpesa-sdk
Package mpesa-sdk
Short Description Laravel SDK for M-Pesa Daraja API
License GPL-3.0-or-later
Informations about the package mpesa-sdk
STILL UNDER DEVELOPMENT
M-Pesa Laravel SDK
A comprehensive Laravel SDK for integrating with Safaricom's M-Pesa Daraja API. This package provides a clean, well-documented interface for all major M-Pesa services including STK Push, C2B, B2C, Transaction Status, and Account Balance.
Features
- ✅ STK Push (Lipa na M-Pesa Online)
- ✅ C2B (Customer to Business) payments
- ✅ B2C (Business to Customer) payments
- ✅ Transaction Status queries
- ✅ Account Balance inquiries
- ✅ Webhook handling with automatic route registration
- ✅ Token management with automatic caching
- ✅ Laravel Facade support
- ✅ Artisan commands for testing and debugging
- ✅ Comprehensive logging
- ✅ Event-driven architecture
- ✅ Full test coverage
Requirements
- PHP 8.1+
- Laravel 11.x (recommended)
- Laravel 10.x (experimental support)
Note: For detailed Laravel version compatibility information, see LARAVEL_COMPATIBILITY.md
Installation
Install the package via Composer:
Publish the configuration file:
Configuration
Add your M-Pesa credentials to your .env file:
Basic Usage
STK Push (Lipa na M-Pesa Online)
C2B (Customer to Business)
B2C (Business to Customer)
Account Balance
Transaction Status
Advanced Usage
Using Individual Services
Handling Webhooks
The package automatically registers webhook routes. You can listen to events:
Artisan Commands
Check token status:
Clear token cache:
Simulate payment (sandbox only):
Testing
Run the tests:
Run tests with coverage:
Events
The package fires the following events:
| Event | Description |
|---|---|
mpesa.stk.callback |
STK Push callback received |
mpesa.c2b.validation |
C2B validation request |
mpesa.c2b.confirmation |
C2B confirmation received |
mpesa.b2c.result |
B2C transaction result |
mpesa.b2c.timeout |
B2C transaction timeout |
mpesa.balance.result |
Balance inquiry result |
mpesa.balance.timeout |
Balance inquiry timeout |
mpesa.transaction.result |
Transaction status result |
mpesa.transaction.timeout |
Transaction status timeout |
Configuration Options
The package supports extensive configuration through the config/mpesa.php file:
Security
- All sensitive data is masked in logs
- OAuth tokens are securely cached
- HTTPS is enforced for all API calls
- Webhook requests are logged with IP and user agent
Error Handling
The package throws specific exceptions:
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Victor Kariuki
- All Contributors
License
The GNU General Public License v3.0. Please see License File for more information.
Changelog
Please see CHANGELOG for more information on what has changed recently.
All versions of mpesa-sdk with dependencies
illuminate/support Version ^11.0
illuminate/http Version ^11.0
illuminate/cache Version ^11.0
illuminate/routing Version ^11.0