9951 explained code solutions for 126 technologies

php-omnipayHow can I use PHP Omnipay to process Yandex payments?

PHP Omnipay is a payment processing library that allows developers to easily integrate payment processing into their applications. It supports a wide range of payment gateways, including Yandex.

To use PHP Omnipay to process Yandex payments, first install the library via Composer:

composer require league/omnipay omnipay/yandex

Next, create an instance of the Omnipay gateway:

use Omnipay\Omnipay;

$gateway = Omnipay::create('Yandex');

Then, set the gateway parameters, such as the shop ID and secret key:


Finally, process the payment:

$response = $gateway->purchase([
    'amount' => '10.00',
    'currency' => 'RUB',
    'returnUrl' => 'https://example.com/return',
    'cancelUrl' => 'https://example.com/cancel',

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
} else {
    // payment failed
    echo $response->getMessage();

This code will send the purchase request to the Yandex gateway and handle the response. If the request is successful, the user will be redirected to the Yandex payment page.

Helpful links

Edit this code on GitHub