PHPackages                             kllakk/yii2-yandex-kassa-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. kllakk/yii2-yandex-kassa-api

ActiveYii2-extension[Payment Processing](/categories/payments)

kllakk/yii2-yandex-kassa-api
============================

This extensions allows you obtain money from users by new Yandex.Kassa's API

0.1(8y ago)09MITPHP

Since Feb 7Pushed 5y agoCompare

[ Source](https://github.com/kllakk/yii2-yandex-kassa-api)[ Packagist](https://packagist.org/packages/kllakk/yii2-yandex-kassa-api)[ RSS](/packages/kllakk-yii2-yandex-kassa-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Yandex.Kassa API extension for Yii2
===================================

[](#yandexkassa-api-extension-for-yii2)

This extension allows you to obtain money from users by new [Yandex.Kassa's API](https://kassa.yandex.ru/docs/checkout-api/).
It was designed to be pretty simple to use so you don't have to deep down into Yandex.Kassa's workflow.

**This extension strongly in beta, so feel free to send pull requests and fix bugs**

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist kllakk/yii2-yandex-kassa-api "*"

```

or add

```
"kllakk/yii2-yandex-kassa-api": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, you have to follow next few steps:

### 1. Add extension into your configuration file

[](#1-add-extension-into-your-configuration-file)

```
'components' => [
    ...
    'kassa' => [
        'class' => 'kllakk\YandexKassaAPI\YandexKassaAPI',
        'returnUrl' => '',
        'shopId' => '',
        'key' => '',
    ],
```

**returnUrl** - User will get there after payment has got succeeded
**shopId** - Your shop id (from Yandex)
**key** - Your secret key (from Yandex)
**currency** - Currency obviously (RUB by default)

### 2. Implement OrderInterface in your Order model

[](#2-implement-orderinterface-in-your-order-model)

```
class Orders extends Model implements OrderInterface {

    ...

    public function setInvoiceId($invoiceId) {
        $this->invoice_id = $invoiceId;
    }

    public function getInvoiceId() {
        return $this->invoice_id;
    }

    public function getPaymentAmount() {
        return $this->amount;
    }

    public function findByInvoiceId($invoiceId) {
        return self::find()->where(['invoice_id' => $invoiceId]);
    }

    public function findById($id) {
        return self::findOne($id);
    }

}
```

### 3. Add new actions to your controller

[](#3-add-new-actions-to-your-controller)

```
 public function actions() {
        return [
            'create-payment' => [
                'class'=>'kllakk\YandexKassaAPI\actions\CreatePaymentAction',
                'orderClass' => Orders::className(),
                'beforePayment' => function($order) {
                    return $order->status == Orders::STATUS_NEW;
                }
            ],
            'notify' => [
                'class'=>'kllakk\YandexKassaAPI\actions\ConfirmPaymentAction',
                'orderClass' => Orders::className(),
                'beforeConfirm' => function($payment, $order) {
                    $order->status = Orders::STATUS_PAID;
                    return $order->save();
                }
            ]
        ];
    }
```

Here we have two callbacks.

**beforePayment** checks is our order okay. You can provide some logic there and **return false** if something went wrong and you wanna cancel your payment.

The second one is **beforeConfirm**. It executes when user successfully paid your payment and now you have to confirm this order, send sms notification, etc. Be careful, if you **return false** is this callback, payment won't be confirmed and user will receive his money back in a few hours.

### 4. Config your Yandex.Kassa notification page

[](#4-config-your-yandexkassa-notification-page)

[![Settings page](https://camo.githubusercontent.com/82fa832ec538f52e41d5d90067f8f5a0ad87a4c57f15c9f325d597dd1b771099/68747470733a2f2f79617374617469632e6e65742f646f6363656e7465722f696d616765732f737570706f72742e79616e6465782e72752f72752f636865636b6f75742f667265657a652f7477684f4669504c714d4c303233354f2d58736d7956397a744d382e706e67)](https://camo.githubusercontent.com/82fa832ec538f52e41d5d90067f8f5a0ad87a4c57f15c9f325d597dd1b771099/68747470733a2f2f79617374617469632e6e65742f646f6363656e7465722f696d616765732f737570706f72742e79616e6465782e72752f72752f636865636b6f75742f667265657a652f7477684f4669504c714d4c303233354f2d58736d7956397a744d382e706e67)

Set your notification page Url as same as you used in your controller.
For example, if you added your actions to SiteController, it would be
Don't forget about **SSL** - Yandex sends notifications only through it.

### 5. Redirect user to payment action afterwards

[](#5-redirect-user-to-payment-action-afterwards)

```
if ($order->payment_type == $order::PAYTYPE_ONLINE) {
    return $this->redirect(['order/create-payment', 'id' =>$order->id]);
} else {
    return $this->redirect(['order/success']);
}
```

You have to pass **$id** to the action so it could find your model by **findById** method.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3016d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5989993?v=4)[kllakk](/maintainers/kllakk)[@kllakk](https://github.com/kllakk)

---

Top Contributors

[![Maclay74](https://avatars.githubusercontent.com/u/5504685?v=4)](https://github.com/Maclay74 "Maclay74 (8 commits)")[![yakovlef](https://avatars.githubusercontent.com/u/4018068?v=4)](https://github.com/yakovlef "yakovlef (1 commits)")

---

Tags

yii2extension

### Embed Badge

![Health badge](/badges/kllakk-yii2-yandex-kassa-api/health.svg)

```
[![Health](https://phpackages.com/badges/kllakk-yii2-yandex-kassa-api/health.svg)](https://phpackages.com/packages/kllakk-yii2-yandex-kassa-api)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
