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")); }
public async Task <IActionResult> OnPost( [FromServices] GetOrderCart getOrder, [FromServices] CreateOrder createOrder, [FromServices] ISessionManager sessionManager) { // Stripe var cartOrder = getOrder.Do(); var sessionId = HttpContext.Session.Id; await createOrder.Do(new CreateOrder.Request { 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 CartOrder = new 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 = "usd", Customer = customer.Id }); var sessionId = HttpContext.Session.Id; // Create an Order 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, ZipCode = cartOrder.CustomerInformation.ZipCode, Stocks = cartOrder.Products.Select(x => new CreateOrder.Stock { StockId = x.StockId, Qty = x.Qty }).ToList() }); sessionManager.ClearCart(); return(RedirectToPage("/Index")); }
public async Task <IActionResult> Pay( [FromBody] string stripeToken, [FromServices] Application.Cart.GetOrder getOrder, [FromServices] CreateOrder createOrder, [FromServices] ISessionManager sessionManager) { var customers = new CustomerService(); var customer = customers.Create(new CustomerCreateOptions { Email = null, 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; 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(Ok()); }
//TODO 3 Implement Stripe Payment for V3 (currently working only on v1) public async Task <IActionResult> OnPost( [FromServices] GetCartOrder getCartOrder, [FromServices] CreateOrder createOrder, [FromServices] ISessionManager sessionManager, string stripeEmail, string stripeToken) { var customers = new CustomerService(); var charges = new ChargeService(); var cartOrder = getCartOrder.Action(); var customer = customers.Create(new CustomerCreateOptions { Email = stripeEmail, Source = stripeToken }); var charge = charges.Create(new ChargeCreateOptions { Amount = cartOrder.GetTotalCharge(), Description = "WebStore Charge", Currency = "AUD", Customer = customer.Id }); var sessionId = HttpContext.Session.Id; await createOrder.Action(new CreateOrder.Request { StripeRef = charge.Id, SessionId = sessionId, FirstName = cartOrder.CustomerInfo.FirstName, LastName = cartOrder.CustomerInfo.LastName, EmailAddress = cartOrder.CustomerInfo.EmailAddress, PhoneNumber = cartOrder.CustomerInfo.PhoneNumber, Address1 = cartOrder.CustomerInfo.Address1, Address2 = cartOrder.CustomerInfo.Address2, City = cartOrder.CustomerInfo.City, Postcode = cartOrder.CustomerInfo.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.Exec(); 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.ExecAsync(new CreateOrderDto { SessionId = sessionId, StripeRef = charge.Id, FirstName = cartOrder.CustomerInformation.FirstName, LastName = cartOrder.CustomerInformation.LastName, Email = cartOrder.CustomerInformation.Email, PhoneNumber = cartOrder.CustomerInformation.PhoneNumber, Address = cartOrder.CustomerInformation.Address, City = cartOrder.CustomerInformation.City, PostCode = cartOrder.CustomerInformation.PostCode, Stocks = cartOrder.Products.Select(x => new StockViewModel { StockId = x.StockId, Quantity = x.Quantity }).ToList() }); sessionManager.ClearCart(); return(RedirectToPage("/Index")); }