public IEnumerable <SkuView> GetSkus()
        {
            SetStripeKey();
            var skuService = new StripeSkuService();
            StripeList <StripeSku> skuItems = skuService.List(
                new StripeSkuListOptions
            {
                Limit = _maximumItemsToReturn
            }
                );

            var jsonProducts = skuItems
                               .Select(p => new SkuView {
                Id = p.Id, Price = p.Price, ProductId = p.ProductId, Currency = p.Currency
            });

            return(jsonProducts);
        }
        public StripeSkuServiceTest()
        {
            this.service = new StripeSkuService();

            this.createOptions = new StripeSkuCreateOptions()
            {
                Attributes = new Dictionary <string, string>
                {
                    { "attr1", "value1" },
                    { "attr2", "value2" },
                },
                Currency  = "usd",
                Inventory = new StripeInventoryOptions
                {
                    Quantity = 100,
                    Type     = "finite",
                },
                PackageDimensions = new StripePackageDimensionOptions
                {
                    Height = 100,
                    Length = 100,
                    Weight = 100,
                    Width  = 100,
                },
                Price   = 1234,
                Product = "prod_123",
            };

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

            this.listOptions = new StripeSkuListOptions()
            {
                Limit = 1,
            };
        }
Example #3
0
        public orders_fixture()
        {
            var productService = new StripeProductService(Cache.ApiKey);
            var product        = productService.Create(new StripeProductCreateOptions {
                Name = "T-shirt",
                Type = "good"
            });

            var skuService = new StripeSkuService(Cache.ApiKey);
            var sku        = skuService.Create(new StripeSkuCreateOptions
            {
                Currency  = "usd",
                Inventory = new StripeInventoryOptions {
                    Type = "infinite",
                },
                Price   = 1234,
                Product = product.Id
            });

            OrderCreateOptions = new StripeOrderCreateOptions()
            {
                Currency = "usd",
                Items    = new List <StripeOrderItemOptions>
                {
                    new StripeOrderItemOptions
                    {
                        Amount      = 1,
                        Description = "Blue Shirts",
                        Parent      = sku.Id,
                        Quantity    = 1
                    },
                },
                Shipping = new StripeShippingOptions
                {
                    Name  = "Namey Namerson",
                    Line1 = "123 Main St"
                }
            };

            OrderUpdateOptions = new StripeOrderUpdateOptions
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "some-key", "some-value" }
                }
            };

            var customer = Cache.GetCustomer();

            OrderPayOptions = new StripeOrderPayOptions
            {
                SourceId = "tok_visa",
                Email    = customer.Email,
            };

            var service = new StripeOrderService(Cache.ApiKey);

            Order          = service.Create(OrderCreateOptions);
            OrderUpdated   = service.Update(Order.Id, OrderUpdateOptions);
            OrderRetrieved = service.Get(Order.Id);
            OrderPaid      = service.Pay(Order.Id, OrderPayOptions);

            OrderListOptions = new StripeOrderListOptions()
            {
                Created = Order.Created
            };

            OrderList = service.List(OrderListOptions);
        }
Example #4
0
        public skus_fixture()
        {
            var productService = new StripeProductService(Cache.ApiKey);

            Product = productService.Create(new StripeProductCreateOptions {
                Name        = "T-shirt",
                Type        = "good",
                Description = "stripe-dotnet product description",
                Attributes  = new string[] { "size", "color" },
            });

            SkuCreateOptions = new StripeSkuCreateOptions
            {
                Id         = $"test-sku-{ Guid.NewGuid() }",
                Attributes = new Dictionary <string, string>
                {
                    { "size", "medium" },
                    { "color", "red" },
                },
                Currency  = "usd",
                Inventory = new StripeInventoryOptions {
                    Quantity = 100,
                    Type     = "finite",
                },
                PackageDimensions = new StripePackageDimensionOptions {
                    Height = 100,
                    Length = 100,
                    Weight = 100,
                    Width  = 100,
                },
                Price   = 1234,
                Product = Product.Id
            };

            SkuTwoCreateOptions = new StripeSkuCreateOptions
            {
                Id         = $"test-sku-{ Guid.NewGuid() }",
                Attributes = new Dictionary <string, string>
                {
                    { "size", "large" },
                    { "color", "blue" },
                },
                Currency  = "usd",
                Inventory = new StripeInventoryOptions {
                    Type = "infinite",
                },
                Price   = 1345,
                Product = Product.Id
            };

            SkuUpdateOptions = new StripeSkuUpdateOptions
            {
                Price = 9999,
            };

            var service = new StripeSkuService(Cache.ApiKey);

            Sku          = service.Create(SkuCreateOptions);
            SkuTwo       = service.Create(SkuTwoCreateOptions);
            SkuUpdated   = service.Update(Sku.Id, SkuUpdateOptions);
            SkuRetrieved = service.Get(Sku.Id);

            var SkuListOptions = new StripeSkuListOptions
            {
                Attributes = new Dictionary <string, string>
                {
                    { "size", "large" },
                },
                Product = Product.Id
            };

            SkuList = service.List(SkuListOptions);

            service.Delete(Sku.Id);
            service.Delete(SkuTwo.Id);
            productService.Delete(Product.Id);
        }