Classic ASP – CCAvenue Payment Gateway integration Help – Initiate Transact

By Initiate Transaction we mean to collect order details and sending customer to CCavenue for Payment

Merchants need an active CCAvenue account to start intrgration. Login to your CCAvenue M.A.R.S account and get the API credentials.

Login to your Merchant Account and download the intergration kit from Resources > Web Integration KIT > Download Integration Kits

You will find Following folder and files. Save files in your application.

bin > ASPEncKit.dll
libs > MCPG.CCA.Util.dll
CCAUtil.aspx

You can keep both DLL in bin folder

‘From Settings tab > API Keys page copy and Save Merchant ID,  Access Code,  Encryption Key

Create a page ccavenue-start.asp and copy following Code

ASP code

<%
    
     if request("btnpayment")<>"" then
     'if request("btnpayment.x")<>"" then 'use this if you want to use Image Button in Form
  
     Randomize
     MyNewRandomNum = Round(Rnd * 99) +1
     MyNewRandomNum=MyNewRandomNum
     orderid = MyNewRandomNum + 267 ' You should use this as Transaction ID and should save to your Database. This will also appear in CCAvenue reports
     
     Merchant_Id = "" 'Put in the Merchant_Id in the quotes provided as shared by ccavenue. From Settings tab > API Keys page;
     strAccessCode = ""  'Put in the access code in the quotes provided as shared by ccavenue. From Settings tab > API Keys page;
     
     total="10" ' Don't Miss to give Value to Total, If missed you will not been able to see any error or CCAvenue Payment Window
    
     total=FormatNumber(total,,,,0)

    'Redirect_Url = "http://example.com/ccavResponseHandler.asp" 'This page will receive the Response from CCAvenue after Payment. You can Process your order here.
     Redirect_Url = "https://www.example.com/ccavResponseHandler.asp" 

     sbilling_cust_name="Test User"
     sbilling_cust_email="testuser@example.com"
     scurrency="USD" 'USD, INR You Might need to contact CCAvenue in order to get Multiple Currency Enabled in your Profile

           CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring  & "merchant_id="& Server.URLEncode(Merchant_Id) &""
     CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring & "&order_id=" & Server.URLEncode(orderid)  &""
     CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring & "&amount=" & Server.URLEncode(total)  &""
      CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring  & "&redirect_url="& Server.URLEncode(Redirect_Url) &""
     
      CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring  & "&billing_cust_name="& sbilling_cust_name &""
      CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring  & "&billing_cust_email="& sbilling_cust_email &""
     CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring & "&merchant_param1="& nitem_number  &""
     CCpaymentgatewayintegrationstring=CCpaymentgatewayintegrationstring & "&currency="& scurrency  &""
     
      url = "http://" & Request.ServerVariables("SERVER_NAME") &  "/CCAUtil.aspx?" +  lcase(CCpaymentgatewayintegrationstring) +   "&act=ENC" ' This will encrypt the string
       
  
     Set ServerXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
                 
     ServerXmlHttp.open "GET", url ,false
     ServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
     ServerXmlHttp.send
     strEncRequest = ServerXmlHttp.ResponseText

     'CCAvenueProductionURL="https://test.ccavenue.com"   
     CCAvenueProductionURL="https://secure.ccavenue.com"

      Response.redirect  CCAvenueProductionURL&"/transaction/transaction.do?command=initiateTransaction&encRequest="  + strEncRequest +  "&access_code="  +  strAccessCode

     end if
 %>

<html>
<head>
    <title></title>
</head>
<body>
    <form action="ccavenue-start.asp" method="post" ID="Form1">
    <input type="image" src="/images/paymentnew_btncheckout.gif" border="0" name="btnpayment" alt="Make payments with ccavenue - it's fast, free and secure!" ID="Image2">
    <input type="submit" border="0" name="btnpayment" alt="Make payments with ccavenue - it's fast, free and secure!" ID="Image2"><br><br>
    </form>
</body>
</html>

Next Chapter will be how to collect response from CCAvenue and process order

Proceed to https://blog.certificationskart.com/windows/ccavenue-payment-gateway-integration-help-process-payment-classic-asp/628/

Error Code: 10002  https://blog.certificationskart.com/payment-gateways/ccavenue/ccavenue-payment-error-code-10002-merchant-authentication-failed/332/

Error Code complete list
https://blog.certificationskart.com/payment-gateways/ccavenue/ccavenue-error-codes-complete-list/248/

More on CCavenue https://blog.certificationskart.com/category/payment-gateways/ccavenue/