1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PayumTW\Collect; |
4
|
|
|
|
5
|
|
|
use Payum\Core\GatewayFactory; |
6
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
7
|
|
|
use PayumTW\Collect\Action\NotifyAction; |
8
|
|
|
use PayumTW\Collect\Action\StatusAction; |
9
|
|
|
use PayumTW\Collect\Action\CaptureAction; |
10
|
|
|
use PayumTW\Collect\Action\NotifyNullAction; |
11
|
|
|
use PayumTW\Collect\Action\ConvertPaymentAction; |
12
|
|
|
use PayumTW\Collect\Action\Api\CreateTransactionAction; |
13
|
|
|
use PayumTW\Collect\Action\Api\GetTransactionDataAction; |
14
|
|
|
|
15
|
|
View Code Duplication |
class CollectCvsGatewayFactory extends GatewayFactory |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
1 |
|
protected function populateConfig(ArrayObject $config) |
21
|
|
|
{ |
22
|
1 |
|
$config->defaults([ |
23
|
1 |
|
'payum.factory_name' => 'collect_cvs', |
24
|
1 |
|
'payum.factory_title' => 'Collect CVS', |
25
|
|
|
|
26
|
1 |
|
'payum.action.capture' => new CaptureAction(), |
27
|
1 |
|
'payum.action.notify' => new NotifyAction(), |
28
|
1 |
|
'payum.action.notify_null' => new NotifyNullAction(), |
29
|
1 |
|
'payum.action.status' => new StatusAction(), |
30
|
1 |
|
'payum.action.convert_payment' => new ConvertPaymentAction(), |
31
|
|
|
|
32
|
1 |
|
'payum.action.api.create_transaction' => new CreateTransactionAction(), |
33
|
1 |
|
'payum.action.api.get_transaction_data' => new GetTransactionDataAction(), |
34
|
1 |
|
]); |
35
|
|
|
|
36
|
1 |
|
if (false == $config['payum.api']) { |
37
|
1 |
|
$config['payum.default_options'] = [ |
38
|
1 |
|
'cust_id' => null, |
39
|
1 |
|
'cust_password' => null, |
40
|
1 |
|
'submit_type' => 'xml', |
41
|
1 |
|
'sandbox' => false, |
42
|
|
|
]; |
43
|
|
|
|
44
|
1 |
|
$config->defaults($config['payum.default_options']); |
45
|
1 |
|
$config['payum.required_options'] = ['cust_id', 'cust_password']; |
46
|
|
|
|
47
|
1 |
|
$config['payum.api'] = function (ArrayObject $config) { |
48
|
1 |
|
$config->validateNotEmpty($config['payum.required_options']); |
49
|
|
|
|
50
|
1 |
|
return new CollectCvsApi((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); |
51
|
|
|
}; |
52
|
1 |
|
} |
53
|
1 |
|
} |
54
|
|
|
} |
55
|
|
|
|