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\SyliusAdyenPlugin; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusAdyenPlugin\Bridge\AdyenBridge; |
16
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
17
|
|
|
use Payum\Core\GatewayFactory; |
18
|
|
|
use BitBag\SyliusAdyenPlugin\Bridge\AdyenBridgeInterface; |
19
|
|
|
|
20
|
|
|
final class AdyenGatewayFactory extends GatewayFactory |
21
|
|
|
{ |
22
|
|
|
const FACTORY_NAME = 'adyen'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritDoc} |
26
|
|
|
*/ |
27
|
|
|
protected function populateConfig(ArrayObject $config): void |
28
|
|
|
{ |
29
|
|
|
$config->defaults([ |
30
|
|
|
'payum.factory_name' => self::FACTORY_NAME, |
31
|
|
|
'payum.factory_title' => 'Adyen', |
32
|
|
|
]); |
33
|
|
|
|
34
|
|
|
if (false === (bool)$config['payum.api']) { |
35
|
|
|
$config['payum.default_options'] = [ |
36
|
|
|
'skinCode' => '', |
37
|
|
|
'merchantAccount' => '', |
38
|
|
|
'hmacKey' => '', |
39
|
|
|
'environment' => AdyenBridgeInterface::TEST_ENVIRONMENT, |
40
|
|
|
'notification_method' => 'basic', |
41
|
|
|
'default_payment_fields' => [], |
42
|
|
|
'ws_user' => '', |
43
|
|
|
'ws_user_password' => '', |
44
|
|
|
]; |
45
|
|
|
$config->defaults($config['payum.default_options']); |
46
|
|
|
$config['payum.required_options'] = [ |
47
|
|
|
'skinCode', |
48
|
|
|
'merchantAccount', |
49
|
|
|
'hmacKey', |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
$config['payum.api'] = function (ArrayObject $config) { |
53
|
|
|
$config->validateNotEmpty($config['payum.required_options']); |
54
|
|
|
|
55
|
|
|
return new AdyenBridge( |
56
|
|
|
[ |
57
|
|
|
'skinCode' => $config['skinCode'], |
58
|
|
|
'merchantAccount' => $config['merchantAccount'], |
59
|
|
|
'hmacKey' => $config['hmacKey'], |
60
|
|
|
'notification_hmac' => $config['hmacNotification'], |
61
|
|
|
'environment' => $config['environment'], |
62
|
|
|
'notification_method' => $config['notification_method'], |
63
|
|
|
'default_payment_fields' => $config['default_payment_fields'], |
64
|
|
|
'ws_user' => $config['wsUser'], |
65
|
|
|
'ws_user_password' => $config['wsUserPassword'], |
66
|
|
|
], |
67
|
|
|
$config['payum.http_client'] |
68
|
|
|
); |
69
|
|
|
}; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|