Ejemplo n.º 1
0
        public async Task <IActionResult> GetPendingBookingById(int id, bool includeStripeKey = false)
        {
            var pendingBookingFromDb = await _repo.GetPendingBookingById(id);

            var pendingBooking = _mapper.Map <PendingBookingDto>(pendingBookingFromDb);

            if (includeStripeKey)
            {
                var output = new
                {
                    pendingBooking = pendingBooking,
                    stripeKey      = _config.GetValue <string>("Stripe:PublishableKey")
                };

                return(Ok(output));
            }
            else
            {
                return(Ok(pendingBooking));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreatePaymentIntent(CreatePaymentIntentDto createPaymentIntentDto)
        {
            var pendingBooking = await _repo.GetPendingBookingById(createPaymentIntentDto.PendingBookingId);

            if (pendingBooking.Deposit > createPaymentIntentDto.AmtForStripe)
            {
                return(BadRequest("Payment amount is less than deposit required"));
            }

            if (createPaymentIntentDto.AmtForStripe > pendingBooking.TotalCost)
            {
                return(BadRequest("Payment amount is greater than total cost"));
            }

            pendingBooking = await _paymentService.AddPaymentIntentToPendingBooking(pendingBooking,
                                                                                    createPaymentIntentDto.AmtForStripe);

            if (pendingBooking == null)
            {
                return(BadRequest("Payment Intent could not be created"));
            }

            return(Ok());
        }