How to integrate CCAvenue payment gateway into your website using ASP.NET? (with Screenshot)

Today, I am going to write about CCAvenuge Payment Gateway integration into your own website. Let’s go!

Your Pre-requisites

  • CCAvenue accounts with Activation.
    – Merchant ID
    – Access Code
    – Secret or Encryption or Working Key
  • Integration kit from CCAvenue website.
  • Visual Studio 2012 or Later

Steps to Integration

1. Downloading Integration Kit

Login into you CCAvenue account. Then go to Resources -> Web Integration Kit -> Download Integration kit & then choose “Download ASP.NET (V3.5) as show in image below. Also, I have attached download link of ASP.NET integration kit here: ASP.Net_Kit_Version_3.5.
CCAvenue Integration

2. Choose the Integration Method

CCAvenue gives 3 different types of integration.

  • Billing Page (Non-Seamless)
  • iFrame Checkout
  • Checkout Form

In our tutorial, we are going to use Billing page method. In backend almost theses 3 methods are same but front-end behaviours will vary. You can find more details about this integration method in ccavenue website.

3. Opening Project in Visual Studio

Extract the file downloaded in step 1, it will 3 folders. Go to folder NON_SEAMLESS_KIT and open the file MCPG.ASP.net.ENC.sln using Visual Studio
CCAvenue Payment Gateway Integration

4. Adding Access Code, Encryption Key and Merchant ID into Project

1. Open the file named ccavRequestHandler.aspx and provide Access Code and Encryption Key as shown in below.
CCAvenue Payment Gateway Integration

2. Open the file ccavResponseHandler.aspx and provide Encryption Key.

3. Open the file dataFrom.htm and provide Merchant Key as shown in the image below.
CCAvenue Payment Gateway Integration

5. Adding Reference to the Project (Most Important)

i. Right click on “Reference” to the solution explorer in Visual Studio.
Adding Reference in Visual Studio

ii. Browse for the MCPG.CCA.Util.dll and add it to project reference.
Adding DLL into Visual Studio

6. Build the Project

i. Clean the project.
ii. Build the project.

Then go to the project folder -> Obj -> Release folder, you will find recently generated MCPG.ASP.net.ENC.dll

7. Run the Project

That’s all! Run the project. You will get dataFrom.htm
ccavenue payment gateway integration

If you followed all these steps as mentioned, you will redirect to ccavenue website while clicking on `checkout` button.
ccavenue payment gateway integration

If you have any queries/concern, please drop in the comment section below.

Quick Info

Updated Post Here: http://aravin.net/complete-guide-integrate-ccavenue-payment-gateway-asp-net-website-screenshot/

  1. Complete List of CCAvenue Error Codes with reason
  2. Complete list of CCAvenue Response code with description
  3. How to integrate CCAvenue payment gateway into ASP.NET Razor website?

