承接 kroshilin/yii2-yandex-kassa 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kroshilin/yii2-yandex-kassa

最新稳定版本:0.1.5

Composer 安装命令:

composer require kroshilin/yii2-yandex-kassa

包简介

Yandex kassa as Yii2 component

README 文档

README

Yandex kassa as Yii2 component

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kroshilin/yii2-yandex-kassa "*"

or add

"kroshilin/yii2-yandex-kassa": "*"

to the require section of your composer.json file.

Usage

First, add extension under the components section of your config.php

'components' => [
	...
	'yakassa' => [
		'class' => 'kroshilin\yakassa\YaKassa',
		'paymentAction' => YII_DEBUG ? 'https://demomoney.yandex.ru/eshop.xml' : 'https://money.yandex.ru/eshop.xml',
		'shopPassword' => 'password',
		'securityType' => 'MD5',
		'shopId' => '12345',
		'scId' => '123',
		'currency' => '10643'
	]
	...
]

Create controller and configure actions for checkOrder and paymentAviso yandex requests If need, you can use callable 'beforeResponse' property of actions, to define additional checks of Yandex's requests. Depends on result of 'beforeResponse' (true||false) action would generate corresponding response.

class YaKassaController extends Controller
{
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'order-check' => ['post'],
                    'payment-notification' => ['post'],
                ],
            ]
        ];
    }

    public function actions()
    {
        return [
            'order-check' => [
                'class' => 'app\components\yakassa\actions\CheckOrderAction',
                'beforeResponse' => function ($request) {
                    /**
                     * @var \yii\web\Request $request
                     */
                    $invoice_id = (int) $request->post('orderNumber');
		                Yii::warning("Кто-то хотел купить несуществующую подписку! InvoiceId: {$invoice_id}", Yii::$app->yakassa->logCategory);
                    return false;
                }
            ],
            'payment-notification' => [
                'class' => 'app\components\yakassa\actions\PaymentAvisoAction',
                'beforeResponse' => function ($request) {
                    /**
                     * @var \yii\web\Request $request
                     */
                }
            ],
        ];
    }
}

Using widget is simple. You have to implement 2 interfaces. First is OrderInterface for your order model, to pass sum and id to form. Second is Customer interface, to pass customer id and pre-fill phone and email if exist.

echo kroshilin\yakassa\widgets\Payment::widget([
    'order' => $order,
    'userIdentity' => Yii::$app->user->identity,
	'data' => ['customParam' => 'value'],
	'paymentType' => ['PC' => 'Со счета в Яндекс.Деньгах', 'AC' => 'С банковской карты']
]);

统计信息

  • 总下载量: 29.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-04-28