Testing payment with CCAvenue

CCAvenue is South Asia’s largest payment gateway, But when it comes to developers, its a pain.

Test account to test payment

Test account details are not part of documentation. You need to contact customer support get your test account enabled.

Note1: Test account does not have any dashboard access. All access and updates are via customer support

Note2: Your API keys are different for test server and it is not provided in dashboard, make sure to get it from customer support.

Note3: You need to register your server with ccavenue test server.

Sample code uses mcrypt, fails in PHP 7.1

They do support OpenSSL version of encryption, contact customer support for updated sample code.

Sample PHP code

function encrypt($plainText,$key)
 {
 $key = hextobin(md5($key));
 $initVector = pack(“C*”, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
 $openMode = openssl_encrypt($plainText, ‘AES-128-CBC’, $key, OPENSSL_RAW_DATA, $initVector);
 $encryptedText = bin2hex($openMode);
 return $encryptedText;
}
function decrypt($encryptedText,$key)
 {
 $key = hextobin(md5($key));
 $initVector = pack(“C*”, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
 $encryptedText = hextobin($encryptedText);
 $decryptedText = openssl_decrypt($encryptedText, ‘AES-128-CBC’, $key, OPENSSL_RAW_DATA, $initVector);
 return $decryptedText;
 
 }

Test server API Endpoint

You need to contact customer support to get API endpoint details. This would not be provided when test account is enabled, since API endpoint are only required for server specific calls like Auth Capture etc.

Note: API endpoint should be an URL name and not IP. (IP is part of older documentation and dosen’t work anymore)

In a nutshell, CCAvenue is powerful and feature packed. Just needs official documentation and customer support to get work done.