-
Notifications
You must be signed in to change notification settings - Fork 38
/
factory.php
44 lines (40 loc) · 1.4 KB
/
factory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace GoPay;
function payments(array|Config $userConfig, array $userServices = [])
{
$config = Config::parseUserConfig($userConfig);
$services = $userServices + [
'cache' => new Token\InMemoryTokenCache,
'logger' => new Http\Log\NullLogger
];
$browser = new Http\JsonBrowser($services['logger'], $config['timeout']);
$gopay = new GoPay($config, $browser);
$auth = new Token\CachedOAuth(new OAuth2($gopay), $services['cache']);
return new Payments($gopay, $auth);
}
/**
* @deprecated Supercash payments are no longer supported
* @param array|Config $userConfig
* @param array $userServices
* @return PaymentsSupercash
*/
function paymentsSupercash(array|Config $userConfig, array $userServices = [])
{
$config = Config::parseUserConfig($userConfig);
$services = $userServices + [
'cache' => new Token\InMemoryTokenCache,
'logger' => new Http\Log\NullLogger
];
$browser = new Http\JsonBrowser($services['logger'], $config['timeout']);
$gopay = new GoPay($config, $browser);
$auth = new Token\CachedOAuth(new OAuth2($gopay), $services['cache']);
return new PaymentsSupercash($gopay, $auth);
}
/** Symfony container needs class for factory :( */
class Api
{
public static function payments(array|Config $config, array $services = [])
{
return payments($config, $services);
}
}