Beispiel #1
0
        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);
        }