@@ -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 |
@@ -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; |
@@ -228,7 +228,9 @@ |
||
228 | 228 | { |
229 | 229 | $cachedData = $this->_loadCache(); |
230 | 230 | (false === $timestamp) ? $type = 'data' : $type = 'time'; |
231 | - if (!isset($cachedData[$key][$type])) return null; |
|
231 | + if (!isset($cachedData[$key][$type])) { |
|
232 | + return null; |
|
233 | + } |
|
232 | 234 | return unserialize($cachedData[$key][$type]); |
233 | 235 | } |
234 | 236 |
@@ -72,7 +72,7 @@ |
||
72 | 72 | // Verify the payment (we must verify to ensure that user has paid the invoice). |
73 | 73 | public function verify(): ReceiptInterface { |
74 | 74 | |
75 | - // $verifyUrl = $this->settings->verifyApiUrl; |
|
75 | + // $verifyUrl = $this->settings->verifyApiUrl; |
|
76 | 76 | |
77 | 77 | $refNum = $this->invoice->getTransactionId(); |
78 | 78 | // Making payment verify |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $this->invoice($invoice); // Set the invoice. |
27 | 27 | $this->settings = (object) $settings; // Set settings. |
28 | 28 | /** @var JibitBase $jibit */ |
29 | - $this->jibit = new JibitBase($this->settings->merchantId, $this->settings->apiSecret,$this->settings->apiPaymentUrl); |
|
29 | + $this->jibit = new JibitBase($this->settings->merchantId, $this->settings->apiSecret, $this->settings->apiPaymentUrl); |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | // Making payment request |
38 | 38 | // you should save the order details in DB, you need if for verify |
39 | - $requestResult = $this->jibit->paymentRequest($this->invoice->getAmount(), $this->invoice->getDetail('order_id'), $this->invoice->getDetail('mobile'),$this->settings->callbackUrl); |
|
39 | + $requestResult = $this->jibit->paymentRequest($this->invoice->getAmount(), $this->invoice->getDetail('order_id'), $this->invoice->getDetail('mobile'), $this->settings->callbackUrl); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | if (!empty($requestResult['pspSwitchingUrl'])) { |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | } |
47 | 47 | if (!empty($requestResult['errors'])) { |
48 | 48 | //fail result and show the error |
49 | - $errMsgs = array_map(function ($err){ return $err['message']; }, $requestResult['errors']); |
|
50 | - throw new PurchaseFailedException(implode('\n',$errMsgs)); |
|
49 | + $errMsgs = array_map(function($err) { return $err['message']; }, $requestResult['errors']); |
|
50 | + throw new PurchaseFailedException(implode('\n', $errMsgs)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $transId = $requestResult['orderIdentifier']; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | //show session detail |
85 | 85 | $order = $this->jibit->getOrderById($refNum); |
86 | - if (!empty($order['payerCard'])){ |
|
86 | + if (!empty($order['payerCard'])) { |
|
87 | 87 | //echo 'payer card pan mask: ' .$order['payerCard']; |
88 | 88 | } |
89 | 89 | //return new Receipt('jibit', 'payment_receipt_number'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | private $cache; |
13 | 13 | public $base_url; |
14 | 14 | |
15 | - public function __construct($apiKey, $secretKey,$base_url) |
|
15 | + public function __construct($apiKey, $secretKey, $base_url) |
|
16 | 16 | { |
17 | 17 | $this->base_url = $base_url; |
18 | 18 | $this->apiKey = $apiKey; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getOrderById($id) |
57 | 57 | { |
58 | - return $this->callCurl('/orders/' .$id, [], true, 0,'GET'); |
|
58 | + return $this->callCurl('/orders/'.$id, [], true, 0, 'GET'); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return $this->generateNewToken(); |
80 | 80 | } |
81 | 81 | |
82 | - throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException( 'unExcepted Err in generateToken.'); |
|
82 | + throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('unExcepted Err in generateToken.'); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | ]; |
93 | 93 | $result = $this->callCurl('/tokens/refresh', $data, false); |
94 | 94 | if (empty($result['accessToken'])) { |
95 | - throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException( 'Err in refresh token.'); |
|
95 | + throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('Err in refresh token.'); |
|
96 | 96 | } |
97 | 97 | if (!empty($result['accessToken'])) { |
98 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
98 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
99 | 99 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
100 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
100 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
101 | 101 | $this->setRefreshToken($result['refreshToken']); |
102 | 102 | return 'ok'; |
103 | 103 | } |
104 | - throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException( 'unExcepted Err in refreshToken.'); |
|
104 | + throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('unExcepted Err in refreshToken.'); |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | if ($haveAuth) { |
123 | 123 | $accessToken = $this->getAccessToken(); |
124 | 124 | } |
125 | - $ch = curl_init($this->base_url . $url); |
|
125 | + $ch = curl_init($this->base_url.$url); |
|
126 | 126 | curl_setopt($ch, CURLOPT_USERAGENT, 'Jibit.class Rest Api'); |
127 | 127 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
128 | 128 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); |
129 | 129 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
130 | 130 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
131 | 131 | 'Content-Type: application/json', |
132 | - 'Authorization: ' . $accessToken, |
|
133 | - 'Content-Length: ' . strlen($jsonData) |
|
132 | + 'Authorization: '.$accessToken, |
|
133 | + 'Content-Length: '.strlen($jsonData) |
|
134 | 134 | )); |
135 | 135 | $result = curl_exec($ch); |
136 | 136 | $err = curl_error($ch); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | curl_close($ch); |
139 | 139 | |
140 | 140 | if ($err) { |
141 | - throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('cURL Error #:' . $err); |
|
141 | + throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('cURL Error #:'.$err); |
|
142 | 142 | } |
143 | 143 | if (empty($result['errors'])) { |
144 | 144 | return $result; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | throw new \Shetabit\Multipay\Exceptions\PurchaseFailedException('Err in generate new token.'); |
192 | 192 | } |
193 | 193 | if (!empty($result['accessToken'])) { |
194 | - $this->cache->store('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
194 | + $this->cache->store('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
195 | 195 | $this->cache->store('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
196 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
196 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
197 | 197 | $this->setRefreshToken($result['refreshToken']); |
198 | 198 | return 'ok'; |
199 | 199 | } |
@@ -211,6 +211,6 @@ discard block |
||
211 | 211 | $this->generateToken(); |
212 | 212 | $data = [ |
213 | 213 | ]; |
214 | - return $this->callCurl('/orders/' . $refNum . '/verify', $data, true, 0, 'GET'); |
|
214 | + return $this->callCurl('/orders/'.$refNum.'/verify', $data, true, 0, 'GET'); |
|
215 | 215 | } |
216 | 216 | } |