Exemple #1
0
        // GET: Subscription
        public ActionResult Index()
        {
            List <SubscriptionProductPlans> prodPlans = new List <SubscriptionProductPlans>();

            var productService = new ProductService();
            var productOptions = new ProductListOptions
            {
                Limit = 5,
            };

            foreach (var prod in productService.List(productOptions))
            {
                var planService = new PlanService();
                var planOptions = new PlanListOptions
                {
                    Limit     = 5,
                    ProductId = prod.Id
                };

                prodPlans.Add(new SubscriptionProductPlans
                {
                    Product = prod,
                    Plan    = planService.List(planOptions)
                });
            }

            return(View(prodPlans));
        }
        public ProductServiceTest()
        {
            this.service = new ProductService();

            this.createOptions = new ProductCreateOptions
            {
                Attributes = new []
                {
                    "attr1",
                    "attr2",
                },
                Name = "product name",
                PackageDimensions = new PackageDimensionOptions
                {
                    Height = 100,
                    Length = 100,
                    Weight = 100,
                    Width  = 100,
                },
                Type = "good",
            };

            this.updateOptions = new ProductUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new ProductListOptions
            {
                Limit = 1,
            };
        }
Exemple #3
0
        public ProductServiceTest(
            StripeMockFixture stripeMockFixture,
            MockHttpClientFixture mockHttpClientFixture)
            : base(stripeMockFixture, mockHttpClientFixture)
        {
            this.service = new ProductService(this.StripeClient);

            this.createOptions = new ProductCreateOptions
            {
                Name = "product name",
                PackageDimensions = new ProductPackageDimensionsOptions
                {
                    Height = 100,
                    Length = 100,
                    Weight = 100,
                    Width  = 100,
                },
            };

            this.updateOptions = new ProductUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new ProductListOptions
            {
                Limit = 1,
            };
        }
        public override Task Execute(MessageData data)
        {
            var options = new ProductListOptions
            {
                Limit = 10
            };
            var service = new ProductService();
            StripeList <Product> products = service.List(
                options
                );

            return(data.SendBack(new MessageData("productsResponse", JsonConvert.SerializeObject(products), A_HOUR)));
        }
Exemple #5
0
        public IActionResult GetAllProducts()
        {
            StripeConfiguration.ApiKey = API_KEY;
            List <object> resultList = new List <object>();

            try
            {
                var options = new ProductListOptions
                {
                    Active = true,
                };
                var service = new ProductService();
                StripeList <Product> products = service.List(
                    options
                    );
                foreach (Product p in products)
                {
                    var priceOptions = new PriceListOptions {
                        Currency = "sgd", Active = true, Product = p.Id
                    };
                    var priceService          = new PriceService();
                    StripeList <Price> prices = priceService.List(priceOptions);
                    float  amount             = 0.0F;
                    string priceId            = "";
                    foreach (Price pr in prices)
                    {
                        priceId = pr.Id;
                        amount  = (float)pr.UnitAmount / 100;
                    }
                    string id   = p.Id;
                    string name = p.Name;

                    resultList.Add(new
                    {
                        id      = id,
                        priceId = priceId,
                        name    = name,
                        amount  = amount,
                    });
                }
            }
            catch
            {
                return(BadRequest());
            }
            return(Ok(new JsonResult(resultList)));
        }
Exemple #6
0
        public async Task <IActionResult> OnGetAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            StripeCustomerId = user.CustomerIdentifier;
            var nullCustomerId = string.IsNullOrEmpty(StripeCustomerId);

            UserEmail = user.Email;

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            var product         = new ProductService();
            var productsOptions = new ProductListOptions
            {
            };
            StripeList <Product> products = product.List(productsOptions);

            SubscriptionProducts = new SelectList(products, "Id", "Name");

            if (!nullCustomerId)
            {
                var subcriptionService = new SubscriptionService();
                IEnumerable <Subscription> response = subcriptionService.List(new SubscriptionListOptions
                {
                    Customer = StripeCustomerId
                });
                Subscriptions = response.ToList();
            }

            StripeKey = _stripeSettings.PublishableKey;

            return(Page());
        }
Exemple #7
0
        public PagedList <ProductBaseListDto> GetFilterPage(ProductListOptions options)
        {
            var queryable = _context.ProductBases
                            .AsNoTracking();

            if (options.ProductStatusId != 0)
            {
                queryable = queryable.Where(p => p.ProductStatusId == options.ProductStatusId);
            }

            if (options.BusinessLineId != 0)
            {
                queryable = queryable.Where(p => p.BusinessLineId == options.BusinessLineId);
            }

            if (options.ProductSourceTypeId != 0)
            {
                queryable = queryable.Where(p => p.ProductSourceTypeId == options.ProductSourceTypeId);
            }

            if (options.ProductDestinationTypeId != 0)
            {
                queryable = queryable.Where(p => p.ProductDestinationTypeId == options.ProductDestinationTypeId);
            }

            if (options.ProductMaterialId != 0)
            {
                queryable = queryable.Where(p => p.ProductMaterialId == options.ProductMaterialId);
            }

            if (options.ProductGroupId != 0)
            {
                queryable = queryable.Where(p => p.ProductGroupId == options.ProductGroupId);
            }
            else if (options.ProductTypeId != 0)
            {
                queryable = queryable.Where(p => p.ProductTypeId == options.ProductTypeId);
            }

            if (options.ProductDesignId != 0)
            {
                queryable = queryable.Where(p => p.ProductDesignId == options.ProductDesignId);
            }
            else if (options.ProductCollectionId != 0)
            {
                queryable = queryable.Where(p => p.ProductCollectionId == options.ProductCollectionId);
            }
            else if (options.ProductBrandId != 0)
            {
                queryable = queryable.Where(p => p.ProductBrandId == options.ProductBrandId);
            }

            return(queryable
                   .OrderBy(p => p.Code)
                   .Select(p => new ProductBaseListDto
            {
                ProductBaseId = p.Id,
                ProductBaseCode = p.Code,
                ProductBaseName = p.Name,
                StockQuantity = p.Products
                                .SelectMany(p => p.Inventory)
                                .Where(i => options.LocationId == 0 ? true : i.LocationId == options.LocationId)
                                .Sum(i => i.StockQuantity),
                //ReservedQuantity = p.Products.Sum(p => p.ProductInventory.Sum(i => i.ReservedQuantity))
                ReservedQuantity = p.Products
                                   .SelectMany(p => p.Inventory)
                                   .Where(i => options.LocationId == 0 ? true : i.LocationId == options.LocationId)
                                   .Sum(i => i.ReservedQuantity)
            })
                   .Where(p => options.Stock == Stock.OnlyInStock ? p.StockQuantity > 0 : (options.Stock == Stock.NotInStock ? p.StockQuantity == 0 : true))
                   .GetPagedList(options.CurrentPage, options.PageSize));
        }