/// <summary>
        /// Gets the details of a payment by Id
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="paymentId"></param>
        /// <returns></returns>
        public async Task <PaymentItem> GetPaymentByPaymentId(MerchantId merchantId, PaymentId paymentId)
        {
            await using PaymentControllerDbContext context = DbContextProvider.Create();

            Model.PaymentItem payment = await context.Payments.Include(c => c.PaymentCard)
                                        .Include(p => p.PaymentCustomer).FirstOrDefaultAsync(
                p =>
                p.PaymentMerchant.Equals(new Model.Merchant()
            {
                MerchantId = merchantId.UUID
            }) &&
                p.PaymentId.Equals(paymentId.UUID)
                ).ConfigureAwait(false);

            return(payment.ToDto());
        }
        /// <summary>
        /// Method for saving payment details to database.
        /// </summary>
        /// <param name="payment">The payment</param>
        /// <returns>PaymentItem object</returns>
        public async Task <PaymentItem> SavePaymentItemAsync(PaymentItem payment)
        {
            await using PaymentControllerDbContext context = DbContextProvider.Create();

            Model.PaymentItem dbPaymentItem = payment.ToDb();
            context.Payments.Add(dbPaymentItem);

            try
            {
                if (payment.PaymentCustomer.CustomerId.IsValid())
                {
                    context.Customers.Attach(dbPaymentItem.PaymentCustomer);
                }
                if (payment.PaymentCustomer.Address.AddressId.IsValid())
                {
                    context.Address.Attach(dbPaymentItem.PaymentCustomer.Address);
                }
                if (payment.PaymentCard.CardId.IsValid())
                {
                    context.Card.Attach(dbPaymentItem.PaymentCard);
                }

                context.Merchant.Attach(dbPaymentItem.PaymentMerchant);

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.LogWarning(ex, "An exception has occured in {name}", nameof(SavePaymentItemAsync));
                Logger.LogInformation("Payment {PaymentId} failed to process.", payment.PaymentId);

                throw;
            }

            return(dbPaymentItem.ToDto());
        }