Completed
Push — master ( 075950...974b7a )
by Vuong
02:25
created

PaymentClient   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 39
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A initDataSignature() 0 8 1
1
<?php
2
/**
3
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace yiiviet\payment\momo;
9
10
use Yii;
11
12
use yiiviet\payment\BasePaymentClient;
13
use yiiviet\payment\DataSignature;
14
use yiiviet\payment\HmacDataSignature;
15
16
/**
17
 * Lớp PaymentClient chứa các thuộc tính dùng để hổ trợ [[PaymentGateway]] kết nối đến MOMO.
18
 *
19
 * @method PaymentGateway getGateway()
20
 * @property PaymentGateway $gateway
21
 *
22
 * @author Vuong Minh <[email protected]>
23
 * @since 1.0
24
 */
25
class PaymentClient extends BasePaymentClient
26
{
27
    /**
28
     * Thuộc tính dùng để khai báo kết nối đến MOMO khi tạo [[request()]] ở [[PaymentGateway]].
29
     * Nó do MOMO cấp khi đăng ký tích hợp website.
30
     *
31
     * @var string
32
     */
33
    public $partnerCode;
34
35
    /**
36
     * Thuộc tính dùng để khai báo kết nối đến MOMO khi tạo [[request()]] ở [[PaymentGateway]].
37
     * Nó do MOMO cấp khi đăng ký tích hợp website.
38
     *
39
     * @var string
40
     */
41
    public $accessKey;
42
43
    /**
44
     * Thuộc tính được dùng để tạo chữ ký dữ liệu khi tạo [[request()]] ở [[PaymentGateway]].
45
     *
46
     * @var string
47
     */
48
    public $secretKey;
49
50
    /**
51
     * @inheritdoc
52
     * @return DataSignature|null|object
53
     * @throws \yii\base\InvalidConfigException
54
     */
55
    protected function initDataSignature(string $data, string $type = null): ?DataSignature
56
    {
57
        return Yii::createObject([
58
            'class' => HmacDataSignature::class,
59
            'key' => $this->secretKey,
60
            'hmacAlgo' => 'sha256'
61
        ]);
62
    }
63
}
64