@@ -6,19 +6,19 @@ |
||
| 6 | 6 | public function encrypt($plainText, $key) { |
| 7 | 7 | $method = "AES-256-GCM"; |
| 8 | 8 | $initVector = openssl_random_pseudo_bytes(16); |
| 9 | - $openMode = openssl_encrypt( $plainText, $method, $key, OPENSSL_RAW_DATA, $initVector, $tag ); |
|
| 9 | + $openMode = openssl_encrypt($plainText, $method, $key, OPENSSL_RAW_DATA, $initVector, $tag); |
|
| 10 | 10 | |
| 11 | - return bin2hex( $initVector ).bin2hex( $openMode . $tag ); |
|
| 11 | + return bin2hex($initVector).bin2hex($openMode.$tag); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function decrypt($encryptedText, $key) { |
| 15 | 15 | $method = 'AES-256-GCM'; |
| 16 | - $encryptedText = hex2bin( $encryptedText ); |
|
| 16 | + $encryptedText = hex2bin($encryptedText); |
|
| 17 | 17 | $iv_len = $tag_length = 16; |
| 18 | - $iv = substr( $encryptedText, 0, $iv_len ); |
|
| 19 | - $tag = substr( $encryptedText, -$tag_length, $iv_len ); |
|
| 20 | - $ciphertext = substr( $encryptedText, $iv_len, -$tag_length ); |
|
| 18 | + $iv = substr($encryptedText, 0, $iv_len); |
|
| 19 | + $tag = substr($encryptedText, -$tag_length, $iv_len); |
|
| 20 | + $ciphertext = substr($encryptedText, $iv_len, -$tag_length); |
|
| 21 | 21 | |
| 22 | - return openssl_decrypt( $ciphertext, $method, $key, OPENSSL_RAW_DATA, $iv, $tag ); |
|
| 22 | + return openssl_decrypt($ciphertext, $method, $key, OPENSSL_RAW_DATA, $iv, $tag); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $data['merchant_param4'] = $this->getMerchantParameter4(); |
| 138 | 138 | $data['merchant_param5'] = $this->getMerchantParameter5(); |
| 139 | 139 | |
| 140 | - if ( $this->getCard() ) { |
|
| 140 | + if ($this->getCard()) { |
|
| 141 | 141 | $data['card_number'] = $this->getCard()->getNumber(); |
| 142 | 142 | $data['expiry_month'] = $this->getCard()->getExpiryMonth(); |
| 143 | 143 | $data['expiry_year'] = $this->getCard()->getExpiryYear(); |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $merchant_data = []; |
| 161 | 161 | |
| 162 | - foreach ( $this->getData() as $k => $v ) { |
|
| 163 | - if ( !empty($v) ) { |
|
| 162 | + foreach ($this->getData() as $k => $v) { |
|
| 163 | + if (!empty($v)) { |
|
| 164 | 164 | $merchant_data[$k] = urlencode($v); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $encrypted_data = $cryto->encrypt(http_build_query($merchant_data), $this->getWorkingKey()); |
| 174 | 174 | |
| 175 | - $url = $this->getEndpoint() . '&encRequest=' . $encrypted_data . '&access_code=' . $this->getAccessCode(); |
|
| 175 | + $url = $this->getEndpoint().'&encRequest='.$encrypted_data.'&access_code='.$this->getAccessCode(); |
|
| 176 | 176 | |
| 177 | 177 | return $this->response = new PurchaseResponse($this, [ |
| 178 | 178 | 'url' => $url, |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | throw new InvalidResponseException('Invalid response from payment gateway'); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( empty($decryptedString) ) { |
|
| 44 | + if (empty($decryptedString)) { |
|
| 45 | 45 | throw new InvalidResponseException('Invalid response from payment gateway'); |
| 46 | 46 | } |
| 47 | 47 | |