Beispiel #1
0
        public async Task <IActionResult> OnPost(
            [FromServices] GetOrderCart getOrder,
            [FromServices] CreateOrder createOrder,
            [FromServices] ISessionManager sessionManager)
        {
            var CartOrder = getOrder.Do();

            //creat order  //move it to CutomerInfo when u want to pay in 2stlsam

            var sessionId = HttpContext.Session.Id;


            await createOrder.Do(new CreateOrder.Request
            {
                SessionId   = sessionId,
                FirstName   = CartOrder.CustomerInfo.FirstName,
                LastName    = CartOrder.CustomerInfo.LastName,
                Email       = CartOrder.CustomerInfo.Email,
                PhoneNumber = CartOrder.CustomerInfo.PhoneNumber,
                City        = CartOrder.CustomerInfo.City,
                Address1    = CartOrder.CustomerInfo.Address1,
                Address2    = CartOrder.CustomerInfo.Address2,

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

            // HttpContext.Session.Remove();//clear the cart after sucses payment
            sessionManager.CleanCart();
            //TODO Send sucsess msg
            return(RedirectToPage("/index"));
        }
        public async Task <IActionResult> OnPost(
            [FromServices] GetOrderCart getOrder,
            [FromServices] CreateOrder createOrder,
            [FromServices] ISessionManager sessionManager)
        {
            var CartOrder = getOrder.Do();

            var sessionID = HttpContext.Session.Id;

            await createOrder.Do(new CreateOrder.Request
            {
                StripeReference = "",
                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("/Index"));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPost(
            string stripeEmail,
            string stripeToken,
            [FromServices] GetOrderCart getOrder,
            [FromServices] CreateOrder createOrder,
            [FromServices] ISessionManager sessionManager)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

            var CartOrder = getOrder.Do();

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

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

            var sessionId = HttpContext.Session.Id;


            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("/Index"));
        }
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken,
                                                 [FromServices] GetOrderCart getOrder,
                                                 [FromServices] CreateOrder createOrder,
                                                 [FromServices] ISessionManager sessionManager)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

            var CartOrder = getOrder.Do();

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

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = CartOrder.GetCharge(),
                Description = "Purchases",
                Currency    = "usd",
                Customer    = customer.Id
            });
            //creat order  //move it to CutomerInfo when u want to pay in 2stlsam

            var sessionId = HttpContext.Session.Id;


            await createOrder.Do(new CreateOrder.Request
            {
                StripeRef = charge.Id,

                SessionId = sessionId,

                FirstName   = CartOrder.CustomerInfo.FirstName,
                LastName    = CartOrder.CustomerInfo.LastName,
                Email       = CartOrder.CustomerInfo.Email,
                PhoneNumber = CartOrder.CustomerInfo.PhoneNumber,
                City        = CartOrder.CustomerInfo.City,
                Address1    = CartOrder.CustomerInfo.Address1,
                Address2    = CartOrder.CustomerInfo.Address2,

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

            // HttpContext.Session.Remove();//clear the cart after sucses payment
            sessionManager.CleanCart();
            //TODO Send sucsess msg
            return(RedirectToPage("/index"));
        }
Beispiel #5
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();


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

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

            TotalPayment = CartOrder.GetTotalCharge();

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

            var sessionId = HttpContext.Session.Id;

            // Create Order

            await new CreateOrder(_ctx).Do(new CreateOrder.Request
            {
                Address1        = CartOrder.customerinformation.Address1,
                SessionId       = sessionId,
                Address2        = CartOrder.customerinformation.Address2,
                City            = CartOrder.customerinformation.City,
                Email           = CartOrder.customerinformation.Email,
                FirstName       = CartOrder.customerinformation.FirstName,
                LastName        = CartOrder.customerinformation.LastName,
                PhoneNumber     = CartOrder.customerinformation.PhoneNumber,
                PostalCode      = CartOrder.customerinformation.PostalCode,
                StripeReference = charge.Id,
                Stocks          = CartOrder.PRoducts.Select(X => new CreateOrder.Stuck
                {
                    Qty     = X.Qty,
                    StuckId = X.StockId
                }).ToList()
            });

            return(Page());  // View();


            // return RedirectToPage("/Index");
        }
Beispiel #6
0
        public IActionResult OnGet()
        {
            var CartOrder = new Shop.Application.Cart.GetOrder(HttpContext.Session, _ctx).Do();

            TotalPayment = CartOrder.GetTotalCharge();

            var information = new GetCustomerInformation(HttpContext.Session).Do();

            if (information == null)
            {
                return(RedirectToPage("/CheckOt/CustomerInformation"));
            }
            else
            {
                return(Page());
            }
        }
Beispiel #7
0
        public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

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

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

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

            var sessionId = HttpContext.Session.Id;

            //Create order
            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()
            });
            return(RedirectToPage("/Index"));
        }