Example #1
0
        public static string Get_Payment_Status(string pOrderId)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            WebRequest         lWebRequest         = WebRequest.Create("https://secure.paytm.in/oltp/HANDLER_INTERNAL/TXNSTATUS?JsonData={\"ORDERID\":\"" + pOrderId + "\",\"MID\":\"" + lPayTmConfiguration.MID + "\"}");
            HttpWebResponse    lHttpWebResponse    = (HttpWebResponse)lWebRequest.GetResponse();
            Stream             lStream             = lHttpWebResponse.GetResponseStream();
            StreamReader       lStreamReader       = new StreamReader(lStream);
            string             lResponseFromSender = lStreamReader.ReadToEnd();


            lStreamReader.Close();
            lStream.Close();
            lHttpWebResponse.Close();
            return(lResponseFromSender);
        }
Example #2
0
        public static void Refund_PayTm_Order(string pOrderId,
                                              string pTxnId,
                                              string pRefundAmount,
                                              string pComments,
                                              string pReferenceId)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            PayTmPaymentGatewayRefundRequest lPaymentGatewayRefundRequest = new PayTmPaymentGatewayRefundRequest();
            Dictionary <string, string>      parameters = new Dictionary <string, string>();

            lPaymentGatewayRefundRequest.MID          = lPayTmConfiguration.MID;
            lPaymentGatewayRefundRequest.TXNID        = pTxnId;
            lPaymentGatewayRefundRequest.ORDERID      = pOrderId;
            lPaymentGatewayRefundRequest.REFUNDAMOUNT = pRefundAmount;
            lPaymentGatewayRefundRequest.TXNTYPE      = "REFUND";
            lPaymentGatewayRefundRequest.COMMENTS     = pComments;
            lPaymentGatewayRefundRequest.REFID        = pReferenceId;
            parameters.Add("MID", lPayTmConfiguration.MID);
            parameters.Add("TXNID", pTxnId);
            parameters.Add("ORDERID", pOrderId);
            parameters.Add("REFUNDAMOUNT", pRefundAmount);
            parameters.Add("TXNTYPE", "REFUND");
            parameters.Add("COMMENTS", pComments);
            parameters.Add("REFID", pReferenceId);

            string checksum = CheckSum.generateCheckSum(lPayTmConfiguration.Merchant_Key, parameters);

            lPaymentGatewayRefundRequest.CHECKSUM = checksum;

            JavaScriptSerializer lJavaScriptSerializer = new JavaScriptSerializer();
            var lJson = lJavaScriptSerializer.Serialize(lPaymentGatewayRefundRequest);

            WebRequest      lWebRequest         = WebRequest.Create(lPayTmConfiguration.Refund_Url + "?JsonData=" + lJson);
            HttpWebResponse lHttpWebResponse    = (HttpWebResponse)lWebRequest.GetResponse();
            Stream          lStream             = lHttpWebResponse.GetResponseStream();
            StreamReader    lStreamReader       = new StreamReader(lStream);
            string          lResponseFromSender = lStreamReader.ReadToEnd();

            //    PaymentGatewayResponse lPaymentGatewayResponse = lJavaScriptSerializer.Deserialize<PaymentGatewayResponse>(lResponseFromSender);
            lStreamReader.Close();
            lStream.Close();
            lHttpWebResponse.Close();

            //    if (lPaymentGatewayResponse != null)
            //    {
        }
Example #3
0
        public static string Add_Delivery_Information(MySqlConnection dbconn,
                                                      string pOrderId,
                                                      string pOrderNumber,
                                                      string pCustomerId,
                                                      string pOrderAmount,
                                                      string pDeliveryDate,
                                                      string pPaymentRef)
        {
            PaymentClass.CCAvenue_Confirm_Order(pPaymentRef, pOrderAmount);
            string lErrorMessage = null;

            string[] lRecords = CommonClass.FetchRecords("ADD_DELIVERY_INFO",
                                                         new string[]
            {
                "P_ORDER_ID",
                "P_CUSTOMER_ID",
                "P_EXTERNAL_USER_ID",
                "P_DELIVERY_DATE"
            },
                                                         new string[]
            {
                pOrderId,
                pCustomerId,
                ClaimsPrincipal.Current.FindFirst("user_id").Value,
                pDeliveryDate
            },
                                                         new string[]
            {
                "P_ERROR_STRING"
            },
                                                         dbconn
                                                         );
            if (lRecords[0] != null && lRecords[0] != "")
            {
                lErrorMessage = lRecords[0];
            }
            else
            {
                Messages.Send_Order_Delivered_Message(pOrderNumber,
                                                      pCustomerId,
                                                      pDeliveryDate,
                                                      dbconn);
            }
            return(lErrorMessage);
        }
