churakovmike/yii2-megakassa

Megakassa 的 Yii2 扩展

安装: 4

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

公开问题: 0

类型:yii2-extension

dev-master 2020-04-07 16:05 UTC

This package is auto-updated.

Last update: 2024-09-08 02:10:37 UTC


README

Yii2 megakassa 扩展。

Latest Stable Version License Maintainability

安装

可以通过以下命令使用 composer 安装扩展:

composer require churakovmike/yii2-megakassa

官方文档,包括可用方法和示例响应,可在支付系统网站上找到 https://megakassa.ru/api

组件配置

在 main-local.php 中添加以下行:

'components' => [
    'megakassaComponent' => [
        'class' => \ChurakovMike\Megakassa\MegaKassaComponent::class,
        'shopId' => XXXXXXX,
        'secretKey' => 'YYYYYYYYYY',
    ],
],

验证回调发送者

public function behaviors()
{
    return [
        ChurakovMike\Megakassa\filters\MegakassaAccessFilter::class,
     ]
}

使用表单

此表单允许上传和验证成功的支付数据。

$form = new ChurakovMike\Megakassa\forms\SuccessCallbackForm();
$form->setAttributes(\Yii::$app->request->post());
$form->validate();

使用组件

获取组件实例的方法与获取任何其他 Yii2 组件的方法相同。

/** @var MegaKassaComponent $component */
$component = \Yii::$app->megaKassaComponent;

可用方法

获取支付系统列表

$list = $component->getPaymentSystems();

检查余额

$balance = $component->getBalance();

执行付款

$withdraw = $component->createWithdraw(
    $methodId,      // ID платежной системы и вылюты
    $amount,        // Сумма к оплате
    $amountDue,     // Сумма к получению
    $currencyFrom,  // RUR
    $wallet,        // Номер карты получателя
    $comment,       // Комментарий к выплате
    $debug          // 0 или 1
);

付款信息

$withdrawDetail = $component->getWithdraw($withdrawId);

付款详情

$balance = $component->getWithdrawList($page);