protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["tx"] != null) { GetPayPalResponce(); } else if (Request.QueryString[Crypto.ArgumentEncrypt("Resp")] != null) { string Status = Crypto.Decrypt(Request.QueryString[Crypto.ArgumentEncrypt("Resp")].ToString(), true); Session["status"] = Status; if (Status.Equals("approved")) { Guid CustID = Guid.Parse(Session["CustomerID"].ToString()); ViewState["CurrentCustomer"] = CustID; Session["CustomerID"] = CustID; ManageUserSVC.ManageUserClient Client = new ManageUserSVC.ManageUserClient(); ManageUserSVC.ManageUserCoverageData Coverage = new ManageUserCoverageData(); if (Session["RenewCoverageInfo"] != null) { Coverage = (ManageUserSVC.ManageUserCoverageData)Session["RenewCoverageInfo"]; } else { Coverage = (ManageUserSVC.ManageUserCoverageData)Session["CoverageInfo"]; } Client.InsertCoverageData(Coverage); bool Propertybuy = false;; Client.Update_Payment(CustID, decimal.Parse(Session["Amount"].ToString()), Propertybuy); lblMessage.Text = "Thank you! Your payment was successful!"; string Local = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"]; dowload(Local.Replace("https://", "http://") + "ProofEvidence.aspx?" + Crypto.ArgumentEncrypt("sss") + "=" + Crypto.Encrypt(CustID.ToString(), true), Coverage); idspan.Visible = true; SendEmailForProofOfEvidnce(Client, CustID, Local); } else if (Status.Equals("notapproved")) { // mess.Visible = false; lblMessage.Text = "Your payment was not processed successfully. Please ensure your payment details are correct.Click" + " <a id='lnkAccount' runat='server' href='Register.aspx?" + Crypto.ArgumentEncrypt("retrypayment") + "=" + Crypto.Encrypt("1", true) + "' style='cursor:pointer;color:black;text-decoration: underline;'>here</a> " + "to retry payment."; } } } }
protected void Button1_Click(object sender, EventArgs e) { lblCerty.Visible = false; lblEve.Visible = false; Guid CustID = Guid.Parse(Session["UserID"].ToString()); ManageUserSVC.ManageUserClient Cl = new ManageUserSVC.ManageUserClient(); DataSet dsCus = new DataSet(); dsCus = Cl.GetCustomerInfo(CustID); bool isactive = false; decimal payment = 0; string email = ""; if (dsCus != null && dsCus.Tables[0].Rows.Count > 0) { payment = Convert.ToDecimal(dsCus.Tables[0].Rows[0]["Payment"].ToString()); email = dsCus.Tables[0].Rows[0]["EmailID"].ToString(); string emailvarify = Convert.ToString(dsCus.Tables[0].Rows[0]["VerifyEmail"].ToString()); isactive = Convert.ToBoolean(dsCus.Tables[0].Rows[0]["IsActivePolicy"].ToString()); ManageUserSVC.ManageUserCustomerData User = new ManageUserSVC.ManageUserCustomerData(); if (emailvarify != "") { if (isactive == true) { DataSet dsCus2 = new DataSet(); dsCus2 = Cl.GetCoveragebyCustomerId(CustID); ManageUserSVC.ManageUserCoverageData Coverage = new ManageUserSVC.ManageUserCoverageData(); if (dsCus2 != null && dsCus2.Tables[0].Rows.Count > 0) { DateTime Coverdate = Convert.ToDateTime(dsCus2.Tables[0].Rows[0]["CoverDate"].ToString()); string fiveyrs = Convert.ToString(dsCus2.Tables[0].Rows[0]["_5YrClaim"].ToString()); string threeyrs = Convert.ToString(dsCus2.Tables[0].Rows[0]["_3YrLoss"].ToString()); string custid = Convert.ToString(dsCus2.Tables[0].Rows[0]["Cust_ID"].ToString()); string insurance = Convert.ToString(dsCus2.Tables[0].Rows[0]["InsuranceType"].ToString()); DataSet CovData = new DataSet(); CovData = Cl.CreateEvedenceInfoByCusID(CustID); if (CovData != null && CovData.Tables[0].Rows.Count > 0) { Coverage.CoverageID = Guid.Parse(CovData.Tables[0].Rows[0]["CoverID"].ToString()); } else { Coverage.CoverageID = Guid.NewGuid(); } Coverage.CoverageDate = Coverdate; Coverage.CustID = Guid.Parse(dsCus2.Tables[0].Rows[0]["Cust_ID"].ToString()); Session["CustomerIDForAdmin"] = CustID; Coverage.yr3Loss = Convert.ToBoolean(threeyrs); Coverage.yr5Loss = Convert.ToBoolean(fiveyrs); Coverage.Status = "True"; Session["CoverageInfo"] = Coverage; } if (Session["CoverageInfo"] != null) { if (payment == 0) { if (email != "") { string Memres = CheckMember(email); if (Memres == "Y") { User.Payment = Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["Membership"]); } else { User.Payment = Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["Non-Membership"]); } } decimal pay = User.Payment * 100; bool property = false; Cl.Update_Payment(CustID, pay, property); } if (Chkmail.Checked == true) { ManageUserSVC.ManageUserCoverageData Coverage2 = (ManageUserSVC.ManageUserCoverageData)Session["CoverageInfo"]; Cl.InsertCoverageData(Coverage2); string Local = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"]; dowload(Local.Replace("https://", "http://") + "ProofEvidence.aspx?" + Crypto.ArgumentEncrypt("sss") + "=" + Crypto.Encrypt(CustID.ToString(), true), Coverage2); SendEmailForProofOfEvidnce(Cl, CustID, Local); BindEvedences(CustID, Cl); lblEve.Visible = true; lblEve.Text = "Evidence Regenerated Successfully"; } else { ManageUserSVC.ManageUserCoverageData Coverage2 = (ManageUserSVC.ManageUserCoverageData)Session["CoverageInfo"]; Cl.InsertCoverageData(Coverage2); string Local = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"]; dowload(Local.Replace("https://", "http://") + "ProofEvidence.aspx?" + Crypto.ArgumentEncrypt("sss") + "=" + Crypto.Encrypt(CustID.ToString(), true), Coverage2); BindEvedences(CustID, Cl); lblEve.Visible = true; lblEve.Text = "Evidence Regenerated Successfully"; } } else { lblEve.Visible = true; lblEve.Text = "Coverage Data is not present!"; } } else { BindEvedences(CustID, Cl); lblEve.Visible = true; lblEve.Text = "Policy is not active,Please activate the policy!"; } } else { lblEve.Visible = true; lblEve.Text = "Email Address is not verified!"; } } }
private void GetPayPalResponce() { string authToken, txToken, query, strResponse, Key, Val, status; authToken = WebConfigurationManager.AppSettings["PDTToken"]; //read in txn token from querystring txToken = Request.QueryString.Get("tx"); query = string.Format("cmd=_notify-synch&tx={0}&at={1}", txToken, authToken); // Create the request back string url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); // Set values for the request back req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = query.Length; // Write the request back IPN strings StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); stOut.Write(query); stOut.Close(); StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream()); strResponse = stIn.ReadToEnd(); if (strResponse.Contains("\n")) { strResponse = strResponse.Replace("\n", " "); } status = strResponse.Substring(0, strResponse.IndexOf(" ")); if (status != "FAIL") { Guid CustID = Guid.Parse(Session["CustomerID"].ToString()); ManageUserSVC.ManageUserClient Client = new ManageUserSVC.ManageUserClient(); ManageUserSVC.ManageUserCoverageData Coverage = new ManageUserCoverageData(); if (Session["RenewCoverageInfo"] != null) { Coverage = (ManageUserSVC.ManageUserCoverageData)Session["RenewCoverageInfo"]; } else { Coverage = (ManageUserSVC.ManageUserCoverageData)Session["CoverageInfo"]; } Client.InsertCoverageData(Coverage); bool Propertybuy = false;; Client.Update_Payment(CustID, decimal.Parse(Session["Amount"].ToString()), Propertybuy); if (Session["RenewCoverageInfo"] != null) { lblMessage.Text = "Payment Successful! Your Account is Renewed Successfully!"; //todo sendmail for renew success } else { string baseurl = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"]; lblMessage.Text = "Thank you! Your payment was successful."; idspan.Visible = true; } string Local = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"]; dowload(Local.Replace("https://", "http://") + "ProofEvidence.aspx?" + Crypto.ArgumentEncrypt("sss") + "=" + Crypto.Encrypt(CustID.ToString(), true), Coverage); SendEmailForProofOfEvidnce(Client, CustID, Local); } else { lblMessage.Text = "Some Error Occured while processing, Please try again By login into Site.!"; } }