Passed
Push — master ( 22c4a0...baf55d )
by
unknown
03:13
created

CompletePurchaseResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 56
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 3 2
A __construct() 0 3 1
A getTransactionReference() 0 3 1
A getTransactionId() 0 3 1
A isSuccessful() 0 3 1
1
<?php
2
3
namespace Omnipay\SmartPay\Message;
4
5
use Omnipay\Common\Exception\InvalidResponseException;
6
use Omnipay\Common\Message\AbstractResponse;
7
use Omnipay\Common\Message\RequestInterface;
8
9
/**
10
 * CyberSource Complete Purchase Response
11
 */
12
class CompletePurchaseResponse extends AbstractResponse
13
{
14
    /**
15
     * Constructor
16
     *
17
     * @param RequestInterface $request the initiating request.
18
     * @param mixed $data
19
     *
20
     * @throws InvalidResponseException If merchant data or order number is missing, or signature does not match
21
     */
22
    public function __construct(RequestInterface $request, $data)
23
    {
24
        parent::__construct($request, $data);
25
    }
26
27
    /**
28
     * Is the response successful?
29
     *
30
     *
31
     * @return boolean
32
     */
33
    public function isSuccessful()
34
    {
35
        return true;
36
    }
37
38
    /**
39
     * Get the transaction identifier if available.
40
     *
41
     * @return null|string
42
     */
43
    public function getTransactionReference()
44
    {
45
        return $this->getKey('transaction_id');
46
    }
47
48
    /**
49
     * Get the merchant-supplied transaction identifier if available.
50
     *
51
     * @return null|string
52
     */
53
    public function getTransactionId()
54
    {
55
        return $this->getKey('req_reference_number');
56
    }
57
58
    /**
59
     * Helper method to get a specific response parameter if available.
60
     *
61
     * @param string $key The key to look up
62
     *
63
     * @return null|mixed
64
     */
65
    protected function getKey($key)
66
    {
67
        return isset($this->data[$key]) ? $this->data[$key] : null;
68
    }
69
}
70