Download the PHP package tfs/mpesa without Composer
On this page you can find all versions of the php package tfs/mpesa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package mpesa
Short Description Modern Laravel package for Safaricom M-Pesa Daraja API integration with comprehensive B2C, B2B, STK Push, and Balance inquiry support
License MIT
Homepage https://github.com/24sevendevs/mpesa
Informations about the package mpesa
Safaricom M-Pesa Daraja API Laravel Package
A modern Laravel package for Safaricom's M-Pesa Daraja API. Supports PHP 7.4+ and PHP 8.x with a flexible API that works with both array parameters and named arguments.
Features
- ✅ STK Push (M-Pesa Express) - Prompt customers to pay via M-Pesa
- ✅ B2C Payments - Send money to customers
- ✅ B2B Payments - PayBill, BuyGoods, PayToPochi
- ✅ Account Balance - Check your M-Pesa balance
- ✅ C2B URL Registration - Register validation/confirmation URLs
- ✅ Dual API Style - Arrays (PHP 7.4+) or Named Arguments (PHP 8.0+)
- ✅ Token Caching - Automatic access token management
- ✅ Custom Auth - Override credentials per transaction
Requirements
| PHP Version | Supported | Recommended Style |
|---|---|---|
| 7.4 | ✅ | Array parameters |
| 8.0+ | ✅ | Named arguments |
Installation
Publish configuration:
Usage Styles
This package supports two parameter styles for maximum compatibility:
Style 1: Array Parameters (PHP 7.4+)
Style 2: Named Arguments (PHP 8.0+)
Style 3: Positional Arguments (Both)
API Reference
STK Push (M-Pesa Express)
Prompt a customer to enter their M-Pesa PIN:
Query STK Push Status
B2C (Business to Customer)
Send money to a customer:
B2B PayBill
Pay a bill to another business:
B2B BuyGoods
Pay to a till number:
B2 Pochi (Business Wallet)
Send to a business wallet:
Account Balance
Check your M-Pesa balance:
C2B URL Registration
Register validation and confirmation URLs:
Custom Authentication
Override credentials per request (useful for multi-tenant apps):
Parameter Reference
Key Naming Convention
Both camelCase and snake_case keys are supported in arrays:
| camelCase | snake_case | Description |
|---|---|---|
accountReference |
account_reference |
Payment reference |
transactionDesc |
transaction_desc |
Transaction description |
checkoutRequestId |
checkout_request_id |
STK query ID |
partyB |
party_b |
Recipient shortcode/phone |
partyA |
party_a |
Sender shortcode |
commandId |
command_id |
B2C command type |
identifierType |
identifier_type |
Balance identifier |
originatorConversationId |
originator_conversation_id |
Pochi conversation ID |
validationUrl |
validation_url |
C2B validation URL |
confirmationUrl |
`confirmation_url |
All versions of mpesa with dependencies
illuminate/support Version >=7.0 <13.0
illuminate/http Version ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/cache Version ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
guzzlehttp/guzzle Version ^6.5|^7.0