PHPackages                             orkhanahmadov/yandex-checkout - 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. orkhanahmadov/yandex-checkout

ActiveLibrary[Payment Processing](/categories/payments)

orkhanahmadov/yandex-checkout
=============================

Easy and complete YooKassa (previously Yandex Checkout) integration for Laravel

1.2.0(4y ago)45.3k2MITPHPPHP ^7.3|^8.0

Since Nov 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/orkhanahmadov/yandex-checkout)[ Packagist](https://packagist.org/packages/orkhanahmadov/yandex-checkout)[ Docs](https://github.com/orkhanahmadov/yandex-checkout)[ GitHub Sponsors](https://github.com/orkhanahmadov)[ RSS](/packages/orkhanahmadov-yandex-checkout/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

[![](https://camo.githubusercontent.com/f86e728a6df9ba9f7c0bf163dc450dccf5e1110bef92a6d0f72c0188ee77dd46/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f59616e646578253230436865636b6f75742e706e673f7468656d653d6c69676874267061636b6167654e616d653d6f726b68616e61686d61646f7625324679616e6465782d636865636b6f7574267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d596f6f4d6f6e65792b25323859616e6465782b436865636b6f75742532392b696e746567726174696f6e2b7061636b6167652b666f722b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d6372656469742d63617264267769647468733d32303026686569676874733d323030)](https://camo.githubusercontent.com/f86e728a6df9ba9f7c0bf163dc450dccf5e1110bef92a6d0f72c0188ee77dd46/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f59616e646578253230436865636b6f75742e706e673f7468656d653d6c69676874267061636b6167654e616d653d6f726b68616e61686d61646f7625324679616e6465782d636865636b6f7574267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d596f6f4d6f6e65792b25323859616e6465782b436865636b6f75742532392b696e746567726174696f6e2b7061636b6167652b666f722b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d6372656469742d63617264267769647468733d32303026686569676874733d323030)

[![Latest Stable Version](https://camo.githubusercontent.com/e95ff78c1701c08bdc7b29604d8639c5ad838b6c2893f03b000e8c788783eb81/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f79616e6465782d636865636b6f75742f762f737461626c65)](https://packagist.org/packages/orkhanahmadov/yandex-checkout)[![Latest Unstable Version](https://camo.githubusercontent.com/23ecdf36a0ba9c30750329b3ea433343abf64e7d69c9998ed4d025499f31af2b/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f79616e6465782d636865636b6f75742f762f756e737461626c65)](https://packagist.org/packages/orkhanahmadov/yandex-checkout)[![Total Downloads](https://camo.githubusercontent.com/57afca035f5600758cddfe1df84abd2ce0fca62dc410e89bc16180374d2ca343/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726b68616e61686d61646f762f79616e6465782d636865636b6f7574)](https://packagist.org/packages/orkhanahmadov/yandex-checkout)[![GitHub license](https://camo.githubusercontent.com/a8760a86b74f69c54c0dd9c1241c4d2a0cab7caa75da5afda1f694bed1740f4a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f726b68616e61686d61646f762f79616e6465782d636865636b6f75742e737667)](https://github.com/orkhanahmadov/yandex-checkout/blob/master/LICENSE.md)

[![Build Status](https://camo.githubusercontent.com/6f7b69ac5b9c1d6734c15d54e38aa10bc008b2819d09626aca223dc900053db4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f726b68616e61686d61646f762f79616e6465782d636865636b6f75742e737667)](https://travis-ci.org/orkhanahmadov/yandex-checkout)[![Test Coverage](https://camo.githubusercontent.com/da30b677dd94c569e5888693b8e7432d17e6346452964cc84a9dd67c9fa4caf2/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f63326137616231323337316563313036626131332f746573745f636f766572616765)](https://codeclimate.com/github/orkhanahmadov/yandex-checkout/test_coverage)[![Maintainability](https://camo.githubusercontent.com/4e721cb8aa1af5edc892b9a24e8a5cf66b498dbf2e31ace035386097613bb54d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f63326137616231323337316563313036626131332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/orkhanahmadov/yandex-checkout/maintainability)[![Quality Score](https://camo.githubusercontent.com/0b84c8e67f333a70dfec718c10486fb0d1cb302274d7273ac688bd9a607568e9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f726b68616e61686d61646f762f79616e6465782d636865636b6f75742e737667)](https://scrutinizer-ci.com/g/orkhanahmadov/yandex-checkout)[![StyleCI](https://camo.githubusercontent.com/8972696bd08312fba1db58e1c2915a091470f32c8fd0a616928b622ef750763b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3331313933303830322f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/311930802?branch=master)

Easy and complete YooKassa (previously Yandex Checkout) integration for Laravel

Todo
====

[](#todo)

- Test coverage

Table of Contents
=================

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Models](#models)
5. [Commands](#commands)
6. [Events](#events)
7. [Configuration](#configuration)

Requirements
------------

[](#requirements)

- PHP **7.3** or above
- Laravel **6** or above

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

[](#installation)

You can install the package via composer:

```
composer require orkhanahmadov/yandex-checkout
```

Run this command to publish required migration file:

```
php artisan vendor:publish --provider="Orkhanahmadov\YandexCheckout\YandexCheckoutServiceProvider" --tag=migrations
```

Usage
-----

[](#usage)

First, set Yandex Checkout shop ID and secret key in `.env` file. You can get these from [YooMoney merchant page](https://yookassa.ru/my).

```
YANDEX_CHECKOUT_SHOP_ID=
YANDEX_CHECKOUT_SECRET_KEY=

```

To use Yandex Checkout service you need instance of `Orkhanahmadov\YandexCheckout\YandexCheckoutService`. You can instantiate this class using Laravel's service container, for example by injecting to your controller

```
use Orkhanahmadov\YandexCheckout\YandexCheckoutService;

class MyController
{
    public function index(YandexCheckoutService $yandexCheckout)
    {
        //
    }
}
```

Or you can use Laravel's service resolver to create instance of the class:

```
use Orkhanahmadov\YandexCheckout\YandexCheckoutService;

class MyClass
{
    public function doSomething()
    {
        $yandexCheckout = app(YandexCheckoutService::class);
        //
    }
}
```

### Available methods:

[](#available-methods)

### `createPayment()`

[](#createpayment)

Creates new payment based on passed credentials and accepts 2 arguments:

- `Model` - Eloquent model payment is associated
- `Payment request` - Payment request that contains amount, currency, etc information

```
$product = Product::first();
$yandexCheckout = app(YandexCheckoutService::class);
$paymentRequest = CreatePaymentRequest::builder()->build([
    'amount' => [
        'value' => 49.99,
        'currency' => 'RUB',
    ],
    'confirmation' => [
        'type' => 'redirect',
        'return_url' => 'https://example.com',
    ],
    'capture' => true,
    'description' => 'Payment for product: ' . $product->id,
]);
$yandexCheckout->createPayment($product, $paymentRequest);
```

Method returns created instance of `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` model.

You should use `$confirmation_url` property to get unique payment URL and redirect user to this URL to start payment.

### `paymentInfo()`

[](#paymentinfo)

Gets information on previously created payment. Accepts single argument:

- `Payment` - This is Yandex Checkout's payment id as a string, or instance of previously created `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` model.

```
$product = Product::first();
$yandexCheckout = app(YandexCheckoutService::class);
$payment = $yandexCheckout->createPayment($product, ...);

$paymentInfo = $yandexCheckout->paymentInfo($payment);
// or
$paymentInfo = $yandexCheckout->paymentInfo('1234-ABCD-5678');
```

Method returns updated instance of `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` model with Yandex Checkout's response.

Models
------

[](#models)

Package ships with `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` Eloquent model. Model stores following information for each payment:

- `payment_id` - string, unique payment key provided by Yandex Checkout
- `status` - string, payment status code
- `response` - array, serialized checkout object

Besides usual Eloquent functionality this model also has specific accessors, scopes and relationship abilities which you can utilize.

### Accessors

[](#accessors)

- `succeeded` - Returns `true` if payment marked as "succeeded", `false` otherwise
- `paid` - Returns `true` if checkout is paid, `false` otherwise
- `confirmation_url` - Returns "confirmation URL" which should be used to start payment
- `cancellation_reason` - Returns payment's cancellation/fail reason. Returns `null` when payment is successful or not started yet

### Scopes

[](#scopes)

- `succeeded()` - Filters "succeeded" payments only
- `pending()` - Filters "pending" payments only. Pending payments are the payments that has status other than "succeeded" or "canceled".

### Relationship

[](#relationship)

You can make any existing Eloquent model "payable" and attach Yandex Checkouts to it. Use `Orkhanahmadov\YandexCheckout\Traits\HandlesYandexCheckout` trait in your existing model to establish direct model relationship.

```
use Illuminate\Database\Eloquent\Model;
use Orkhanahmadov\YandexCheckout\Traits\HandlesYandexCheckout;

class Product extends Model
{
    use HandlesYandexCheckout;
}
```

Now `Product` model has direct relationship with Yandex Checkouts. By using `HandlesYandexCheckout` your model also gets access to payment related relationships and payment methods.

#### `createPayment()`

[](#createpayment-1)

```
$product = Product::first();

$paymentRequest = CreatePaymentRequest::builder()->build([
    'amount' => [
      'value' => 49.99,
      'currency' => 'RUB',
    ],
    'confirmation' => [
      'type' => 'redirect',
      'return_url' => 'https://example.com',
    ],
    'capture' => true,
    'description' => 'Payment for product: ' . $product->id,
]);
$product->createPayment($paymentRequest);
```

#### `yandexCheckouts()`

[](#yandexcheckouts)

Eloquent relationship method. Return all related Yandex Checkouts.

```
$product = Product::first();
$product->yandexCheckouts; // returns collection of related Yandex Checkouts
$product->yandexCheckouts()->where('payment_id', '123-ABC-456'); // use it as regular Eloquent relationship
$product->yandexCheckouts()->pending(); // use scopes on YandexCheckout model
```

Commands
--------

[](#commands)

Package ships with artisan command for checking payment results.

```
php artisan yandex-checkout:check
```

Executing above command will loop through all "pending" checkouts and update their models.

Command also accepts payment ID as an argument to check single checkout result.

```
php artisan yandex-checkout:check 1234-ABCD-5678
```

You can set up a Cron job schedule to frequently check all "pending" checkout.

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('yandex-checkout:check')->everyMinute();
}
```

Events
------

[](#events)

Package ships with Laravel events which gets fired on specific conditions.

Available event classes:

- `Orkhanahmadov\YandexCheckout\Events\CheckoutCreated` - gets fired when new checkout is created
- `Orkhanahmadov\YandexCheckout\Events\CheckoutSucceeded` - gets fired when payment status changes to "succeeded"
- `Orkhanahmadov\YandexCheckout\Events\CheckoutCanceled` - gets fired when payment status changes to "canceled"
- `Orkhanahmadov\YandexCheckout\Events\CheckoutChecked` - gets fired when payment information is checked

Each event receives instance of `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` Eloquent model as public `$yandexCheckout` property.

You can set up event listeners to trigger when specific payment event gets fired.

```
protected $listen = [
    'Orkhanahmadov\YandexCheckout\Events\CheckoutSucceeded' => [
        'App\Listeners\DispatchOrder',
        'App\Listeners\SendInvoice',
    ],
];
```

Configuration
-------------

[](#configuration)

Run this command to publish package config file:

```
php artisan vendor:publish --provider="Orkhanahmadov\YandexCheckout\YandexCheckoutServiceProvider" --tag=config
```

Config file contains following settings:

- `shop_id` - Defines Yandex Checkout's "shop ID", defaults to `.env` variable
- `secret_key` - Defines Yandex Checkout's "secret key", defaults to `.env` variable
- `table_name` - Defines name for Yandex Checkout payments database table. Default: "yandex\_checkouts"
- `events` - Payment events related settings
    - `created` - "Checkout created" event class. By default uses `Orkhanahmadov\YandexCheckout\Events\CheckoutCreated` class
    - `succeeded` - "Checkout succeeded" event class. By default uses `Orkhanahmadov\YandexCheckout\Events\CheckoutSucceeded` class
    - `canceled` - "Checkout canceled" event class. By default uses `Orkhanahmadov\YandexCheckout\Events\CheckoutCanceled` class
    - `checked` - "Checkout checked" event class. By default uses `Orkhanahmadov\YandexCheckout\Events\CheckoutChecked` class

If you want to use your own event class for specific payment event you can replace class namespace with your class namespace. Each checkout event receives instance of `Orkhanahmadov\YandexCheckout\Models\YandexCheckout` Eloquent model. Because of this, make sure you add payment model as dependency to your event class constructor signature or you can extend `Orkhanahmadov\YandexCheckout\Events\CheckoutEvent` class which already has payment model as dependency.

Setting specific payment event to `null` disables that event.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Orkhan Ahmadov](https://github.com/orkhanahmadov)
- [LinksDerIsar](https://www.linksderisar.com)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~227 days

Total

3

Last Release

1553d ago

PHP version history (2 changes)1.0.0PHP ^7.3

1.1.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c82e54991e0224fdc49d34ee60d0cfce5ea0cca1cd59771155e3b372d1fa1d11?d=identicon)[orkhanahmadov](/maintainers/orkhanahmadov)

---

Top Contributors

[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (40 commits)")

---

Tags

yandexyookassayoomoneylaravel-paymentyandex-checkout

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orkhanahmadov-yandex-checkout/health.svg)

```
[![Health](https://phpackages.com/badges/orkhanahmadov-yandex-checkout/health.svg)](https://phpackages.com/packages/orkhanahmadov-yandex-checkout)
```

###  Alternatives

[laravel/pennant

A simple, lightweight library for managing feature flags.

57311.1M53](/packages/laravel-pennant)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[bref/laravel-bridge

An advanced Laravel integration for Bref, including Octane support.

3384.1M11](/packages/bref-laravel-bridge)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M178](/packages/illuminate-broadcasting)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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