@@ -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 | } |
@@ -193,7 +193,7 @@ |
||
| 193 | 193 | $terminalCode = $this->settings->terminalCode; |
| 194 | 194 | $amount = $this->invoice->getAmount(); //rial |
| 195 | 195 | $redirectAddress = $this->settings->callbackUrl; |
| 196 | - $invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time()); |
|
| 196 | + $invoiceNumber = crc32($this->invoice->getUuid()).rand(0, time()); |
|
| 197 | 197 | $timeStamp = date("Y/m/d H:i:s"); |
| 198 | 198 | $invoiceDate = date("Y/m/d H:i:s"); |
| 199 | 199 | |
@@ -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 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $result = json_decode($response->getBody()->getContents(), true); |
| 102 | 102 | |
| 103 | 103 | // some error has happened |
| 104 | - if (! empty($result['errors']) || empty($result['data']) || $result['data']['code'] != 100) { |
|
| 104 | + if (!empty($result['errors']) || empty($result['data']) || $result['data']['code'] != 100) { |
|
| 105 | 105 | throw new PurchaseFailedException($result['errors']['message'], $result['errors']['code']); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $result = json_decode($response->getBody()->getContents(), true); |
| 159 | 159 | |
| 160 | - if (empty($result['data']) || ! isset($result['data']['ref_id']) || $result['data']['code'] != 100) { |
|
| 160 | + if (empty($result['data']) || !isset($result['data']['ref_id']) || $result['data']['code'] != 100) { |
|
| 161 | 161 | $message = $result['errors']['message']; |
| 162 | 162 | $code = $result['errors']['code']; |
| 163 | 163 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | $context = stream_context_create( |
| 56 | 56 | [ |
| 57 | 57 | 'ssl' => array( |
| 58 | - 'verify_peer' => false, |
|
| 59 | - 'verify_peer_name' => false |
|
| 58 | + 'verify_peer' => false, |
|
| 59 | + 'verify_peer_name' => false |
|
| 60 | 60 | )] |
| 61 | 61 | ); |
| 62 | 62 | |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | $context = stream_context_create( |
| 125 | 125 | [ |
| 126 | 126 | 'ssl' => array( |
| 127 | - 'verify_peer' => false, |
|
| 128 | - 'verify_peer_name' => false |
|
| 127 | + 'verify_peer' => false, |
|
| 128 | + 'verify_peer_name' => false |
|
| 129 | 129 | )] |
| 130 | 130 | ); |
| 131 | 131 | |
@@ -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 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // purchase was not successful |
| 76 | 76 | if ($data[0] != "0") { |
| 77 | - throw new PurchaseFailedException($this->translateStatus($data[0]), (int)$data[0]); |
|
| 77 | + throw new PurchaseFailedException($this->translateStatus($data[0]), (int) $data[0]); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $this->invoice->transactionId($data[1]); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | ]); |
| 135 | 135 | |
| 136 | 136 | // step1: verify request |
| 137 | - $verifyResponse = (int)$soap->bpVerifyRequest($data)->return; |
|
| 137 | + $verifyResponse = (int) $soap->bpVerifyRequest($data)->return; |
|
| 138 | 138 | if ($verifyResponse != 0) { |
| 139 | 139 | // rollback money and throw exception |
| 140 | 140 | // avoid rollback if request was already verified |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | if (empty($body['code']) || $body['code'] != -1) { |
| 83 | 83 | // error has happened |
| 84 | - throw new PurchaseFailedException($body['message'],$body['code']??0); |
|
| 84 | + throw new PurchaseFailedException($body['message'], $body['code'] ?? 0); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $this->invoice->transactionId($body['trans_id']); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if (!isset($body['code']) || $body['code'] != 0) { |
| 138 | 138 | $message = $body['message'] ?? 'خطای ناشناخته ای رخت داده است'; |
| 139 | 139 | |
| 140 | - throw new InvalidPaymentException($message,$body['code']??0); |
|
| 140 | + throw new InvalidPaymentException($message, $body['code'] ?? 0); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $this->createReceipt($transactionId); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | // some error has happened |
| 107 | 107 | $message = is_array($body) ? array_pop($body) : $this->convertStatusCodeToMessage($statusCode); |
| 108 | 108 | |
| 109 | - throw new PurchaseFailedException($message,is_numeric($statusCode)?$statusCode:0); |
|
| 109 | + throw new PurchaseFailedException($message, is_numeric($statusCode) ? $statusCode : 0); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $this->invoice->transactionId($body['code']); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if ($statusCode !== 200) { |
| 165 | 165 | $message = is_array($body) ? array_pop($body) : $this->convertStatusCodeToMessage($statusCode); |
| 166 | 166 | |
| 167 | - $this->notVerified($message,is_numeric($statusCode)?$statusCode:0); |
|
| 167 | + $this->notVerified($message, is_numeric($statusCode) ? $statusCode : 0); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | return $this->createReceipt($refId); |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @throws InvalidPaymentException |
| 193 | 193 | */ |
| 194 | - private function notVerified($message,$status = 0) |
|
| 194 | + private function notVerified($message, $status = 0) |
|
| 195 | 195 | { |
| 196 | - throw new InvalidPaymentException($message,$status); |
|
| 196 | + throw new InvalidPaymentException($message, $status); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |