@@ -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 | 'curl' => [CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1'], |
| 51 | 51 | ]); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function verify(): ReceiptInterface |
| 132 | 132 | { |
| 133 | - $status = (int)Request::input('Status'); |
|
| 133 | + $status = (int) Request::input('Status'); |
|
| 134 | 134 | if ($status != 2) { |
| 135 | 135 | $this->purchaseFailed($status); |
| 136 | 136 | } |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | if (array_key_exists($status, $translations)) { |
| 236 | - throw new InvalidPaymentException($translations[$status], (int)$status); |
|
| 236 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
| 237 | 237 | } else { |
| 238 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 238 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -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, |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $referenceId = hexdec(uniqid()); |
| 115 | 115 | |
| 116 | - $callback = $this->settings->callbackUrl . "?referenceId=" . $referenceId . "&price=" . $amount . "&mobile=" . $mobile; |
|
| 116 | + $callback = $this->settings->callbackUrl."?referenceId=".$referenceId."&price=".$amount."&mobile=".$mobile; |
|
| 117 | 117 | |
| 118 | 118 | $data = [ |
| 119 | 119 | 'referenceId' => $referenceId, |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | public function verify(): ReceiptInterface |
| 170 | 170 | { |
| 171 | 171 | $data = [ |
| 172 | - 'referenceId' => (int)$this->getInvoice()->getTransactionId(), |
|
| 172 | + 'referenceId' => (int) $this->getInvoice()->getTransactionId(), |
|
| 173 | 173 | 'header' => '', |
| 174 | 174 | 'content' => http_build_query($_POST), |
| 175 | 175 | ]; |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | if ($message) { |
| 298 | - throw new InvalidPaymentException($message, (int)$status); |
|
| 298 | + throw new InvalidPaymentException($message, (int) $status); |
|
| 299 | 299 | } else { |
| 300 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 300 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | { |
| 306 | 306 | $header[] = 'Content-Type: application/json'; |
| 307 | 307 | if ($forAuth) { |
| 308 | - $header[] = 'Authorization: Bearer ' . $this->auth(); |
|
| 308 | + $header[] = 'Authorization: Bearer '.$this->auth(); |
|
| 309 | 309 | } |
| 310 | 310 | $ch = curl_init($url); |
| 311 | 311 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
@@ -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], (int)$status); |
|
| 179 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
| 180 | 180 | } else { |
| 181 | - throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', (int)$status); |
|
| 181 | + throw new InvalidPaymentException('تراکنش با خطا مواجه شد.', (int) $status); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -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 | /** |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | $mobile = ''; |
| 56 | 56 | //set CellNumber for get user cards |
| 57 | 57 | if (!empty($this->invoice->getDetails()['mobile'])) { |
| 58 | - $mobile = '&CellNumber=' . $this->invoice->getDetails()['mobile']; |
|
| 58 | + $mobile = '&CellNumber='.$this->invoice->getDetails()['mobile']; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $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 | + $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 | 62 | $address_service_token = $this->settings->apiGetToken; |
| 63 | 63 | |
| 64 | 64 | $token_array = $this->makeHttpChargeRequest('POST', $data_query, $address_service_token); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $this->notVerified($resp_code); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $data_query = 'digitalreceipt=' . Request::input('digitalreceipt') . '&Tid=' . $this->settings->terminalId; |
|
| 114 | + $data_query = 'digitalreceipt='.Request::input('digitalreceipt').'&Tid='.$this->settings->terminalId; |
|
| 115 | 115 | $advice_array = $this->makeHttpChargeRequest('POST', $data_query, $this->settings->apiVerificationUrl); |
| 116 | 116 | $decode_advice_array = json_decode($advice_array); |
| 117 | 117 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | 189 | if (array_key_exists($status, $translations)) { |
| 190 | - throw new InvalidPaymentException($translations[$status], (int)$status); |
|
| 190 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
| 191 | 191 | } else { |
| 192 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 192 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ))->GetToken2Result; |
| 77 | 77 | $result = json_decode($response); |
| 78 | 78 | |
| 79 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, ['0', '00'])) { |
|
| 79 | + if (!isset($result->ResCod) || !in_array($result->ResCod, ['0', '00'])) { |
|
| 80 | 80 | // error has happened |
| 81 | 81 | $message = $result->Message ?? 'خطای ناشناخته رخ داده'; |
| 82 | 82 | throw new PurchaseFailedException($message); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function verify() : ReceiptInterface |
| 121 | 121 | { |
| 122 | 122 | $resCode = Request::input('ResCod'); |
| 123 | - if (! in_array($resCode, array('0', '00'))) { |
|
| 123 | + if (!in_array($resCode, array('0', '00'))) { |
|
| 124 | 124 | $message = 'پرداخت توسط کاربر لغو شد'; |
| 125 | 125 | throw new InvalidPaymentException($message); |
| 126 | 126 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | $response = $client->Confirm2($data)->Confirm2Result; |
| 139 | 139 | $result = json_decode($response); |
| 140 | 140 | |
| 141 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, array('0', '00'))) { |
|
| 141 | + if (!isset($result->ResCod) || !in_array($result->ResCod, array('0', '00'))) { |
|
| 142 | 142 | $message = $result->Message ?? 'خطا در انجام عملیات رخ داده است'; |
| 143 | - throw new InvalidPaymentException($message, (int)(isset($result->ResCod) ? $result->ResCod : 0)); |
|
| 143 | + throw new InvalidPaymentException($message, (int) (isset($result->ResCod) ? $result->ResCod : 0)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $this->createReceipt($result->RefNo); |
@@ -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'), |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | 234 | if (array_key_exists($status, $translations)) { |
| 235 | - throw new InvalidPaymentException($translations[$status], (int)$status); |
|
| 235 | + throw new InvalidPaymentException($translations[$status], (int) $status); |
|
| 236 | 236 | } else { |
| 237 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 237 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function __construct(Invoice $invoice, $settings) |
| 46 | 46 | { |
| 47 | 47 | $this->invoice($invoice); // Set the invoice. |
| 48 | - $this->settings = (object)$settings; // Set settings. |
|
| 48 | + $this->settings = (object) $settings; // Set settings. |
|
| 49 | 49 | $this->client = new Client(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function pay(): RedirectionForm |
| 106 | 106 | { |
| 107 | - $payUrl = $this->settings->apiPaymentUrl . $this->invoice->getTransactionId(); |
|
| 107 | + $payUrl = $this->settings->apiPaymentUrl.$this->invoice->getTransactionId(); |
|
| 108 | 108 | |
| 109 | 109 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 110 | 110 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $response = $this->client->request( |
| 127 | 127 | 'POST', |
| 128 | - $this->settings->apiVerificationUrl . $paymentId, |
|
| 128 | + $this->settings->apiVerificationUrl.$paymentId, |
|
| 129 | 129 | [ |
| 130 | 130 | "http_errors" => false, |
| 131 | 131 | "headers" => [ |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | private function notVerified($message, $status) |
| 158 | 158 | { |
| 159 | 159 | if (empty($message)) { |
| 160 | - throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int)$status); |
|
| 160 | + throw new InvalidPaymentException('خطای ناشناخته ای رخ داده است.', (int) $status); |
|
| 161 | 161 | } else { |
| 162 | - throw new InvalidPaymentException($message, (int)$status); |
|
| 162 | + throw new InvalidPaymentException($message, (int) $status); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $error_message = $r['errorMessage']; |
| 139 | 139 | throw new InvalidPaymentException($error_message); |
| 140 | 140 | } else { //success |
| 141 | - $receipt = $this->createReceipt($params['referenceNumber']); |
|
| 141 | + $receipt = $this->createReceipt($params['referenceNumber']); |
|
| 142 | 142 | $receipt->detail([ |
| 143 | 143 | 'referenceNo' => $params['referenceNumber'], |
| 144 | 144 | 'rrn' => Request::input('rrn'), |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | 151 | $error_message = $result['error']; |
| 152 | - throw new InvalidPaymentException($error_message, (int)$result['success']); |
|
| 152 | + throw new InvalidPaymentException($error_message, (int) $result['success']); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -126,7 +126,7 @@ |
||
| 126 | 126 | |
| 127 | 127 | if ($result->Status != 100) { |
| 128 | 128 | $message = $this->translateStatus($result->Status); |
| 129 | - throw new InvalidPaymentException($message, (int)$result->Status); |
|
| 129 | + throw new InvalidPaymentException($message, (int) $result->Status); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return $this->createReceipt($result->RefID); |