Tuesday, 22 July 2014

Ccavenue Payment Integration in asp.net mvc5



Here i am writing a simple article to integrate Ccavenue payment integration.

Controller 

public ActionResult ccavenueForm()
 {
   try
            {
                Payment_ccavenue myUtility = new Payment_ccavenue();
             //This id(also User Id)  available at "Generate Working Key" of "Settings & Options" ;
                string Merchant_Id = "M_ravicm_14844";
             // 'your script should substitute the amount here in the quotes provided here
                string Amount = Session["Payment_Amount_CCAvenue"].ToString();
                string Order_Id = Session["Custom_Field"].ToString();// 'your script should substitute the order description here in the quotes provided here
                string Redirect_Url = GlobalVariables.Redirect_Redirect_ccavenue;//'your redirect URL where your customer will be redirected after authorisation from CCAvenue               
                string WorkingKey = "1r5aced2v9mmaqhb3k";// 'put in the 32 bit alphanumeric key in the quotes provided here.Please note that get this key ,login to your CCAvenue merchant account and visit the "Generate Working Key" section at the "Settings & Options" page. 
                ViewBag.Redirect_Redirect_ccavenue = Redirect_Url;
                ViewBag.Checksum = myUtility.getchecksum(Merchant_Id, Order_Id, Amount, Redirect_Url, WorkingKey);
                return View();
            }
            catch
            {
                // string S = Exception.ToString();
                return RedirectToRoute("ErrorHandling");
            }
        }

View 


<!-- #include virtual = "/payment/libfuncs.asp" -->
<HTML>
<HEAD>
<TITLE>Sub-merchant checkout page: www.mywebsite.com</TITLE>
</HEAD>
<BODY onload="document.forms['ccavenueForm'].submit();">
@{
string     Merchant_Id = "M_ravicm_14844"; //This id(also User Id)  available at "Generate Working Key" of "Settings & Options" ;
string Amount = Session["Payment_Amount_CCAvenue"].ToString();// 'your script should substitute the amount here in the quotes provided here
string Order_Id = Session["Custom_Field"].ToString();// 'your script should substitute the order description here in the quotes provided here
string Redirect_Url = @ViewBag.Redirect_Redirect_ccavenue;//'your redirect URL where your customer will be redirected after authorisation from CCAvenue
  //  Amount = "21";
    string WorkingKey = "2er4ed2v9mmaqhb3k"  ;// 'put in the 32 bit alphanumeric key in the quotes provided here.Please note that get this key ,login to your CCAvenue merchant account and visit the "Generate Working Key" section at the "Settings & Options" page. 
    
    string Checksum = ViewBag.Checksum;
    //Amount = "1111";
    string  billing_cust_name = "";
    string  billing_cust_address = "";
    string  billing_cust_state = "";
    string  billing_cust_country = "";
    string  billing_cust_tel = "";
    string  billing_cust_email = "";
    string delivery_cust_name = "";
    string  delivery_cust_address = "";
    string  delivery_cust_state = "";
    string  delivery_cust_country = "";
    string  delivery_cust_tel = "";
    string  delivery_cust_notes = "";
    string  Merchant_Param = "" ;
    string  billing_zip = "";
    string  delivery_zip = "";
    string billing_city = "";
    string delivery_city = "";

    }
<formmethod="post"name="ccavenueForm"action="https://www.ccavenue.com/shopzone/cc_details.jsp">
    <input type=hidden name=Merchant_Id value="@Merchant_Id">
    <input type=hidden name=Amount value="@Amount">
    <input type=hidden name=Order_Id value="@Order_Id">
    <input type=hidden name=Redirect_Url value="@Redirect_Url">
    <input type=hidden name=Checksum value="@Checksum">
    <input type="hidden" name="billing_cust_name" value="@billing_cust_name"> 
    <input type="hidden" name="billing_cust_address" value="@billing_cust_address"> 
    <input type="hidden" name="billing_cust_state" value="@billing_cust_state">
    <input type="hidden" name="billing_cust_country" value="@billing_cust_country"> 
    <input type="hidden" name="billing_cust_city" value="@billing_city"> 
    <input type="hidden" name="billing_zip_code" value="@billing_zip"> 
    <input type="hidden" name="billing_cust_tel" value="@billing_cust_tel"> 
    <input type="hidden" name="billing_cust_email" value="@billing_cust_email"> 
    <input type="hidden" name="delivery_cust_name" value="@delivery_cust_name"> 
    <input type="hidden" name="delivery_cust_address" value="@delivery_cust_address">
    <input type="hidden" name="delivery_cust_country" value="@delivery_cust_country"> 
    <input type="hidden" name="delivery_cust_state" value="@delivery_cust_state">
    <input type="hidden" name="delivery_cust_tel" value="@delivery_cust_tel"> 
    <input type="hidden" name="delivery_cust_notes" value="@delivery_cust_notes"> 
    <input type="hidden" name="Merchant_Param" value="@Merchant_Param"> 
    <input type="hidden" name="billing_zip_code" value="@billing_zip"> 
    <input type="hidden" name="delivery_cust_city" value="@delivery_city"> 
    <input type="hidden" name="delivery_zip_code" value="@delivery_zip"> 
    <!--<INPUT TYPE="submit" value="submit">-->
    </form>
</BODY>
</HTML>

0 comments:

Post a Comment