|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file has been created by developers from BitBag. |
|
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
|
6
|
|
|
* another great project. |
|
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
|
8
|
|
|
* an email on [email protected]. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace BitBag\SyliusQuadPayPlugin; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface; |
|
16
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
|
17
|
|
|
use Payum\Core\GatewayFactory; |
|
18
|
|
|
|
|
19
|
|
|
final class QuadPayGatewayFactory extends GatewayFactory |
|
20
|
|
|
{ |
|
21
|
|
|
public const FACTORY_NAME = 'quadpay'; |
|
22
|
|
|
public const CURRENCIES_AVAILABLE = ['USD']; |
|
23
|
|
|
|
|
24
|
|
|
protected function populateConfig(ArrayObject $config): void |
|
25
|
|
|
{ |
|
26
|
|
|
$config->defaults([ |
|
27
|
|
|
'payum.factory_name' => self::FACTORY_NAME, |
|
28
|
|
|
'payum.factory_title' => 'QuadPay', |
|
29
|
|
|
'payum.http_client' => '@bitbag_sylius_quadpay_plugin.quadpay_api_client', |
|
30
|
|
|
]); |
|
31
|
|
|
|
|
32
|
|
|
if (false === (bool) $config['payum.api']) { |
|
33
|
|
|
$config['payum.default_options'] = [ |
|
34
|
|
|
'clientId' => null, |
|
35
|
|
|
'clientSecret' => null, |
|
36
|
|
|
'apiEndpoint' => null, |
|
37
|
|
|
'authTokenEndpoint' => null, |
|
38
|
|
|
'apiAudience' => null, |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
$config->defaults($config['payum.default_options']); |
|
42
|
|
|
|
|
43
|
|
|
$config['payum.required_options'] = [ |
|
44
|
|
|
'clientId', |
|
45
|
|
|
'clientSecret', |
|
46
|
|
|
'apiEndpoint', |
|
47
|
|
|
'authTokenEndpoint', |
|
48
|
|
|
'apiAudience', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$config['payum.api'] = function (ArrayObject $config) { |
|
52
|
|
|
$config->validateNotEmpty($config['payum.required_options']); |
|
53
|
|
|
|
|
54
|
|
|
/** @var QuadPayApiClientInterface $quadPayApiClient */ |
|
55
|
|
|
$quadPayApiClient = $config['payum.http_client']; |
|
56
|
|
|
|
|
57
|
|
|
$quadPayApiClient->setConfig( |
|
58
|
|
|
$config['clientId'], |
|
59
|
|
|
$config['clientSecret'], |
|
60
|
|
|
$config['apiEndpoint'], |
|
61
|
|
|
$config['authTokenEndpoint'], |
|
62
|
|
|
$config['apiAudience'] |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
return $quadPayApiClient; |
|
66
|
|
|
}; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|