// GET: InitPlans public ActionResult Index() { var myFreePlan = new StripePlanCreateOptions(); myFreePlan.Id = "free_plan"; myFreePlan.Amount = 0; // all amounts on Stripe are in cents, pence, etc myFreePlan.Currency = "usd"; // "usd" only supported right now myFreePlan.Interval = "month"; // "month" or "year" myFreePlan.IntervalCount = 1; // optional myFreePlan.Name = "Basic Plan"; myFreePlan.TrialPeriodDays = 1; // amount of time that will lapse before the customer is billed var myBasicPlan = new StripePlanCreateOptions(); myBasicPlan.Id = "basic_plan"; myBasicPlan.Amount = 0; // all amounts on Stripe are in cents, pence, etc myBasicPlan.Currency = "usd"; // "usd" only supported right now myBasicPlan.Interval = "month"; // "month" or "year" myBasicPlan.IntervalCount = 1; // optional myBasicPlan.Name = "Basic Plan"; myBasicPlan.TrialPeriodDays = 1; // amount of time that will lapse before the customer is billed var myProfessionalPlan = new StripePlanCreateOptions(); myProfessionalPlan.Id = "pro_plan"; myProfessionalPlan.Amount = 999; // all amounts on Stripe are in cents, pence, etc myProfessionalPlan.Currency = "usd"; // "usd" only supported right now myProfessionalPlan.Interval = "month"; // "month" or "year" myProfessionalPlan.IntervalCount = 1; // optional myProfessionalPlan.Name = "Professional Plan"; myProfessionalPlan.TrialPeriodDays = 1; // amount of time that will lapse before the customer is billed var myBuinessPlan = new StripePlanCreateOptions(); myBuinessPlan.Id = "business_plan"; myBuinessPlan.Amount = 1999; // all amounts on Stripe are in cents, pence, etc myBuinessPlan.Currency = "usd"; // "usd" only supported right now myBuinessPlan.Interval = "month"; // "month" or "year" myBuinessPlan.IntervalCount = 1; // optional myBuinessPlan.Name = "Business Plan"; myBuinessPlan.TrialPeriodDays = 1; // amount of time that will lapse before the customer is billed var planService = new StripePlanService(); StripePlan response = planService.Create(myFreePlan); StripePlan response2 = planService.Create(myBasicPlan); StripePlan response3 = planService.Create(myProfessionalPlan); StripePlan response4 = planService.Create(myBuinessPlan); CreateCoupon(); return View(); }
/// <summary> /// Creates a new plan inside of Stripe, using the given subscription plan's information /// </summary> /// <param name="plan"></param> public static void CreatePlan(IStripeSubscriptionPlan plan) { // Save it to Stripe StripePlanCreateOptions newStripePlanOptions = new StripePlanCreateOptions(); newStripePlanOptions.Amount = Convert.ToInt32(plan.Price * 100.0); // all amounts on Stripe are in cents, pence, etc newStripePlanOptions.Currency = string.IsNullOrEmpty(plan.Currency) ? "usd" : plan.Currency; // "usd" only supported right now newStripePlanOptions.Interval = "month"; // "month" or "year" newStripePlanOptions.IntervalCount = 1; // optional newStripePlanOptions.Name = plan.Title; newStripePlanOptions.TrialPeriodDays = plan.TrialDays; // amount of time that will lapse before the customer is billed newStripePlanOptions.Id = plan.PaymentSystemId; StripePlanService planService = new StripePlanService(); StripePlan newPlan = planService.Create(newStripePlanOptions); plan.PaymentSystemId = newPlan.Id; System.Diagnostics.Trace.TraceInformation("Created new plan in stripe: '{0}' with id {1}", plan.Title, plan.PaymentSystemId); }
private StripePlan CreatePlan(NewDonationModel model) { var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindById(User.Identity.GetUserId()); var myPlan = new StripePlanCreateOptions(); myPlan.Amount = (int)(model.Amount*100); myPlan.Currency = "usd"; myPlan.Interval = "month"; myPlan.Name = currentUser.FirstName + "-" + currentUser.LastName + "-" + model.Amount + "-" + model.Category; myPlan.Id = currentUser.FirstName + "-" + currentUser.LastName + "-" + model.Amount + "-" + model.Category; var planService = new StripePlanService("sk_test_yPi2XADkAP3wiS1i6tkjErxZ"); return planService.Create(myPlan); }