Beispiel #1
0
        public async Task <IActionResult> OnPost()
        {
            var cartOrder = new Application.Cart.GetOrder(_sessionManager).Do();


            await new CreateOrder(_orderManager, _stockManager).Do(new CreateOrder.Request()
            {
                //ToDo: change stripeReference
                StripeReference = "Charge.Id",
                SessionId       = HttpContext.Session.Id,
                FirstName       = cartOrder.CustomerInformation.FirstName,
                LastName        = cartOrder.CustomerInformation.LastName,
                Email           = cartOrder.CustomerInformation.Email,
                PhoneNumber     = cartOrder.CustomerInformation.PhoneNumber,
                Address1        = cartOrder.CustomerInformation.Address1,
                Address2        = cartOrder.CustomerInformation.Address2,
                City            = cartOrder.CustomerInformation.City,
                PostCode        = cartOrder.CustomerInformation.PostCode,
                Stocks          = cartOrder.Products.Select(x => new CreateOrder.Stock()
                {
                    StockId = x.StockId, Qty = x.Qty
                }).ToList()
            });

            _sessionManager.ClearCart();
            return(RedirectToPage("/Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPost()
        {
            var CardOrder = new Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();

            var sessionId = HttpContext.Session.Id;

            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                SessionId   = sessionId,
                FirstName   = CardOrder.CustomerInformation.FirstName,
                LastName    = CardOrder.CustomerInformation.LastName,
                Email       = CardOrder.CustomerInformation.Email,
                PhoneNumber = CardOrder.CustomerInformation.PhoneNumber,
                Address1    = CardOrder.CustomerInformation.Address1,
                Address2    = CardOrder.CustomerInformation.Address2,
                City        = CardOrder.CustomerInformation.City,
                PostCode    = CardOrder.CustomerInformation.PostCode,
                Stocks      = CardOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId = x.StockId,
                    Qty     = x.Qty
                }).ToList()
            });

            return(RedirectToPage("/Index"));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var cartOrder = new Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();

            var customers = new CustomerService();
            var charges   = new ChargeService();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email       = stripeEmail,
                SourceToken = stripeToken,
                Shipping    = new ShippingOptions
                {
                    Name    = "Gaurav Rawat",
                    Address = new AddressOptions
                    {
                        City       = "New Delhi",
                        Line1      = "sadiq nagar",
                        Line2      = "ansal plaza",
                        Country    = "India",
                        PostalCode = "110049",
                        State      = "Delhi"
                    },
                    Phone = "9654514162"
                }
            });

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = 500,
                Description = "Sample Charge",
                Currency    = "inr",
                CustomerId  = customer.Id,
            });

            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                FirstName = cartOrder.Customer.FirstName,
                LastName  = cartOrder.Customer.LastName,
                Email     = cartOrder.Customer.Email,
                PhoneNo   = cartOrder.Customer.PhoneNo,
                Address1  = cartOrder.Customer.Address1,
                Address2  = cartOrder.Customer.Address1,
                City      = cartOrder.Customer.City,
                PostCode  = cartOrder.Customer.PostCode,
                Stocks    = cartOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId = x.StockId,
                    Qty     = x.Qty
                }).ToList(),
                StripRef = charge.Id
            });

            return(RedirectToPage("/index"));
        }
Beispiel #4
0
        public async Task <IActionResult> OnPost(
            string stripeEmail,
            string stripeToken,
            [FromServices] Application.Cart.GetOrder getOrder,
            [FromServices] CreateOrder createOrder,
            [FromServices] ISessionManager sessionManager)
        {
            var customers = new CustomerService();
            var customer  = customers.Create(new CustomerCreateOptions
            {
                Email  = stripeEmail,
                Source = stripeToken
            });

            var cartOrder = getOrder.Do();

            var options = new ChargeCreateOptions
            {
                Amount      = cartOrder.GetTotalCharge(),
                Description = "Shop Purchase",
                Currency    = "usd",
                Customer    = customer.Id
            };

            var service = new ChargeService();
            var charge  = service.Create(options);

            var sessionId = HttpContext.Session.Id;

            var reference = await createOrder.Do(new CreateOrder.Request
            {
                StripeReference = charge.Id,
                SessionId       = sessionId,

                FirstName   = cartOrder.CustomerInformation.FirstName,
                LastName    = cartOrder.CustomerInformation.LastName,
                Email       = cartOrder.CustomerInformation.Email,
                PhoneNumber = cartOrder.CustomerInformation.PhoneNumber,
                Address1    = cartOrder.CustomerInformation.Address1,
                Address2    = cartOrder.CustomerInformation.Address2,
                City        = cartOrder.CustomerInformation.City,
                PostCode    = cartOrder.CustomerInformation.PostCode,

                Stocks = cartOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId = x.StockId,
                    Qty     = x.Qty
                }).ToList()
            });

            sessionManager.ClearCart();

            return(RedirectToPage("Thankyou", new { orderRef = reference }));
        }
