public void HappyPathNoCouponTest() { LibLogic.Helpers.SslSecurity.Callback(); var pay = new LibLogic.Payments.StripePayment(userid, new LibLogic.Email.FakeEmail()); pay.MakePayment(this.token, ""); }
public void MissingTokenTest() { LibLogic.Helpers.SslSecurity.Callback(); var pay = new LibLogic.Payments.StripePayment(userid, new LibLogic.Email.FakeEmail()); pay.MakePayment("", ""); }
public void Charge() { if (Helpers.SessionVariables.Instance.LoggedIn == false) { return; } // Test credit card number: 4242 4242 4242 4242 string message = ""; try { string stripeToken = Helpers.GlobalHelper.RequestParam("stripeToken"); string couponDiscount = Helpers.GlobalHelper.RequestEncodedParam("discount"); var pay = new LibLogic.Payments.StripePayment(Helpers.SessionVariables.Instance.UserId, new LibLogic.Email.LiveEmail()); pay.MakePayment(stripeToken, couponDiscount); LibLogic.ActionLog.Log_BackgroundThread("Payment made", Helpers.SessionVariables.Instance.UserId); Task.Run(() => SetDefaultVpnServer()); } catch (Exception ex) { LibLogic.Helpers.Logging.Log(ex); message = "fail"; } this.HttpContext.Response.Redirect("/charge?status=" + message, false); }
public void RemoveSubscription() { if (Helpers.SessionVariables.Instance.LoggedIn == false || Helpers.SessionVariables.Instance.IsAdmin == false) { return; } try { int userid; bool isNumeric = int.TryParse(VpnSite.Helpers.GlobalHelper.RequestParam("id").Trim().ToLower(), out userid); if (!isNumeric) { Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode("invalid id"), false); } string removeaccount = Helpers.GlobalHelper.RequestEncodedParam("removeaccount"); if (removeaccount != null && removeaccount == "yes") { var payments = new LibLogic.Payments.StripePayment(userid, new LibLogic.Email.LiveEmail()); payments.CancelSubscription(); Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode("User with id removed: " + userid), false); } } catch (Exception ex) { LibLogic.Helpers.Logging.Log(ex); Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode(ex.Message), false); } }
public void CancelSubscription() { if (Helpers.SessionVariables.Instance.LoggedIn == false) { return; } this.HttpContext.Response.ContentType = "text/html"; try { var pay = new LibLogic.Payments.StripePayment(Helpers.SessionVariables.Instance.UserId, new LibLogic.Email.LiveEmail()); pay.CancelSubscription(); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; LibLogic.ActionLog.Log_BackgroundThread("Subscription Cancelled", Helpers.SessionVariables.Instance.UserId); } catch (Exception ex) { LibLogic.Helpers.Logging.Log(ex); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; this.HttpContext.Response.Write(ex.Message); } }