Exemplo n.º 1
0
        public IActionResult Purchase(Guid id)
        {
            var book = _bookService.GetById(id);

            if (book == null)
            {
                return(NotFound());
            }

            var gateway     = _braintreeService.GetGateway();
            var clientToken = gateway.ClientToken.Generate();

            ViewBag.ClientToken = clientToken;

            var data = new BookPurchaseVM
            {
                Id          = book.Id,
                Description = book.Description,
                Author      = book.Author,
                Thumbnail   = book.Thumbnail,
                Title       = book.Title,
                Price       = book.Price,
                Nonce       = ""
            };

            return(View(data));
        }
Exemplo n.º 2
0
        public IActionResult BraintreePlans()
        {
            var gateway = _braintreeService.GetGateway();
            var plans   = gateway.Plan.All();

            return(View(plans));
        }
        public async Task <IActionResult> Purchase(int id)
        {
            var car = await _appDbContext.Cars.Include("Category").FirstOrDefaultAsync(c => c.Id == id);

            if (car is not null)
            {
                var gateway     = _braintreeService.GetGateway();
                var clientToken = await gateway.ClientToken.GenerateAsync();

                var viewModel = new CarPurchaseViewModel
                {
                    ImageUrl = car.ImageURL,
                    Title    = "Purchase",
                    Category = car.Category,
                    Price    = car.Price,
                    Nonce    = string.Empty,
                };
                ViewBag.ClientToken = clientToken;
                return(View(viewModel));
            }
            return(NoContent());
        }