AllpayGatewayFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 14

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 14
dl 0
loc 43
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A populateConfig() 0 37 2
1
<?php
2
3
namespace PayumTW\Allpay;
4
5
use Payum\Core\GatewayFactory;
6
use PayumTW\Allpay\Action\SyncAction;
7
use Payum\Core\Bridge\Spl\ArrayObject;
8
use PayumTW\Allpay\Action\CancelAction;
9
use PayumTW\Allpay\Action\NotifyAction;
10
use PayumTW\Allpay\Action\RefundAction;
11
use PayumTW\Allpay\Action\StatusAction;
12
use PayumTW\Allpay\Action\CaptureAction;
13
use PayumTW\Allpay\Action\ConvertPaymentAction;
14
use PayumTW\Allpay\Action\Api\CancelTransactionAction;
15
use PayumTW\Allpay\Action\Api\CreateTransactionAction;
16
use PayumTW\Allpay\Action\Api\RefundTransactionAction;
17
use PayumTW\Allpay\Action\Api\GetTransactionDataAction;
18
19
class AllpayGatewayFactory extends GatewayFactory
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    protected function populateConfig(ArrayObject $config)
25
    {
26 1
        $config->defaults([
27 1
            'payum.factory_name' => 'allpay',
28 1
            'payum.factory_title' => 'Allpay',
29 1
            'payum.action.capture' => new CaptureAction(),
30 1
            'payum.action.notify' => new NotifyAction(),
31 1
            'payum.action.refund' => new RefundAction(),
32 1
            'payum.action.cancel' => new CancelAction(),
33 1
            'payum.action.sync' => new SyncAction(),
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
            'payum.action.api.get_transaction_data' => new GetTransactionDataAction(),
41
        ]);
42
43 1
        if (false == $config['payum.api']) {
44 1
            $config['payum.default_options'] = [
45
                'MerchantID' => '2000132',
46
                'HashKey' => '5294y06JbISpM5x9',
47
                'HashIV' => 'v77hoKGq4kWxNNIS',
48
                'sandbox' => true,
49
            ];
50
51 1
            $config->defaults($config['payum.default_options']);
52 1
            $config['payum.required_options'] = ['MerchantID', 'HashKey', 'HashIV'];
53
54
            $config['payum.api'] = function (ArrayObject $config) {
55 1
                $config->validateNotEmpty($config['payum.required_options']);
56
57 1
                return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']);
58
            };
59
        }
60 1
    }
61
}
62