@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | $requestResult = $this->jibit->paymentRequest($this->invoice->getAmount(), $this->invoice->getUuid(), $this->invoice->getDetail('mobile'), $this->settings->callbackUrl); |
58 | 58 | |
59 | 59 | |
60 | - if (! empty($requestResult['pspSwitchingUrl'])) { |
|
60 | + if (!empty($requestResult['pspSwitchingUrl'])) { |
|
61 | 61 | $this->paymentUrl = $requestResult['pspSwitchingUrl']; |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($requestResult['errors'])) { |
|
65 | - $errMsgs = array_map(function ($err) { |
|
64 | + if (!empty($requestResult['errors'])) { |
|
65 | + $errMsgs = array_map(function($err) { |
|
66 | 66 | return $err['code']; |
67 | 67 | }, $requestResult['errors']); |
68 | 68 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $requestResult = $this->jibit->paymentVerify($purchaseId); |
105 | 105 | |
106 | - if (! empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
106 | + if (!empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
107 | 107 | $order = $this->jibit->getOrderById($purchaseId); |
108 | 108 | |
109 | 109 | $receipt = new Receipt('jibit', $purchaseId); |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $cache = $this->cacheArray; |
118 | 118 | $cache["hash-sum"] = $this->getStringHash(serialize($cache)); |
119 | 119 | $data = serialize($cache); |
120 | - $firstLine = '<?php die("Access denied") ?>' . PHP_EOL; |
|
121 | - $success = file_put_contents($this->getCacheFilePath(), $firstLine . $data) !== false; |
|
120 | + $firstLine = '<?php die("Access denied") ?>'.PHP_EOL; |
|
121 | + $success = file_put_contents($this->getCacheFilePath(), $firstLine.$data) !== false; |
|
122 | 122 | |
123 | 123 | if (!$success) { |
124 | 124 | throw new \Exception("Cannot save cache"); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function store($key, $data, $expiration = 60, $permanent = false) |
141 | 141 | { |
142 | 142 | if (!is_string($key)) { |
143 | - throw new \InvalidArgumentException('$key must be a string, got type "' . get_class($key) . '" instead'); |
|
143 | + throw new \InvalidArgumentException('$key must be a string, got type "'.get_class($key).'" instead'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($this->isDevMode()) { |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | private function getStringHash($str) |
347 | 347 | { |
348 | 348 | if (!is_string($str)) { |
349 | - throw new \InvalidArgumentException('$key must be a string, got type "' . get_class($str) . '" instead'); |
|
349 | + throw new \InvalidArgumentException('$key must be a string, got type "'.get_class($str).'" instead'); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | return md5($str); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | public function setCacheFilename($cacheFilename) |
427 | 427 | { |
428 | 428 | if (!is_string($cacheFilename)) { |
429 | - throw new \InvalidArgumentException('$key must be a string, got type "' . get_class($cacheFilename) . '" instead'); |
|
429 | + throw new \InvalidArgumentException('$key must be a string, got type "'.get_class($cacheFilename).'" instead'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $this->cacheFilename = $cacheFilename; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function getCacheFilePath() |
467 | 467 | { |
468 | - return $this->getCacheDir() . $this->getCacheFilenameHashed() . $this->getCacheFileExtension(); |
|
468 | + return $this->getCacheDir().$this->getCacheFilenameHashed().$this->getCacheFileExtension(); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getOrderById($id) |
95 | 95 | { |
96 | - return $this->callCurl('/purchases?purchaseId=' . $id, [], true, 0, 'GET'); |
|
96 | + return $this->callCurl('/purchases?purchaseId='.$id, [], true, 0, 'GET'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | if (!empty($result['accessToken'])) { |
139 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
139 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
140 | 140 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
141 | 141 | |
142 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
142 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
143 | 143 | $this->setRefreshToken($result['refreshToken']); |
144 | 144 | |
145 | 145 | return 'ok'; |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | $accessToken = $this->getAccessToken(); |
170 | 170 | } |
171 | 171 | |
172 | - $ch = curl_init($this->baseUrl . $url); |
|
172 | + $ch = curl_init($this->baseUrl.$url); |
|
173 | 173 | curl_setopt($ch, CURLOPT_USERAGENT, 'Jibit.class Rest Api'); |
174 | 174 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
175 | 175 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); |
176 | 176 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
177 | 177 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
178 | 178 | 'Content-Type: application/json', |
179 | - 'Authorization: ' . $accessToken, |
|
180 | - 'Content-Length: ' . strlen($jsonData) |
|
179 | + 'Authorization: '.$accessToken, |
|
180 | + 'Content-Length: '.strlen($jsonData) |
|
181 | 181 | ]); |
182 | 182 | |
183 | 183 | $result = curl_exec($ch); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | curl_close($ch); |
187 | 187 | |
188 | 188 | if ($err) { |
189 | - throw new PurchaseFailedException('cURL Error #:' . $err); |
|
189 | + throw new PurchaseFailedException('cURL Error #:'.$err); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if (empty($result['errors'])) { |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | throw new PurchaseFailedException('Token generation encoutered an error.'); |
256 | 256 | } |
257 | 257 | |
258 | - if (! empty($result['accessToken'])) { |
|
259 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
258 | + if (!empty($result['accessToken'])) { |
|
259 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
260 | 260 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
261 | 261 | |
262 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
262 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
263 | 263 | $this->setRefreshToken($result['refreshToken']); |
264 | 264 | |
265 | 265 | return 'ok'; |
@@ -280,6 +280,6 @@ discard block |
||
280 | 280 | $this->generateToken(); |
281 | 281 | $data = []; |
282 | 282 | |
283 | - return $this->callCurl('/purchases/' . $purchaseId . '/verify', $data, true, 0, 'GET'); |
|
283 | + return $this->callCurl('/purchases/'.$purchaseId.'/verify', $data, true, 0, 'GET'); |
|
284 | 284 | } |
285 | 285 | } |
@@ -124,8 +124,8 @@ |
||
124 | 124 | 'apiPaymentUrl' => 'https://napi.jibit.ir/ppg/v3', |
125 | 125 | 'apiKey' => '', |
126 | 126 | 'secretKey' => '', |
127 | - // You can change the token storage path in Laravel like this |
|
128 | - // 'tokenStoragePath' => function_exists('storage_path') ? storage_path('jibit/') : 'jibit/' |
|
127 | + // You can change the token storage path in Laravel like this |
|
128 | + // 'tokenStoragePath' => function_exists('storage_path') ? storage_path('jibit/') : 'jibit/' |
|
129 | 129 | 'tokenStoragePath' => 'jibit/', |
130 | 130 | 'callbackUrl' => 'http://yoursite.com/path/to', |
131 | 131 | 'description' => 'payment using jibit', |