@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $token = Request::input('Token'); |
| 108 | 108 | |
| 109 | 109 | if ($status != 0 || empty($token)) { |
| 110 | - throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int)$status); |
|
| 110 | + throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int) $status); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $data = $this->prepareVerificationData(); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $hasWrongRRN = (!isset($result->RRN) || $result->RRN <= 0); |
| 124 | 124 | if ($hasWrongStatus || $hasWrongRRN) { |
| 125 | 125 | $message = 'خطا از سمت بانک با کد '.$result->Status.' رخ داده است.'; |
| 126 | - throw new InvalidPaymentException($message, (int)$result->Status); |
|
| 126 | + throw new InvalidPaymentException($message, (int) $result->Status); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return $this->createReceipt($result->RRN); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function getOrderById($id) |
| 106 | 106 | { |
| 107 | - return $this->callCurl('/purchases?purchaseId=' . $id, [], true, 0, 'GET'); |
|
| 107 | + return $this->callCurl('/purchases?purchaseId='.$id, [], true, 0, 'GET'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if (!empty($result['accessToken'])) { |
| 154 | - $this->cache->set('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
| 154 | + $this->cache->set('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
| 155 | 155 | $this->cache->set('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
| 156 | 156 | |
| 157 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
| 157 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
| 158 | 158 | $this->setRefreshToken($result['refreshToken']); |
| 159 | 159 | |
| 160 | 160 | return 'ok'; |
@@ -184,15 +184,15 @@ discard block |
||
| 184 | 184 | $accessToken = $this->getAccessToken(); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $ch = curl_init($this->baseUrl . $url); |
|
| 187 | + $ch = curl_init($this->baseUrl.$url); |
|
| 188 | 188 | curl_setopt($ch, CURLOPT_USERAGENT, 'Jibit.class Rest Api'); |
| 189 | 189 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
| 190 | 190 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); |
| 191 | 191 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 192 | 192 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
| 193 | 193 | 'Content-Type: application/json', |
| 194 | - 'Authorization: ' . $accessToken, |
|
| 195 | - 'Content-Length: ' . strlen($jsonData) |
|
| 194 | + 'Authorization: '.$accessToken, |
|
| 195 | + 'Content-Length: '.strlen($jsonData) |
|
| 196 | 196 | ]); |
| 197 | 197 | |
| 198 | 198 | $result = curl_exec($ch); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | curl_close($ch); |
| 202 | 202 | |
| 203 | 203 | if ($err) { |
| 204 | - throw new PurchaseFailedException('cURL Error #:' . $err); |
|
| 204 | + throw new PurchaseFailedException('cURL Error #:'.$err); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | if (empty($result['errors'])) { |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | throw new PurchaseFailedException('Token generation encoutered an error.'); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if (! empty($result['accessToken'])) { |
|
| 275 | - $this->cache->set('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
| 274 | + if (!empty($result['accessToken'])) { |
|
| 275 | + $this->cache->set('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
| 276 | 276 | $this->cache->set('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
| 277 | 277 | |
| 278 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
| 278 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
| 279 | 279 | $this->setRefreshToken($result['refreshToken']); |
| 280 | 280 | |
| 281 | 281 | return 'ok'; |
@@ -296,6 +296,6 @@ discard block |
||
| 296 | 296 | $this->generateToken(); |
| 297 | 297 | $data = []; |
| 298 | 298 | |
| 299 | - return $this->callCurl('/purchases/' . $purchaseId . '/verify', $data, true, 0, 'GET'); |
|
| 299 | + return $this->callCurl('/purchases/'.$purchaseId.'/verify', $data, true, 0, 'GET'); |
|
| 300 | 300 | } |
| 301 | 301 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - if (! empty($requestResult['pspSwitchingUrl'])) { |
|
| 67 | + if (!empty($requestResult['pspSwitchingUrl'])) { |
|
| 68 | 68 | $this->paymentUrl = $requestResult['pspSwitchingUrl']; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if (! empty($requestResult['errors'])) { |
|
| 72 | - $errMsgs = array_map(function ($err) { |
|
| 71 | + if (!empty($requestResult['errors'])) { |
|
| 72 | + $errMsgs = array_map(function($err) { |
|
| 73 | 73 | return $err['code']; |
| 74 | 74 | }, $requestResult['errors']); |
| 75 | 75 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $requestResult = $this->jibit->paymentVerify($purchaseId); |
| 112 | 112 | |
| 113 | - if (! empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
| 113 | + if (!empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
| 114 | 114 | $order = $this->jibit->getOrderById($purchaseId); |
| 115 | 115 | |
| 116 | 116 | $receipt = new Receipt('jibit', $purchaseId); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function __construct(Invoice $invoice, $settings) |
| 62 | 62 | { |
| 63 | 63 | $this->invoice($invoice); |
| 64 | - $this->settings= (object) $settings; |
|
| 64 | + $this->settings = (object) $settings; |
|
| 65 | 65 | $this->client = new Client(); |
| 66 | 66 | $this->oauthToken = $this->oauth(); |
| 67 | 67 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | RequestOptions::HEADERS => [ |
| 114 | 114 | 'Agent' => $this->invoice->getDetail('agent') ?? 'WEB', |
| 115 | 115 | 'Content-Type' => 'application/json', |
| 116 | - 'Authorization' => 'Bearer ' . $this->oauthToken, |
|
| 116 | + 'Authorization' => 'Bearer '.$this->oauthToken, |
|
| 117 | 117 | 'Digipay-Version' => '2022-02-02', |
| 118 | 118 | ], |
| 119 | 119 | RequestOptions::HTTP_ERRORS => false, |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | $response = $this->client->request( |
| 154 | 154 | 'POST', |
| 155 | - $this->settings->apiVerificationUrl . $tracingId, |
|
| 155 | + $this->settings->apiVerificationUrl.$tracingId, |
|
| 156 | 156 | [ |
| 157 | 157 | RequestOptions::QUERY => ['type' => $digipayTicketType], |
| 158 | 158 | RequestOptions::HEADERS => [ |
| 159 | 159 | "Accept" => "application/json", |
| 160 | - "Authorization" => "Bearer " . $this->oauthToken, |
|
| 160 | + "Authorization" => "Bearer ".$this->oauthToken, |
|
| 161 | 161 | ], |
| 162 | 162 | RequestOptions::HTTP_ERRORS => false, |
| 163 | 163 | ] |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $this->settings->apiOauthUrl, |
| 187 | 187 | [ |
| 188 | 188 | RequestOptions::HEADERS => [ |
| 189 | - 'Authorization' => 'Basic ' . base64_encode("{$this->settings->client_id}:{$this->settings->client_secret}"), |
|
| 189 | + 'Authorization' => 'Basic '.base64_encode("{$this->settings->client_id}:{$this->settings->client_secret}"), |
|
| 190 | 190 | ], |
| 191 | 191 | RequestOptions::MULTIPART => [ |
| 192 | 192 | [ |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $this->invoice($invoice); |
| 48 | 48 | $this->client = new Client(); |
| 49 | - $this->settings = (object)$settings; |
|
| 49 | + $this->settings = (object) $settings; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function pay(): RedirectionForm |
| 120 | 120 | { |
| 121 | - $payUrl = $this->settings->apiPaymentUrl . '?authority=' . $this->invoice->getTransactionId(); |
|
| 121 | + $payUrl = $this->settings->apiPaymentUrl.'?authority='.$this->invoice->getTransactionId(); |
|
| 122 | 122 | |
| 123 | 123 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 124 | 124 | } |
@@ -194,7 +194,7 @@ |
||
| 194 | 194 | */ |
| 195 | 195 | protected function prepareInvoiceData(): array |
| 196 | 196 | { |
| 197 | - $this->invoice->uuid($this->invoice->getNumericUuid() . rand(0, time())); |
|
| 197 | + $this->invoice->uuid($this->invoice->getNumericUuid().rand(0, time())); |
|
| 198 | 198 | $action = 1003; // 1003 : for buy request (bank standard) |
| 199 | 199 | $merchantCode = $this->settings->merchantId; |
| 200 | 200 | $terminalCode = $this->settings->terminalCode; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function __construct(Invoice $invoice, $settings) |
| 59 | 59 | { |
| 60 | 60 | $this->invoice($invoice); |
| 61 | - $this->settings = (object)$settings; |
|
| 61 | + $this->settings = (object) $settings; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $this->invoice->convertUuidToNumeric(); |
| 192 | 192 | if (strpos($this->settings->callbackUrl, '?') !== false) { |
| 193 | - $query = '&' . http_build_query(['invoice' => $this->invoice->getNumericUuid()]); |
|
| 193 | + $query = '&'.http_build_query(['invoice' => $this->invoice->getNumericUuid()]); |
|
| 194 | 194 | } else { |
| 195 | - $query = '?' . http_build_query(['invoice' => $this->invoice->getNumericUuid()]); |
|
| 195 | + $query = '?'.http_build_query(['invoice' => $this->invoice->getNumericUuid()]); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return $this->callApi('POST', self::TokenURL, [ |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | 'localInvoiceId' => $this->invoice->getNumericUuid(), |
| 202 | 202 | 'amountInRials' => $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1), // convert to rial |
| 203 | 203 | 'localDate' => $this->getTime()['content'], |
| 204 | - 'callbackURL' => $this->settings->callbackUrl . $query, |
|
| 204 | + 'callbackURL' => $this->settings->callbackUrl.$query, |
|
| 205 | 205 | 'paymentId' => "0", |
| 206 | 206 | 'additionalData' => '', |
| 207 | 207 | ]); |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | public function reverse(): array |
| 216 | 216 | { |
| 217 | 217 | return $this->callApi('POST', self::ReverseURL, [ |
| 218 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 219 | - 'payGateTranId' => (int)$this->invoice->getUuid() |
|
| 218 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 219 | + 'payGateTranId' => (int) $this->invoice->getUuid() |
|
| 220 | 220 | ]); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | public function cancel(): array |
| 229 | 229 | { |
| 230 | 230 | return $this->callApi('POST', self::CancelURL, [ |
| 231 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 232 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 231 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 232 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 233 | 233 | ]); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | public function verifyTransaction(): array |
| 242 | 242 | { |
| 243 | 243 | return $this->callApi('POST', self::VerifyURL, [ |
| 244 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 245 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 244 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 245 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 246 | 246 | ]); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | public function settlement(): array |
| 255 | 255 | { |
| 256 | 256 | return $this->callApi('POST', self::SettlementURL, [ |
| 257 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 258 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 257 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 258 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 259 | 259 | ]); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function cardHash(): array |
| 268 | 268 | { |
| 269 | - return $this->callApi('GET', self::CardHashURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
| 269 | + return $this->callApi('GET', self::CardHashURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function transactionResult(): array |
| 278 | 278 | { |
| 279 | - return $this->callApi('GET', self::TranResultURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
| 279 | + return $this->callApi('GET', self::TranResultURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } else { |
| 72 | 72 | $description = $this->settings->description; |
| 73 | 73 | } |
| 74 | - $this->invoice->uuid(intval(1, time()) . $this->invoice->getNumericUuid()); |
|
| 74 | + $this->invoice->uuid(intval(1, time()).$this->invoice->getNumericUuid()); |
|
| 75 | 75 | |
| 76 | 76 | $data->merchantId = $this->settings->merchantId; |
| 77 | 77 | $data->amount = $this->invoice->getAmount(); |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | private function notVerified($message, $status) |
| 172 | 172 | { |
| 173 | 173 | if ($message) { |
| 174 | - throw new InvalidPaymentException($message, (int)$status); |
|
| 174 | + throw new InvalidPaymentException($message, (int) $status); |
|
| 175 | 175 | } else { |
| 176 | - throw new InvalidPaymentException('payment failed', (int)$status); |
|
| 176 | + throw new InvalidPaymentException('payment failed', (int) $status); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function __construct(Invoice $invoice, $settings) |
| 47 | 47 | { |
| 48 | 48 | $this->invoice($invoice); |
| 49 | - $this->settings = (object)$settings; |
|
| 49 | + $this->settings = (object) $settings; |
|
| 50 | 50 | $this->httpClientInit(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function purchase() |
| 61 | 61 | { |
| 62 | 62 | $this->invoice->uuid($this->invoice->getNumericUuid()); |
| 63 | - $token = $this->getToken(); |
|
| 63 | + $token = $this->getToken(); |
|
| 64 | 64 | $this->invoice->transactionId($token['Token']); |
| 65 | 65 | |
| 66 | 66 | return $this->invoice->getTransactionId(); |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | private function httpClientInit(): void |
| 185 | 185 | { |
| 186 | 186 | $this->client = new Client([ |
| 187 | - 'curl'=>[CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 187 | + 'curl'=>[CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1', ], |
|
| 188 | 188 | 'verify' => false, |
| 189 | 189 | 'base_uri' => $this->settings->baseUri, |
| 190 | - 'headers' => ['Content-Type' => 'application/json',], |
|
| 190 | + 'headers' => ['Content-Type' => 'application/json', ], |
|
| 191 | 191 | ]); |
| 192 | 192 | } |
| 193 | 193 | |