Download the PHP package akika/laravel-mpesa without Composer
On this page you can find all versions of the php package akika/laravel-mpesa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-mpesa
Laravel Mpesa Package by Akika Digital
This Laravel package provides convenient methods for integrating Mpesa Daraja API's functionalities into your Laravel application.
Installation
You can install the package via composer:
After installing the package, publish the configuration file using the following command:
This will generate a mpesa.php file in your config directory where you can set your Mpesa credentials and other configuration options.
.env file Setup
Add the following configurations into the .env file
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
Fetching Token
You can fetch the token required for Mpesa API calls as follows:
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:
You can register the C2B URLs using the provided command below:
The above command requires you to have set the below variables in your env or in the config file:
Simulating C2B Transactions
You can simulate payment requests from clients:
Initiating STK Push
You can initiate online payment on behalf of a customer:
$transactionDesc
can be null
Querying STK Push Status
You can query the result of a STK Push transaction:
Reversing Transactions
You can reverse a C2B M-Pesa transaction:
$ocassion
is an optional field.
Business to Customer (B2C) Transactions
You can perform Business to Customer transactions:
$ocassion
is an optional field.
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.
$accountReference
: A unique (system generated) identifier for the transaction.$receiverShortCode
: The shortcode to which money will be moved$amount
: The transaction amount.$remarks
: Any additional information to be associated with the transaction.
Business to Business (B2B) Transactions
B2B Paybill
You can perform Business to Business transactions:
$destShortcode
: This is the party receiving the money.$accountNumber
: The account number to be associated with the payment. Up to 13 characters.$requester
is an optional field.
B2B Buy Goods
This api accepts variables as provided in section B2B Paybill above.
B2B Express Checkout
$destShortcode
: This is the party receiving the money.$partnerName
: This is the organization Friendly name used by the vendor as known by the Merchant.$paymentReference
: This is a reference to the payment being made. This will appear in the text for easy reference by the merchant. e.g. Order ID$requestRefID
: This is an auto-genarated reference ID generated by your system.
QR Code Generation
You can generate QR codes for making payments:
$amount
is an optional field
Bill Manager
You can optin to the bill manager service and send invoices:
$sendReminders
is a boolean field. Allows true or false (1 or 0)
Tax Remittance
You can remit tax to the government:
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.
$name
: Name of standing order that must be unique for each customer.$startDate
: The date you wish for the standing order to start executing$endDate
: The date you wish for the standing order to stop executing$transactionType
: This is the transaction type that is used to identify the transaction when sending the request to M-PESA. Either till or paybill$type
: This is the transaction type that is used to identify the transaction when sending the request to M-PESA.$amount
: This is the money that the customer pays to the Shortcode.$phoneNumber
: The phone number sending money. The parameter expected is a Valid Safaricom Mobile Number that is M-PESA registered in the format 2547XXXXXXXX$accountReference
: This is a unique identifier for the transaction and is generated by the system. It has a maximum limit of 13 characters.$transactionDesc
: This is any additional information/comment that can be sent along with the request from your system. Maximum of 13 Characters$frequency
: The frequency of the standing order (one-off, daily, weekly, monthly, bi-monthly, quarterly, half-year, annually)
Mpesa Transaction History
The following API takes in the start and and end dates and returns the transactions between that period.
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
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 with dependencies
illuminate/support Version ^8.0 | ^9.0 | ^10.0 | ^11.0
illuminate/http Version ^8.0 | ^9.0 | ^10.0 | ^11.0
guzzlehttp/guzzle Version ^7.5