Completed
Push — master ( 1361da...302d2b )
by Vuong
01:13
created

Response::isCancelled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-onepay
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace Omnipay\OnePay\Message;
9
10
use Omnipay\Common\Message\AbstractResponse;
11
12
/**
13
 * @method AbstractRequest getRequest()
14
 *
15
 * @author Vuong Minh <[email protected]>
16
 * @since 1.0.0
17
 */
18
class Response extends AbstractResponse
19
{
20
    use Concerns\ResponseProperties;
21
22
    /**
23
     * Trả về trạng thái thành công hay không do OnePay phản hồi.
24
     *
25
     * @return bool
26
     */
27
    public function isSuccessful(): bool
28
    {
29
        return '0' === $this->getCode();
30
    }
31
32
    /**
33
     * Trả về trạng thái có bị khách hủy đơn hay không do OnePay phản hồi.
34
     *
35
     * @return bool
36
     */
37
    public function isCancelled(): bool
38
    {
39
        return '99' === $this->getCode();
40
    }
41
42
    /**
43
     * Trả về thông báo từ OnePay.
44
     *
45
     * @return null|string
46
     */
47
    public function getMessage(): ?string
48
    {
49
        return $this->data['vpc_Message'] ?? null;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getCode(): ?string
56
    {
57
        return $this->data['vpc_TxnResponseCode'] ?? null;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getTransactionId(): ?string
64
    {
65
        return $this->data['vpc_MerchTxnRef'] ?? null;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getTransactionReference(): ?string
72
    {
73
        return $this->data['vpc_TransactionNo'] ?? null;
74
    }
75
}
76