@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function __construct(Invoice $invoice, $settings) |
50 | 50 | { |
51 | 51 | $this->invoice($invoice); |
52 | - $this->settings = (object)$settings; |
|
52 | + $this->settings = (object) $settings; |
|
53 | 53 | $this->client = new Client( |
54 | 54 | [ |
55 | 55 | 'base_uri' => $this->settings->apiPurchaseUrl, |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $referenceId = hexdec(uniqid()); |
113 | 113 | $amount = $this->invoice->getAmount(); |
114 | 114 | |
115 | - $callback = $this->settings->callbackUrl . "?referenceId=" . $referenceId . "&price=" . $amount . "&mobile=" . $mobile; |
|
115 | + $callback = $this->settings->callbackUrl."?referenceId=".$referenceId."&price=".$amount."&mobile=".$mobile; |
|
116 | 116 | |
117 | 117 | $data = [ |
118 | 118 | 'referenceId' => $referenceId, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function verify(): ReceiptInterface |
169 | 169 | { |
170 | 170 | $data = [ |
171 | - 'referenceId' => (int)$this->getInvoice()->getTransactionId(), |
|
171 | + 'referenceId' => (int) $this->getInvoice()->getTransactionId(), |
|
172 | 172 | 'header' => '', |
173 | 173 | 'content' => http_build_query($_POST), |
174 | 174 | ]; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | $header[] = 'Content-Type: application/json'; |
308 | 308 | if ($forAuth) { |
309 | - $header[] = 'Authorization: Bearer ' . $this->auth(); |
|
309 | + $header[] = 'Authorization: Bearer '.$this->auth(); |
|
310 | 310 | } |
311 | 311 | $ch = curl_init($url); |
312 | 312 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
@@ -195,7 +195,7 @@ |
||
195 | 195 | $terminalCode = $this->settings->terminalCode; |
196 | 196 | $amount = $this->invoice->getAmount(); //rial |
197 | 197 | $redirectAddress = $this->settings->callbackUrl; |
198 | - $invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time()); |
|
198 | + $invoiceNumber = crc32($this->invoice->getUuid()).rand(0, time()); |
|
199 | 199 | |
200 | 200 | $iranTime = new DateTime('now', new DateTimeZone('Asia/Tehran')); |
201 | 201 | $timeStamp = $iranTime->format("Y/m/d H:i:s"); |
@@ -139,7 +139,7 @@ |
||
139 | 139 | $error_message = $r['errorMessage']; |
140 | 140 | throw new InvalidPaymentException($error_message); |
141 | 141 | } else { //success |
142 | - $receipt = $this->createReceipt($params['referenceNumber']); |
|
142 | + $receipt = $this->createReceipt($params['referenceNumber']); |
|
143 | 143 | $receipt->detail([ |
144 | 144 | 'referenceNo' => $params['referenceNumber'], |
145 | 145 | 'rrn' => Request::input('rrn'), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ))->GetToken2Result; |
78 | 78 | $result = json_decode($response); |
79 | 79 | |
80 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, ['0', '00'])) { |
|
80 | + if (!isset($result->ResCod) || !in_array($result->ResCod, ['0', '00'])) { |
|
81 | 81 | // error has happened |
82 | 82 | $message = $result->Message ?? 'خطای ناشناخته رخ داده'; |
83 | 83 | throw new PurchaseFailedException($message); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function verify() : ReceiptInterface |
122 | 122 | { |
123 | 123 | $resCode = Request::input('ResCod'); |
124 | - if (! in_array($resCode, array('0', '00'))) { |
|
124 | + if (!in_array($resCode, array('0', '00'))) { |
|
125 | 125 | $message = 'پرداخت توسط کاربر لغو شد'; |
126 | 126 | throw new InvalidPaymentException($message); |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $response = $client->Confirm2($data)->Confirm2Result; |
140 | 140 | $result = json_decode($response); |
141 | 141 | |
142 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, array('0', '00'))) { |
|
142 | + if (!isset($result->ResCod) || !in_array($result->ResCod, array('0', '00'))) { |
|
143 | 143 | $message = $result->Message ?? 'خطا در انجام عملیات رخ داده است'; |
144 | 144 | throw new InvalidPaymentException($message); |
145 | 145 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | */ |
91 | 91 | public function pay(): RedirectionForm |
92 | 92 | { |
93 | - $url = $this->settings->apiPaymentUrl . $this->invoice->getTransactionId(); |
|
93 | + $url = $this->settings->apiPaymentUrl.$this->invoice->getTransactionId(); |
|
94 | 94 | |
95 | 95 | return $this->redirectWithForm($url, [], 'GET'); |
96 | 96 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function __construct(Invoice $invoice, $settings) |
38 | 38 | { |
39 | 39 | $this->invoice($invoice); |
40 | - $this->settings = (object)$settings; |
|
40 | + $this->settings = (object) $settings; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $response = $soap->RequestToken($data['MID'], $data['ResNum'], $data['Amount'], $data['CellNumber']); |
79 | 79 | |
80 | - $status = (int)$response; |
|
80 | + $status = (int) $response; |
|
81 | 81 | |
82 | 82 | if ($status < 0) { // if something has done in a wrong way |
83 | 83 | $this->purchaseFailed($response); |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | ]), |
137 | 137 | ] |
138 | 138 | ); |
139 | - $status = (int)$soap->VerifyTransaction($data['RefNum'], $data['merchantId']); |
|
139 | + $status = (int) $soap->VerifyTransaction($data['RefNum'], $data['merchantId']); |
|
140 | 140 | |
141 | 141 | if ($status < 0) { |
142 | 142 | $this->notVerified($status); |
143 | 143 | } |
144 | 144 | |
145 | - $receipt = $this->createReceipt($data['RefNum']); |
|
145 | + $receipt = $this->createReceipt($data['RefNum']); |
|
146 | 146 | $receipt->detail([ |
147 | 147 | 'traceNo' => Request::input('TraceNo'), |
148 | 148 | 'referenceNo' => Request::input('RRN'), |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function pay(): RedirectionForm |
92 | 92 | { |
93 | 93 | $url = $this->settings->mode === "normal" ? $this->settings->apiPaymentUrl : $this->settings->apiPaymentUrlSandbox; |
94 | - $url = $url . $this->invoice->getTransactionId(); |
|
94 | + $url = $url.$this->invoice->getTransactionId(); |
|
95 | 95 | |
96 | 96 | return $this->redirectWithForm($url, [], 'GET'); |
97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $tracking_number = Request::post("tracking_number"); |
108 | 108 | $transid = Request::post("transid"); |
109 | - if ($tracking_number === null || $tracking_number === ""|| $transid === ""|| $transid === null) { |
|
109 | + if ($tracking_number === null || $tracking_number === "" || $transid === "" || $transid === null) { |
|
110 | 110 | $this->notVerified('پرداخت ناموفق.'); |
111 | 111 | } |
112 | 112 | $data = [ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function getErrorMessage($code) |
174 | 174 | { |
175 | - $code = (int)$code; |
|
175 | + $code = (int) $code; |
|
176 | 176 | switch ($code) { |
177 | 177 | case -1: return "مبلغ نباید خالی باشد."; |
178 | 178 | case -2: return "کد پین درگاه نمیتواند خالی باشد."; |
@@ -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 | } |
70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $callback = $this->settings->callbackUrl; |
85 | 85 | $fallback = $this->settings->fallbackUrl; |
86 | 86 | $sub_url = self::subUrls['purchase']; |
87 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
87 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
88 | 88 | |
89 | 89 | $signature = $this->makeSignature( |
90 | 90 | $sub_url, |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | private function getPaymentStatus() |
254 | 254 | { |
255 | 255 | $sub_url = self::subUrls['paymentStatus']; |
256 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
256 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
257 | 257 | |
258 | 258 | $signature = $this->makeSignature( |
259 | 259 | $sub_url, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | ]; |
291 | 291 | |
292 | 292 | if (array_key_exists($status, $translations)) { |
293 | - throw new PurchaseFailedException("تراکنش در وضعیت " . $translations[$status] . " است."); |
|
293 | + throw new PurchaseFailedException("تراکنش در وضعیت ".$translations[$status]." است."); |
|
294 | 294 | } else { |
295 | 295 | throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.'); |
296 | 296 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | private function VerifyTransaction() |
314 | 314 | { |
315 | 315 | $sub_url = self::subUrls['verify']; |
316 | - $url = $this->settings->apiPaymentUrl . $sub_url; |
|
316 | + $url = $this->settings->apiPaymentUrl.$sub_url; |
|
317 | 317 | |
318 | 318 | $signature = $this->makeSignature( |
319 | 319 | $sub_url, |