@@ -195,9 +195,9 @@ |
||
195 | 195 | -90 => 'تراکنش قبلا تایید شده است' |
196 | 196 | ); |
197 | 197 | if (array_key_exists($status, $translations)) { |
198 | - throw new InvalidPaymentException($translations[$status], is_numeric($status)?$status:0); |
|
198 | + throw new InvalidPaymentException($translations[$status], is_numeric($status) ? $status : 0); |
|
199 | 199 | } else { |
200 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', is_numeric($status)?$status:0); |
|
200 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', is_numeric($status) ? $status : 0); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -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 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function __construct(Invoice $invoice, $settings) |
39 | 39 | { |
40 | 40 | $this->invoice($invoice); |
41 | - $this->settings = (object)$settings; |
|
41 | + $this->settings = (object) $settings; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | // purchase was not successful |
81 | 81 | if ($data[0] != "0") { |
82 | - throw new PurchaseFailedException($this->translateStatus($data[0]), (int)$data[0]); |
|
82 | + throw new PurchaseFailedException($this->translateStatus($data[0]), (int) $data[0]); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $this->invoice->transactionId($data[1]); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | // step1: verify request |
146 | - $verifyResponse = (int)$soap->bpVerifyRequest($data)->return; |
|
146 | + $verifyResponse = (int) $soap->bpVerifyRequest($data)->return; |
|
147 | 147 | if ($verifyResponse != 0) { |
148 | 148 | // rollback money and throw exception |
149 | 149 | // avoid rollback if request was already verified |
@@ -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 | //convert to rial |
64 | 64 | $this->invoice->amount($this->invoice->getAmount() * 10); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'localInvoiceId' => $this->invoice->getUuid(), |
200 | 200 | 'amountInRials' => $this->invoice->getAmount(), |
201 | 201 | 'localDate' => $this->getTime()['content'], |
202 | - 'callbackURL' => $this->settings->callbackUrl . "?" . http_build_query(['invoice' => $this->invoice->getUuid()]), |
|
202 | + 'callbackURL' => $this->settings->callbackUrl."?".http_build_query(['invoice' => $this->invoice->getUuid()]), |
|
203 | 203 | 'paymentId' => "0", |
204 | 204 | 'additionalData' => '', |
205 | 205 | ]); |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | public function reverse(): array |
214 | 214 | { |
215 | 215 | return $this->callApi('POST', self::ReverseURL, [ |
216 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
217 | - 'payGateTranId' => (int)$this->invoice->getUuid() |
|
216 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
217 | + 'payGateTranId' => (int) $this->invoice->getUuid() |
|
218 | 218 | ]); |
219 | 219 | } |
220 | 220 | |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | public function cancel(): array |
227 | 227 | { |
228 | 228 | return $this->callApi('POST', self::CancelURL, [ |
229 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
230 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
229 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
230 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
231 | 231 | ]); |
232 | 232 | } |
233 | 233 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | public function verifyTransaction(): array |
240 | 240 | { |
241 | 241 | return $this->callApi('POST', self::VerifyURL, [ |
242 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
243 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
242 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
243 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
244 | 244 | ]); |
245 | 245 | } |
246 | 246 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | public function settlement(): array |
253 | 253 | { |
254 | 254 | return $this->callApi('POST', self::SettlementURL, [ |
255 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, |
|
256 | - 'payGateTranId' => (int)$this->payGateTransactionId |
|
255 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, |
|
256 | + 'payGateTranId' => (int) $this->payGateTransactionId |
|
257 | 257 | ]); |
258 | 258 | } |
259 | 259 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function cardHash(): array |
266 | 266 | { |
267 | - return $this->callApi('GET', self::CardHashURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
267 | + return $this->callApi('GET', self::CardHashURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function transactionResult(): array |
276 | 276 | { |
277 | - return $this->callApi('GET', self::TranResultURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); |
|
277 | + return $this->callApi('GET', self::TranResultURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function __construct(Invoice $invoice, $settings) |
53 | 53 | { |
54 | 54 | $this->invoice($invoice); |
55 | - $this->settings=$settings; |
|
55 | + $this->settings = $settings; |
|
56 | 56 | $this->client = new Client(); |
57 | 57 | $this->oauthToken = $this->oauth(); |
58 | 58 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function verify(): ReceiptInterface |
115 | 115 | { |
116 | - $tracingId=Request::input("trackingCode"); |
|
116 | + $tracingId = Request::input("trackingCode"); |
|
117 | 117 | |
118 | 118 | $response = $this->client->request( |
119 | 119 | 'POST', |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | "grant_type" => 'password', |
156 | 156 | ] |
157 | 157 | ); |
158 | - if ($response->getStatusCode()!=200) { |
|
159 | - if ($response->getStatusCode()==401) { |
|
158 | + if ($response->getStatusCode() != 200) { |
|
159 | + if ($response->getStatusCode() == 401) { |
|
160 | 160 | throw new PurchaseFailedException("خطا نام کاربری یا رمز عبور شما اشتباه می باشد."); |
161 | 161 | } else { |
162 | 162 | throw new PurchaseFailedException("خطا در هنگام احراز هویت."); |
@@ -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; |
@@ -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)); |