Skip to content

Commit

Permalink
Add client factory
Browse files Browse the repository at this point in the history
  • Loading branch information
voronkovich committed Sep 19, 2024
1 parent ab54f7f commit f2047ec
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions src/ClientFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

declare(strict_types=1);

namespace Voronkovich\SberbankAcquiring;

/**
* Factory for creating API clients.
*
* @author Oleg Voronkovich <[email protected]>
*/
final class ClientFactory
{
/**
* Create a client for the Sberbank production environment.
*
* @param array $options Client options (username, password and etc.)
*
* @see https://ecomtest.sberbank.ru/doc#section/Obshaya-informaciya/Obrabotka-soobshenij
*
* @return Client instance
*/
public static function sberbank(array $options): Client
{
return new Client(
\array_merge(
[
'apiUri' => 'https://ecommerce.sberbank.ru',
'prefixDefault' => '/ecomm/gw/partner/api/v1/',
'ecom' => true,
],
$options
)
);
}

/**
* Create a client for the Sberbank testing environment.
*
* @param array $options Client options (username, password and etc.)
*
* @see https://ecomtest.sberbank.ru/doc#section/Obshaya-informaciya/Obrabotka-soobshenij
*
* @return Client instance
*/
public static function sberbankTest(array $options): Client
{
return new Client(
\array_merge(
[
'apiUri' => 'https://ecomtest.sberbank.ru',
'prefixDefault' => '/ecomm/gw/partner/api/v1/',
'ecom' => true,
],
$options
)
);
}

/**
* Create a client for the Alfabank production environment.
*
* @param array $options Client options (username, password and etc.)
*
* @see https://pay.alfabank.ru/ecommerce/instructions/merchantManual/pages/fz_index.html#koordinati_podkljuchenija
*
* @return Client instance
*/
public static function alfabank(array $options): Client
{
return new Client(
\array_merge(
[
'apiUri' => 'https://pay.alfabank.ru',
'prefixDefault' => '/payment/rest/',
'prefixSbpQr' => '/payment/rest/sbp/c2b/qr/dynamic/',
'prefixApple' => '/payment/applepay/',
'prefixGoogle' => '/payment/google/',
'prefixSamsung' => '/payment/samsung/',
],
$options
)
);
}

/**
* Create a client for the Alfabank testing environment.
*
* @param array $options Client options (username, password and etc.)
*
* @see https://ecomtest.sberbank.ru/doc#section/Obshaya-informaciya/Obrabotka-soobshenij
*
* @return Client instance
*/
public static function alfabankTest(array $options): Client
{
return new Client(
\array_merge(
[
'apiUri' => 'https://alfa.rbsuat.com',
'prefixDefault' => '/payment/rest/',
'prefixSbpQr' => '/payment/rest/sbp/c2b/qr/dynamic/',
'prefixApple' => '/payment/applepay/',
'prefixGoogle' => '/payment/google/',
'prefixSamsung' => '/payment/samsung/',
],
$options
)
);
}
}

0 comments on commit f2047ec

Please sign in to comment.