Example #4
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);
        }
Example #5
0
        public static void Initiate_PayTm_Order(string pOrderId,
                                                string pTransactionAmount,
                                                string pEmail,
                                                string pMobileNumber)
        {
            PayTmConfiguration lPayTmConfiguration = PaymentClass.Get_Paytm_Configuration();
            string             lMobileNumber       = pMobileNumber;

            if (lPayTmConfiguration.Mobile_Number != null)
            {
                lMobileNumber = lPayTmConfiguration.Mobile_Number;
            }

            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>Paytm 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='" + paytmURL + "' name='f1'>";
            outputHTML += "<table border='1'>";
            outputHTML += "<tbody>";
            foreach (string key in parameters.Keys)
            {
                outputHTML += "<input type='hidden' name='" + key + "' value='" + parameters[key] + "'>";
            }
            outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "'>";
            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);
        }
Example #6
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);
        }
Example #7
0
        public static void Confirm_Order(MySqlConnection dbconn,
                                         string lOrderId)
        {
            MySqlDataReader lMySqlDataReader = CommonClass.FetchRecords("GET_ORDER_BY_ID",
                                                                        new string[]
            {
                "P_ORDER_ID",
                "P_EXTERNAL_USER_ID"
            },
                                                                        new string[]
            {
                lOrderId,
                ClaimsPrincipal.Current.FindFirst("user_id").Value
            },
                                                                        dbconn
                                                                        );
            string lAddress         = "";
            string lOrderDate       = "";
            string lOrderAmount     = "";
            string lSubtotal        = "";
            string lShippingCharges = "";
            string lDiscount        = "";
            string lGrandTotal      = "";
            string lOrderNumber     = "";
            string lPaymentType     = "";
            string lUserId          = null;
            string lDeliveryMethod  = null;

            string[] lCodEligible      = null;
            string   lPinCode          = null;
            string   lPromotionApplied = "N";

            if (lMySqlDataReader.Read())
            {
                lOrderNumber = lMySqlDataReader["ORDER_NUMBER"].ToString();
                if (lMySqlDataReader["ADDRESS_ID"] != null)
                {
                    string[] lAddressArray = CommonClass.Get_Address_By_Id(lMySqlDataReader["ADDRESS_ID"].ToString());
                    lAddress = CommonClass.Format_Address(lAddressArray[0], lAddressArray[1], lAddressArray[2], lAddressArray[3], lAddressArray[4], lAddressArray[5]);
                    lPinCode = lAddressArray[5];
                }
                lOrderDate        = lMySqlDataReader["ORDER_DATE"].ToString();
                lOrderAmount      = lMySqlDataReader["ORDER_TOTAL"].ToString();
                lShippingCharges  = lMySqlDataReader["SHIPPING_CHARGE"].ToString();
                lDiscount         = lMySqlDataReader["DISCOUNTS"].ToString();
                lSubtotal         = (double.Parse(lOrderAmount) - double.Parse(lShippingCharges) + double.Parse(lDiscount)).ToString();
                lPaymentType      = lMySqlDataReader["PAYMENT_TYPE"].ToString();
                lGrandTotal       = lOrderAmount;
                lUserId           = lMySqlDataReader["USER_ID"].ToString();
                lDeliveryMethod   = lMySqlDataReader["DELIVERY_METHOD_ID"].ToString();
                lPromotionApplied = lMySqlDataReader["PROMOTION_APPLIED"].ToString();
            }

            lMySqlDataReader.Close();


            if (lPinCode != null && lPromotionApplied == "N")
            {
                lCodEligible = CommonClass.FetchRecords("IS_COD",
                                                        new string[]
                {
                    "P_PIN_CODE"
                },
                                                        new string[]
                {
                    lPinCode
                },
                                                        new string[]
                {
                    "P_ELIGIBLE"
                },
                                                        dbconn);
            }

            PaymentClass.Allocate_Order(dbconn, lUserId);

            UserDetails lUserDetails = Messages.Get_Contact_Details(lUserId, dbconn);

            lMySqlDataReader = CommonClass.FetchRecords("GET_ORDER_DETAILS_BY_ID",
                                                        new string[]
            {
                "P_ORDER_ID",
                "P_EXTERNAL_ID"
            },
                                                        new string[]
            {
                lOrderId,
                ClaimsPrincipal.Current.FindFirst("user_id").Value
            },
                                                        dbconn);
            string lOrderSummary = "";

            while (lMySqlDataReader.Read())
            {
                lOrderSummary += "<tr>";
                lOrderSummary += "<td>" + lMySqlDataReader["PRODUCT_NAME"].ToString() + " </td>";
                lOrderSummary += "<td>" + lMySqlDataReader["MEASUREMENT_UNIT"].ToString() + " </td>";
                lOrderSummary += "<td>" + lMySqlDataReader["QUANTITY"].ToString() + " </td>";
                lOrderSummary += "<td>₹ " + lMySqlDataReader["PRICE"].ToString() + " </td>";
                lOrderSummary += "<td>₹ " + lMySqlDataReader["SUBTOTAL"].ToString() + " </td>";
                lOrderSummary += "</tr>";
            }
            lMySqlDataReader.Close();

            Messages.Send_Order_Confirmation_Message(lUserDetails.Email,
                                                     lUserDetails.User_Name,
                                                     lAddress,
                                                     lUserDetails.Mobile_Number,
                                                     lOrderNumber,
                                                     lOrderDate,
                                                     lOrderAmount,
                                                     lOrderSummary,
                                                     lSubtotal,
                                                     lShippingCharges,
                                                     lGrandTotal,
                                                     lDiscount,
                                                     lPaymentType,
                                                     dbconn);


            if (lDeliveryMethod == "3" && lCodEligible[0] != "1")
            {
                Messages.Send_Order_Confirmation_Message_To_Seller(
                    lAddress,
                    lOrderNumber,
                    lOrderDate,
                    lOrderAmount,
                    lOrderSummary,
                    lSubtotal,
                    lShippingCharges,
                    lGrandTotal,
                    lDiscount,
                    lPaymentType,
                    dbconn);
            }
        }
