@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | public function sendData($data) |
18 | 18 | { |
19 | - if ( !$data['sessionId'] ) { |
|
19 | + if (!$data['sessionId']) { |
|
20 | 20 | throw new InvalidRequestException('Session id is required'); |
21 | 21 | } |
22 | 22 | |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | $headers = [ |
26 | 26 | 'Accept' => 'application/json', |
27 | 27 | 'Content-Type' => 'application/json', |
28 | - 'Authorization' => 'Basic ' . $this->getAuthorization() |
|
28 | + 'Authorization' => 'Basic '.$this->getAuthorization() |
|
29 | 29 | ]; |
30 | 30 | |
31 | 31 | try { |
32 | - $httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/' . $sessionId), $headers); |
|
32 | + $httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/'.$sessionId), $headers); |
|
33 | 33 | } catch (\Exception $exception) { |
34 | 34 | throw new InvalidRequestException($exception->getMessage()); |
35 | 35 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public function getRedirectUrl() { |
23 | - foreach ( $this->data->links ?? [] as $link ) { |
|
23 | + foreach ($this->data->links ?? [] as $link) { |
|
24 | 24 | if ($link->rel === 'hpp') { |
25 | 25 | return $link->href; |
26 | 26 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | $headers = [ |
28 | 28 | 'Accept' => 'application/json', |
29 | 29 | 'Content-Type' => 'application/json', |
30 | - 'Authorization' => 'Basic ' . $this->getAuthorization() |
|
30 | + 'Authorization' => 'Basic '.$this->getAuthorization() |
|
31 | 31 | ]; |
32 | 32 | |
33 | 33 | try { |
34 | - $httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/' . $sessionId), $headers); |
|
34 | + $httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/'.$sessionId), $headers); |
|
35 | 35 | } |
36 | 36 | catch (\Exception $exception) { |
37 | 37 | throw new InvalidRequestException($exception->getMessage()); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getTransactionStatus() { |
57 | - if ($this->getTransaction() && $this->getAuthorised() && $this->getResponseText() === 'APPROVED') { |
|
57 | + if ($this->getTransaction() && $this->getAuthorised() && $this->getResponseText() === 'APPROVED') { |
|
58 | 58 | return static::STATUS_COMPLETED; |
59 | 59 | } |
60 | 60 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | public function getCardExpiry() |
92 | 92 | { |
93 | - return ($this->getCard()['dateExpiryMonth'] ?? '') . '/' . ($this->getCard()['dateExpiryYear'] ?? ''); |
|
93 | + return ($this->getCard()['dateExpiryMonth'] ?? '').'/'.($this->getCard()['dateExpiryYear'] ?? ''); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function getCardType() |
@@ -28,8 +28,7 @@ |
||
28 | 28 | |
29 | 29 | try { |
30 | 30 | $httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/' . $sessionId), $headers); |
31 | - } |
|
32 | - catch (\Exception $exception) { |
|
31 | + } catch (\Exception $exception) { |
|
33 | 32 | throw new InvalidRequestException($exception->getMessage()); |
34 | 33 | } |
35 | 34 |
@@ -12,8 +12,8 @@ |
||
12 | 12 | return ( |
13 | 13 | $this->data && |
14 | 14 | ($this->data->authorised ?? false) && |
15 | - ( strtoupper($this->data->type ?? '') ) === 'REFUND' && |
|
16 | - ( strtoupper($this->data->responseText ?? '') ) === 'APPROVED' |
|
15 | + (strtoupper($this->data->type ?? '')) === 'REFUND' && |
|
16 | + (strtoupper($this->data->responseText ?? '')) === 'APPROVED' |
|
17 | 17 | ) ?? false; |
18 | 18 | } |
19 | 19 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | $headers = [ |
31 | 31 | 'Accept' => 'application/json', |
32 | 32 | 'Content-Type' => 'application/json', |
33 | - 'Authorization' => 'Basic ' . $this->getAuthorization(), |
|
33 | + 'Authorization' => 'Basic '.$this->getAuthorization(), |
|
34 | 34 | ]; |
35 | 35 | |
36 | 36 | $httpResponse = $this->httpClient->request('POST', $this->getEndpoint('transactions'), $headers, json_encode($data)); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | return ( |
32 | 32 | $transaction && |
33 | 33 | ($transaction['authorised'] ?? false) && |
34 | - ( strtoupper($transaction['responseText'] ?? '') ) === 'APPROVED' |
|
34 | + (strtoupper($transaction['responseText'] ?? '')) === 'APPROVED' |
|
35 | 35 | ) ?? false; |
36 | 36 | } |
37 | 37 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | public function getCardExpiry() |
96 | 96 | { |
97 | - return $this->getCardExpiryMonth() . '/' . $this->getCardExpiryYear(); |
|
97 | + return $this->getCardExpiryMonth().'/'.$this->getCardExpiryYear(); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function getCardExpiryYear() |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | public function getCardReference() |
116 | 116 | { |
117 | - if ( !in_array($this->getTransactionMethod(), ['card', 'visacheckout']) ) { |
|
117 | + if (!in_array($this->getTransactionMethod(), ['card', 'visacheckout'])) { |
|
118 | 118 | return null; |
119 | 119 | } |
120 | 120 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | protected function getAuthorization() |
35 | 35 | { |
36 | - return base64_encode($this->getApiUsername() . ':' . $this->getApiKey()); |
|
36 | + return base64_encode($this->getApiUsername().':'.$this->getApiKey()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function setCreateToken($value) |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'oxipay', 'visacheckout', 'wechat' |
92 | 92 | ]; |
93 | 93 | |
94 | - foreach ( $list as $method ) { |
|
95 | - if ( !in_array($method, $options) ) { |
|
94 | + foreach ($list as $method) { |
|
95 | + if (!in_array($method, $options)) { |
|
96 | 96 | throw new InvalidRequestException("Unknown payment method: {$method}"); |
97 | 97 | } |
98 | 98 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'resubmission', 'reauthorisation', 'delayedcharges', 'noshow' |
161 | 161 | ]; |
162 | 162 | |
163 | - if ( ! in_array($value, $options) ) { |
|
163 | + if (!in_array($value, $options)) { |
|
164 | 164 | throw new InvalidRequestException("Invalid option '{$value}' set for StoredCardIndicator."); |
165 | 165 | } |
166 | 166 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | 'twomonthly', 'threemonthly', 'fourmonthly', 'sixmonthly', 'annually' |
193 | 193 | ]; |
194 | 194 | |
195 | - if ( ! in_array($value, $options) ) { |
|
195 | + if (!in_array($value, $options)) { |
|
196 | 196 | throw new InvalidRequestException("Invalid option '{$value}' set for RecurringFrequency."); |
197 | 197 | } |
198 | 198 | |
@@ -221,6 +221,6 @@ discard block |
||
221 | 221 | protected function getEndpoint($path = '') |
222 | 222 | { |
223 | 223 | $base = $this->getTestMode() ? self::ENDPOINT_TEST : self::ENDPOINT_LIVE; |
224 | - return $base . '/' . $path; |
|
224 | + return $base.'/'.$path; |
|
225 | 225 | } |
226 | 226 | } |
@@ -25,57 +25,57 @@ discard block |
||
25 | 25 | $data['currency'] = $this->getCurrency(); |
26 | 26 | $data['callbackUrls'] = []; |
27 | 27 | |
28 | - if ( (bool) $this->getCreateToken() ) { |
|
28 | + if ((bool) $this->getCreateToken()) { |
|
29 | 29 | $data['storeCard'] = true; |
30 | 30 | } |
31 | 31 | |
32 | - if ( $this->getStoredCardIndicator() ) { |
|
32 | + if ($this->getStoredCardIndicator()) { |
|
33 | 33 | $data['storedCardIndicator'] = $this->getStoredCardIndicator(); |
34 | 34 | } |
35 | 35 | |
36 | - if ( $this->getRecurringExpiry() ) { |
|
36 | + if ($this->getRecurringExpiry()) { |
|
37 | 37 | $data['recurringExpiry'] = $this->getRecurringExpiry(); |
38 | 38 | } |
39 | 39 | |
40 | - if ( $this->getRecurringFrequency() ) { |
|
40 | + if ($this->getRecurringFrequency()) { |
|
41 | 41 | $data['recurringFrequency'] = $this->getRecurringFrequency(); |
42 | 42 | } |
43 | 43 | |
44 | - if ( $this->getToken() || $this->getCardReference() ) { |
|
44 | + if ($this->getToken() || $this->getCardReference()) { |
|
45 | 45 | $data['cardId'] = $this->getToken() ?? $this->getCardReference(); |
46 | 46 | } |
47 | 47 | |
48 | - if ( is_array($this->getPaymentMethods()) ) { |
|
48 | + if (is_array($this->getPaymentMethods())) { |
|
49 | 49 | $data['methods'] = $this->getPaymentMethods(); |
50 | 50 | } |
51 | 51 | |
52 | - if ( is_array($this->getCardTypes()) ) { |
|
52 | + if (is_array($this->getCardTypes())) { |
|
53 | 53 | $data['cardTypes'] = $this->getCardTypes(); |
54 | 54 | } |
55 | 55 | |
56 | - if ( is_array($this->getMetadata()) ) { |
|
56 | + if (is_array($this->getMetadata())) { |
|
57 | 57 | $data['metaData'] = $this->getMetadata(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | $merchantReference = $this->getMerchantReference() ?? $this->getDescription(); |
61 | 61 | |
62 | - if ( $merchantReference ) { |
|
62 | + if ($merchantReference) { |
|
63 | 63 | $data['merchantReference'] = $merchantReference; |
64 | 64 | } |
65 | 65 | |
66 | - if ( $this->getReturnUrl() ) { |
|
66 | + if ($this->getReturnUrl()) { |
|
67 | 67 | $data['callbackUrls']['approved'] = $this->getReturnUrl(); |
68 | 68 | } |
69 | 69 | |
70 | - if ( $this->getDeclineUrl() ) { |
|
70 | + if ($this->getDeclineUrl()) { |
|
71 | 71 | $data['callbackUrls']['declined'] = $this->getDeclineUrl(); |
72 | 72 | } |
73 | 73 | |
74 | - if ( $this->getCancelUrl() ) { |
|
74 | + if ($this->getCancelUrl()) { |
|
75 | 75 | $data['callbackUrls']['cancelled'] = $this->getCancelUrl(); |
76 | 76 | } |
77 | 77 | |
78 | - if ( $this->getNotifyUrl() ) { |
|
78 | + if ($this->getNotifyUrl()) { |
|
79 | 79 | $data['notificationUrl'] = $this->getNotifyUrl(); |
80 | 80 | } |
81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $headers = [ |
88 | 88 | 'Accept' => 'application/json', |
89 | 89 | 'Content-Type' => 'application/json', |
90 | - 'Authorization' => 'Basic ' . $this->getAuthorization(), |
|
90 | + 'Authorization' => 'Basic '.$this->getAuthorization(), |
|
91 | 91 | ]; |
92 | 92 | |
93 | 93 | $httpResponse = $this->httpClient->request('POST', $this->getEndpoint('sessions'), $headers, json_encode($data)); |