public async Task <ActionResult <TransactionViewModel> > ConfirmIntent(ConfirmIntentBody confirmIntentBody)
        {
            try
            {
                Logger.LogInformation("Confirming {Id} for {User}", confirmIntentBody.IntentId, confirmIntentBody.UserId);
                var result = await TransactionService.ConfirmIntent(confirmIntentBody);

                return(result);
            }
            catch (Exception e)
            {
                Logger.LogError(e.ToString());
                return(BadRequest(e));
            }
        }
        /// <inheritdoc />
        /// <exception cref="Exception">Thrown if error</exception>
        public async Task <TransactionViewModel> ConfirmIntent(ConfirmIntentBody confirmIntentBody)
        {
            var transaction =
                await ApplicationContext.Transactions.FirstOrDefaultAsync(x =>
                                                                          x.StripeIntentId == confirmIntentBody.IntentId);

            if (transaction == null)
            {
                throw new Exception("Transaction not found");
            }

            var service = new PaymentIntentService();

            try
            {
                // requests intent confirm from Stripe api
                var intent = service.Confirm(confirmIntentBody.IntentId);

                // updates transaction with Stripe response
                transaction.Updated = DateTime.Now;
                transaction.Status  = Enum.Parse <PaymentStatus>(intent.Status, true);

                // if the intent has finished set paid
                if (transaction.Status == PaymentStatus.succeeded)
                {
                    transaction.Paid = true;
                    transaction.End  = DateTime.Now;
                }

                await ApplicationContext.SaveChangesAsync();

                return(Mapper.Map <TransactionViewModel>(transaction));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }