示例#1
0
        public static void CCAvenue_Confirm_Order(string pPaymentRef,
                                                  string pAmount)
        {
            CCAvanueConfiguration lCCAvanueConfiguration = PaymentClass.Get_CCAvenue_Configuration();
            CCACrypto             ccaCrypto = new CCACrypto();
            string lJsonData     = "{\"order_List\": [ {\"reference_no\":\"" + pPaymentRef + "\",\"amount\":\"" + pAmount + "\"} ] }";
            string strEncRequest = ccaCrypto.Encrypt(lJsonData, lCCAvanueConfiguration.Working_Key);

            RestClient lRestClient = new RestClient("https://login.ccavenue.com/apis/servlet/DoWebTrans");

            lJsonData = "{\"request_type\":\"JSON\",\"Command\":\"confirmOrder\",\"access_code\":\"" + lCCAvanueConfiguration.Access_Code + "\",\"response_type\":\"JSON\"}";

            RestRequest lRestRequest = new RestRequest(Method.POST);

            lRestRequest.AddQueryParameter("command", "confirmOrder");
            lRestRequest.AddQueryParameter("request_type", "JSON");
            lRestRequest.AddQueryParameter("access_code", lCCAvanueConfiguration.Access_Code);
            lRestRequest.AddQueryParameter("response_type", "JSON");
            lRestRequest.AddQueryParameter("enc_request", strEncRequest);
            IRestResponse lRestResponse = lRestClient.Execute(lRestRequest);

            //HttpContext.Current.Response.Write(lRestResponse.Content);
        }
示例#2
0
        public static void Initiate_CCAvenue_Order(string pOrderId,
                                                   string pTransactionAmount,
                                                   string pEmail,
                                                   string pMobileNumber,
                                                   string pAddressId,
                                                   MySqlConnection dbconn)
        {
            UserAddress lUserAddress = UserClass.Get_User_Address(pAddressId,
                                                                  dbconn);

            CCAvanueConfiguration lCCAvanueConfiguration = PaymentClass.Get_CCAvenue_Configuration();
            string    lMobileNumber = pMobileNumber;
            CCACrypto ccaCrypto     = new CCACrypto();
            string    ccaRequest    = "";
            var       lCallBackUrl  = "http://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + "/CC_Order_Response.aspx"; //This parameter is not mandatory. Use this to pass the callback url dynamically.

            if (CommonClass.Is_Production())
            {
                lCallBackUrl = lCallBackUrl.Replace("http://", "https://");
            }
            ccaRequest += "merchant_id=" + HttpUtility.UrlEncode(lCCAvanueConfiguration.Merchant_Key) + "&";
            ccaRequest += "order_id=" + HttpUtility.UrlEncode(pOrderId) + "&";
            ccaRequest += "currency=" + HttpUtility.UrlEncode("INR") + "&";
            ccaRequest += "amount=" + HttpUtility.UrlEncode(pTransactionAmount) + "&";
            ccaRequest += "redirect_url=" + HttpUtility.UrlEncode(lCallBackUrl) + "&";
            ccaRequest += "cancel_url=" + HttpUtility.UrlEncode(lCallBackUrl) + "&";
            ccaRequest += "language=" + HttpUtility.UrlEncode("en") + "&";
            ccaRequest += "billing_name=" + HttpUtility.UrlEncode(lUserAddress.User_Name) + "&";
            ccaRequest += "billing_address=" + HttpUtility.UrlEncode(lUserAddress.Address) + "&";
            ccaRequest += "billing_city=" + HttpUtility.UrlEncode(lUserAddress.City) + "&";
            ccaRequest += "billing_state=" + HttpUtility.UrlEncode(lUserAddress.State) + "&";
            ccaRequest += "billing_zip=" + HttpUtility.UrlEncode(lUserAddress.Pin_Code) + "&";
            ccaRequest += "billing_country=" + HttpUtility.UrlEncode("India") + "&";
            ccaRequest += "billing_tel=" + HttpUtility.UrlEncode(lUserAddress.Mobile_Number) + "&";
            ccaRequest += "billing_email=" + HttpUtility.UrlEncode(pEmail) + "&";
            ccaRequest += "delivery_name=" + HttpUtility.UrlEncode(lUserAddress.User_Name) + "&";
            ccaRequest += "delivery_address=" + HttpUtility.UrlEncode(lUserAddress.Address) + "&";
            ccaRequest += "delivery_city=" + HttpUtility.UrlEncode(lUserAddress.City) + "&";
            ccaRequest += "delivery_state=" + HttpUtility.UrlEncode(lUserAddress.State) + "&";
            ccaRequest += "delivery_zip=" + HttpUtility.UrlEncode(lUserAddress.Pin_Code) + "&";
            ccaRequest += "delivery_country=" + HttpUtility.UrlEncode("India") + "&";
            ccaRequest += "delivery_tel=" + HttpUtility.UrlEncode(lUserAddress.Mobile_Number) + "&";

            string strEncRequest = ccaCrypto.Encrypt(ccaRequest, lCCAvanueConfiguration.Working_Key);

            //Dictionary<string, string> parameters = new Dictionary<string, string>();
            ////string lOrderId = lRecords[0];
            //parameters.Add("REQUEST_TYPE", "DEFAULT");
            //parameters.Add("MID", lPayTmConfiguration.MID);
            //parameters.Add("CHANNEL_ID", lPayTmConfiguration.Channel_Id);
            //parameters.Add("INDUSTRY_TYPE_ID", lPayTmConfiguration.Industry_Type);
            //parameters.Add("WEBSITE", lPayTmConfiguration.Website_Name);
            //parameters.Add("EMAIL", pEmail);
            //parameters.Add("MOBILE_NO", lMobileNumber);
            //parameters.Add("CUST_ID", ClaimsPrincipal.Current.FindFirst("user_id").Value);
            //parameters.Add("ORDER_ID", pOrderId);
            //parameters.Add("TXN_AMOUNT", pTransactionAmount);
            //var lCallBackUrl = "http://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + "/Order_Response.aspx"; //This parameter is not mandatory. Use this to pass the callback url dynamically.
            //if (CommonClass.Is_Production())
            //{
            //    lCallBackUrl = lCallBackUrl.Replace("http://", "https://");
            //}
            //parameters.Add("CALLBACK_URL", lCallBackUrl);
            //string paytmURL = lPayTmConfiguration.Payment_Url;

            //string checksum = CheckSum.generateCheckSum(lPayTmConfiguration.Merchant_Key, parameters);
            string outputHTML = "<html>";

            outputHTML += "<head>";
            outputHTML += "<title>CCAvenue Merchant Check Out Page</title>";
            outputHTML += "</head>";
            outputHTML += "<body>";
            outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
            outputHTML += "<form method='post' action='" + lCCAvanueConfiguration.Payment_Url + "' name='f1'>";
            outputHTML += "<table border='1'>";
            outputHTML += "<tbody>";
            outputHTML += "<input type='hidden' name='encRequest' value='" + strEncRequest + "'>";
            outputHTML += "<input type='hidden' name='access_code' value='" + lCCAvanueConfiguration.Access_Code + "'>";
            outputHTML += "</tbody>";
            outputHTML += "</table>";
            outputHTML += "<script type='text/javascript'>";
            outputHTML += "document.f1.submit();";
            outputHTML += "</script>";
            outputHTML += "</form>";
            outputHTML += "</body>";
            outputHTML += "</html>";
            HttpContext.Current.Response.Write(outputHTML);
        }