EsunbankGatewayFactory::populateConfig()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 36
ccs 28
cts 28
cp 1
rs 8.8571
cc 2
eloc 25
nc 2
nop 1
crap 2
1
<?php
2
3
namespace PayumTW\Esunbank;
4
5
use Payum\Core\GatewayFactory;
6
use Payum\Core\Bridge\Spl\ArrayObject;
7
use PayumTW\Esunbank\Action\SyncAction;
8
use PayumTW\Esunbank\Action\CancelAction;
9
use PayumTW\Esunbank\Action\RefundAction;
10
use PayumTW\Esunbank\Action\StatusAction;
11
use PayumTW\Esunbank\Action\CaptureAction;
12
use PayumTW\Esunbank\Action\ConvertPaymentAction;
13
use PayumTW\Esunbank\Action\Api\CancelTransactionAction;
14
use PayumTW\Esunbank\Action\Api\CreateTransactionAction;
15
use PayumTW\Esunbank\Action\Api\RefundTransactionAction;
16
use PayumTW\Esunbank\Action\Api\GetTransactionDataAction;
17
18
class EsunbankGatewayFactory extends GatewayFactory
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    protected function populateConfig(ArrayObject $config)
24
    {
25 1
        $config->defaults([
26 1
            'payum.factory_name' => 'esunbank',
27 1
            'payum.factory_title' => 'Esunbank',
28 1
            'payum.action.capture' => new CaptureAction(),
29 1
            'payum.action.refund' => new RefundAction(),
30 1
            'payum.action.cancel' => new CancelAction(),
31 1
            'payum.action.sync' => new SyncAction(),
32 1
            'payum.action.status' => new StatusAction(),
33 1
            'payum.action.convert_payment' => new ConvertPaymentAction(),
34
35 1
            'payum.action.api.create_transaction' => new CreateTransactionAction(),
36 1
            'payum.action.api.refund_transaction' => new RefundTransactionAction(),
37 1
            'payum.action.api.cancel_transaction' => new CancelTransactionAction(),
38 1
            'payum.action.api.get_transaction_data' => new GetTransactionDataAction(),
39 1
        ]);
40
41 1
        if (false == $config['payum.api']) {
42 1
            $config['payum.default_options'] = [
43 1
                'MID' => '8089000016',
44 1
                'M' => 'WEGSC0Q7BAJGTQYL8BV8KRQRZXH6VK0B',
45 1
                'mobile' => null,
46 1
                'sandbox' => true,
47
            ];
48
49 1
            $config->defaults($config['payum.default_options']);
50 1
            $config['payum.required_options'] = ['MID', 'M'];
51
52 1
            $config['payum.api'] = function (ArrayObject $config) {
53 1
                $config->validateNotEmpty($config['payum.required_options']);
54
55 1
                return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']);
56
            };
57 1
        }
58 1
    }
59
}
60