Completed
Push — master ( 667b31...e64f5b )
by Leith
02:32
created

getTransactionReference()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
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->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
        return $this->isSuccessful() ? null : $this->data->paymentResult->errorDetails->errorMessage;
40
    }
41
42
    /**
43
     * Get the card brand if available e.g. Visa
44
     *
45
     * @return null|string
46
     */
47 2
    public function getCardBrand()
48
    {
49 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->cardDescription : null;
50
    }
51
52
    /**
53
     * Get the card expiry if available e.g. Visa
54
     *
55
     * @return null|string
56
     */
57 2
    public function getCardExpiry()
58
    {
59 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->expiryDate : null;
60
    }
61
62
    /**
63
     * Get the card masked number if available e.g. Visa
64
     *
65
     * @return null|string
66
     */
67 2
    public function getCardNumber()
68
    {
69 2
        return $this->isSuccessful() ? $this->data->paymentResult->paymentDetails->authDetails->maskedCardNumber : null;
70
    }
71
}
72