@@ -16,10 +16,10 @@ |
||
16 | 16 | class Digipay extends Driver |
17 | 17 | { |
18 | 18 | /** |
19 | - * Digipay Client. |
|
20 | - * |
|
21 | - * @var object |
|
22 | - */ |
|
19 | + * Digipay Client. |
|
20 | + * |
|
21 | + * @var object |
|
22 | + */ |
|
23 | 23 | protected $client; |
24 | 24 | |
25 | 25 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function __construct(Invoice $invoice, $settings) |
53 | 53 | { |
54 | 54 | $this->invoice($invoice); |
55 | - $this->settings=$settings; |
|
55 | + $this->settings = $settings; |
|
56 | 56 | $this->client = new Client(); |
57 | 57 | $this->oauthToken = $this->oauth(); |
58 | 58 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function verify(): ReceiptInterface |
115 | 115 | { |
116 | - $tracingId=Request::input("trackingCode"); |
|
116 | + $tracingId = Request::input("trackingCode"); |
|
117 | 117 | |
118 | 118 | $response = $this->client->request( |
119 | 119 | 'POST', |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | "grant_type" => 'password', |
156 | 156 | ] |
157 | 157 | ); |
158 | - if ($response->getStatusCode()!=200) { |
|
159 | - if ($response->getStatusCode()==401) { |
|
158 | + if ($response->getStatusCode() != 200) { |
|
159 | + if ($response->getStatusCode() == 401) { |
|
160 | 160 | throw new PurchaseFailedException("خطا نام کاربری یا رمز عبور شما اشتباه می باشد."); |
161 | 161 | } else { |
162 | 162 | throw new PurchaseFailedException("خطا در هنگام احراز هویت."); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $result = json_decode($response->getBody()->getContents(), true); |
102 | 102 | |
103 | 103 | // some error has happened |
104 | - if (! empty($result['errors']) || empty($result['data']) || $result['data']['code'] != 100) { |
|
104 | + if (!empty($result['errors']) || empty($result['data']) || $result['data']['code'] != 100) { |
|
105 | 105 | throw new PurchaseFailedException($result['errors']['message'], $result['errors']['code']); |
106 | 106 | } |
107 | 107 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | $result = json_decode($response->getBody()->getContents(), true); |
163 | 163 | |
164 | - if (empty($result['data']) || ! isset($result['data']['ref_id']) || $result['data']['code'] != 100) { |
|
164 | + if (empty($result['data']) || !isset($result['data']['ref_id']) || $result['data']['code'] != 100) { |
|
165 | 165 | $message = $result['errors']['message'] ?? ""; |
166 | 166 | $code = $result['errors']['code']; |
167 | 167 |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (true === $this->_checkCacheDir()) { |
107 | 107 | $filename = $this->getCache(); |
108 | 108 | $filename = preg_replace('/[^0-9a-z\.\_\-]/i', '', strtolower($filename)); |
109 | - return $this->getCachePath() . $this->_getHash($filename) . $this->getExtension(); |
|
109 | + return $this->getCachePath().$this->_getHash($filename).$this->getExtension(); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | private function _checkCacheDir() |
119 | 119 | { |
120 | 120 | if (!is_dir($this->getCachePath()) && !mkdir($this->getCachePath(), 0775, true)) { |
121 | - throw new \Exception('Unable to create cache directory ' . $this->getCachePath()); |
|
121 | + throw new \Exception('Unable to create cache directory '.$this->getCachePath()); |
|
122 | 122 | } elseif (!is_readable($this->getCachePath()) || !is_writable($this->getCachePath())) { |
123 | 123 | if (!chmod($this->getCachePath(), 0775)) { |
124 | - throw new \Exception($this->getCachePath() . ' must be readable and writeable'); |
|
124 | + throw new \Exception($this->getCachePath().' must be readable and writeable'); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | return true; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getOrderById($id) |
55 | 55 | { |
56 | - return $this->callCurl('/orders/' .$id, [], true, 0, 'GET'); |
|
56 | + return $this->callCurl('/orders/'.$id, [], true, 0, 'GET'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('Err in refresh token.'); |
92 | 92 | } |
93 | 93 | if (!empty($result['accessToken'])) { |
94 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
94 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
95 | 95 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
96 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
96 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
97 | 97 | $this->setRefreshToken($result['refreshToken']); |
98 | 98 | return 'ok'; |
99 | 99 | } |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | if ($haveAuth) { |
118 | 118 | $accessToken = $this->getAccessToken(); |
119 | 119 | } |
120 | - $ch = curl_init($this->base_url . $url); |
|
120 | + $ch = curl_init($this->base_url.$url); |
|
121 | 121 | curl_setopt($ch, CURLOPT_USERAGENT, 'Jibit.class Rest Api'); |
122 | 122 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
123 | 123 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); |
124 | 124 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
125 | 125 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
126 | 126 | 'Content-Type: application/json', |
127 | - 'Authorization: ' . $accessToken, |
|
128 | - 'Content-Length: ' . strlen($jsonData) |
|
127 | + 'Authorization: '.$accessToken, |
|
128 | + 'Content-Length: '.strlen($jsonData) |
|
129 | 129 | )); |
130 | 130 | $result = curl_exec($ch); |
131 | 131 | $err = curl_error($ch); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | curl_close($ch); |
134 | 134 | |
135 | 135 | if ($err) { |
136 | - throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('cURL Error #:' . $err); |
|
136 | + throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('cURL Error #:'.$err); |
|
137 | 137 | } |
138 | 138 | if (empty($result['errors'])) { |
139 | 139 | return $result; |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('Err in generate new token.'); |
186 | 186 | } |
187 | 187 | if (!empty($result['accessToken'])) { |
188 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
188 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
189 | 189 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
190 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
190 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
191 | 191 | $this->setRefreshToken($result['refreshToken']); |
192 | 192 | return 'ok'; |
193 | 193 | } |
@@ -204,6 +204,6 @@ discard block |
||
204 | 204 | $this->generateToken(); |
205 | 205 | $data = [ |
206 | 206 | ]; |
207 | - return $this->callCurl('/orders/' . $refNum . '/verify', $data, true, 0, 'GET'); |
|
207 | + return $this->callCurl('/orders/'.$refNum.'/verify', $data, true, 0, 'GET'); |
|
208 | 208 | } |
209 | 209 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | } |
46 | 46 | if (!empty($requestResult['errors'])) { |
47 | 47 | //fail result and show the error |
48 | - $errMsgs = array_map(function ($err) { |
|
48 | + $errMsgs = array_map(function($err) { |
|
49 | 49 | return $err['message']; |
50 | 50 | }, $requestResult['errors']); |
51 | 51 | throw new PurchaseFailedException(implode('\n', $errMsgs)); |