ssiva/yii2-mpesa-sdk
最新稳定版本:v1.1.2
Composer 安装命令:
composer require ssiva/yii2-mpesa-sdk
包简介
This package provides a seamless integration of M-PESA Daraja APIs in Yii2 applications
关键字:
README 文档
README
This package provides a seamless integration of M-PESA Daraja APIs in Yii2 applications
- B2C (Business to Customer)
- C2B (Customer to Business)
- B2B (Business to Business)
- Account Balance inquiries
- Transaction reversals queries
- Transaction status queries.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist ssiva/yii2-mpesa-sdk
or
composer require --prefer-dist ssiva/yii2-mpesa-sdk
or add
"ssiva/yii2-mpesa-sdk": "*"
to the require section of your composer.json file.
Configuration
Set up the config values as required
- Copy the file mpesa.php to
@app/config/mpesa.phpand set you config values. - Add the component configuration to
config/web.phpas below- Require the copied config file
$mpesa = require __DIR__.'/mmpesa.php';
- Add the required value to the components array
'mpesaDaraja' => $mpesa,
- Require the copied config file
The library is now ready for use.
Usage Examples
<?php namespace YOURNAMESPACE; class CheckoutController extends Controller { public function actionCheckout( $mpesaDaraja = Yii::$app->mpesaDaraja->getDaraja(); // authenticate $mpesaDaraja->authenticate(); // STK Push $stkParams = [ 'Amount' => '2', 'PartyA' => '2547XXXXXXXX', 'PhoneNumber' => '2547XXXXXXXX', 'AccountReference' => '13', 'TransactionDesc' => 'Shopping', ]; $mpesaDaraja->stkPush($stkParams); // stk push status query $stkQueryParams = [ 'CheckoutRequestID' => "ws_CO_290320231617432767XXXXXXXX", ]; $mpesaDaraja->stkPushQuery($stkQueryParams); // transaction status query $statusParams = [ 'Remarks' => "Status test for RCC3LAPCEL", "TransactionID" => "RCC3LAPCEL", "Occasion" => "Optional Value for Occasion" ]; $mpesaDaraja->transactionStatus($statusParams); } }
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-14