Download the PHP package akika/laravel-mpesa-multivendor without Composer
On this page you can find all versions of the php package akika/laravel-mpesa-multivendor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download akika/laravel-mpesa-multivendor
More information about akika/laravel-mpesa-multivendor
Files in akika/laravel-mpesa-multivendor
Package laravel-mpesa-multivendor
Short Description A multivendor Laravel package for integrating Safaricom M-Pesa Daraja APIs. It allows seamless M-Pesa transactions for multiple vendors.
License MIT
Homepage https://github.com/akikadigital/laravel-mpesa-multivendor
Informations about the package laravel-mpesa-multivendor
Laravel Mpesa Multivendor Package by Akika Digital
Laravel M-Pesa Multivendor is a fully tested Laravel package for integrating Mpesa Daraja API's. It supports multiple shortcodes within the same application and provides a clean service-based interface for STK Push, C2B, B2C, B2B, Account Balance, Reversals, Dynamic QR, Bill Manager, Tax Remittance, Ratiba Standing Orders, Transaction History, IMSI Lookup, Organization Verification, and more.
Installation
You can install the package via composer:
After installing the package, enable the package using the following command:
The above command will not only enable the package, but also publish the config file. You can use the below command to republish the config file.
This will generate a mpesa.php file in your config directory where you can set your Mpesa credentials and other configuration options.
Architecture
The package uses a service-based architecture.
Available services:
Credentials consists of the following array. The details are shortcode based to support multivendor.
Details of the config file
.env file Setup
Add the following configurations into the .env file
The value is either production or sandbox
NOTE: The mpesa.php config file sets the default MPESA_ENV value to sandbox. This will always load sandbox urls.
Function Responses
All responses, except the token generation response, conform to the responses documented on the daraja portal.
Usage
Initializing Mpesa
Mpesa can be initialized in two ways:
Using Default Configuration
Using Vendor Credentials
Important Urls
Daraja utilizes the two main urls for callbacks. Timeout Url and Result Url. The two urls will also be used in this package as follows:
$resultUrlor$callbackUrl: Endpoint to send the results in case of success$timeoutUrl: Endpoint to send the results in case of operations timeout
Access Token Management
Access tokens are automatically generated and cached by the package.
No manual token management is required.
Getting Account Balance
You can fetch mpesa account balance as follows:
C2B Transactions
Registering URLs for C2B Transactions
You can register validation and confirmation URLs for C2B transactions:
Simulating C2B Transactions
You can simulate payment requests from clients:
Initiating STK Push
You can initiate online payment on behalf of a customer:
Querying STK Push Status
You can query the result of a STK Push transaction:
Reversing Transactions
You can reverse a C2B M-Pesa transaction:
Business to Customer (B2C) Transactions
You can perform Business to Customer transactions:
Send to Customer
B2C Topup
This API enables you to load funds to a B2C shortcode directly for disbursement. The transaction moves money from your MMF/Working account to the recipient’s utility account.
Business to Business (B2B) Transactions
B2B Buy Goods
You can perform Business to Business transactions:
B2B Paybill
You can perform Business to Business transactions:
B2B Express Checkout
QR Code Generation
You can generate QR codes for making payments:
$amountis an optional field
Bill Manager
You can optin to the bill manager service and send invoices:
Opt in
Send Single Invoice
Send Bulk Invoices
Below is an array showing sample invoices:
Cancel Single Invoice
Cancel Bulk Invoices
Tax Remittance
You can remit tax to the government using this package. To use this API, prior integration is required with KRA for tax declaration, payment registration number (PRN) generation, and exchange of other tax-related information.:
Mpesa Ratiba
The Standing Order APIs enable teams to integrate with the standing order solution by initiating a request to create a standing order on the customer profile.
Create Standing Order
Query Standing Order
Cancel Standing Order
Mpesa Transaction History
Register URL
The URL you register will be used to receive transaction hostories
Query History
The following API takes in the start and and end dates and returns the transactions between that period.
IMSI
Get the IMSI number for a given phone number.
NOTE: This API is charged per request, so use it only when necessary (e.g., for fraud prevention or network analysis).
Successful Response
API Response Body
$response has the following as a json object
Succssful result body
A successful result body has the following structure
Unsuccessful reusult body
An unsuccessful result body has the following structure
Quality Assurance
The package is fully tested using Pest PHP and PHPUnit.
Test Coverage
Current test coverage:
- ✅ 100% Line Coverage
- ✅ 100% Method Coverage
- ✅ 100% Class Coverage
Main coverage report:
Services coverage report:
The test suite covers:
- Authentication & Access Token Management
- STK Push
- C2B Transactions
- B2C Transactions
- B2B Transactions
- Account Balance
- Dynamic QR
- Bill Manager
- Tax Remittance
- Ratiba (Standing Orders)
- Transaction History
- Transaction Status
- IMSI Lookup
- Organization Verification
- Reversals
- Pochi Payments
- Security Credential Generation
- Service Provider Registration
- Console Commands
- Facades
- Exception Handling
- URL Validation
Run the test suite:
Generate a coverage report:
License
The Laravel Mpesa package is open-sourced software licensed under the MIT license. See the LICENSE file for details.
All versions of laravel-mpesa-multivendor with dependencies
illuminate/support Version ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/http Version ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0