-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWalleeGatewayFactory.php
executable file
·55 lines (48 loc) · 1.97 KB
/
WalleeGatewayFactory.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
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Instride\Payum\Wallee;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Service\TransactionCompletionService;
use Wallee\Sdk\Service\TransactionService;
use Instride\Payum\Wallee\Action\CaptureOffSiteAction;
use Instride\Payum\Wallee\Action\ConvertPaymentAction;
use Instride\Payum\Wallee\Action\NotifyAction;
use Instride\Payum\Wallee\Action\NotifyNullAction;
use Instride\Payum\Wallee\Action\StatusAction;
class WalleeGatewayFactory extends GatewayFactory
{
/**
* {@inheritDoc}
*/
protected function populateConfig(ArrayObject $config)
{
$config->defaults([
'payum.factory_name' => 'wallee',
'payum.factory_title' => 'Wallee E-Commerce',
'payum.action.capture' => new CaptureOffSiteAction(),
'payum.action.status' => new StatusAction(),
'payum.action.convert_payment' => new ConvertPaymentAction(),
'payum.action.notify' => new NotifyAction(),
'payum.action.notify_null' => new NotifyNullAction(),
]);
if (false == $config['payum.api']) {
$config['payum.default_options'] = [
'space_id' => '',
'user_id' => '',
'secret' => ''
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['space_id', 'user_id', 'secret'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$client = new ApiClient($config['user_id'], $config['secret']);
return new ApiWrapper(
new TransactionService($client),
new TransactionCompletionService($client),
$config['space_id']
);
};
}
}
}