2017 © Pedro Peláez
 

yii2-extension yii2-yandex-kassa

Yandex kassa as Yii2 component

image

kroshilin/yii2-yandex-kassa

Yandex kassa as Yii2 component

  • Friday, December 16, 2016
  • by kroshilin
  • Repository
  • 2 Watchers
  • 27 Stars
  • 4,135 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 7 Versions
  • 8 % Grown

The README.md

Yandex Kassa

Yandex kassa as Yii2 component, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

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

or add, (*4)

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

to the require section of your composer.json file., (*5)

Usage

First, add extension under the components section of your config.php, (*6)

'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., (*7)

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., (*8)

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

The Versions

16/12 2016

dev-master

9999999-dev

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

16/12 2016

0.1.5

0.1.5.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

17/05 2016

0.1.4

0.1.4.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

05/05 2016

0.1.3

0.1.3.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

05/05 2016

0.1.2

0.1.2.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

29/04 2016

0.1.1

0.1.1.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa

28/04 2016

0.1.0

0.1.0.0

Yandex kassa as Yii2 component

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Kroshilin

extension yii2 yandex yandex-money yandex-kassa