Repository navigation
Expand file tree
/
Copy pathfactory.php
More file actions
59 lines (55 loc) · 1.93 KB
/
Copy pathfactory.php
File metadata and controls
59 lines (55 loc) · 1.93 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace GoPay;
/**
* @param array<string, mixed>|Config $userConfig
* @param array{cache?: Token\TokenCache, logger?: Http\Log\Logger} $userServices
*
* @return Payments
*/
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<string, mixed>|Config $userConfig
* @param array{cache?: Token\TokenCache, logger?: Http\Log\Logger} $userServices
*
* @return PaymentsSupercash
*/
function paymentsSupercash(array|Config $userConfig, array $userServices = []) // @phpstan-ignore class.notFound
{
$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']);
// Class was removed together with Supercash support, function is kept for BC
return new PaymentsSupercash($gopay, $auth); // @phpstan-ignore class.notFound
}
/** Symfony container needs class for factory :( */
class Api
{
/**
* @param array<string, mixed>|Config $config
* @param array{cache?: Token\TokenCache, logger?: Http\Log\Logger} $services
*
* @return Payments
*/
public static function payments(array|Config $config, array $services = [])
{
return payments($config, $services);
}
}