PayConfirmRequest   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Importance

Changes 0
Metric Value
wmc 12
lcom 3
cbo 5
dl 0
loc 131
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A sendData() 0 9 1
A getRequestId() 0 4 1
A setRequestId() 0 4 1
A getPartnerRefId() 0 4 1
A setPartnerRefId() 0 4 1
A getMomoTransId() 0 4 1
A setMomoTransId() 0 4 1
A getCustomerNumber() 0 4 1
A setCustomerNumber() 0 4 1
A getRequestType() 0 4 1
A setRequestType() 0 4 1
A getSignatureParameters() 0 6 1
1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-momo
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace Omnipay\MoMo\Message;
9
10
/**
11
 * @link https://developers.momo.vn/#/docs/pos_payment?id=x%c3%a1c-nh%e1%ba%adn-giao-d%e1%bb%8bch
12
 * @link https://developers.momo.vn/#/docs/qr_payment?id=x%c3%a1c-nh%e1%ba%adn-giao-d%e1%bb%8bch
13
 * @link https://developers.momo.vn/#/docs/app_in_app?id=x%c3%a1c-nh%e1%ba%adn-giao-d%e1%bb%8bch
14
 *
15
 * @author Vuong Minh <[email protected]>
16
 * @since 1.0.0
17
 */
18
class PayConfirmRequest extends AbstractSignatureRequest
19
{
20
    /**
21
     * {@inheritdoc}
22
     * @throws \Omnipay\Common\Exception\InvalidResponseException
23
     */
24
    public function sendData($data): PayConfirmResponse
25
    {
26
        $response = $this->httpClient->request('POST', $this->getEndpoint().'/pay/confirm', [
27
            'Content-Type' => 'application/json; charset=utf-8',
28
        ], json_encode($data));
29
        $responseData = $response->getBody()->getContents();
30
31
        return $this->response = new PayConfirmResponse($this, json_decode($responseData, true) ?? []);
32
    }
33
34
    /**
35
     * Trả về request id.
36
     *
37
     * @return null|string
38
     */
39
    public function getRequestId(): ?string
40
    {
41
        return $this->getParameter('requestId');
42
    }
43
44
    /**
45
     * Thiết lập request id của đơn hàng.
46
     *
47
     * @param  null|string  $id
48
     * @return $this
49
     */
50
    public function setRequestId(?string $id)
51
    {
52
        return $this->setParameter('requestId', $id);
53
    }
54
55
    /**
56
     * Trả về mã đơn hàng.
57
     *
58
     * @return null|string
59
     */
60
    public function getPartnerRefId(): ?string
61
    {
62
        return $this->getParameter('partnerRefId');
63
    }
64
65
    /**
66
     * Thiết lập mã đơn hàng.
67
     *
68
     * @param  null|string  $id
69
     * @return $this
70
     */
71
    public function setPartnerRefId(?string $id)
72
    {
73
        return $this->setParameter('partnerRefId', $id);
74
    }
75
76
    /**
77
     * Trả về mã đơn hàng của MoMo.
78
     *
79
     * @return null|string
80
     */
81
    public function getMomoTransId(): ?string
82
    {
83
        return $this->getParameter('momoTransId');
84
    }
85
86
    /**
87
     * Thiết lập mã giao dịch của MoMo.
88
     *
89
     * @param  null|string  $id
90
     * @return $this
91
     */
92
    public function setMomoTransId(?string $id)
93
    {
94
        return $this->setParameter('momoTransId', $id);
95
    }
96
97
    /**
98
     * Trả về só điện thoại của khách hàng.
99
     *
100
     * @return null|string
101
     */
102
    public function getCustomerNumber(): ?string
103
    {
104
        return $this->getParameter('customerNumber');
105
    }
106
107
    /**
108
     * Thiết lập số điện thoại khách hàng.
109
     *
110
     * @param  null|string  $number
111
     * @return $this
112
     */
113
    public function setCustomerNumber(?string $number)
114
    {
115
        return $this->setParameter('customerNumber', $number);
116
    }
117
118
    /**
119
     * Trả về loại request yêu cầu MoMo xử lý.
120
     *
121
     * @return null|string
122
     */
123
    public function getRequestType(): ?string
124
    {
125
        return $this->getParameter('requestType');
126
    }
127
128
    /**
129
     * Thiết lập loại request type yêu cầu MoMo, commit hoặc rollback.
130
     *
131
     * @param  null|string  $type
132
     * @return $this
133
     */
134
    public function setRequestType(?string $type)
135
    {
136
        return $this->setParameter('requestType', $type);
137
    }
138
139
    /**
140
     * {@inheritdoc}
141
     */
142
    protected function getSignatureParameters(): array
143
    {
144
        return [
145
            'partnerCode', 'partnerRefId', 'requestType', 'requestId', 'momoTransId',
146
        ];
147
    }
148
}
149