public MPESAValidationResponse ValidateMPESAPayment(MPESAValidation validation)
        {
            var validationResult = _paymentAccessor.ValidateMPESAPayment(validation.MerchantRequestID, validation.CheckoutRequestID, validation.ResultCode);

            if (validationResult.IsSuccess)
            {
                var donationID = validationResult.Payload.Item1;
                var userID     = validationResult.Payload.Item2;
                if (validation.ResultCode == "0")
                {
                    _donateAccessor.UpdateDonationStatus(donationID, 6);
                    _donateAccessor.ClearUserCart(userID);
                    SendPaymentConfirmationEmail(userID, donationID);
                }
                else
                {
                    _donateAccessor.UpdateDonationStatus(donationID, 4);
                }
                return(new MPESAValidationResponse
                {
                    ResponseCode = "00000000",
                    ResponseDesc = "Success"
                });
            }
            else
            {
                return(new MPESAValidationResponse
                {
                    ResponseCode = "99999999",
                    ResponseDesc = "Failure"
                });
            }
        }
        public Result MakeDropOffDonation(int userID, DateTime date, string currencyCode)
        {
            var cartItems = _donateAccessor.GetCartItems(userID, currencyCode).Payload;

            var total = cartItems.Sum(x => x.TotalAmount);

            var donationResult = _donateAccessor.MakeDonation(userID, total, "dropoff", currencyCode);

            if (!donationResult.IsSuccess)
            {
                return(new Result(false, donationResult.Message));
            }

            var donation = donationResult.Payload;

            var dropOffDonation = new DropOffDonation
            {
                DonationID   = donation.DonationID,
                DeliveryDate = date
            };

            _donateAccessor.MakeDropOffDonation(dropOffDonation);

            var items = cartItems.Select(x => new DonationItem
            {
                DonationID    = donation.DonationID,
                ItemID        = x.ItemID,
                TotalAmount   = x.TotalAmount,
                NumberOfItems = x.NumItems,
                CurrencyID    = x.CurrencyID
            }).ToList();

            var itemsResult = _donateAccessor.AddDonationItems(items);

            if (itemsResult.IsSuccess)
            {
                _donateAccessor.ClearUserCart(userID);
            }

            SendDropOffDonationConfirmationEmail(userID, items, date.ToLongDateString());
            return(itemsResult);
        }