| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 | $block_type = "\x01"; | 
| 92 | 92 |              $padding = str_repeat("\xFF", $pad_length); | 
| 93 | 93 | } | 
| 94 | - return "\x00" . $block_type . $padding . "\x00" . $data; | |
| 94 | + return "\x00".$block_type.$padding."\x00".$data; | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 | public static function removePKCS1Padding($data, $blocksize) | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 |          while ($div > 0) { | 
| 137 | 137 | $mod = bcmod($div, $base); | 
| 138 | 138 | $div = bcdiv($div, $base); | 
| 139 | - $result = chr($mod) . $result; | |
| 139 | + $result = chr($mod).$result; | |
| 140 | 140 | } | 
| 141 | 141 | return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT); | 
| 142 | 142 | } | 
| @@ -70,7 +70,7 @@ | ||
| 70 | 70 | return; | 
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | -        array_walk($listeners[$event], function ($listener) use ($arguments) { | |
| 73 | +        array_walk($listeners[$event], function($listener) use ($arguments) { | |
| 74 | 74 | call_user_func_array($listener, $arguments); | 
| 75 | 75 | }); | 
| 76 | 76 | } | 
| @@ -104,7 +104,7 @@ | ||
| 104 | 104 | */ | 
| 105 | 105 | protected function getDefaultViewRenderer() : callable | 
| 106 | 106 |      { | 
| 107 | -        return function (string $view, string $action, array $inputs, string $method) { | |
| 107 | +        return function(string $view, string $action, array $inputs, string $method) { | |
| 108 | 108 | ob_start(); | 
| 109 | 109 | |
| 110 | 110 | require($view); | 
| @@ -93,7 +93,7 @@ | ||
| 93 | 93 |      { | 
| 94 | 94 | $strategy = static::$strategies[$this->getMode()] ?? null; | 
| 95 | 95 | |
| 96 | -        if (! $strategy) { | |
| 96 | +        if (!$strategy) { | |
| 97 | 97 | $this->strategyNotFound(); | 
| 98 | 98 | } | 
| 99 | 99 | |
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | public function __construct(Invoice $invoice, $settings) | 
| 44 | 44 |      { | 
| 45 | 45 | $this->invoice($invoice); | 
| 46 | - $this->settings = (object)$settings; | |
| 46 | + $this->settings = (object) $settings; | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | /** | 
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 | */ | 
| 76 | 76 | public function pay(): RedirectionForm | 
| 77 | 77 |      { | 
| 78 | - return $this->redirectWithForm($this->settings->apiPaymentUrl . $this->invoice->getTransactionId(), [], 'GET'); | |
| 78 | + return $this->redirectWithForm($this->settings->apiPaymentUrl.$this->invoice->getTransactionId(), [], 'GET'); | |
| 79 | 79 | } | 
| 80 | 80 | |
| 81 | 81 | /** | 
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | public function __construct(Invoice $invoice, $settings) | 
| 37 | 37 |      { | 
| 38 | 38 | $this->invoice($invoice); | 
| 39 | - $this->settings = (object)$settings; | |
| 39 | + $this->settings = (object) $settings; | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | /** | 
| @@ -1,9 +1,9 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 |  define('ATIPAY_URL', 'https://mipg.atipay.net/v1/'); | 
| 4 | -define('ATIPAY_TOKEN_URL', ATIPAY_URL . 'get-token'); | |
| 5 | -define('ATIPAY_REDIRECT_TO_PSP_URL', ATIPAY_URL . 'redirect-to-gateway'); | |
| 6 | -define('ATIPAY_VERIFY_URL', ATIPAY_URL . 'verify-payment'); | |
| 4 | +define('ATIPAY_TOKEN_URL', ATIPAY_URL.'get-token'); | |
| 5 | +define('ATIPAY_REDIRECT_TO_PSP_URL', ATIPAY_URL.'redirect-to-gateway'); | |
| 6 | +define('ATIPAY_VERIFY_URL', ATIPAY_URL.'verify-payment'); | |
| 7 | 7 | |
| 8 | 8 | function fn_atipay_get_token($params) | 
| 9 | 9 |  { | 
| @@ -13,14 +13,14 @@ discard block | ||
| 13 | 13 |          if (isset($r['status']) && !empty($r['status'])) { | 
| 14 | 14 | $status = $r['status']; | 
| 15 | 15 |              if ($status == 1) { | 
| 16 | - $return['success']=1; | |
| 17 | - $return['token']=$r['token']; | |
| 16 | + $return['success'] = 1; | |
| 17 | + $return['token'] = $r['token']; | |
| 18 | 18 |              } else { | 
| 19 | - $return['success']=0; | |
| 20 | - $return['errorMessage']=$r['errorDescription']; | |
| 19 | + $return['success'] = 0; | |
| 20 | + $return['errorMessage'] = $r['errorDescription']; | |
| 21 | 21 | } | 
| 22 | 22 |          } else { | 
| 23 | - $return['success']=0; | |
| 23 | + $return['success'] = 0; | |
| 24 | 24 |              if (isset($r['faMessage']) && !empty($r['faMessage'])) { | 
| 25 | 25 | $return['errorMessage'] = $r['faMessage']; | 
| 26 | 26 |              } else { | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | } | 
| 29 | 29 | } | 
| 30 | 30 |      } else { | 
| 31 | - $return['success']=0; | |
| 31 | + $return['success'] = 0; | |
| 32 | 32 | $return['errorMessage'] = "خطا در دریافت اطلاعات توکن پرداخت"; | 
| 33 | 33 | } | 
| 34 | 34 | |
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | |
| 61 | 61 | function _fn_generate_get_token_form($params, $submit_text, $action) | 
| 62 | 62 |  { | 
| 63 | - $form ="<form action='$action' method='POST' align='center' name='atipay_payment_form_token' id='atipay_payment_form_token' >"; | |
| 63 | + $form = "<form action='$action' method='POST' align='center' name='atipay_payment_form_token' id='atipay_payment_form_token' >"; | |
| 64 | 64 |      foreach ($params as $k=>$v) { | 
| 65 | 65 | $form .= "<input type='hidden' value='$v' name='$k' >"; | 
| 66 | 66 | } | 
| @@ -77,15 +77,15 @@ discard block | ||
| 77 | 77 |      if (isset($params['state']) && !empty($params['state'])) { | 
| 78 | 78 | $state = $params['state']; | 
| 79 | 79 |          if ($state == 'OK') { | 
| 80 | - $result['success']=1; | |
| 81 | - $result['error']=""; | |
| 80 | + $result['success'] = 1; | |
| 81 | + $result['error'] = ""; | |
| 82 | 82 |          } else { | 
| 83 | - $result['success']=0; | |
| 84 | - $result['error']= _fn_return_state_text($state); | |
| 83 | + $result['success'] = 0; | |
| 84 | + $result['error'] = _fn_return_state_text($state); | |
| 85 | 85 | } | 
| 86 | 86 |      } else { | 
| 87 | - $result['success']=0; | |
| 88 | - $result['error']="خطای نامشخص در پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 87 | + $result['success'] = 0; | |
| 88 | + $result['error'] = "خطای نامشخص در پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 89 | 89 | } | 
| 90 | 90 | |
| 91 | 91 | return $result; | 
| @@ -98,18 +98,18 @@ discard block | ||
| 98 | 98 |      if ($r) { | 
| 99 | 99 |          if (isset($r['amount']) && !empty($r['amount'])) { | 
| 100 | 100 |              if ($r['amount'] == $amount) { | 
| 101 | - $return['success']=1; | |
| 102 | - $return['errorMessage']=""; | |
| 101 | + $return['success'] = 1; | |
| 102 | + $return['errorMessage'] = ""; | |
| 103 | 103 |              } else { | 
| 104 | - $return['success']=0; | |
| 105 | - $return['errorMessage']="خطا در تایید مبلغ پرداخت.در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 104 | + $return['success'] = 0; | |
| 105 | + $return['errorMessage'] = "خطا در تایید مبلغ پرداخت.در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 106 | 106 | } | 
| 107 | 107 |          } else { | 
| 108 | - $return['success']=0; | |
| 109 | - $return['errorMessage']="خطا در تایید اطلاعات پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 108 | + $return['success'] = 0; | |
| 109 | + $return['errorMessage'] = "خطا در تایید اطلاعات پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | |
| 110 | 110 | } | 
| 111 | 111 |      } else { | 
| 112 | - $return['success']=0; | |
| 112 | + $return['success'] = 0; | |
| 113 | 113 | $return['errorMessage'] = "خطا در تایید نهایی پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود."; | 
| 114 | 114 | } | 
| 115 | 115 | |
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 |      if ($httpcode == "200") { | 
| 184 | 184 | //nothing YET | 
| 185 | 185 |      } else { | 
| 186 | -        $json= json_encode(array('error'=>'Y')); | |
| 186 | +        $json = json_encode(array('error'=>'Y')); | |
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | 189 | return $json; | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 |      if ($httpcode == "200") { | 
| 208 | 208 | return json_decode($json, true); | 
| 209 | 209 |      } else { | 
| 210 | -        $json = array('error'=>'Y','jsonError'=>$httpcode,'message'=>$httpcode); | |
| 210 | +        $json = array('error'=>'Y', 'jsonError'=>$httpcode, 'message'=>$httpcode); | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | return $json; | 
| @@ -114,7 +114,7 @@ | ||
| 114 | 114 | |
| 115 | 115 | // convert to rial | 
| 116 | 116 |              if ($this->settings->currency == 'T') { | 
| 117 | -                $multiIdentityRows = array_map(function ($item) { | |
| 117 | +                $multiIdentityRows = array_map(function($item) { | |
| 118 | 118 | $item['Amount'] = $item['Amount'] * 10; | 
| 119 | 119 | return $item; | 
| 120 | 120 | }, $multiIdentityRows); | 
| @@ -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 | |
| 64 | 64 | /** | 
| @@ -191,9 +191,9 @@ discard block | ||
| 191 | 191 | public function token(): array | 
| 192 | 192 |      { | 
| 193 | 193 |          if (strpos($this->settings->callbackUrl, '?') !== false) { | 
| 194 | - $query = '&' . http_build_query(['invoice' => $this->invoice->getUuid()]); | |
| 194 | + $query = '&'.http_build_query(['invoice' => $this->invoice->getUuid()]); | |
| 195 | 195 |          } else { | 
| 196 | - $query = '?' . http_build_query(['invoice' => $this->invoice->getUuid()]); | |
| 196 | + $query = '?'.http_build_query(['invoice' => $this->invoice->getUuid()]); | |
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 |          return $this->callApi('POST', self::TokenURL, [ | 
| @@ -202,7 +202,7 @@ discard block | ||
| 202 | 202 | 'localInvoiceId' => $this->invoice->getUuid(), | 
| 203 | 203 | 'amountInRials' => $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1), // convert to rial | 
| 204 | 204 | 'localDate' => $this->getTime()['content'], | 
| 205 | - 'callbackURL' => $this->settings->callbackUrl . $query, | |
| 205 | + 'callbackURL' => $this->settings->callbackUrl.$query, | |
| 206 | 206 | 'paymentId' => "0", | 
| 207 | 207 | 'additionalData' => '', | 
| 208 | 208 | ]); | 
| @@ -216,8 +216,8 @@ discard block | ||
| 216 | 216 | public function reverse(): array | 
| 217 | 217 |      { | 
| 218 | 218 |          return $this->callApi('POST', self::ReverseURL, [ | 
| 219 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, | |
| 220 | - 'payGateTranId' => (int)$this->invoice->getUuid() | |
| 219 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, | |
| 220 | + 'payGateTranId' => (int) $this->invoice->getUuid() | |
| 221 | 221 | ]); | 
| 222 | 222 | } | 
| 223 | 223 | |
| @@ -229,8 +229,8 @@ discard block | ||
| 229 | 229 | public function cancel(): array | 
| 230 | 230 |      { | 
| 231 | 231 |          return $this->callApi('POST', self::CancelURL, [ | 
| 232 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, | |
| 233 | - 'payGateTranId' => (int)$this->payGateTransactionId | |
| 232 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, | |
| 233 | + 'payGateTranId' => (int) $this->payGateTransactionId | |
| 234 | 234 | ]); | 
| 235 | 235 | } | 
| 236 | 236 | |
| @@ -242,8 +242,8 @@ discard block | ||
| 242 | 242 | public function verifyTransaction(): array | 
| 243 | 243 |      { | 
| 244 | 244 |          return $this->callApi('POST', self::VerifyURL, [ | 
| 245 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, | |
| 246 | - 'payGateTranId' => (int)$this->payGateTransactionId | |
| 245 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, | |
| 246 | + 'payGateTranId' => (int) $this->payGateTransactionId | |
| 247 | 247 | ]); | 
| 248 | 248 | } | 
| 249 | 249 | |
| @@ -255,8 +255,8 @@ discard block | ||
| 255 | 255 | public function settlement(): array | 
| 256 | 256 |      { | 
| 257 | 257 |          return $this->callApi('POST', self::SettlementURL, [ | 
| 258 | - 'merchantConfigurationId' => (int)$this->settings->merchantConfigID, | |
| 259 | - 'payGateTranId' => (int)$this->payGateTransactionId | |
| 258 | + 'merchantConfigurationId' => (int) $this->settings->merchantConfigID, | |
| 259 | + 'payGateTranId' => (int) $this->payGateTransactionId | |
| 260 | 260 | ]); | 
| 261 | 261 | } | 
| 262 | 262 | |
| @@ -267,7 +267,7 @@ discard block | ||
| 267 | 267 | */ | 
| 268 | 268 | public function cardHash(): array | 
| 269 | 269 |      { | 
| 270 | -        return $this->callApi('GET', self::CardHashURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); | |
| 270 | +        return $this->callApi('GET', self::CardHashURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); | |
| 271 | 271 | } | 
| 272 | 272 | |
| 273 | 273 | /** | 
| @@ -277,7 +277,7 @@ discard block | ||
| 277 | 277 | */ | 
| 278 | 278 | public function transactionResult(): array | 
| 279 | 279 |      { | 
| 280 | -        return $this->callApi('GET', self::TranResultURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []); | |
| 280 | +        return $this->callApi('GET', self::TranResultURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []); | |
| 281 | 281 | } | 
| 282 | 282 | |
| 283 | 283 | /** |