public async Task <IActionResult> Payment(string stripeEmail, string stripeToken) { //stripe custom classes var customers = new CustomerService(); var charges = new ChargeService(); var CartOrder = new GetOrder(HttpContext.Session, _db).Get(); 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 new CreateOrder(_db).Create(new CustomerInformation { StripeReference = charge.Id, SessionId = sessionId, FirstName = CartOrder.CustomerInformation.FirstName, LastName = CartOrder.CustomerInformation.LastName, Email = CartOrder.CustomerInformation.Email, PhoneNumber = CartOrder.CustomerInformation.PhoneNumber, Adress1 = CartOrder.CustomerInformation.Adress1, Adress2 = CartOrder.CustomerInformation.Adress2, City = CartOrder.CustomerInformation.City, PostCode = CartOrder.CustomerInformation.PostCode, Stocks = CartOrder.Products.Select(x => new CreateOrder.Stock { StockId = x.StockId, Qty = x.Qty }).ToList() }); return(View()); }
public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken) { var customers = new CustomerService(); var charges = new ChargeService(); var CartOrder = new GetOrder(HttpContext.Session, _ctx).Do(); var customer = customers.Create(new CustomerCreateOptions { Email = stripeEmail, SourceToken = stripeToken }); var charge = charges.Create(new ChargeCreateOptions { Amount = CartOrder.GetTotalCharge(), Description = "Sample Charge", Currency = "eur", CustomerId = customer.Id }); var sessionID = HttpContext.Session.Id; #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task await new CreateOrder(_ctx).Do(new CreateOrder.Request { StripeRef = 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.Robots.Select(x => new CreateOrder.Stock { StockID = x.StockID, Quantity = x.Quantity }).ToList() }); #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task HttpContext.Session.Clear(); return(RedirectToPage("/Index")); }
public async Task <IActionResult> OnPost(string stripeEmail, string stripeToken) { var customers = new CustomerService(); var charges = new ChargeService(); var CartOrder = new GetOrder(HttpContext.Session, _context).Do(); var customer = customers.Create(new CustomerCreateOptions { Email = stripeEmail, SourceToken = stripeToken }); var charge = charges.Create(new ChargeCreateOptions { Amount = CartOrder.GetTotalCharge(), Description = "Sample Charge", Currency = "usd", CustomerId = customer.Id }); var sessionId = HttpContext.Session.Id; await new CreateOrder(_context).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, Qty = x.Qty }).ToList() }); return(RedirectToPage("/Index")); }
//controller za payment public IActionResult OnPost(string stripeEmail, string stripeToken) { var customers = new CustomerService(); var charges = new ChargeService(); 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 = "eu", Customer = customer.Id }); return(RedirectToPage("/Index")); }