Completed
Push — master ( efede1...807d53 )
by Leith
02:09
created
src/Message/CompletePurchaseResponse.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -10,125 +10,125 @@
 block discarded – undo
10 10
  */
11 11
 class CompletePurchaseResponse extends AbstractResponse
12 12
 {
13
-    /** @var array */
14
-    protected $merchantParameters;
15
-    /** @var string */
16
-    protected $returnSignature;
17
-    /** @var boolean */
18
-    protected $usingUpcaseParameters = false;
19
-    /** @var boolean */
20
-    protected $usingUpcaseResponse   = false;
13
+	/** @var array */
14
+	protected $merchantParameters;
15
+	/** @var string */
16
+	protected $returnSignature;
17
+	/** @var boolean */
18
+	protected $usingUpcaseParameters = false;
19
+	/** @var boolean */
20
+	protected $usingUpcaseResponse   = false;
21 21
 
22
-    /**
23
-     * Constructor
24
-     *
25
-     * @param RequestInterface $request the initiating request.
26
-     * @param mixed $data
27
-     *
28
-     * @throws InvalidResponseException If order number is missing or signature does not match
29
-     */
30
-    public function __construct(RequestInterface $request, $data)
31
-    {
32
-        parent::__construct($request, $data);
22
+	/**
23
+	 * Constructor
24
+	 *
25
+	 * @param RequestInterface $request the initiating request.
26
+	 * @param mixed $data
27
+	 *
28
+	 * @throws InvalidResponseException If order number is missing or signature does not match
29
+	 */
30
+	public function __construct(RequestInterface $request, $data)
31
+	{
32
+		parent::__construct($request, $data);
33 33
 
34
-        if (!empty($data['Ds_MerchantParameters'])) {
35
-            $this->merchantParameters = $this->decodeMerchantParameters($data['Ds_MerchantParameters']);
36
-        } elseif (!empty($data['DS_MERCHANTPARAMETERS'])) {
37
-            $this->merchantParameters = $this->decodeMerchantParameters($data['DS_MERCHANTPARAMETERS']);
38
-            $this->usingUpcaseResponse = true;
39
-        } else {
40
-            throw new InvalidResponseException('Invalid response from payment gateway (no data)');
41
-        }
34
+		if (!empty($data['Ds_MerchantParameters'])) {
35
+			$this->merchantParameters = $this->decodeMerchantParameters($data['Ds_MerchantParameters']);
36
+		} elseif (!empty($data['DS_MERCHANTPARAMETERS'])) {
37
+			$this->merchantParameters = $this->decodeMerchantParameters($data['DS_MERCHANTPARAMETERS']);
38
+			$this->usingUpcaseResponse = true;
39
+		} else {
40
+			throw new InvalidResponseException('Invalid response from payment gateway (no data)');
41
+		}
42 42
 
43
-        if (!empty($this->merchantParameters['Ds_Order'])) {
44
-            $order = $this->merchantParameters['Ds_Order'];
45
-        } elseif (!empty($this->merchantParameters['DS_ORDER'])) {
46
-            $order = $this->merchantParameters['DS_ORDER'];
47
-            $this->usingUpcaseParameters = true;
48
-        } else {
49
-            throw new InvalidResponseException();
50
-        }
43
+		if (!empty($this->merchantParameters['Ds_Order'])) {
44
+			$order = $this->merchantParameters['Ds_Order'];
45
+		} elseif (!empty($this->merchantParameters['DS_ORDER'])) {
46
+			$order = $this->merchantParameters['DS_ORDER'];
47
+			$this->usingUpcaseParameters = true;
48
+		} else {
49
+			throw new InvalidResponseException();
50
+		}
51 51
 
52
-        $this->returnSignature = $this->createReturnSignature(
53
-            $data[$this->usingUpcaseResponse ? 'DS_MERCHANTPARAMETERS' : 'Ds_MerchantParameters'],
54
-            $order,
55
-            base64_decode($this->request->getHmacKey())
56
-        );
52
+		$this->returnSignature = $this->createReturnSignature(
53
+			$data[$this->usingUpcaseResponse ? 'DS_MERCHANTPARAMETERS' : 'Ds_MerchantParameters'],
54
+			$order,
55
+			base64_decode($this->request->getHmacKey())
56
+		);
57 57
 
58
-        if ($this->returnSignature != $data[$this->usingUpcaseResponse ? 'DS_SIGNATURE' : 'Ds_Signature']) {
59
-            throw new InvalidResponseException('Invalid response from payment gateway (signature mismatch)');
60
-        }
61
-    }
58
+		if ($this->returnSignature != $data[$this->usingUpcaseResponse ? 'DS_SIGNATURE' : 'Ds_Signature']) {
59
+			throw new InvalidResponseException('Invalid response from payment gateway (signature mismatch)');
60
+		}
61
+	}
62 62
 
63
-    /**
64
-     * Is the response successful?
65
-     *
66
-     * @return boolean
67
-     */
68
-    public function isSuccessful()
69
-    {
70
-        $key = $this->usingUpcaseParameters ? 'DS_RESPONSE' : 'Ds_Response';
71
-        return isset($this->merchantParameters[$key])
72
-            && is_numeric($this->merchantParameters[$key])
73
-            && 0 <= $this->merchantParameters[$key]
74
-            && 100 > $this->merchantParameters[$key];
75
-    }
63
+	/**
64
+	 * Is the response successful?
65
+	 *
66
+	 * @return boolean
67
+	 */
68
+	public function isSuccessful()
69
+	{
70
+		$key = $this->usingUpcaseParameters ? 'DS_RESPONSE' : 'Ds_Response';
71
+		return isset($this->merchantParameters[$key])
72
+			&& is_numeric($this->merchantParameters[$key])
73
+			&& 0 <= $this->merchantParameters[$key]
74
+			&& 100 > $this->merchantParameters[$key];
75
+	}
76 76
 
77
-    /**
78
-     * Get the response data, included the decoded merchant parameters if available.
79
-     *
80
-     * @return mixed
81
-     */
82
-    public function getData()
83
-    {
84
-        $data = parent::getData();
85
-        return is_array($data) && is_array($this->merchantParameters)
86
-            ? array_merge($data, $this->merchantParameters)
87
-            : $data;
88
-    }
77
+	/**
78
+	 * Get the response data, included the decoded merchant parameters if available.
79
+	 *
80
+	 * @return mixed
81
+	 */
82
+	public function getData()
83
+	{
84
+		$data = parent::getData();
85
+		return is_array($data) && is_array($this->merchantParameters)
86
+			? array_merge($data, $this->merchantParameters)
87
+			: $data;
88
+	}
89 89
 
90
-    /**
91
-     * Helper method to get a specific merchant parameter if available.
92
-     *
93
-     * @param string $key The key to look up
94
-     *
95
-     * @return null|mixed
96
-     */
97
-    protected function getKey($key)
98
-    {
99
-        if ($this->usingUpcaseParameters) {
100
-            $key = strtoupper($key);
101
-        }
102
-        return isset($this->merchantParameters[$key]) ? $this->merchantParameters[$key] : null;
103
-    }
90
+	/**
91
+	 * Helper method to get a specific merchant parameter if available.
92
+	 *
93
+	 * @param string $key The key to look up
94
+	 *
95
+	 * @return null|mixed
96
+	 */
97
+	protected function getKey($key)
98
+	{
99
+		if ($this->usingUpcaseParameters) {
100
+			$key = strtoupper($key);
101
+		}
102
+		return isset($this->merchantParameters[$key]) ? $this->merchantParameters[$key] : null;
103
+	}
104 104
 
105
-    /**
106
-     * Get the authorisation code if available.
107
-     *
108
-     * @return null|string
109
-     */
110
-    public function getTransactionReference()
111
-    {
112
-        return $this->getKey('Ds_AuthorisationCode');
113
-    }
105
+	/**
106
+	 * Get the authorisation code if available.
107
+	 *
108
+	 * @return null|string
109
+	 */
110
+	public function getTransactionReference()
111
+	{
112
+		return $this->getKey('Ds_AuthorisationCode');
113
+	}
114 114
 
115
-    /**
116
-     * Get the merchant response message if available.
117
-     *
118
-     * @return null|string
119
-     */
120
-    public function getMessage()
121
-    {
122
-        return $this->getKey('Ds_Response');
123
-    }
115
+	/**
116
+	 * Get the merchant response message if available.
117
+	 *
118
+	 * @return null|string
119
+	 */
120
+	public function getMessage()
121
+	{
122
+		return $this->getKey('Ds_Response');
123
+	}
124 124
 
125
-    /**
126
-     * Get the card type if available.
127
-     *
128
-     * @return null|string
129
-     */
130
-    public function getCardType()
131
-    {
132
-        return $this->getKey('Ds_Card_Type');
133
-    }
125
+	/**
126
+	 * Get the card type if available.
127
+	 *
128
+	 * @return null|string
129
+	 */
130
+	public function getCardType()
131
+	{
132
+		return $this->getKey('Ds_Card_Type');
133
+	}
134 134
 }
Please login to merge, or discard this patch.