Beispiel #5
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var CartOrder       = new Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();
            var customerOptions = new CustomerCreateOptions
            {
                Email  = stripeEmail,
                Source = stripeToken
            };
            var      customerService = new CustomerService();
            Customer customer        = customerService.Create(customerOptions);

            var chargeOptions = new ChargeCreateOptions
            {
                Customer    = customer.Id,
                Description = "Shop Purchase",
                Amount      = CartOrder.GetTotalCharge(),
                Currency    = "zar",
            };
            var    chargeService = new ChargeService();
            Charge charge        = chargeService.Create(chargeOptions);

            var sessionId = HttpContext.Session.Id;

            // Create order
            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                StripeReference = charge.OrderId,
                SessionId       = sessionId,

                FirstName   = CartOrder.CustomerInformation.FirstName,
                LastName    = CartOrder.CustomerInformation.LastName,
                Email       = CartOrder.CustomerInformation.Email,
                PhoneNumber = CartOrder.CustomerInformation.PhoneNumber,
                Address1    = CartOrder.CustomerInformation.Address1,
                Address2    = CartOrder.CustomerInformation.Address2,
                City        = CartOrder.CustomerInformation.City,
                PostCode    = CartOrder.CustomerInformation.PostCode,

                Stocks = CartOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId  = x.StockId,
                    Quantity = x.Quantity
                }).ToList()
            });

            return(RedirectToPage("/Index"));
        }
Beispiel #6
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

            var CartOrder = new Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email  = stripeEmail,
                Source = stripeToken
            });

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = CartOrder.GetTotalCharge(),
                Description = "Shop Purchase",
                Currency    = "brl",
                Customer    = customer.Id
            });

            var sessionId = HttpContext.Session.Id;

            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                StripeReference = charge.Id,
                SessionId       = sessionId,

                Name         = CartOrder.CustomerInformation.Name,
                Email        = CartOrder.CustomerInformation.Email,
                PhoneNumber  = CartOrder.CustomerInformation.PhoneNumber,
                Address      = CartOrder.CustomerInformation.Address,
                City         = CartOrder.CustomerInformation.City,
                Neighborhood = CartOrder.CustomerInformation.Neighborhood,
                State        = CartOrder.CustomerInformation.State,
                ZipCode      = CartOrder.CustomerInformation.ZipCode,

                Stocks = CartOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId  = x.StockId,
                    Quantity = x.Quantity
                }).ToList()
            });

            return(RedirectToPage("/Index"));
        }
Beispiel #7
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

            var CardOrder = new Application.Cart.GetOrder(HttpContext.Session, _context).Do();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email  = stripeEmail,
                Source = stripeToken
            });

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = CardOrder.GetTotalCharge(),
                Description = "Shop Purchase",
                Currency    = "gbp",
                Customer    = customer.Id
            });

            //create order
            await new CreateOrder(_context).Do(new CreateOrder.Request
            {
                StripeReference = charge.Id,
                FirstName       = CardOrder.CustomerInformation.FirstName,
                LastName        = CardOrder.CustomerInformation.LastName,
                PostCode        = CardOrder.CustomerInformation.PostCode,
                City            = CardOrder.CustomerInformation.City,
                Address1        = CardOrder.CustomerInformation.Address1,
                Address2        = CardOrder.CustomerInformation.Address2,
                Email           = CardOrder.CustomerInformation.Email,
                PhoneNumber     = CardOrder.CustomerInformation.PhoneNumber,

                Stocks = CardOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId = x.StockId,
                    Qty     = x.Qty
                }).ToList()
            });

            return(RedirectToPage("/Index"));
        }
Beispiel #8
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

            var CartOrder = new Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email  = stripeEmail,
                Source = stripeToken
            });

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = CartOrder.GetTotalCharge(),
                Description = "Shop Purchase",
                Currency    = "gbp",
                CustomerId  = customer.Id
            });

            var sessionId = HttpContext.Session.Id;

            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                StripeReference = charge.Id,
                SessionId       = sessionId,

                FirstName   = CartOrder.CustomerInformation.Firstname,
                LastName    = CartOrder.CustomerInformation.LastName,
                Email       = CartOrder.CustomerInformation.Email,
                PhoneNumber = CartOrder.CustomerInformation.PhoneNumber,
                Address1    = CartOrder.CustomerInformation.Address1,
                Address2    = CartOrder.CustomerInformation.Address2,
                City        = CartOrder.CustomerInformation.City,
                PostCode    = CartOrder.CustomerInformation.PostCode,

                Stocks = CartOrder.Products.Select(x => new CreateOrder.Stock
                {
                    StockId = x.StockId,
                    Qty     = x.Qty
                })
                         .ToList()
            });

            HttpContext.Session.SetString("cart", string.Empty);

            new SendOrderInfo().Do(new SendOrderInfo.Request
            {
                FirstName   = CartOrder.CustomerInformation.Firstname,
                LastName    = CartOrder.CustomerInformation.LastName,
                Email       = CartOrder.CustomerInformation.Email,
                PhoneNumber = CartOrder.CustomerInformation.PhoneNumber,
                Address1    = CartOrder.CustomerInformation.Address1,
                Address2    = CartOrder.CustomerInformation.Address2,
                City        = CartOrder.CustomerInformation.City,
                PostCode    = CartOrder.CustomerInformation.PostCode,

                Stocks = CartOrder.Products.Select(x => new SendOrderInfo.Stock
                {
                    Id          = x.StockId,
                    Description = _ctx.Stock.Where(y => y.Id == x.StockId).Select(y => y.Description).FirstOrDefault(),
                    Qty         = x.Qty,
                    ProductId   = x.ProductId,
                    Product     = _ctx.Products.Where(y => y.Id == x.ProductId).FirstOrDefault()
                })
                         .ToList()
            });

            return(RedirectToPage("/Index"));
        }