75 thoughts on “How to integrate CCAvenue payment gateway into your website using ASP.NET? (with Screenshot)

  1. Prabhat says:

    I think key assigned to our project will not work for this sample project, so do I need to get keys for this sample project or can I use the same as mentioned at our MARS account?

  2. Amit says:

    Hi,
    I have followed each step of yours exactly the way you described.
    Now running on localhost i am getting to this page where nothing is appearing inside payment information, rest everything is appearing.
    I am working on localhost and had got separated keys for it from the customer care.

    this part is blank

  3. heena bhalodia says:

    i get authentication error when i click on check out button,

    Error Details :

    Error Code: 10002 Merchant Authentication failed.
    Don’t worry… It happens to the best of us.

    • aravin says:

      This error can be caused by an incorrect merchant ID, an incorrect access code, or if the order originates from an unregistered URL. Make sure that all three of these values are correct. For your security, CCAvenue does not report exactly which of these three values might be in error.

      If possible, share the sample code [email protected]

    • aravin says:

      1. You can use the domain which is registered on CCAveneue. If you need to use any other subdomain, you need to get permission from CCAvenue(write email to [email protected] ).

      2. You need to pass the parameter “amount” when click on “Pay Now” button. (which is available on dataForm.htm)

      • Heena Bhalodia says:

        Thanks aravin i have registered test url now testing url is working. but when i click on Pay Now button it is redirect to dataForm.htm page ..can i hide this page and jump to ccavRequestHandler.aspx page ?

        Actually i don’t have any idea how to integrate
        dataFrom.html,
        ccavRequestHandler.aspx,
        ccavResponseHandler.aspx
        this 3 pages in Shopping Cart Project on Pay Now button.

  4. Thrilok says:

    Hi Aravin

    Error Code: 10001 Invalid Request – Encrypted request invalid/not present.

    Don’t worry… It happens to the best of us.

    I Got this Exception After Running That Code

  5. Thrilok says:

    Error Code: 10002 Merchant Authentication failed.

    Don’t worry… It happens to the best of us.

    i got that Error

  6. Thrilok says:

    Hi Aravin,
    I entered Correct working Key,Acess Code,Merchent Id but I click On Check out Button it
    causes The
    Error Code: 10002 Merchant Authentication failed.

    Don’t worry… It happens to the best of us.

    please give me the correct way how to get the Check Out Page .As soon As possible

  7. aravin says:

    Hi @Thrilok,

    1. Which URL you’re testing? I mean your website name.

    If you’re using LocalHost, you need to add localhost to your CCAvenue Account.

  8. Hi aravin, i am creating ASP.NET MVC application and i need to integrate with CCAvenue for payment process. which version of ASP.NET kit i need to download from the CCAvenue.
    Can you please put some steps here for MVC projects.

  9. Apeksha says:

    Hello Aravin,

    I am trying to integrate ccAvenue in asp.net mvc in that I have copied the same dataform.htm in one of my view as well as i copied RequestHandler.aspx and ResponseHandler.aspx in my two different views. When I try to open the view same as dataform.htm , I get the checkout button and when I click on it it redirect me to 10002 Error code page.

    Please help me out.

    • aravin says:

      @Apeksha,

      If you’re running in localhost, you need to add “localhost” in your CCAvenue account.

      Also, you have to use Access code & Secrect key of your “localhost” which is added to your account.

      Send email to [email protected] to add your testing url to your ccavenue account.


      It is recommended to use your localhost IP for testing purpose. i.e 127.0.0.1 instead of localhost

    • aravin says:

      @Vivek,

      If you’re running on localhost, you need to add “localhost” in your CCAvenue account.

      Also, you have to use Access code & Secret key of your “localhost” which is added to your account.

      Send an email to [email protected] to add your testing URL to your CCavenue account.


      It is recommended to use your localhost IP for testing purpose. i.e 127.0.0.1 instead of localhost

  10. Binita says:

    Hello,

    I followed each and every step correctly which includes correct MerchantID, Working Key, Access Key and adding Localhost URL to my account. Still getting “Error Code: 10002 Merchant Authentication failed.” I am using Visual Studio 2010. Can you guide me?
    Thanks in advance.

  11. Kanwaljeet says:

    Hi Aravin,

    Thanks for the good article.

    I followed the each step and code was working, but now it’s giving the below error:

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    string encResponse = ccaCrypto.Decrypt(Request.Form[“encResp”], workingKey);

    Thanks in advance.

  12. Dear Sir,

    when i click payment option then i get this response.

    redirect url can not contain new line charectors

    Session(“OrderId”) = OrderNo
    Session(“Amount”) = lblNetPrice.Text
    Session(“delivery_cust_name”) = txtName.Text
    Session(“delivery_cust_address”) = txtAddress.Text
    Session(“delivery_cust_tel”) = txtMobileNo.Text
    Session(“delivery_cust_city”) = txtCity.Text
    Session(“delivery_cust_state”) = txtState.Text
    Session(“delivery_cust_zipcode”) = txtPinCode.Text
    Session(“delivery_cust_country”) = txtCountry.Text

    Dim URL As String = “http://mysportchoice.com,”
    Dim COnfirmURL As String = “http://mysportchoice.com/OrderCancel.aspx?OrderNo=” + OrderNo + “&OrderId=” + OrderId.ToString() + “”
    Dim param As String = “?merchant_id=75334&order_id=” + OrderNo + “&amount=” + lblNetPrice.Text + “&currency=INR&redirect_url=” + URL + “&cancel_url=” + URL + “”
    param += “&billing_name=” + txtName.Text + “&billing_address=” + txtAddress.Text + “&billing_city=” + txtCity.Text + “&billing_state=” + txtState.Text + “”
    param += “&billing_zip=” + txtPinCode.Text + “&billing_country=” + txtCountry.Text + “&billing_tel=” + txtMobileNo.Text + “&billing_email=” + Session(“CustEmail”).ToString() + “”

    Response.Redirect(“ccavRequestHandler.aspx” + param + “”)

    • aravin says:

      Netaji bro, You have to implement by API. You can refer api doc in ccavenue website.

      Login -> Resources -> API Implementation guides -> API Calls -> Cancel

  13. how to check order_status in asp.net code
    i have ccavResponseHandler.aspx.cs

    this code
    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);
    }
    }
    please i don’t know to check order_status in this code so i will do redirect page according to order_status

    for (int i = 0; i < Params.Count; i++)
    {
    Response.Write(Params.Keys[i] + " = " + Params[i] + "”);

    }

  14. Meera says:

    hi ,
    I got the following error. i have done all the process as given .

    Error Code: 10002 Merchant Authentication failed.

    Don’t worry… It happens to the best of us.

    kindly update

  15. Heta Dave says:

    hi..
    I want to integrate CCAvenu Payment Integration using CCAvenu IFrame Express Checkout in asp.net mvc. But I don’t have any idea. Can you guide me?
    Thanks in advance

  16. Ashish Barnwal says:

    I am creating a e-commerce website. when i want to redirect on ccavenue websites from click event of button which is present on Cart.aspx page. So How to redirect plzz Help me.
    I am a fresher.

  17. Ashish Barnwal says:

    Hii aravin,

    I am creating a e-commerce website. when i want to redirect on ccavenue websites from click event of button which is present on Cart.aspx page. So How to redirect plzz Help me.I am a fresher.
    Plzz Hurry up, I am just waiting to complete My Project but my payment mode is not complete. I have all things but I have no idea,how to redirect on ccavenue and i don’t need a dataform.html then how can we transfer the data.

    • aravin says:

      Hi Ashish,

      You have to try PHP kit. This tutorial is about ASP.NET.

      Also, you can find ready-made kit for WordPress integration.

  18. Ashish Barnwal says:

    i am already host websites on iis server, then now i want to use social account Login like google and facebook.
    I am easily use this functionality on local host system but when i host on iis server then i have an Ip address where is my websites in in running mode. then there is a problem to redirect a login page

  19. dileep says:

    i am getting an error
    Error Code: 10001 Invalid Request – Encrypted request invalid/not present.

  20. Gaurav Saini says:

    hi aravin i’m building a portal with ccavenue gateway . i have done all the steps that i have got from ccavenue team. it works fine it send me to bank page.
    but my question is i have developed website in asp.net how do i integrate that ccavenue code with my application or what folder of ccavenue should be copied on my different apllication.

  21. Amreen says:

    Hi, Arvin i am confused in Request handler page how this page call when i click on make payment button i am very confused please help me out.

    • aravin says:

      Hi Amreen, on button click HTML post method will post all the data to payment processor. If possible share your confusion in detail.

  22. Amit kumar yadav says:

    i got these error after uploading my project to flex panel
    CS0246: The type or namespace name ‘CCA’ could not be found (are you missing a using directive or an assembly reference?)
    How to solve it ..
    Plzz help me..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.