@@ -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 | } |
@@ -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 | } |
@@ -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 = [ |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | protected function notVerified($message, $status = 0) |
161 | 161 | { |
162 | 162 | if (empty($message)) { |
163 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
163 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
164 | 164 | } else { |
165 | - throw new InvalidPaymentException($message, (int)$status); |
|
165 | + throw new InvalidPaymentException($message, (int) $status); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -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 "کد پین درگاه نمیتواند خالی باشد."; |
@@ -166,9 +166,9 @@ |
||
166 | 166 | private function notVerified($message, $status) |
167 | 167 | { |
168 | 168 | if ($message) { |
169 | - throw new InvalidPaymentException($message, (int)$status); |
|
169 | + throw new InvalidPaymentException($message, (int) $status); |
|
170 | 170 | } else { |
171 | - throw new InvalidPaymentException('payment failed', (int)$status); |
|
171 | + throw new InvalidPaymentException('payment failed', (int) $status); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
@@ -200,7 +200,7 @@ |
||
200 | 200 | */ |
201 | 201 | private function notVerified($message, $status) |
202 | 202 | { |
203 | - throw new InvalidPaymentException($message, (int)$status); |
|
203 | + throw new InvalidPaymentException($message, (int) $status); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -155,9 +155,9 @@ |
||
155 | 155 | private function notVerified($message, $status) |
156 | 156 | { |
157 | 157 | if (empty($message)) { |
158 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
158 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
159 | 159 | } else { |
160 | - throw new InvalidPaymentException($message, (int)$status); |
|
160 | + throw new InvalidPaymentException($message, (int) $status); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |