@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function pay(): RedirectionForm |
| 113 | 113 | { |
| 114 | - $payUrl = $this->settings->apiPaymentUrl . $this->invoice->getTransactionId(); |
|
| 114 | + $payUrl = $this->settings->apiPaymentUrl.$this->invoice->getTransactionId(); |
|
| 115 | 115 | |
| 116 | 116 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 117 | 117 | } |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | 208 | if (array_key_exists($status, $translations)) { |
| 209 | - throw new InvalidPaymentException($translations[$status], is_numeric($status)?$status:0); |
|
| 209 | + throw new InvalidPaymentException($translations[$status], is_numeric($status) ? $status : 0); |
|
| 210 | 210 | } else { |
| 211 | - throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', is_numeric($status)?$status:0); |
|
| 211 | + throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', is_numeric($status) ? $status : 0); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | $urlWithQuery = $url; |
| 158 | 158 | foreach ($params as $key => $value) { |
| 159 | - $urlWithQuery .= (parse_url($urlWithQuery, PHP_URL_QUERY) ? '&' : '?') . "{$key}={$value}"; |
|
| 159 | + $urlWithQuery .= (parse_url($urlWithQuery, PHP_URL_QUERY) ? '&' : '?')."{$key}={$value}"; |
|
| 160 | 160 | } |
| 161 | 161 | return $urlWithQuery; |
| 162 | 162 | } |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | 178 | if (array_key_exists($status, $translations)) { |
| 179 | - throw new InvalidPaymentException($translations[$status], is_numeric($status)?$status:0); |
|
| 179 | + throw new InvalidPaymentException($translations[$status], is_numeric($status) ? $status : 0); |
|
| 180 | 180 | } else { |
| 181 | - throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', is_numeric($status)?$status:0); |
|
| 181 | + throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', is_numeric($status) ? $status : 0); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | public function __construct(Invoice $invoice, $settings) |
| 40 | 40 | { |
| 41 | 41 | $this->invoice($invoice); |
| 42 | - $this->settings = (object)$settings; |
|
| 42 | + $this->settings = (object) $settings; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | $mobile = ''; |
| 57 | 57 | //set CellNumber for get user cards |
| 58 | 58 | if (!empty($this->invoice->getDetails()['mobile'])) { |
| 59 | - $mobile = '&CellNumber=' . $this->invoice->getDetails()['mobile']; |
|
| 59 | + $mobile = '&CellNumber='.$this->invoice->getDetails()['mobile']; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $data_query = 'Amount=' . $this->test_input($amount) . '&callbackURL=' . $this->test_input($this->settings->callbackUrl) . '&InvoiceID=' . $this->test_input($this->invoice->getUuid()) . '&TerminalID=' . $this->test_input($this->settings->terminalId) . '&Payload=' . $this->test_input("") . $mobile; |
|
| 62 | + $data_query = 'Amount='.$this->test_input($amount).'&callbackURL='.$this->test_input($this->settings->callbackUrl).'&InvoiceID='.$this->test_input($this->invoice->getUuid()).'&TerminalID='.$this->test_input($this->settings->terminalId).'&Payload='.$this->test_input("").$mobile; |
|
| 63 | 63 | $address_service_token = $this->settings->apiGetToken; |
| 64 | 64 | |
| 65 | 65 | $token_array = $this->makeHttpChargeRequest('POST', $data_query, $address_service_token); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $this->notVerified($resp_code); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $data_query = 'digitalreceipt=' . Request::input('digitalreceipt') . '&Tid=' . $this->settings->terminalId; |
|
| 115 | + $data_query = 'digitalreceipt='.Request::input('digitalreceipt').'&Tid='.$this->settings->terminalId; |
|
| 116 | 116 | $advice_array = $this->makeHttpChargeRequest('POST', $data_query, $this->settings->apiVerificationUrl); |
| 117 | 117 | $decode_advice_array = json_decode($advice_array); |
| 118 | 118 | |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | if (array_key_exists($status, $translations)) { |
| 191 | - throw new InvalidPaymentException($translations[$status], is_numeric($status)?$status:0); |
|
| 191 | + throw new InvalidPaymentException($translations[$status], is_numeric($status) ? $status : 0); |
|
| 192 | 192 | } else { |
| 193 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', is_numeric($status)?$status:0); |
|
| 193 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', is_numeric($status) ? $status : 0); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -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)); |