-
Notifications
You must be signed in to change notification settings - Fork 2
/
AlphaBankGatewayFactory.php
88 lines (78 loc) · 3.19 KB
/
AlphaBankGatewayFactory.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Dnna\Payum\AlphaBank;
use Dnna\Payum\AlphaBank\Action\Api\RequestRefundAction;
use Dnna\Payum\AlphaBank\Action\ConvertPaymentAction;
use Dnna\Payum\AlphaBank\Action\CaptureAction;
use Dnna\Payum\AlphaBank\Action\RefundAction;
use Dnna\Payum\AlphaBank\Action\StatusAction;
use Dnna\Payum\AlphaBank\Action\Api\CreateChargeAction;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
class AlphaBankGatewayFactory extends GatewayFactory
{
/**
* {@inheritDoc}
*/
protected function populateConfig(ArrayObject $config): void
{
$config->defaults(
[
'payum.factory_name' => 'alphabank',
'payum.factory_title' => 'Alpha Bank',
'payum.template.create_charge' => '@DnnaPayumAlphaBank/Action/create_charge.html.twig',
'payum.action.capture' => new CaptureAction(),
'payum.action.refund' => new RefundAction(),
'payum.action.create_charge' => function (ArrayObject $config) {
if ($config['sandbox'] == true) {
$actionUrl = 'https://ecommerce-test.cardlink.gr/vpos/shophandlermpi';
} else {
$actionUrl = 'https://www.alphaecommerce.gr/vpos/shophandlermpi';
}
return new CreateChargeAction(
$config['payum.template.create_charge'],
$actionUrl,
$config['mid'],
$config['sharedSecretKey']
);
},
'payum.action.request_refund' => function (ArrayObject $config) {
return new RequestRefundAction(
$config['mid'],
$config['sharedSecretKey']
);
},
'payum.action.convert_payment' => function (ArrayObject $config) {
return new ConvertPaymentAction(
$config['sandbox'],
$config['useMasterPass'],
$config['lang'],
$config['cssUrl']
);
},
'payum.action.status' => new StatusAction(),
]
);
if (false == $config['payum.api']) {
$config['payum.default_options'] = array(
'mid' => '',
'sharedSecretKey' => '',
'useMasterPass' => false,
'lang' => 'el',
'cssUrl' => '',
'sandbox' => true,
);
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = [];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
return new Api((array)$config, $config['payum.http_client'], $config['httplug.message_factory']);
};
}
$config['payum.paths'] = array_replace(
[
'DnnaPayumAlphaBank' => __DIR__ . '/Resources/views',
],
$config['payum.paths'] ?: []
);
}
}