Example #8
0
        public static void Create_Order(MySqlConnection dbconn,
                                        string CustomerId,
                                        string GrandTotal,
                                        string ShippingCharges,
                                        string Discounts,
                                        string AddressId,
                                        string PromotionId,
                                        string PaymentType,
                                        string Status,
                                        string DeliveryMethod)
        {
            string[] lRecords = CommonClass.ExecuteQuery("ADD_ORDER",
                                                         new string[]
            {
                "P_USER_ID",
                "P_EXTERNAL_USER_ID",
                "P_ORDER_TOTAL",
                "P_SHIPPING_CHARGE",
                "P_DISCOUNTS",
                "P_ADDRESS_ID",
                "P_PROMOTION_ID",
                "P_PAYMENT_TYPE",
                "P_ORDER_STATUS",
                "P_DELIVERY_METHOD",
                "P_SHOPPING_CART_ID"
            },
                                                         new string[]
            {
                CustomerId,
                ClaimsPrincipal.Current.FindFirst("user_id").Value,
                GrandTotal,
                ShippingCharges,
                Discounts,
                AddressId,
                PromotionId,
                PaymentType,
                Status,
                DeliveryMethod,
                HttpContext.Current.Session["SHOPPING_CART_ID"].ToString()
            },
                                                         new string[]
            {
                "P_ORDER_ID"
            },
                                                         dbconn);
            string lOrderid = lRecords[0];

            if (PaymentType == "Others")
            {
                UserModel lUserModel = CommonClass.Get_External_User_Profile(dbconn);

                PaymentClass.Initiate_CCAvenue_Order(lOrderid,
                                                     GrandTotal,
                                                     lUserModel.Email_Address,
                                                     lUserModel.Mobile_Number,
                                                     AddressId,
                                                     dbconn);
                dbconn.Close();
            }
            else
            {
                Confirm_Order(dbconn,
                              lOrderid);
                dbconn.Close();
                HttpContext.Current.Session.Abandon();
                HttpContext.Current.Session.Clear();
                HttpContext.Current.Response.Redirect("~/OrderSummary.aspx?Order_Id=" + lOrderid);
            }
        }