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")); }
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")); }