コード例 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["TranferOTP"].ToString() == Session["txtCodeTranferOTP"].ToString())
            {
                string uid           = Configuration.SuvidhaUser;
                string pin           = Configuration.SuvidhaPin;
                string mobileno      = Session["MobileNo"].ToString();
                string benecode      = Session["BenfCode"].ToString();
                string ifsccode      = Session["IfscCode"].ToString();
                string amount        = Session["TransferAmount"].ToString();
                string paytype       = Session["BeneficiaryType"].ToString();
                string accountno     = Session["BeneAccount"].ToString();
                string beneName      = Session["BeneName"].ToString();
                string transactionId = TransactionID();

                string URL = "http://recharge.suvidhaarecharge.com/api/MoneyTransfer/MoneyTransfer?Username="******"&Password="******"&Mobile=" + mobileno + "&BeneCode=" + benecode + "&IFSC=" + ifsccode + "&Amount=" + amount + "&PayType=" + paytype + "&AccountNumber=" + accountno + "&Name=" + beneName + "&YourTransactionID=" + transactionId + "";

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);

                string postData = "http://recharge.suvidhaarecharge.com/api/MoneyTransfer/MoneyTransfer?Username="******"&Password="******"&Mobile=" + mobileno + "&BeneCode=" + benecode + "&IFSC=" + ifsccode + "&Amount=" + amount + "&PayType=" + paytype + "&AccountNumber=" + accountno + "&Name=" + benecode + "&YourTransactionID=" + transactionId + "";
                httpWebRequest.Method        = WebRequestMethods.Http.Post;
                httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
                httpWebRequest.ContentLength = postData.Length;

                using (StreamWriter writer = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    writer.Write(postData);
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    CustRegistraion      cr = js.Deserialize <CustRegistraion>(result);
                    Int32  user_id          = cr.UserId;
                    string bankAcno         = cr.BankAccNo;
                    string benename         = cr.BeneficiaryName;
                    string sendermobile     = cr.SenderMobile;
                    string requestno        = cr.requestNo;
                    string errormsg         = cr.ErrorMsg;
                    string message          = cr.Message;

                    if (message == "SUCCESS")
                    {
                        string trasactionno = TransactionID();
                        string sysIPaddress = GetIPAddress();
                        Int32  userID       = Convert.ToInt32(Session["Customerid"]);

                        obj_wallet.UpdateCustomerWalletFundtransfer(Convert.ToDecimal(txtAmount.Text), userID);

                        obj_wallet.AddFundTransferDetail(trasactionno, userID, Session["UserIdenfifyNo"].ToString(), Session["BeneName"].ToString(), Session["BeneAccount"].ToString(), Session["BeneficiaryType"].ToString(), Session["IfscCode"].ToString(), Session["MobileNo"].ToString(), Convert.ToDecimal(Session["TransferAmount"]), sysIPaddress);

                        string mobile = Session["MobileNo"].ToString();
                        SendMsg(mobile);
                        string requeststatus = "Amount Transfered";

                        BindUserWalletDetails(Convert.ToString(userID));
                        Session["transactiontype"] = "Withdrawal Amount";
                        int logid = Convert.ToInt32(Session["userid"]);
                        obj_wallet.DeductCustomerWalletAmt(Convert.ToInt32(Session["walletid"]), userID, Convert.ToDecimal(Session["walletamount"]), Convert.ToDecimal(Session["TransferAmount"]), trasactionno, Session["transactiontype"].ToString(), requeststatus, Session["Customername"].ToString(), Session["CustEmailid"].ToString(), logid, Session["UserIdenfifyNo"].ToString());
                        obj_wallet.UpdateCustomerWalletFundtransfer(Convert.ToDecimal(Session["TransferAmount"]), logid);

                        bool    status        = true;
                        long    transaccont   = Convert.ToInt64(Session["BeneAccount"]);
                        decimal tranferamount = Convert.ToDecimal(Session["TransferAmount"]);
                        string  requestid     = Convert.ToString(Session["RequestID"]);
                        if (Session["RequestID"] != null)
                        {
                            obj_wallet.UpdateCustomerFundTransferStatus(status, tranferamount, transaccont, requeststatus, requestid);
                        }

                        lblMessage.ForeColor       = Color.Green;
                        lblMessage.Text            = "Amount Transfer Successfully!";
                        Session["MobileNo"]        = null;
                        Session["BeneAccount"]     = null;
                        Session["BeneName"]        = null;
                        Session["IfscCode"]        = null;
                        Session["BeneficiaryType"] = null;
                        Session["TransferAmount"]  = null;
                        Session["Customerid"]      = null;
                        Session["TranferOTP"]      = null;
                        txtAmount.Text             = "";
                        Session["RequestUserid"]   = null;
                        Session["RequestID"]       = null;
                        Session["RequestAmount"]   = null;

                        Session["TranferOTP"]        = null;
                        Session["txtCodeTranferOTP"] = null;
                    }
                    if (errormsg != null)
                    {
                        lblMessage.ForeColor = Color.Red;
                        lblMessage.Text      = errormsg;
                    }
                }
            }
            else
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text      = "OTP entered is incorrect";
            }
        }
        catch
        { }
    }