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