Skip to content

Commit

Permalink
Add support for YooKassa
Browse files Browse the repository at this point in the history
  • Loading branch information
voronkovich committed Oct 11, 2024
1 parent 459828f commit 5dc3c8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`:
Expand Down
22 changes: 22 additions & 0 deletions src/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
}
}

0 comments on commit 5dc3c8a

Please sign in to comment.