CCAVENUE PAYMENT INTEGRATION WITH ASP.NET WEBSITE



problem1: step by step procedure for integrating  cc avenue  payment gateway to  asp.net website

 Before  starting the integration  make sure that you have an active cc avenue  account
 
step1: from your cc avenue account note your working key,access code,merchant id


step2: From http://ccavenue.com → Resources → Web Integration Kit → Download Integration Kit → Download ASP.NET 3.5  

the kit itself contains 3 sub folders
1.Custom checkout forms
2.I frame kit
3.Non seamless kit

we need to use the NON SEAMELESS  KIT


 step3: Before proceeding to integration steps,as part of testing its mandatory that you need  to whitelist your local host address ,otherwise this setup won't work during testing,for that drop a mail to   service@ccavenue.com indicating your requirement. you need to mention your merchant id,and specify local host address that you want to add


NB: CORRESPONDS TO EVERY LOCAL HOST ADDRESS THAT ARE WHITE LISTED BY CC AVENUE IS THERE EXIST SEPARATE ACCESS KEY,WORKING KEYS AVAILABLE IN YOUR  CC AVENUE ACCOUNT.YOU NEED TO USE RESPECTIVE ACCESS KEY AND WORKING KEY FOR THE GRANDAD LOCAL HOST ADDRESS


Step4:Open project in visual studio



 
file>open>project/solution>brows the downloaded kit (open NON SEAMELESS  KIT)

Open MCPG.ASP.net.ENC
 
Step5:Adding reference to the project 

 It is assumed to be one of the tedious task of integration .Now right click to the reference tab in solution explorer ,add reference

Browse the downloaded folder

  1. bin → MCPG.ASP.net.ENC.dll & add it to the project.
  2. lib → MCPG.CCA.Util.dll & add it to project.


Take a look at the solution explorer,we can see the following  forms


1.ccavRequestHandler.aspx
2.ccavResponseHandler.aspx


 Goto  ccavRequestHandler.aspx.cs, provide your  32 bit working Key  and Access Code obtained  from  cc avenue account
and in ccavResponseHandler.aspx.cs  fill out  32 bit working Key 

Now open  dataform.htm from solution explorer

 <td><input type="text" name="merchant_id" id="merchant_id" value=""/></td>

find the text field for merchant id and fill out the value field  with your  merchant id

and  fill  out the redirect url and  Cancel URL  as follows

  <td>Redirect URL</td>
            <td><input type="text" name="redirect_url" value="ccavResponseHandler.aspx"/></td>

 <td>Cancel URL</td>
            <td><input type="text" name="cancel_url" value="ccavResponseHandler.php"/></td>



Step 5: now build your project 


copy the dll's from   (assume  eg: if your project is in the D drive )

D:\NON_SEAMLESS_KIT\MCPG.ASP.net.ENC\bin and 

D:\NON_SEAMLESS_KIT\MCPG.ASP.net.ENC\obj\Release

to your  projects bin folder.

Now you  have  all the required dll's needed for the integrating cc avenue to your website.

FINAL INTEGRATION FOR YOUR WEBSITE

 Assume that i need to display cc avenue payment page after entering my billing details


on the button click of my billing page i just call a page cca_redirect.aspx which contains all the coding required for parameter passing



here is the coding session


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using CCA.Util;





public partial class cca_redirect : System.Web.UI.Page
{
    CCACrypto ccaCrypto = new CCACrypto();
 string workingKey = "";//put in the 32bit alpha numeric key in the quotes provided here    

  // string workingKey = "";//put in the 32bit alpha numeric key in the quotes provided here    
    string ccarequest = "";
    public string strEncRequest = "";
    public string strAccessCode = "";//put your access key here


    double bill_amt;
    string order_id, billing_name, billing_address, billing_city, billing_zip, billing_email, billing_tel, billing_state, billing_country;



