@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $transactionId = $this->invoice->getTransactionId(); |
122 | 122 | $paymentUrl = $this->getPaymentUrl(); |
123 | 123 | |
124 | - $payUrl = $paymentUrl . $transactionId; |
|
124 | + $payUrl = $paymentUrl.$transactionId; |
|
125 | 125 | |
126 | 126 | return $this->redirectWithForm($payUrl, [], 'GET'); |
127 | 127 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $refId = $result['data']['ref_id']; |
165 | 165 | |
166 | - $receipt = $this->createReceipt($refId); |
|
166 | + $receipt = $this->createReceipt($refId); |
|
167 | 167 | $receipt->detail([ |
168 | 168 | 'code' => $result['data']['code'], |
169 | 169 | 'message' => $result['data']['message'] ?? null, |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function getOrderById($id) |
106 | 106 | { |
107 | - return $this->callCurl('/purchases?purchaseId=' . $id, [], true, 0, 'GET'); |
|
107 | + return $this->callCurl('/purchases?purchaseId='.$id, [], true, 0, 'GET'); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($result['accessToken'])) { |
154 | - $this->cache->set('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
154 | + $this->cache->set('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
155 | 155 | $this->cache->set('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
156 | 156 | |
157 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
157 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
158 | 158 | $this->setRefreshToken($result['refreshToken']); |
159 | 159 | |
160 | 160 | return 'ok'; |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | $accessToken = $this->getAccessToken(); |
185 | 185 | } |
186 | 186 | |
187 | - $ch = curl_init($this->baseUrl . $url); |
|
187 | + $ch = curl_init($this->baseUrl.$url); |
|
188 | 188 | curl_setopt($ch, CURLOPT_USERAGENT, 'Jibit.class Rest Api'); |
189 | 189 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); |
190 | 190 | curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); |
191 | 191 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
192 | 192 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
193 | 193 | 'Content-Type: application/json', |
194 | - 'Authorization: ' . $accessToken, |
|
195 | - 'Content-Length: ' . strlen($jsonData) |
|
194 | + 'Authorization: '.$accessToken, |
|
195 | + 'Content-Length: '.strlen($jsonData) |
|
196 | 196 | ]); |
197 | 197 | |
198 | 198 | $result = curl_exec($ch); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | curl_close($ch); |
202 | 202 | |
203 | 203 | if ($err) { |
204 | - throw new PurchaseFailedException('cURL Error #:' . $err); |
|
204 | + throw new PurchaseFailedException('cURL Error #:'.$err); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if (empty($result['errors'])) { |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | throw new PurchaseFailedException('Token generation encoutered an error.'); |
272 | 272 | } |
273 | 273 | |
274 | - if (! empty($result['accessToken'])) { |
|
275 | - $this->cache->set('accessToken', 'Bearer ' . $result['accessToken'], 24 * 60 * 60 - 60); |
|
274 | + if (!empty($result['accessToken'])) { |
|
275 | + $this->cache->set('accessToken', 'Bearer '.$result['accessToken'], 24 * 60 * 60 - 60); |
|
276 | 276 | $this->cache->set('refreshToken', $result['refreshToken'], 48 * 60 * 60 - 60); |
277 | 277 | |
278 | - $this->setAccessToken('Bearer ' . $result['accessToken']); |
|
278 | + $this->setAccessToken('Bearer '.$result['accessToken']); |
|
279 | 279 | $this->setRefreshToken($result['refreshToken']); |
280 | 280 | |
281 | 281 | return 'ok'; |
@@ -296,6 +296,6 @@ discard block |
||
296 | 296 | $this->generateToken(); |
297 | 297 | $data = []; |
298 | 298 | |
299 | - return $this->callCurl('/purchases/' . $purchaseId . '/verify', $data, true, 0, 'GET'); |
|
299 | + return $this->callCurl('/purchases/'.$purchaseId.'/verify', $data, true, 0, 'GET'); |
|
300 | 300 | } |
301 | 301 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | |
67 | - if (! empty($requestResult['pspSwitchingUrl'])) { |
|
67 | + if (!empty($requestResult['pspSwitchingUrl'])) { |
|
68 | 68 | $this->paymentUrl = $requestResult['pspSwitchingUrl']; |
69 | 69 | } |
70 | 70 | |
71 | - if (! empty($requestResult['errors'])) { |
|
72 | - $errMsgs = array_map(function ($err) { |
|
71 | + if (!empty($requestResult['errors'])) { |
|
72 | + $errMsgs = array_map(function($err) { |
|
73 | 73 | return $err['code']; |
74 | 74 | }, $requestResult['errors']); |
75 | 75 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $requestResult = $this->jibit->paymentVerify($purchaseId); |
112 | 112 | |
113 | - if (! empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
113 | + if (!empty($requestResult['status']) && $requestResult['status'] === 'SUCCESSFUL') { |
|
114 | 114 | $order = $this->jibit->getOrderById($purchaseId); |
115 | 115 | |
116 | 116 | $receipt = new Receipt('jibit', $purchaseId); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $this->invoice($invoice); |
48 | 48 | $this->client = new Client(); |
49 | - $this->settings = (object)$settings; |
|
49 | + $this->settings = (object) $settings; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function pay(): RedirectionForm |
120 | 120 | { |
121 | - $payUrl = $this->settings->apiPaymentUrl . '?authority=' . $this->invoice->getTransactionId(); |
|
121 | + $payUrl = $this->settings->apiPaymentUrl.'?authority='.$this->invoice->getTransactionId(); |
|
122 | 122 | |
123 | 123 | return $this->redirectWithForm($payUrl, [], 'GET'); |
124 | 124 | } |
@@ -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 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | // purchase was not successful |
74 | 74 | if ($data[0] != "0") { |
75 | - throw new PurchaseFailedException($this->translateStatus($data[0]), (int)$data[0]); |
|
75 | + throw new PurchaseFailedException($this->translateStatus($data[0]), (int) $data[0]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $this->invoice->transactionId($data[1]); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $soap = $this->client($this->settings->apiVerificationUrl); |
121 | 121 | |
122 | 122 | // step1: verify request |
123 | - $verifyResponse = (int)$soap->bpVerifyRequest($data)->return; |
|
123 | + $verifyResponse = (int) $soap->bpVerifyRequest($data)->return; |
|
124 | 124 | if ($verifyResponse != 0) { |
125 | 125 | // rollback money and throw exception |
126 | 126 | // avoid rollback if request was already verified |
@@ -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 | /** |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | $mobile = ''; |
55 | 55 | //set CellNumber for get user cards |
56 | 56 | if (!empty($this->invoice->getDetails()['mobile'])) { |
57 | - $mobile = '&CellNumber=' . $this->invoice->getDetails()['mobile']; |
|
57 | + $mobile = '&CellNumber='.$this->invoice->getDetails()['mobile']; |
|
58 | 58 | } |
59 | 59 | |
60 | - $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; |
|
60 | + $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; |
|
61 | 61 | $address_service_token = $this->settings->apiGetToken; |
62 | 62 | |
63 | 63 | $token_array = $this->makeHttpChargeRequest('POST', $data_query, $address_service_token); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->notVerified($responseCode); |
111 | 111 | } |
112 | 112 | |
113 | - $data_query = 'digitalreceipt=' . Request::input('digitalreceipt') . '&Tid=' . $this->settings->terminalId; |
|
113 | + $data_query = 'digitalreceipt='.Request::input('digitalreceipt').'&Tid='.$this->settings->terminalId; |
|
114 | 114 | $advice_array = $this->makeHttpChargeRequest('POST', $data_query, $this->settings->apiVerificationUrl); |
115 | 115 | $decode_advice_array = json_decode($advice_array); |
116 | 116 | |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | ); |
187 | 187 | |
188 | 188 | if (array_key_exists($status, $translations)) { |
189 | - throw new InvalidPaymentException($translations[$status], (int)$status); |
|
189 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
190 | 190 | } else { |
191 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
191 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $token = $this->invoice->getTransactionId() ?? Request::input('Token'); |
108 | 108 | |
109 | 109 | if (empty($token)) { |
110 | - throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int)$status); |
|
110 | + throw new InvalidPaymentException('تراکنش توسط کاربر کنسل شده است.', (int) $status); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $data = $this->prepareVerificationData(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $hasWrongRRN = (!isset($result->RRN) || $result->RRN <= 0); |
124 | 124 | if ($hasWrongStatus || $hasWrongRRN) { |
125 | 125 | $message = 'خطا از سمت بانک با کد '.$result->Status.' رخ داده است.'; |
126 | - throw new InvalidPaymentException($message, (int)$result->Status); |
|
126 | + throw new InvalidPaymentException($message, (int) $result->Status); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | return $this->createReceipt($result->RRN); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | if (!is_null($externalSourceAmount = $this->invoice->getDetail('externalSourceAmount'))) { |
102 | - $data['externalSourceAmount'] = $this->normalizerAmount($externalSourceAmount) ; |
|
102 | + $data['externalSourceAmount'] = $this->normalizerAmount($externalSourceAmount); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | if (is_null($this->invoice->getDetail('cartList'))) { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | if (!is_null($externalSourceAmount = $this->invoice->getDetail('externalSourceAmount'))) { |
410 | - $data['externalSourceAmount'] = $this->normalizerAmount($externalSourceAmount) ; |
|
410 | + $data['externalSourceAmount'] = $this->normalizerAmount($externalSourceAmount); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | if (is_null($this->invoice->getDetail('cartList'))) { |
@@ -236,7 +236,7 @@ |
||
236 | 236 | 'apiPaymentUrl' => 'https://pna.shaparak.ir/mhui/home/index/', |
237 | 237 | 'apiConfirmationUrl' => 'https://pna.shaparak.ir/mhipg/api/Payment/confirm', |
238 | 238 | 'CorporationPin' => '', |
239 | - 'currency' => 'R',//Can be R, T (Rial, Toman) |
|
239 | + 'currency' => 'R', //Can be R, T (Rial, Toman) |
|
240 | 240 | 'callbackUrl' => 'http://yoursite.com/path/to', |
241 | 241 | 'description' => 'payment using pna', |
242 | 242 | ], |