@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $receipt = new Receipt('fanavacard', $referenceId); |
| 137 | 137 | $receipt->detail([ |
| 138 | - 'ResNum'=>Request::input('ResNum'), |
|
| 139 | - 'RefNum'=>Request::input('RefNum'), |
|
| 140 | - 'token'=>Request::input('token'), |
|
| 141 | - 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
| 142 | - 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
| 143 | - 'transactionAmount'=>Request::input('transactionAmount'), |
|
| 144 | - 'emailAddress'=>Request::input('emailAddress'), |
|
| 145 | - 'mobileNo'=>Request::input('mobileNo'), |
|
| 146 | - ]); |
|
| 138 | + 'ResNum'=>Request::input('ResNum'), |
|
| 139 | + 'RefNum'=>Request::input('RefNum'), |
|
| 140 | + 'token'=>Request::input('token'), |
|
| 141 | + 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
| 142 | + 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
| 143 | + 'transactionAmount'=>Request::input('transactionAmount'), |
|
| 144 | + 'emailAddress'=>Request::input('emailAddress'), |
|
| 145 | + 'mobileNo'=>Request::input('mobileNo'), |
|
| 146 | + ]); |
|
| 147 | 147 | return $receipt; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | private function httpClientInit(): void |
| 186 | 186 | { |
| 187 | 187 | $this->client = new Client([ |
| 188 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 189 | - 'verify' => false, |
|
| 190 | - 'base_uri' => $this->settings->baseUri, |
|
| 191 | - 'headers' => ['Content-Type' => 'application/json',], |
|
| 192 | - ]); |
|
| 188 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 189 | + 'verify' => false, |
|
| 190 | + 'base_uri' => $this->settings->baseUri, |
|
| 191 | + 'headers' => ['Content-Type' => 'application/json',], |
|
| 192 | + ]); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | private function getWsContext(): array |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function __construct(Invoice $invoice, $settings) |
| 46 | 46 | { |
| 47 | 47 | $this->invoice($invoice); |
| 48 | - $this->settings = (object)$settings; |
|
| 48 | + $this->settings = (object) $settings; |
|
| 49 | 49 | $this->httpClientInit(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function purchase() |
| 60 | 60 | { |
| 61 | 61 | $this->invoice->uuid(crc32($this->invoice->getUuid())); |
| 62 | - $token = $this->getToken(); |
|
| 62 | + $token = $this->getToken(); |
|
| 63 | 63 | $this->invoice->transactionId($token['Token']); |
| 64 | 64 | |
| 65 | 65 | return $this->invoice->getTransactionId(); |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | private function httpClientInit(): void |
| 184 | 184 | { |
| 185 | 185 | $this->client = new Client([ |
| 186 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 186 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1', ], |
|
| 187 | 187 | 'verify' => false, |
| 188 | 188 | 'base_uri' => $this->settings->baseUri, |
| 189 | - 'headers' => ['Content-Type' => 'application/json',], |
|
| 189 | + 'headers' => ['Content-Type' => 'application/json', ], |
|
| 190 | 190 | ]); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | |
| 115 | 115 | // convert to rial |
| 116 | 116 | if ($this->settings->currency == 'T') { |
| 117 | - $multiIdentityRows = array_map(function ($item) { |
|
| 117 | + $multiIdentityRows = array_map(function($item) { |
|
| 118 | 118 | $item['Amount'] = $item['Amount'] * 10; |
| 119 | 119 | return $item; |
| 120 | 120 | }, $multiIdentityRows); |
@@ -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 | /** |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | public function token(): array |
| 192 | 192 | { |
| 193 | 193 | if (strpos($this->settings->callbackUrl, '?') !== false) { |
| 194 | - $query = '&' . http_build_query(['invoice' => $this->invoice->getUuid()]); |
|
| 194 | + $query = '&'.http_build_query(['invoice' => $this->invoice->getUuid()]); |
|
| 195 | 195 | } else { |
| 196 | - $query = '?' . http_build_query(['invoice' => $this->invoice->getUuid()]); |
|
| 196 | + $query = '?'.http_build_query(['invoice' => $this->invoice->getUuid()]); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $this->callApi('POST', self::TokenURL, [ |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | 'localInvoiceId' => $this->invoice->getUuid(), |
| 203 | 203 | 'amountInRials' => $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1), // convert to rial |
| 204 | 204 | 'localDate' => $this->getTime()['content'], |
| 205 | - 'callbackURL' => $this->settings->callbackUrl . $query, |
|
| 205 | + 'callbackURL' => $this->settings->callbackUrl.$query, |
|
| 206 | 206 | 'paymentId' => "0", |
| 207 | 207 | 'additionalData' => '', |
| 208 | 208 | ]); |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | public function reverse(): array |
| 217 | 217 | { |
| 218 | 218 | return $this->callApi('POST', self::ReverseURL, [ |
| 219 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 220 | - 'payGateTranId' => (int)$this->invoice->getUuid() |
|
| 219 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 220 | + 'payGateTranId' => (int) $this->invoice->getUuid() |
|
| 221 | 221 | ]); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | public function cancel(): array |
| 230 | 230 | { |
| 231 | 231 | return $this->callApi('POST', self::CancelURL, [ |
| 232 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 233 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 232 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 233 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 234 | 234 | ]); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | public function verifyTransaction(): array |
| 243 | 243 | { |
| 244 | 244 | return $this->callApi('POST', self::VerifyURL, [ |
| 245 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 246 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 245 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 246 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 247 | 247 | ]); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | public function settlement(): array |
| 256 | 256 | { |
| 257 | 257 | return $this->callApi('POST', self::SettlementURL, [ |
| 258 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
| 259 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
| 258 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
| 259 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
| 260 | 260 | ]); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function cardHash(): array |
| 269 | 269 | { |
| 270 | - return $this->callApi('GET', self::CardHashURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
| 270 | + return $this->callApi('GET', self::CardHashURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function transactionResult(): array |
| 279 | 279 | { |
| 280 | - return $this->callApi('GET', self::TranResultURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
| 280 | + return $this->callApi('GET', self::TranResultURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | public function __construct(Invoice $invoice, $settings) |
| 65 | 65 | { |
| 66 | 66 | $this->invoice($invoice); |
| 67 | - $this->settings = (object)$settings; |
|
| 67 | + $this->settings = (object) $settings; |
|
| 68 | 68 | $this->client = new Client(); |
| 69 | 69 | $this->convertAmountItems(); |
| 70 | 70 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (empty($details['phone']) && empty($details['mobile'])) { |
| 78 | 78 | throw new PurchaseFailedException('Phone number is required'); |
| 79 | 79 | } |
| 80 | - if (!isset($details['items']) || count($details['items']) == 0) { |
|
| 80 | + if (!isset($details['items']) || count($details['items']) == 0) { |
|
| 81 | 81 | throw new PurchaseFailedException('Items is required for this driver'); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ? $this->settings->fallbackUrl |
| 89 | 89 | : $callback; |
| 90 | 90 | $sub_url = self::subUrls['purchase']; |
| 91 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
| 91 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
| 92 | 92 | |
| 93 | 93 | $signature = $this->makeSignature( |
| 94 | 94 | $sub_url, |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | |
| 182 | 182 | $new_items = array_map( |
| 183 | - function ($item) { |
|
| 183 | + function($item) { |
|
| 184 | 184 | $item['amount'] *= ($this->settings->currency == 'T' ? 10 : 1); // convert to rial |
| 185 | 185 | return $item; |
| 186 | 186 | }, |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | private function getPaymentStatus() |
| 267 | 267 | { |
| 268 | 268 | $sub_url = self::subUrls['paymentStatus']; |
| 269 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
| 269 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
| 270 | 270 | |
| 271 | 271 | $signature = $this->makeSignature( |
| 272 | 272 | $sub_url, |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | ]; |
| 304 | 304 | |
| 305 | 305 | if (array_key_exists($status, $translations)) { |
| 306 | - throw new PurchaseFailedException("تراکنش در وضعیت " . $translations[$status] . " است."); |
|
| 306 | + throw new PurchaseFailedException("تراکنش در وضعیت ".$translations[$status]." است."); |
|
| 307 | 307 | } else { |
| 308 | 308 | throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.'); |
| 309 | 309 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | private function VerifyTransaction() |
| 327 | 327 | { |
| 328 | 328 | $sub_url = self::subUrls['verify']; |
| 329 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
| 329 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
| 330 | 330 | |
| 331 | 331 | $signature = $this->makeSignature( |
| 332 | 332 | $sub_url, |
@@ -199,7 +199,7 @@ |
||
| 199 | 199 | $terminalCode = $this->settings->terminalCode; |
| 200 | 200 | $amount = $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1); // convert to rial |
| 201 | 201 | $redirectAddress = $this->settings->callbackUrl; |
| 202 | - $invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time()); |
|
| 202 | + $invoiceNumber = crc32($this->invoice->getUuid()).rand(0, time()); |
|
| 203 | 203 | |
| 204 | 204 | $iranTime = new DateTime('now', new DateTimeZone('Asia/Tehran')); |
| 205 | 205 | $timeStamp = $iranTime->format("Y/m/d H:i:s"); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function __construct(Invoice $invoice, $settings) |
| 46 | 46 | { |
| 47 | 47 | $this->invoice($invoice); |
| 48 | - $this->settings = (object)$settings; |
|
| 48 | + $this->settings = (object) $settings; |
|
| 49 | 49 | $this->client = new Client(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $data = [ |
| 63 | 63 | 'api_key' => $this->settings->merchantId, |
| 64 | - 'order_id' => intval(1, time()) . crc32($this->invoice->getUuid()), |
|
| 64 | + 'order_id' => intval(1, time()).crc32($this->invoice->getUuid()), |
|
| 65 | 65 | 'amount' => $this->invoice->getAmount() / ($this->settings->currency == 'T' ? 1 : 10), // convert to toman |
| 66 | 66 | 'callback_uri' => $this->settings->callbackUrl, |
| 67 | 67 | ]; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function pay(): RedirectionForm |
| 123 | 123 | { |
| 124 | - $payUrl = $this->settings->apiPaymentUrl . $this->invoice->getTransactionId(); |
|
| 124 | + $payUrl = $this->settings->apiPaymentUrl.$this->invoice->getTransactionId(); |
|
| 125 | 125 | |
| 126 | 126 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 127 | 127 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function pay(): RedirectionForm |
| 113 | 113 | { |
| 114 | - $url = $this->settings->apiPaymentUrl . $this->invoice->getTransactionId(); |
|
| 114 | + $url = $this->settings->apiPaymentUrl.$this->invoice->getTransactionId(); |
|
| 115 | 115 | |
| 116 | 116 | return $this->redirectWithForm($url, [], 'GET'); |
| 117 | 117 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | protected function notVerified($message, $status = 0) |
| 197 | 197 | { |
| 198 | 198 | if (empty($message)) { |
| 199 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 199 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 200 | 200 | } else { |
| 201 | - throw new InvalidPaymentException($message, (int)$status); |
|
| 201 | + throw new InvalidPaymentException($message, (int) $status); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function pay() : RedirectionForm |
| 82 | 82 | { |
| 83 | - $payUrl = $this->settings->apiPaymentUrl . '?Token=' . $this->invoice->getTransactionId() ; |
|
| 83 | + $payUrl = $this->settings->apiPaymentUrl.'?Token='.$this->invoice->getTransactionId(); |
|
| 84 | 84 | |
| 85 | 85 | return $this->redirectWithForm( |
| 86 | 86 | $payUrl, |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $token = Request::input('Token'); |
| 104 | 104 | |
| 105 | 105 | if ($status != 0 || empty($token)) { |
| 106 | - throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int)$status); |
|
| 106 | + throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int) $status); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $data = $this->prepareVerificationData(); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $hasWrongRRN = (!isset($result->RRN) || $result->RRN <= 0); |
| 120 | 120 | if ($hasWrongStatus || $hasWrongRRN) { |
| 121 | 121 | $message = 'خطا از سمت بانک با کد '.$result->Status.' رخ داده است.'; |
| 122 | - throw new InvalidPaymentException($message, (int)$result->Status); |
|
| 122 | + throw new InvalidPaymentException($message, (int) $result->Status); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $this->createReceipt($result->RRN); |
@@ -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], (int)$status); |
|
| 209 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
| 210 | 210 | } else { |
| 211 | - throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', (int)$status); |
|
| 211 | + throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', (int) $status); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |