Exemplo n.º 1
0
        public OrderServiceTest()
        {
            this.service = new OrderService();

            this.createOptions = new OrderCreateOptions
            {
                Currency = "usd",
                Items    = new List <OrderItemOptions>
                {
                    new OrderItemOptions
                    {
                        Parent   = "sku_123",
                        Quantity = 1
                    },
                }
            };

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

            this.payOptions = new OrderPayOptions
            {
                CustomerId = "cus_123",
            };

            this.listOptions = new OrderListOptions
            {
                Limit = 1,
            };
        }
Exemplo n.º 2
0
        public OrderServiceTest(
            StripeMockFixture stripeMockFixture,
            MockHttpClientFixture mockHttpClientFixture)
            : base(stripeMockFixture, mockHttpClientFixture)
        {
            this.service = new OrderService(this.StripeClient);

            this.createOptions = new OrderCreateOptions
            {
                Currency = "usd",
                Items    = new List <OrderItemOptions>
                {
                    new OrderItemOptions
                    {
                        Parent   = "sku_123",
                        Quantity = 1,
                    },
                },
            };

            this.listOptions = new OrderListOptions
            {
                Limit = 1,
            };

            this.payOptions = new OrderPayOptions
            {
                Customer = "cus_123",
            };

            this.returnOptions = new OrderReturnOptions
            {
                Items = new List <OrderReturnItemOptions>
                {
                    new OrderReturnItemOptions
                    {
                        Parent   = "sku_123",
                        Quantity = 1,
                    },
                },
            };

            this.updateOptions = new OrderUpdateOptions
            {
                Metadata = new Dictionary <string, string>
                {
                    { "key", "value" },
                },
            };
        }
Exemplo n.º 3
0
        public IActionResult Charge(PayModelView model)
        {
            var customers = new CustomerService();
            var customer  = customers.Create(new CustomerCreateOptions
            {
                Name   = model.Name,
                Email  = model.Email,
                Source = model.Token
            });
            var service = new OrderService();
            var options = service.Create(new OrderCreateOptions
            {
                Currency = "usd",
                Email    = model.Email,
                Items    = new List <OrderItemOptions> {
                    new OrderItemOptions {
                        Type     = model.Type,
                        Parent   = "sku_GLdbjkfZychwTo",
                        Quantity = model.Quantity,
                    },
                },
                Shipping = new ShippingOptions
                {
                    Name    = model.Name,
                    Address = new AddressOptions
                    {
                        Line1      = model.Line1,
                        City       = model.City,
                        State      = model.State,
                        Country    = "US",
                        PostalCode = model.PostalCode,
                    },
                }
            });

            var optionpay = new OrderPayOptions
            {
                Customer = customer.Id,
            };

            service.Pay(
                options.Id,
                optionpay
                );

            return(View());
        }