akika/laravel-mwaloni
Composer 安装命令:
composer require akika/laravel-mwaloni
包简介
A single-tenant Laravel package for integrating Mpesa, Equity Jenga API's and NCBA Loop API through Mwaloni Wallet
README 文档
README
This Laravel package provides convenient methods for integrating Mwaloni functionalities into your Laravel application.
Installation
You can install the package via composer:
composer require akika/laravel-mwaloni
After installing the package, publish the configuration file using the following command:
php artisan mwaloni:install
This will generate a mwaloni.php file in your config directory where you can set your Mwaloni credentials and other configuration options.
.env file Setup
Add the following configurations into the .env file
MWALONI_ENV= # sandbox|production MWALONI_DEBUG= # true|false MWALONI_URL_SANDBOX= # Can be added for local tests
NOTE:
- The mwaloni.php config file sets the default
MWALONI_ENVvalue tosandbox. This will always load sandbox url and credentials. - It also sets the default debug mode to true. When true, the package will log into the log destination provided
- The other variables except
MWALONI_ENVandMWALONI_DEBUGwill be provided by Mwaloni during onboarding. - When debug mode is set to true, Mwaloni will log both data object and result on every API call
Function Responses
All responses, will be in json format as received from the Mwaloni portal.
Sample failed response
{
"status":"01",
"message":"Service not found",
}
Sample successful transaction response
{
"status":"00",
"message":"Cashout was successful."
}
Usage
Initializing Mwaloni
To initialize Mwaloni, paste the following code within your code.
use Akika\LaravelMwaloni\Mwaloni; // Paste before class definition /** * * Initialize the Mwaloni class using credentials provided * * @param string $serviceId * @param string $username * @param string $password * @param string $apiKey */ $mwaloni = new Mwaloni($serviceId, $username, $password, $apiKey); // Paste code where appropriate in your code.
Authentication
Authentication si required in order to consume Mwaloni APIs. The function below will perform authentication.
$response = $mwaloni->authenticate();
Authentication result
{
"status":"00",
"message":"Success",
"data":{
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.xxxx.xxxxxx",
"tokenType":"Bearer",
"expiresIn":3600
}
}
- A generated token can be used for up to 60 minutes.
Setting token
- On successful authentication, use the following function to set up the toke for use on subsequent calls.
/** * * Set the API token * * @param string $token */ $response = $mwaloni->setToken($token); // $data->token
Query account balance
$response = $mwaloni->fetchBalance();
A successful balance query response will have the below structure:
{
"status":"00",
"message":"Success",
"balance":3250544,
"balanceBreakdown":{
"utilityBalance":3250544,
"workingBalance":0
}
}
Send money to mpesa enabled lines
/** * * Send money to a mobile number * * @param string $orderNumber - The order number * @param string $phoneNumber - The phone number * @param float $amount - The amount to send * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->mobile($orderNumber, $phoneNumber, $amount, $description);
Send to mpesa till number
/** * * Send money to a till number * * @param string $orderNumber - The order number * @param string $accountName - The name of the account holder * @param string $accountNumber - The till number * @param float $amount - The amount to send * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->till($orderNumber, $accountName, $accountNumber, $amount, $description);
Send to mpesa paybill
/** * * Send money to a paybill number * * @param string $accountReference - The account reference * @param string $orderNumber - The order number * @param string $accountName - The name of the account holder * @param string $accountNumber - The paybill number * @param float $amount - The amount to send * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->paybill($accountReference, $orderNumber, $accountName, $accountNumber, $amount, $description);
Send to bank via ift
/** * * Send money to a bank account through ift * * @param string $orderNumber - The order number * @param string $accountName - The name of the account holder * @param string $accountNumber - The account number * @param string $address - The address of the account holder * @param string $countryCode - The country code * @param float $amount - The amount to send * @param string $currencyCode - The currency code * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->ift($orderNumber, $accountName, $accountNumber, $address, $countryCode, $amount, $currencyCode, $description);
Send to bank via eft
/** * * Send money to a bank account through eft * * @param string $orderNumber - The order number * @param string $accountNumber - The account number * @param string $accountName - The name of the account holder * @param string $bankCode - The bank code * @param string $bankName - The name of the bank * @param string $bankCountryCode - The country code of the bank * @param string $bankCIF - The CIF/Swift Code of the bank * @param string $accountAddress - The address of the account holder * @param float $amount - The amount to send * @param string $currencyCode - The currency code * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->eft($orderNumber, $accountNumber, $accountName, $bankCode, $bankName, $bankCountryCode, $bankCIF, $accountAddress, $amount, $currencyCode, $description);
Send to bank via pesalink
/** * * Send money to a bank account through pesalink * * @param string $orderNumber - The order number * @param string $accountNumber - The account number * @param string $accountName - The name of the account holder * @param string $bankName - The name of the bank * @param string $bankCountryCode - The country code of the bank * @param string $bankCIF - The CIF/Swift Code of the bank * @param float $amount - The amount to send * @param string $currencyCode - The currency code * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->pesalink($orderNumber, $accountNumber, $accountName, $bankName, $bankCountryCode, $bankCIF, $amount, $currencyCode, $description);
Send to bank via rtgs
/** * * Send money to a bank account through rtgs * * @param string $orderNumber - The order number * @param string $accountNumber - The account number * @param string $accountName - The name of the account holder * @param string $bankName - The name of the bank * @param string $swiftCode - The swift code of the bank * @param string $address - The address of the account holder * @param string $bankCountryCode - The country code of the bank * @param float $amount - The amount to send * @param string $currencyCode - The currency code * @param string $description - The description of the transaction * * @return mixed */ $response = $mwaloni->rtgs($orderNumber, $accountNumber, $accountName, $bankName, $swiftCode, $address, $bankCountryCode, $amount, $currencyCode, $description);
Send via Stanbic
/** * Send money to a Stanbic bank account * * @param string $orderNumber - The order number * @param string $bankName - The name of the bank * @param string $accountNumber - The account number * @param string $accountName - The name of the account holder * @param string $bankCode - The bank code * @param float $amount - The amount to send * @param string $description - The description of the transaction */ $response = $mwaloni->sendStanbic($orderNumber, $bankName, $accountNumber, $accountName, $bankCode, $amount, $description)
Send via MoMo
/** * Send money via MTN Mobile Money * * @param string $orderNumber * @param string $accountNumber * @param float $amount * @param string $description * @return mixed */ $response = $mwaloni->sendMomo($orderNumber, $accountNumber, $amount, $description);
Query transaction status
/** * * Fetch the status of a transaction * * @param string $orderNumber * * @return mixed */ $response = $mwaloni->getStatus($orderNumber);
KPLC Postpaid
/** * * Send money to a KPLC postpaid account * * @param string $meterNumber - The meter number * @param string $accountNumber - The account number * @param string $msisdn - The phone number attached to the account * @param float $amount - The amount to send * * @return mixed */ $response = $mwaloni->kplcPostpaid($meterNumber, $accountNumber, $msisdn, $amount);
Perform contact lookup
/** * * Fetch the status of a transaction * * @param string $orderNumber * * @return mixed */ $response = $mwaloni->contactLookup($contact);
Send SMS
/** * * Send an SMS * * @param string $phone * @param string $message * * @return mixed */ $response = $mwaloni->sendSms($phone, $message);
akika/laravel-mwaloni 适用场景与选型建议
akika/laravel-mwaloni 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「digital」 「wallet」 「loop」 「mpesa」 「equity bank」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 akika/laravel-mwaloni 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 akika/laravel-mwaloni 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 akika/laravel-mwaloni 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Library for validation of cryptocoin wallets
A Laravel package to easily integrate Xendit payment gateway. It supports credit and debit cards, and e-wallet payments and custom invoices, queued notifications, webhook listeners and more.
Zoho Sign v1 API PHP Wrapper - PHP 7.4 Ready
Sendrill DB
Extends TYPO3 with a new content object XPATH for flexible querying of XML
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-09