-
Notifications
You must be signed in to change notification settings - Fork 2
/
TcomPayWayOffsiteGatewayFactory.php
68 lines (59 loc) · 2.37 KB
/
TcomPayWayOffsiteGatewayFactory.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
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Locastic\TcomPayWayPayumBundle;
use Locastic\TcomPayWay\AuthorizeForm\Model\Payment as PaymentOffsite;
use Locastic\TcomPayWayPayumBundle\Action\CaptureOffsiteAction;
use Locastic\TcomPayWayPayumBundle\Action\ConvertPaymentAction;
use Locastic\TcomPayWayPayumBundle\Action\StatusAction;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
class TcomPayWayOffsiteGatewayFactory extends GatewayFactory
{
/**
* {@inheritDoc}
*/
protected function populateConfig(ArrayObject $config)
{
$config->defaults([
'payum.tcompayway.template.capture' => '@LocasticTcomPayWayOffsite/capture.html.twig',
'payum.factory_name' => 'tcompayway_offsite',
'payum.factory_title' => 'TcomPayWay Offsite',
'payum.action.capture' => function (ArrayObject $config) {
return new CaptureOffsiteAction($config['payum.tcompayway.template.capture']);
},
'payum.action.status' => new StatusAction(),
'payum.action.fill_order_details' => new ConvertPaymentAction(),
]);
if (false == $config['payum.api']) {
$config['payum.default_options'] = array(
'shop_id' => '',
'secret_key' => '',
'authorization_type' => '0',
'sandbox' => true,
'disable_installments' => '1',
);
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = array(
'shop_id',
'secret_key',
);
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$api = new PaymentOffsite(
$config['shop_id'],
$config['secret_key'],
null,
null,
$config['authorization_type'],
null,
null,
$config['sandbox']
);
$api->setPgwDisableInstallments($config['disable_installments']);
return $api;
};
}
$config['payum.paths'] = array_replace([
'LocasticTcomPayWayOffsite' => __DIR__.'/Resources/views/TcomPayWay/Offsite',
], $config['payum.paths'] ?: []);
}
}