Example #1
0
        public BasketForPaymentDto Do(string stripeToken, decimal basketPrice, List <ProductFromBasketCookieDto> basketProductsCookie)
        {
            var customers = new CustomerService();
            var charges   = new ChargeService();

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

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = (int)(basketPrice * 100),
                Description = "Test Desc",
                Currency    = "usd",
                Customer    = customer.Id,
            });

            var basketForPaymentDto = new BasketForPaymentDto()
            {
                BasketPrice    = basketPrice,
                StripeRef      = charge.Id,
                BasketProducts = basketProductsCookie
            };

            return(basketForPaymentDto);
        }
Example #2
0
        public Order ScaffoldOrderForCreation(OrderInfoDto customerInfo, BasketForPaymentDto basketForPaymentDto)
        {
            var result = new Order()
            {
                OrderRef     = Guid.NewGuid(),
                Name         = customerInfo.Name,
                SurName      = customerInfo.SurName,
                Street       = customerInfo.Street,
                PostCode     = customerInfo.PostCode,
                Phone        = customerInfo.Phone,
                Email        = customerInfo.Email,
                City         = customerInfo.City,
                Country      = customerInfo.Country,
                DeliveryType = customerInfo.DeliveryType,
                OrderPrice   = basketForPaymentDto.BasketPrice,
                StripeRef    = basketForPaymentDto.StripeRef,
                OrderStocks  = basketForPaymentDto.BasketProducts.Select(x => new OrderStock()
                {
                    StockId  = x.StockId,
                    Quantity = x.StockQty,
                    Price    = _ctx.Stocks.Include(s => s.Product).FirstOrDefault(s => s.Id == x.StockId).Product.Price
                }).ToList()
            };


            return(result);
        }