Loading src/CCAvenueEncryption.php +4 −17 Changes for src/CCAvenueEncryption.php: 4 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -17,37 +17,24 @@ class CCAvenueEncryption { public function encrypt($plainText, $key) { $secretKey = $this->hextobin(md5($key)); $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); $blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc'); $plainPad = $this->pkcs5_pad($plainText, $blockSize); if (mcrypt_generic_init($openMode, $secretKey, $initVector) != -1) { $encryptedText = mcrypt_generic($openMode, $plainPad); mcrypt_generic_deinit($openMode); } return bin2hex($encryptedText); $encryptedText = openssl_encrypt($plainText, "AES-128-CBC", $secretKey, OPENSSL_RAW_DATA, $initVector); $encryptedText = bin2hex($encryptedText); return $encryptedText; } public function decrypt($encryptedText, $key) { $secretKey = $this->hextobin(md5($key)); $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); $encryptedText = $this->hextobin($encryptedText); $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); mcrypt_generic_init($openMode, $secretKey, $initVector); $decryptedText = mdecrypt_generic($openMode, $encryptedText); $decryptedText = rtrim($decryptedText, "\0"); mcrypt_generic_deinit($openMode); $decryptedText = openssl_decrypt($encryptedText, "AES-128-CBC", $secretKey, OPENSSL_RAW_DATA, $initVector); return $decryptedText; } //*********** Padding Function ********************* public function pkcs5_pad($plainText, $blockSize) { $pad = $blockSize - (strlen($plainText) % $blockSize); return $plainText . str_repeat(chr($pad), $pad); } //********** Hexadecimal to Binary function for php 4.0 version ******** public function hextobin($hexString) { $length = strlen($hexString); $binString = ""; Loading src/Plugin/Commerce/PaymentGateway/CCAvenueRedirect.php +11 −0 Changes for src/Plugin/Commerce/PaymentGateway/CCAvenueRedirect.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -166,4 +166,15 @@ class CCAvenueRedirect extends OffsitePaymentGatewayBase { ])); } /** * {@inheritdoc} */ public function defaultConfiguration() { return parent::defaultConfiguration() + [ 'merchant_id' => '', 'access_code' => '', 'working_key' => '', ]; } } src/PluginForm/CCAvenueRedirect/PaymentCCAvenueForm.php +2 −3 Changes for src/PluginForm/CCAvenueRedirect/PaymentCCAvenueForm.php: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -10,9 +10,8 @@ use Drupal\commerce_order\Entity\Order; class PaymentCCAvenueForm extends BasePaymentOffsiteForm { const CCAVENUE_API_TEST_URL = 'https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_URL = 'https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_TEST_URL = 'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_URL = 'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction'; /** * {@inheritdoc} Loading Loading
src/CCAvenueEncryption.php +4 −17 Changes for src/CCAvenueEncryption.php: 4 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -17,37 +17,24 @@ class CCAvenueEncryption { public function encrypt($plainText, $key) { $secretKey = $this->hextobin(md5($key)); $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); $blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc'); $plainPad = $this->pkcs5_pad($plainText, $blockSize); if (mcrypt_generic_init($openMode, $secretKey, $initVector) != -1) { $encryptedText = mcrypt_generic($openMode, $plainPad); mcrypt_generic_deinit($openMode); } return bin2hex($encryptedText); $encryptedText = openssl_encrypt($plainText, "AES-128-CBC", $secretKey, OPENSSL_RAW_DATA, $initVector); $encryptedText = bin2hex($encryptedText); return $encryptedText; } public function decrypt($encryptedText, $key) { $secretKey = $this->hextobin(md5($key)); $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); $encryptedText = $this->hextobin($encryptedText); $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); mcrypt_generic_init($openMode, $secretKey, $initVector); $decryptedText = mdecrypt_generic($openMode, $encryptedText); $decryptedText = rtrim($decryptedText, "\0"); mcrypt_generic_deinit($openMode); $decryptedText = openssl_decrypt($encryptedText, "AES-128-CBC", $secretKey, OPENSSL_RAW_DATA, $initVector); return $decryptedText; } //*********** Padding Function ********************* public function pkcs5_pad($plainText, $blockSize) { $pad = $blockSize - (strlen($plainText) % $blockSize); return $plainText . str_repeat(chr($pad), $pad); } //********** Hexadecimal to Binary function for php 4.0 version ******** public function hextobin($hexString) { $length = strlen($hexString); $binString = ""; Loading
src/Plugin/Commerce/PaymentGateway/CCAvenueRedirect.php +11 −0 Changes for src/Plugin/Commerce/PaymentGateway/CCAvenueRedirect.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -166,4 +166,15 @@ class CCAvenueRedirect extends OffsitePaymentGatewayBase { ])); } /** * {@inheritdoc} */ public function defaultConfiguration() { return parent::defaultConfiguration() + [ 'merchant_id' => '', 'access_code' => '', 'working_key' => '', ]; } }
src/PluginForm/CCAvenueRedirect/PaymentCCAvenueForm.php +2 −3 Changes for src/PluginForm/CCAvenueRedirect/PaymentCCAvenueForm.php: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -10,9 +10,8 @@ use Drupal\commerce_order\Entity\Order; class PaymentCCAvenueForm extends BasePaymentOffsiteForm { const CCAVENUE_API_TEST_URL = 'https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_URL = 'https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_TEST_URL = 'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction'; const CCAVENUE_API_URL = 'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction'; /** * {@inheritdoc} Loading