예제 #1
0
        public ActionResult Create(PriceCreateViewModel model, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            List <Prices> prices = Price.Get().Where(t => t.ServicesId == model.ServiceSelected).ToList().Where(p => p.FromDate <= model.FromDate && (p.ToDate > model.FromDate || p.ToDate == null)).ToList();

            if (prices.Count != 0)
            {
                prices[0].ToDate = model.FromDate;
                Price.Update(prices[0]);
            }

            var price = new Prices
            {
                ServicesId = model.ServiceSelected,
                ToDate     = null,
                Value      = model.Value,
                FromDate   = model.FromDate
            };

            if (prices.Count == 2)
            {
                price.ToDate = prices[1].FromDate;
            }

            Price.Create(price);

            return(RedirectToLocal(redirectUrl));
        }
        public int GetPriceAmount(string subscriptionPriceId)
        {
            var priceObject = _priceService.Get(subscriptionPriceId);

            int price = (int)priceObject.UnitAmount !;

            return(price);
        }
예제 #3
0
        public ActionResult <ConfigResponse> GetConfig()
        {
            var service = new PriceService();
            var price   = service.Get(StripeOptions.Price);

            return(new ConfigResponse
            {
                PublishableKey = StripeOptions.PublishableKey,
                UnitAmount = price.UnitAmount,
                Currency = price.Currency,
            });
        }