-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab54f7f
commit f2047ec
Showing
1 changed file
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
); | ||
} | ||
} |