From 5dc3c8ad82ec84f1537357a7a0f80d3f0b23bac2 Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Fri, 11 Oct 2024 17:14:06 +0300 Subject: [PATCH] Add support for YooKassa --- README.md | 5 ++++- src/ClientFactory.php | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7734ffa..e0b47fc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Total Downloads](https://poser.pugx.org/voronkovich/sberbank-acquiring-client/downloads)](https://packagist.org/packages/voronkovich/sberbank-acquiring-client/stats) [![License](https://poser.pugx.org/voronkovich/sberbank-acquiring-client/license)](./LICENSE) -PHP client for [Sberbank](https://ecomtest.sberbank.ru/doc) and [Alfabank](https://pay.alfabank.ru/ecommerce/instructions/merchantManual/pages/index/rest.html) REST API. +PHP client for [Sberbank](https://ecomtest.sberbank.ru/doc), [Alfabank](https://pay.alfabank.ru/ecommerce/instructions/merchantManual/pages/index/rest.html) and [YooKassa](https://yoomoney.ru/i/forms/yc-program-interface-api-sberbank.pdf) REST APIs. ## Requirements @@ -39,6 +39,9 @@ $client = ClientFactory::alfabank(['userName' => 'username', 'password' => 'pass // Alfabank testing environment $client = ClientFactory::alfabankTest(['userName' => 'username', 'password' => 'password']); + +// YooKassa production environment +$client = ClientFactory::yookassa(['userName' => 'username', 'password' => 'password']); ``` Alternatively you can use an authentication `token`: diff --git a/src/ClientFactory.php b/src/ClientFactory.php index 06c24c9..5372058 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -108,4 +108,26 @@ public static function alfabankTest(array $options): Client ) ); } + + /** + * Create a client for the YooKassa production environment. + * + * @param array $options Client options (username, password and etc.) + * + * @see https://yoomoney.ru/i/forms/yc-program-interface-api-sberbank.pdf + * + * @return Client instance + */ + public static function yookassa(array $options): Client + { + return new Client( + \array_merge( + [ + 'apiUri' => 'https://3dsec-payments.yookassa.ru', + 'prefixDefault' => '/payment/rest/', + ], + $options + ) + ); + } }