public void SerializeTiersProperly() { var options = new StripePlanCreateOptions { Tiers = new List <StripePlanTierOptions> { new StripePlanTierOptions { UnitAmount = 1000, UpTo = new StripePlanTierOptions.UpToBound { Bound = 10 } }, new StripePlanTierOptions { UnitAmount = 2000, UpTo = new StripePlanTierOptions.UpToInf() } }, }; var url = this.service.ApplyAllParameters(options, string.Empty, false); Assert.Equal("?tiers[0][unit_amount]=1000&tiers[0][up_to]=10&tiers[1][unit_amount]=2000&tiers[1][up_to]=inf", url); }
public static async Task <string> CreateInitialPlanAsync(StripePlanCreateOptions options) { StripeConfiguration.SetApiKey("sk_test_5nCTR2UZmnOPWgZASvirbYDy"); StripePlanCreateOptions planOptions = new StripePlanCreateOptions() { Product = new StripePlanProductCreateOptions() { Name = "Initial_test_04_10_18_(1)" }, Active = options.Active, Amount = 1190, BillingScheme = options.BillingScheme, Currency = options.Currency, Interval = options.Interval, IntervalCount = options.IntervalCount, Nickname = options.Nickname, TrialPeriodDays = options.TrialPeriodDays, UsageType = options.UsageType }; StripePlanService planService = new StripePlanService(); StripePlan plan = await planService.CreateAsync(planOptions); return(plan.StripeResponse.ResponseJson); }
public plans_fixture() { PlanCreateOptions = new StripePlanCreateOptions() { // Add a space at the end to ensure the ID is properly URL encoded // when passed in the URL for other methods Id = "test-plan-" + Guid.NewGuid().ToString() + " ", Name = "plan-name", Amount = 5000, Currency = "usd", Interval = "month", }; PlanUpdateOptions = new StripePlanUpdateOptions { Name = "plan-name-2" }; var service = new StripePlanService(Cache.ApiKey); Plan = service.Create(PlanCreateOptions); PlanRetrieved = service.Get(Plan.Id); PlanUpdated = service.Update(Plan.Id, PlanUpdateOptions); PlansList = service.List(); PlanDeleted = service.Delete(Plan.Id); }
public transform_usage_plan_fixture() { ProductCreateOptions = new StripeProductCreateOptions { Name = $"test-product-{ Guid.NewGuid() }", Type = "service" }; var productService = new StripeProductService(Cache.ApiKey); var product = productService.Create(ProductCreateOptions); var transformUsage = new StripePlanTransformUsageOptions() { DivideBy = 100, Round = "up" }; PlanCreateOptions = new StripePlanCreateOptions() { Nickname = "tiered-plan-name", Amount = 1000, Currency = "usd", Interval = "month", ProductId = product.Id, TransformUsage = transformUsage, }; var planService = new StripePlanService(Cache.ApiKey); Plan = planService.Create(PlanCreateOptions); PlanRetrieved = planService.Get(Plan.Id); }
public void TestCreatePlan() { StripeSDKMain stripe = new StripeSDKMain(); StripePlanCreateOptions stripePlanCreateOptions = new StripePlanCreateOptions() { Id = "Basic", Name = "Premium", Amount = 1000, Currency = "usd", Interval = "month", }; Serializer serializer = new Serializer(); var stripePlanCreateOptionsJSON = serializer.Serialize <StripePlanCreateOptions>(stripePlanCreateOptions); string Response = ""; string Errors = ""; int ErrorCode = 0; var Api_Key = GetApiKey(); stripe.CreatePlan(Api_Key, stripePlanCreateOptionsJSON, ref Response, ref Errors, ref ErrorCode); if (ErrorCode == 0) { Console.WriteLine(Response); } else { Console.WriteLine(Errors); } }
public StripePlanServiceTest() { this.service = new StripePlanService(); this.createOptions = new StripePlanCreateOptions() { Amount = 123, Currency = "usd", Interval = "month", Nickname = "Plan Nickmame", Product = new StripePlanProductCreateOptions { Name = "Product Name", }, }; this.updateOptions = new StripePlanUpdateOptions() { Metadata = new Dictionary <string, string>() { { "key", "value" }, }, }; this.listOptions = new StripePlanListOptions() { Limit = 1, }; }
public add_plan_to_product_fixture() { ProductCreateOptions = new StripeProductCreateOptions { Name = $"test-product-{ Guid.NewGuid() }", Type = "service" }; var productService = new StripeProductService(Cache.ApiKey); Product = productService.Create(ProductCreateOptions); PlanCreateOptions = new StripePlanCreateOptions() { Nickname = "plan-name", Amount = 5000, Currency = "usd", Interval = "month", ProductId = Product.Id }; var planService = new StripePlanService(Cache.ApiKey); Plan = planService.Create(PlanCreateOptions); PlanRetrieved = planService.Get(Plan.Id); }
public static StripePlanCreateOptions GetPlanCreateOptions(string planName = "plan", string planUsageType = "licensed") { if (Items.ContainsKey($"{planName}_create_options")) { return((StripePlanCreateOptions)Items[$"{planName}_create_options"]); } var options = new StripePlanCreateOptions { Amount = 1000, Currency = "usd", Nickname = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(), Interval = StripePlanIntervals.Week, Product = new StripePlanProductCreateOptions { Name = "Test Product", StatementDescriptor = "TEST THIS PRODUCT" }, UsageType = planUsageType, }; Items.Add($"{planName}_create_options", options); return(options); }
/// <summary> /// Create plan for this donation if is does not exist and return its instance. If it does exist /// return the instance. /// </summary> /// <param name="donation"></param> /// <returns></returns> public StripePlan GetOrCreatePlan(Donation donation) { var planService = new StripePlanService(_stripeSettings.Value.SecretKey); // Construct plan name from the selected donation type and the cycle var cycle = EnumInfo <PaymentCycle> .GetValue(donation.CycleId); var frequency = EnumInfo <PaymentCycle> .GetDescription(cycle); var amount = donation.DonationAmount ?? 0; if (donation.DonationAmount == null) { var model = (DonationViewModel)donation; model.DonationOptions = DonationOptions; amount = model.GetDisplayAmount(); } var planName = $"{frequency}_{amount}".ToLower(); // Create new plan is this one does not exist if (!Exists(planService, planName)) { var plan = new StripePlanCreateOptions { Id = planName, Amount = amount * 100, Currency = "usd", Name = planName, StatementDescriptor = _stripeSettings.Value.StatementDescriptor }; // Take care intervals if (cycle == PaymentCycle.Quarter) { plan.IntervalCount = 3; plan.Interval = "month"; } else { plan.Interval = cycle.ToString().ToLower(); // day/month/year } return(planService.Create(plan)); } else { return(planService.Get(planName)); } }
public static StripePlan CreatePlan(StripePlanCreateOptions planOptions) { var invoiceSevice = new StripeInvoiceService(); try { var planService = new StripePlanService(); StripePlan plan = planService.Create(planOptions); return(plan); } catch (Exception ex) { return(null); } }
/// <summary> /// Create plan for this donation if is does not exist and return its instance. If it does exist /// return the instance. /// </summary> /// <param name="donation"></param> /// <returns></returns> public StripePlan GetOrCreatePlan(Donation donation) { var planService = new StripePlanService(_stripeSettings.Value.SecretKey); // Construct plan name from the selected donation type and the cycle var cycle = EnumInfo <PaymentCycle> .GetValue(donation.CycleId); var frequency = EnumInfo <PaymentCycle> .GetDescription(cycle); decimal amount = donation.DonationAmount ?? 0; string currency = donation.Currency; var planName = $"{frequency}_{amount}_{currency}".ToLower(); // // Create new plan is this one does not exist if (!Exists(planService, planName)) { var plan = new StripePlanCreateOptions { Id = planName, Amount = Convert.ToInt32(amount * 100), Currency = currency.ToLower(), Nickname = planName, Product = new StripePlanProductCreateOptions() { Name = planName } //StatementDescriptor = _stripeSettings.Value.StatementDescriptor }; // Take care intervals if (cycle == PaymentCycle.Quarter) { plan.IntervalCount = 3; plan.Interval = "month"; } else { plan.Interval = cycle.ToString().ToLower(); // day/month/year } return(planService.Create(plan)); } else { return(planService.Get(planName)); } }
public string CreateSubscription(int cost, string planName, string interval) { string id = Guid.NewGuid().ToString(); var newPlan = new StripePlanCreateOptions(); newPlan.Id = id; newPlan.Amount = cost; // all amounts on Stripe are in cents, pence, etc newPlan.Currency = "usd"; // "usd" only supported right now newPlan.Interval = interval; // "month" or "year" newPlan.Name = planName; var planService = new StripePlanService(); StripePlan response = planService.Create(newPlan); return(id); }
public ActionResult AjaxAddPlan(string PlanName, string PlanType, string PlanPrice, string Features) { objResponse Response = new objResponse(); string planID = Guid.NewGuid().ToString(); try { Response = objSubscriptionManager.AddPlans(PlanName, PlanPrice, PlanType, "usd", planID); if (Response.ErrorCode == 0) { var myPlan = new StripePlanCreateOptions(); myPlan.Id = planID; myPlan.Amount = Convert.ToInt32(PlanPrice) * 100; // all amounts on Stripe are in cents, pence, etc myPlan.Currency = "usd"; // "usd" only supported right now myPlan.Interval = PlanType; // "month" or "year" //myPlan.IntervalCount = 1; // optional myPlan.Name = PlanName; myPlan.TrialPeriodDays = 0; // amount of time that will lapse before the customer is billed var planService = new StripePlanService(); StripePlan response = planService.Create(myPlan); List <string> temp = Features.Split(',').ToList <string>(); foreach (var feature in temp) { Response = objSubscriptionManager.AddPlanFeature(Convert.ToInt32(Response.ErrorMessage), feature); if (Response.ErrorCode != 0) { break; } } PlanModel objPlanModel = new PlanModel(); objPlanModel.plans = objSubscriptionManager.GetPlans(); return(View(objPlanModel)); } else { return(Json("", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json("", JsonRequestBehavior.AllowGet)); } }
private static int GetCustomPlan(int skuCount) { int Totalcost = 249; int planid = 0; double Extra_Count = skuCount / 250; int Extra_Cost = (int)Math.Floor(Extra_Count) * 50; Totalcost += Extra_Cost; int OldPlanId = AccountData.GetPlanId(Totalcost); if (OldPlanId > 0) { var plandetials = StripeHelper.GetPlan(OldPlanId.ToString()); if (plandetials != null) { planid = OldPlanId; } } if (planid < 1) { var plans = StripeHelper.GetTopPlan(); var Plan = plans[0]; planid = Convert.ToInt32(Plan.Id) + 1; var planOptions = new StripePlanCreateOptions() { Id = planid.ToString(), Name = "Custom", Amount = Totalcost * 100, Currency = "usd", Interval = "month", }; var res = StripeHelper.CreatePlan(planOptions); if (res != null) { AccountData.CreateCustomPlan(planid, Totalcost); } else { planid = 0; } } return(planid); }
/// <summary> /// Automatically create the standard plans to enable, new users to be able to subscribe. These /// are managed in Stripe /// </summary> public void EnsurePlansExist() { var planService = new StripePlanService(_stripeSettings.Value.SecretKey); var options = new DonationViewModel(DonationOptions).DonationOptions; foreach (var cycle in GetCycles()) { foreach (var option in options) { if (cycle.Key != PaymentCycle.OneOff) { if (option.Amount > 0) { var planName = $"{cycle.Value}_{option.Amount}".ToLower(); var plan = new StripePlanCreateOptions { Id = planName, Amount = option.Amount * 100, Currency = "usd", Name = planName, StatementDescriptor = _stripeSettings.Value.StatementDescriptor }; // Take care intervals if (cycle.Key == PaymentCycle.Quarter) { plan.IntervalCount = 3; plan.Interval = "month"; } else { plan.Interval = cycle.Key.ToString().ToLower(); // day/month/year } if (!Exists(planService, planName)) { planService.Create(plan); } } } } } }
public ActionResult Create([Bind(Include = "Id,Name")] Product product) { try { if (ModelState.IsValid) { product.Id = Guid.NewGuid(); StripeConfiguration.SetApiKey("sk_test_ILBG36E21hK6nO8C6fOpQvWs"); var service = new StripeProductService(); //var products = service.Create(new StripeProductCreateOptions //{ // Name = product.Name, // Active = true, // Type= "service" //}); //product.StripeProductId = products.Id; var options = new StripePlanCreateOptions { Product = new StripePlanProductCreateOptions { Name = product.Name }, Amount = 5000, Currency = "usd", Interval = "month", }; var services = new StripePlanService(); StripePlan plan = services.Create(options); product.PlanId = plan.Id; product.StripeProductId = plan.ProductId; db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { throw ex; } return(View(product)); }
public tiered_plan_fixture() { ProductCreateOptions = new StripeProductCreateOptions { Name = $"test-product-{ Guid.NewGuid() }", Type = "service" }; var productService = new StripeProductService(Cache.ApiKey); var product = productService.Create(ProductCreateOptions); var tiers = new List <StripePlanTierOptions> { new StripePlanTierOptions() { Amount = 1000, UpTo = new StripePlanTierOptions.UpToBound() { Bound = 10 } }, new StripePlanTierOptions() { Amount = 2000, UpTo = new StripePlanTierOptions.UpToInf() } }; PlanCreateOptions = new StripePlanCreateOptions() { Nickname = "tiered-plan-name", BillingScheme = "tiered", TiersMode = "volume", Tiers = tiers, Currency = "usd", Interval = "month", ProductId = product.Id }; var planService = new StripePlanService(Cache.ApiKey); Plan = planService.Create(PlanCreateOptions); PlanRetrieved = planService.Get(Plan.Id); }
public static StripePlanCreateOptions GetPlan2CreateOptions() { if (Items.ContainsKey("plan2_create_options")) { return((StripePlanCreateOptions)Items["plan2_create_options"]); } var options = new StripePlanCreateOptions { Amount = 500, Currency = "usd", Name = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(), Interval = StripePlanIntervals.Week }; Items.Add("plan2_create_options", options); return(options); }
/// <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); }
/// <summary> /// Creates a new plan inside of Stripe, using the given subscription plan's information /// NOTE: Unlike other method calls, this requires that the plan object already have a defined PaymentSystemId property set /// </summary> /// <param name="plan"></param> public static StripePlan CreatePlan(IPlanEntity 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 = "usd"; // "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); Logger.Log <StripeManager>("Created new plan in stripe: '{0}' with id {1}", LogLevel.Information, plan.Title, plan.PaymentSystemId); return(newPlan); }
public ActionResult Create(PlanCreateViewModel model) { if (ModelState.IsValid) { var options = new StripePlanCreateOptions { Id = model.Id, Amount = model.Amount, Currency = model.Currency, Interval = model.Interval, IntervalCount = model.IntervalCount, Name = model.Name, TrialPeriodDays = model.TrialPeriodDays }; var planService = new StripePlanService(); var plan = planService.Create(options); return(RedirectToAction("Index")); } return(View(model)); }
public void CreatePlan(string Api_Key, string stripePlanCreateOptionsJSON, ref string Response, ref string Errors, ref int ErrorCode) { try { StripeConfiguration.SetApiKey(Api_Key); Serializer serializer = new Serializer(); StripePlanCreateOptions stripePlanCreateOptions = serializer.Deserialize <StripePlanCreateOptions>(stripePlanCreateOptionsJSON); var stripePlanService = new StripePlanService(); StripePlan stripePlan = stripePlanService.Create(stripePlanCreateOptions); Response = stripePlan.StripeResponse.ResponseJson; ErrorCode = 0; } catch (StripeException e) { ErrorCode = 1; Serializer serializer = new Serializer(); StripeError stripeError = e.StripeError; Errors = serializer.Serialize <StripeError>(stripeError); } }
public static async Task <string> CreateExtraPlanAsync(StripePlanCreateOptions options) { StripeConfiguration.SetApiKey("sk_test_5nCTR2UZmnOPWgZASvirbYDy"); StripePlanCreateOptions planOptions = new StripePlanCreateOptions() { Product = new StripePlanProductCreateOptions() { Name = "Extra" + "" + "" }, Active = options.Active, //Amount = 1190, BillingScheme = options.BillingScheme, Currency = options.Currency, Interval = options.Interval, IntervalCount = options.IntervalCount, Nickname = options.Nickname, Tiers = new List <StripePlanTierOptions>() { new StripePlanTierOptions() { Amount = options.Tiers.First().Amount, UpTo = new StripePlanTierOptions.UpToInf() { } } }, TiersMode = "volume", UsageType = "metered" //TransformUsage = new StripePlanTransformUsageOptions() }; StripePlanService planService = new StripePlanService(); StripePlan plan = await planService.CreateAsync(planOptions); return(plan.StripeResponse.ResponseJson); }
public async Task <StripePlan> CreatePlan(string name, int amount, string colour, string description, string features, string currency = "gbp", string interval = "month", int intervalCount = 1, int trialPeriodDays = 30) { var myPlan = new StripePlanCreateOptions() { Id = Guid.NewGuid().ToString(), Amount = amount, // all amounts on Stripe are in cents, pence, etc Currency = currency, // "usd" only supported right now Interval = interval, // "month" or "year" IntervalCount = intervalCount, // optional Nickname = name, TrialPeriodDays = trialPeriodDays, // amount of time that will lapse before the customer is billed Product = new StripePlanProductCreateOptions() { Name = name } }; myPlan.Metadata.Add("Colour", colour); myPlan.Metadata.Add("Description", description); myPlan.Metadata.Add("Features", features); StripePlan response = await _stripe.PlanService.CreateAsync(myPlan); return(response); }
protected void SaveSubscriptionClick(object sender, EventArgs e) { var subscriptions = new Subscriptions(); var isNew = true; if (Request.Params["id"] != "0") { isNew = false; subscriptions = _subscriptions; _subscriptionId = _subscriptions.Id; } else { subscriptions.IsActive = true; } int productType = int.Parse(SubscriptionTypeDdl.SelectedValue); subscriptions.SubscriptionType = productType; subscriptions.Name = SubscriptionNameText.Text.Trim(); subscriptions.MaxGuest = Int16.Parse(HidMaxGuest.Value); double price; double.TryParse(PriceText.Text, out price); subscriptions.Price = price; int maxPurchase; int.TryParse(MaxPurchaseText.Text, out maxPurchase); subscriptions.ProductHighlight = ProductHighlightText.Text; subscriptions.WhatYouGet = WhatYouGetEditor.Text; subscriptions.MaxPurchases = maxPurchase; // SEO Tab 2 subscriptions.MetaDescription = MetaDescription.Text; subscriptions.MetaKeyword = MetaKeyword.Text; // Photos on tab 3 if (isNew) { switch (int.Parse(SubscriptionTypeDdl.SelectedValue)) { case (int)Enums.SubscriptionType.Subscription: string planId = SubscriptionNameText.Text.Trim().Replace(" ", "-").ToLower(); try { // Create Plans On Stripe var planOptions = new StripePlanCreateOptions { Id = planId, Name = SubscriptionNameText.Text.Trim(), Amount = Convert.ToInt32(price * 100), Currency = "usd", Interval = "month" }; CreateStripePlan(planOptions); } catch (Exception ex) { ErrorMessageLabel.Visible = true; ErrorMessageLabel.Text = ex.Message + " - " + planId; return; } subscriptions.StripePlanId = planId; subscriptions.StripePlanCreated = DateTime.UtcNow; break; case (int)Enums.SubscriptionType.GiftCard: break; } _subscriptionId = _subscriptionRepository.Add(subscriptions); } else { var photos = new List <SubscriptionImages>(); foreach (ListViewDataItem item in SubscriptionImageListView.Items) { //to get the dropdown of each line HiddenField productPhotoId = (HiddenField)item.FindControl("PhotoId"); var photo = _subscriptionRepository.GetImageById(int.Parse(productPhotoId.Value)); var orderItem = (HiddenField)item.FindControl("Order"); photo.Order = 1; if (!string.IsNullOrEmpty(orderItem.Value)) { photo.Order = int.Parse(orderItem.Value); photo.IsCover = false; photo.IsActive = true; } photos.Add(photo); } if (photos.FirstOrDefault(p => p.Order == 0 || p.Order == 1) != null) { photos.First(p => p.Order == 0 || p.Order == 1).IsCover = true; } _subscriptionRepository.Update(subscriptions, photos); } string productImageDefault = Constant.ImageDefault; var productImage = _subscriptionRepository.SubscriptionImagesList.FirstOrDefault(x => x.SubscriptionId == subscriptions.Id && x.IsCover && x.IsActive); if (productImage != null) { productImageDefault = productImage.Url; } if (!string.IsNullOrEmpty(productImageDefault)) { var imageName = Helper.ReplaceLastOccurrence(productImageDefault, ".", "-ovl."); string imageUrl = Server.MapPath(imageName); if (!File.Exists(imageUrl)) { System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(productImageDefault)); Bitmap newImage = Helper.ChangeOpacity(image, 0.7f); using (MemoryStream memory = new MemoryStream()) { using (FileStream fs = new FileStream(imageUrl, FileMode.Create, FileAccess.ReadWrite)) { newImage.Save(memory, ImageFormat.Jpeg); byte[] bytes = memory.ToArray(); fs.Write(bytes, 0, bytes.Length); } } } } _subscriptionRepository.ResetCache(); Response.Redirect(Constant.SubscriptionListPage); }
// // http://localhost:5000/Webhooks/Incoming public async Task Invoke(HttpContext httpContext) { string json = null; json = await new StreamReader(httpContext.Request.Body).ReadToEndAsync(); if (JObject.Parse(json)["data"]["object"]["metadata"]["pandadoc_document_reference"] != null && JObject.Parse(json)["data"]["object"]["customer"] != null) { string pandadocDocumentReference = JObject.Parse(json)["data"]["object"]["metadata"]["pandadoc_document_reference"].ToString(); string customer = JObject.Parse(json)["data"]["object"]["customer"].ToString(); if (!string.IsNullOrEmpty(pandadocDocumentReference) && !string.IsNullOrEmpty(customer)) { StripeChargeSusseeded resultChargeSusseeded = new StripeChargeSusseeded() { CustomerId = customer, PandadocDocumentReference = pandadocDocumentReference }; string value = await PandaDoc.GetDocumentDetailsAsync(await PandaDoc.GetDocument(pandadocDocumentReference)); var obj = JsonConvert.DeserializeObject <RootObject>(value); var optInitial = new StripePlanCreateOptions() { Product = new StripePlanProductCreateOptions() { Name = "Initial_test_05_10_18_2" }, Active = true, Amount = int.Parse(obj.Pricing.Tables[0].Total), BillingScheme = "per_unit", Currency = obj.GrandTotal.Currency, Interval = "month", IntervalCount = 3, Nickname = "Initial_test_05_10_18_2", UsageType = "licensed" }; var optExtra = new StripePlanCreateOptions() { Product = new StripePlanProductCreateOptions() { Name = "Extra_test_05_10_18_2" }, Active = true, BillingScheme = "tiered", Currency = obj.GrandTotal.Currency, Interval = obj.Pricing.Tables[1].Items[0].CustomColumns.Period, IntervalCount = 1, Nickname = "Extra_test_05_10_18_2", Tiers = new List <StripePlanTierOptions>() { new StripePlanTierOptions() { Amount = obj.Pricing.Tables[1].Items[0].Qty, UpTo = new StripePlanTierOptions.UpToInf() { } } }, TiersMode = "volume", UsageType = "metered" }; var responseJsonInitial = await StripeActions.CreateInitialPlanAsync(optInitial); var responseJsonExtra = await StripeActions.CreateExtraPlanAsync(optExtra); await StripeActions.CreateSubscription(resultChargeSusseeded.CustomerId, "plan_DjHBD7IMeE2vMW"); _log.LogWarning($"DONE"); } } }
private void CreateStripePlan(StripePlanCreateOptions planOptions) { var planService = new StripePlanService(); StripePlan plan = planService.Create(planOptions); }