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