Download the PHP package abutimartin/mpesa-sdk without Composer
On this page you can find all versions of the php package abutimartin/mpesa-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abutimartin/mpesa-sdk
More information about abutimartin/mpesa-sdk
Files in abutimartin/mpesa-sdk
Package mpesa-sdk
Short Description Comprehensive PHP SDK for Safaricom M-Pesa API integration
License MIT
Homepage https://github.com/Enrique-Mertoe/php-mpesa-sdk
Informations about the package mpesa-sdk
M-Pesa SDK for PHP
A comprehensive PHP SDK for integrating with Safaricom's M-Pesa API. This SDK provides a clean, modern interface for all M-Pesa services including STK Push, B2C, B2B, C2B, Account Balance, Transaction Status, and Reversal operations.
Works with both standalone PHP projects and Laravel applications.
Features
- ✅ STK Push (Lipa Na M-Pesa Online) - Customer payments
- ✅ B2C (Business to Customer) - Send money to customers
- ✅ B2B (Business to Business) - Business payments
- ✅ C2B (Customer to Business) - Register and simulate C2B
- ✅ Account Balance - Check account balance
- ✅ Transaction Status - Query transaction status
- ✅ Reversal - Reverse transactions
- ✅ Callback Handling - Built-in callback processors
- ✅ Environment Management - Sandbox and Production support
- ✅ Comprehensive Logging - Built-in logging system
- ✅ Input Validation - Automatic parameter validation
- ✅ Error Handling - Detailed error reporting
- ✅ Framework Integration - Laravel, Symfony, CodeIgniter support
Requirements
- PHP 8.0 or higher
- cURL extension
- JSON extension
- OpenSSL extension
Installation
For All PHP Projects
Laravel Setup (Additional Steps)
The service provider auto-registers in Laravel 5.5+. Publish the config:
Add to your .env
:
Quick Start
🔥 Standalone PHP Usage
🚀 Laravel Usage
Configuration
🔧 Standalone PHP Configuration
Option 1: Direct Configuration
Option 2: Environment Variables
Create .env
file:
Then:
⚙️ Laravel Configuration
Laravel automatically loads from config/mpesa.php
and .env
:
🔍 Query Transaction Status
Standalone PHP
Laravel
📊 Account Balance
🔄 Callback Handling
Standalone PHP Callback
Laravel Callback
Usage Examples
📱 STK Push (Lipa Na M-Pesa)
Standalone PHP
Laravel
💰 B2C (Send Money)
Standalone PHP
Laravel
Logging
The SDK includes comprehensive logging:
Error Handling
Testing
Run the test suite:
Run with coverage:
Examples
The examples/
directory contains comprehensive examples:
stkpush.php
- STK Push examplescallbacks/
- Callback handling examplessdk_integration.php
- Full integration exampleframework_callback.php
- Framework integration examples
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, email [email protected] or create an issue on GitHub.
Changelog
v1.0.0
- Initial release
- STK Push support
- B2C support
- Callback handling
- Comprehensive logging
- Framework integration examples
Author
Abuti Martin
- Email: [email protected]
- GitHub: @abutimartin
Made with ❤️ for the PHP community
All versions of mpesa-sdk with dependencies
ext-curl Version *
ext-json Version *
ext-openssl Version *