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\CancelAction; |
8
|
|
|
use PayumTW\Collect\Action\NotifyAction; |
9
|
|
|
use PayumTW\Collect\Action\RefundAction; |
10
|
|
|
use PayumTW\Collect\Action\StatusAction; |
11
|
|
|
use PayumTW\Collect\Action\CaptureAction; |
12
|
|
|
use PayumTW\Collect\Action\NotifyNullAction; |
13
|
|
|
use PayumTW\Collect\Action\ConvertPaymentAction; |
14
|
|
|
use PayumTW\Collect\Action\Api\CancelTransactionAction; |
15
|
|
|
use PayumTW\Collect\Action\Api\CreateTransactionAction; |
16
|
|
|
use PayumTW\Collect\Action\Api\RefundTransactionAction; |
17
|
|
|
|
18
|
|
|
class CollectGatewayFactory extends GatewayFactory |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
1 |
|
protected function populateConfig(ArrayObject $config) |
24
|
|
|
{ |
25
|
1 |
|
$config->defaults([ |
26
|
1 |
|
'payum.factory_name' => 'collect', |
27
|
1 |
|
'payum.factory_title' => 'Collect', |
28
|
|
|
|
29
|
1 |
|
'payum.action.capture' => new CaptureAction(), |
30
|
1 |
|
'payum.action.notify' => new NotifyAction(), |
31
|
1 |
|
'payum.action.notify_null' => new NotifyNullAction(), |
32
|
1 |
|
'payum.action.refund' => new RefundAction(), |
33
|
1 |
|
'payum.action.cancel' => new CancelAction(), |
34
|
1 |
|
'payum.action.status' => new StatusAction(), |
35
|
1 |
|
'payum.action.convert_payment' => new ConvertPaymentAction(), |
36
|
|
|
|
37
|
1 |
|
'payum.action.api.create_transaction' => new CreateTransactionAction(), |
38
|
1 |
|
'payum.action.api.refund_transaction' => new RefundTransactionAction(), |
39
|
1 |
|
'payum.action.api.cancel_transaction' => new CancelTransactionAction(), |
40
|
1 |
|
]); |
41
|
|
|
|
42
|
1 |
|
if (false == $config['payum.api']) { |
43
|
1 |
|
$config['payum.default_options'] = [ |
44
|
1 |
|
'link_id' => null, |
45
|
1 |
|
'hash_base' => null, |
46
|
1 |
|
'sandbox' => false, |
47
|
|
|
]; |
48
|
|
|
|
49
|
1 |
|
$config->defaults($config['payum.default_options']); |
50
|
1 |
|
$config['payum.required_options'] = ['link_id', 'hash_base']; |
51
|
|
|
|
52
|
1 |
|
$config['payum.api'] = function (ArrayObject $config) { |
53
|
1 |
|
$config->validateNotEmpty($config['payum.required_options']); |
54
|
|
|
|
55
|
1 |
|
return new CollectApi((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); |
56
|
|
|
}; |
57
|
1 |
|
} |
58
|
1 |
|
} |
59
|
|
|
} |
60
|
|
|
|