keenops/laravel-mpesa
Composer 安装命令:
composer require keenops/laravel-mpesa
包简介
Laravel wrapper for the Vodacom M-Pesa API, providing a seamless integration experience for Laravel applications
关键字:
README 文档
README
Engineered for seamless integration with the Vodacom M-Pesa OpenApi, it offers Laravel developers a streamlined pathway to execute customer-to-business transactions with ease and efficiency.
Installation
You can install the package via composer:
composer require keenops/laravel-mpesa:v0.0.1-beta.2
Runing the above command should also publish in a config directory a file named laravel-mpesa.php. If so didnt happen, publish the configuration files by running the command:
php artisan vendor:publish --tag=laravel-mpesa
Usage
Add Vodacom M-Pesa API credentials to a .env file. The credentials can be obtained here
MPESA_API_KEY= // get this from your mpesa developer/bussiness account
MPESA_PUBLIC_KEY= // get this from your mpesa developer/bussiness account
MPESA_ENVIROMENT= // options are: sandbox, openapi
MPESA_MARKET_COUNTRY= // options are: TZN, GHA, LES, DRC
MPESA_MARKET_CURRENCY= // options are: TZS, GHS, SLS, USD
Customer to Business Transaction
In your controller use like this
namespace App\Http\Controllers; use Keenops\Mpesa\Mpesa; class CheckoutController extends Controller { public function checkout() { return Mpesa::c2b( amount: '1000', customerNumber:'255746277553', serviceCode: '000000', reference: 'T12344Z', description: 'Three items', conversationId: '1e9b774d1da34af78412a498cbc28f43e' ); //this returns json response from M-Pesa API. Refer the link https://openapiportal.m-pesa.com/ for error and success codes } }
Business to Customer Transaction
In your controller:
namespace App\Http\Controllers; use Keenops\Mpesa\Mpesa; class PayoutController extends Controller { public function sendMoney() { return Mpesa::b2c( amount: '1000', customerNumber: '255746277553', serviceCode: '000000', reference: 'REF123456', description: 'Payment for services', conversationId: 'b2c12345678xyz' ); // Returns JSON response from M-Pesa API. } }
Business to Business Transaction
In your controller:
namespace App\Http\Controllers; use Keenops\Mpesa\Mpesa; class TransferController extends Controller { public function transfer() { return Mpesa::b2b( senderCode: '000001', receiverCode: '000002', amount: '50000', reference: 'B2BRef001', description: 'Supplier payment', conversationId: 'b2bconv112233' ); // Returns JSON response from M-Pesa API. } }
Reverse a Transaction
In your controller:
namespace App\Http\Controllers; use Keenops\Mpesa\Mpesa; class ReversalController extends Controller { public function reverseTransaction() { return Mpesa::reverse( amount: '1000', serviceProviderCode: '000000', conversationId: 'revConv778899', transactionId: 'Trans123456789' ); // Returns JSON response from M-Pesa API. } }
Query Transaction Status
In your controller:
namespace App\Http\Controllers; use Keenops\Mpesa\Mpesa; class StatusController extends Controller { public function checkStatus() { return Mpesa::transactionStatus( queryReference: 'REF123456', serviceProviderCode: '000000', conversationId: 'statusConv456789' ); // Returns JSON response from M-Pesa API. } }
Errors
Specific error codes may be displayed within parenthesis when send or receive operations fail. The most common of these error codes are specified in API documetation found on openapiportal.m-pesa.com
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email git@kimwalu.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
keenops/laravel-mpesa 适用场景与选型建议
keenops/laravel-mpesa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「keenops」 「laravel-mpesa」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 keenops/laravel-mpesa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 keenops/laravel-mpesa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 keenops/laravel-mpesa 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A package that helps integrate the Mpesa APIs to your Laravel Project
This is a wrapper around Mpesa APIs for Laravel.
A Laravel Mpesa integration package
A package that helps integrate the Mpesa APIs to your Laravel Project
A simple library for integrating with Safaricom's M-Pesa API
A simple mpesa package for laravel framework
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-16