CompletePurchaseResponse::getCardExpiry()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Omnipay\CapitaPay360\Message;
4
5
use Omnipay\Common\Message\AbstractResponse;
6
7
/**
8
 * CapitaPay360 Complete Purchase Response
9
 */
10
class CompletePurchaseResponse extends AbstractResponse
11
{
12
    /**
13
     * Is the response successful?
14
     *
15
     * @return boolean
16
     */
17 2
    public function isSuccessful()
18
    {
19 2
        return $this->data->transactionState == 'COMPLETE' && $this->data->paymentResult->status == 'SUCCESS';
20
    }
21
22
    /**
23
     * Get the authorisation code if available.
24
     *
25
     * @return null|string
26
     */
27 2
    public function getTransactionReference()
28
    {
29 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->authCode : null;
30
    }
31
32
    /**
33
     * Get the merchant response message if available.
34
     *
35
     * @return null|string
36
     */
37 2
    public function getMessage()
38
    {
39 2
        if ($this->isSuccessful())
40
        {
41
            return null;
42
        }
43
        if (isset($this->data->paymentResult->errorDetails->errorMessage))
44
        {
45
            return $this->data->paymentResult->errorDetails->errorMessage;
46
        }
47 2
        return $this->data->transactionState;
48
    }
49 2
50
    /**
51
     * Get the card brand if available e.g. Visa
52
     *
53
     * @return null|string
54
     */
55
    public function getCardBrand()
56
    {
57 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->cardDescription : null;
58
    }
59 2
60
    /**
61
     * Get the card expiry if available e.g. Visa
62
     *
63
     * @return null|string
64
     */
65
    public function getCardExpiry()
66
    {
67 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->expiryDate : null;
68
    }
69 2
70
    /**
71
     * Get the card masked number if available e.g. Visa
72
     *
73
     * @return null|string
74
     */
75
    public function getCardNumber()
76
    {
77
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->maskedCardNumber : null;
78
    }
79
}
80