    protected void Page_Load(object sender, EventArgs e)
    {




//you need to pass all the session values before calling this page

       // double amount = Convert.ToDouble(Session["amount"]);


        order_id =  Session["id"].ToString();

        if (order_id.StartsWith("I") == true)
        {
           bill_amt = Convert.ToDouble(Session["amount"]);
                     
        }
        else if (order_id.StartsWith("O") == true)
        {
            bill_amt = Convert.ToDouble(Session["amount"]);
                    }



        billing_name = Session["name"].ToString();
        billing_address = Session["billing_addr"].ToString();
        billing_city = Session["city"].ToString();
        billing_zip = Session["postcode"].ToString();
        billing_state = Session["state"].ToString();
        billing_country = Session["country"].ToString();
        billing_tel = Session["telephone"].ToString();
        billing_email = Session["email"].ToString();
   

        //displaying values to the form
        billing_name1.Value = billing_name.ToUpper() ;
        billing_state1.Value = billing_state.ToUpper ();
        billing_address1.Value = billing_address.ToUpper ();
        billing_city1.Value = billing_city.ToUpper ();
        bill_country1.Value = billing_country.ToUpper ();
        pincode1.Value = billing_zip.ToUpper();
        mobile1.Value = billing_tel.ToUpper ();
        mail.Value = billing_email;
        billamt1.Value = bill_amt.ToString() ;


        ccarequest = ccarequest + "merchant_id" + "=" + "
merchant_id" + "&";

                 //put your merchant id here
        ccarequest = ccarequest + "order_id" + "=" + order_id  + "&";
        ccarequest = ccarequest + "language" + "=" + "EN" + "&";
        ccarequest = ccarequest + "currency" + "=" + "INR" + "&";
        ccarequest = ccarequest + "amount" + "=" + bill_amt + "&";
      ccarequest = ccarequest + "redirect_url" + "=" + "
redirect url " + "&";    //put your redirect url here 

      
        ccarequest = ccarequest + "cancel_url" + "=" + "
cancel url" + "&";    //put your cancel url here
 
            ccarequest = ccarequest + "billing_name" + "=" + billing_name  + "&";
        ccarequest = ccarequest + "billing_address" + "=" + billing_address  + "&";
        ccarequest = ccarequest + "billing_city" + "=" + billing_city  + "&";
        ccarequest = ccarequest + "billing_zip" + "=" + billing_zip  + "&";
        ccarequest = ccarequest + "billing_tel" + "=" + billing_tel  + "&";
        ccarequest = ccarequest + "billing_email" + "=" + billing_email  + "&";
        ccarequest = ccarequest + "billing_state" + "=" + billing_state  + "&";
        ccarequest = ccarequest + "billing_country" + "=" + billing_country  + "&";
        ccarequest = ccarequest + "delivery_name" + "=" + billing_name  + "&";
        ccarequest = ccarequest + "delivery_address" + "=" + billing_address  + "&";
        ccarequest = ccarequest + "delivery_city" + "=" + billing_city  + "&";
        ccarequest = ccarequest + "delivery_zip" + "=" + billing_zip + "&";
        ccarequest = ccarequest + "delivery_tel" + "=" + billing_tel  + "&";
        ccarequest = ccarequest + "delivery_state" + "=" + billing_state  + "&";
        ccarequest = ccarequest + "delivery_country" + "=" + billing_country  + "&";
        ccarequest = ccarequest + "merchant_param1" + "=" + "additional Info." + "&";
        ccarequest = ccarequest + "merchant_param2" + "=" + "additional Info." + "&";
        ccarequest = ccarequest + "merchant_param3" + "=" + "additional Info." + "&";
        ccarequest = ccarequest + "merchant_param4" + "=" + "additional Info." + "&";
        ccarequest = ccarequest + "merchant_param5" + "=" + "additional Info." + "&";

        strEncRequest = ccaCrypto.Encrypt(ccarequest, workingKey);
  
    
    }


  
}


NB:ITS MANDATORY TO PASS ALL THE REQUIRED PARAMETERS TO CC AVENUE,OTHERWISE REDIRECTION WILL NOT BE POSSIBLE 


Take  html source code of your page add these two hidden  fields

  <input type="hidden" id="encRequest" name="encRequest" value="<%=strEncRequest%>"/>

        <input type="hidden" name="access_code" id="Hidden1" value="<%=strAccessCode%>"/>



And in form action:

  <form id="cca_redirect" action="https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction" method="post">


If you want to display the details of parameters that are passed to cc avenue to our form add  the following elements to our form


 <tr>   <td style="width: 277px"> Billing Address</td><td> 

 <input id="billing_address1"  name="billing_address1" runat="server" style="width: 314px; height: 17px; font-weight: bold;" readonly ="true"/></td></tr>
                          
<tr> <td style="width: 277px"> Billing City</td><td>  <strong> 

<input id="billing_city1" type="text"  name="billing_city1" runat="server" style="width: 314px; height: 21px" read only ="true"/></strong></td></tr> 

<tr ><td style="width: 277px; height: 31px;"> BillinState</td><td style="height: 31px">  <strong>  


<input id="billing_state1" type="text"  name="billing_state1" runat="server" style="width: 314px; height: 17px" readonly ="true"/></strong></td></tr>
                         
                           


THAT'S COMPLETES SENDING PARAMETERS TO CC AVENUE !!!!!



Configuring return page

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Collections.Specialized;
using CCA.Util;
using  System.Data;


public partial class cca_return : System.Web.UI.Page
{
   
  
    protected void Page_Load(object sender, EventArgs e)
    {
           

      
 
 
 string workingKey = "" 


//put in the 32bit alpha numeric key in the quotes provided here
              
        CCACrypto ccaCrypto = new CCACrypto();
        string encResponse = ccaCrypto.Decrypt(Request.Form["encResp"], workingKey);
        NameValueCollection Params = new NameValueCollection();
        string[] segments = encResponse.Split('&');
        foreach (string seg in segments)
        {
            string[] parts = seg.Split('=');
            if (parts.Length > 0)
            {
                string Key = parts[0].Trim();
                string Value = parts[1].Trim();
                Params.Add(Key, Value);
            }
        }


      


        Response.Write("<b><p>TRANSACTION SUCCESSFULLY COMPLETED!!!</P></B><br>");
        Response.Write(Params.Keys[0] + " = " + Params[0] + "<br>");
        Response.Write(Params.Keys[1] + " = " + Params[1] + "<br>");
        Response.Write(Params.Keys[2] + " = " + Params[2] + "<br>");
        Response.Write(Params.Keys[3] + " = " + Params[3] + "<br>");
        Response.Write(Params.Keys[6] + " = " + Params[6] + "<br>");
        Response.Write("Thank you for making purchase with  us!!!!!");

      

    }

}



  thanks for  listening with us ************************@jyothi23/jun/2018 

Comments

Post a Comment