/// <summary>
 /// Update batch payment details
 /// </summary>
 /// <param name="batch">Batch details</param>
 /// <param name="updatedOn">Date/time batch updated</param>
 /// <param name="updatedBy">Who pdated batch</param>
 public void UpdatePaymentToOrganisationBatchProcessStatus(PaymentToOrganisationBatch batch, DateTime updatedOn, string updatedBy)
 {
     using (var db = new GenerousAPIEntities())
     {
         db.UpdatePaymentToOrganisationBatchProcessStatus(batch.Id, updatedOn, updatedBy);
     }
 }
Exemple #2
0
        /// <summary>
        /// Update a record for transaction details
        /// </summary>
        /// <param name="transactionDetails">Transaction details</param>
        /// <returns>Response with success, message, and profile token</returns>
        public ProcessorResponse UpdateTransactionRecord(TransactionDetail transactionDetails)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    //save changes to database
                    db.Entry(transactionDetails).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                response.Message   = "Transaction successfully updated";
                response.AuthToken = transactionDetails.PaymentProfileTokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemple #3
0
        /// <summary>
        /// Delete a payment profile for a donor
        /// </summary>
        /// <param name="BankAccountTokenId">Payment profile token id</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse DeleteBankAccount(string BankAccountTokenId)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var           BankAccount   = db.BankAccounts.Where(x => x.BankAccountTokenId == BankAccountTokenId).SingleOrDefault();
                    DbEntityEntry dbEntityEntry = db.Entry(BankAccount);

                    if (dbEntityEntry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.BankAccounts.Attach(BankAccount);
                    }

                    BankAccount.Active = false;
                    db.SaveChanges();
                }

                response.AuthToken = BankAccountTokenId;
                response.Message   = "Bank Account successfully deleted";
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemple #4
0
        /// <summary>
        /// Update existing donor payment profile for a donor
        /// </summary>
        /// <param name="BankAccount">Donor payment profile details</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse UpdateBankAccount(BankAccount BankAccount)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    //save changes to database
                    db.Entry(BankAccount).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                response.Message   = "Bank Account successfully updated";
                response.AuthToken = BankAccount.BankAccountTokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemple #5
0
 /// <summary>
 /// Get an organisation record to process fees
 /// </summary>
 /// <param name="OrgId">org Id</param>
 /// <returns>Org record</returns>
 public OrganisationFeeProcessing GetOrganisationsToProcessFeeRecordByOrganisationId(int OrgId)
 {
     using (var db = new GenerousAPIEntities())
     {
         return(db.OrganisationFeeProcessings.Where(x => x.OrganisationId == OrgId).FirstOrDefault <OrganisationFeeProcessing>());
     }
 }
Exemple #6
0
 /// <summary>
 /// List of active records to process the fees
 /// </summary>
 /// <returns></returns>
 public IEnumerable <OrganisationFeeProcessing> GetOrganisationsToProcessFee()
 {
     using (var db = new GenerousAPIEntities())
     {
         return(db.OrganisationFeeProcessings.Where(x => x.IsActive.Value).ToList <OrganisationFeeProcessing>());
     }
 }
        /// <summary>
        /// Create a payment batch for an organisatsion
        /// </summary>
        /// <param name="batch">Payment batch details</param>
        public void CreatePaymentToOrganisationBatch(PaymentToOrganisationBatch batch)
        {
            using (var db = new GenerousAPIEntities())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.PaymentToOrganisationBatches.Add(batch);

                        if (batch.PaymentToOrganisationBatchLineItems != null && batch.PaymentToOrganisationBatchLineItems.Count > 0)
                        {
                            db.PaymentToOrganisationBatchLineItems.AddRange(batch.PaymentToOrganisationBatchLineItems);
                        }

                        db.SaveChanges();

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                }
            }
        }
 /// <summary>
 /// Get a payment line item for an organisation
 /// </summary>
 /// <param name="batchLineItemId">Line Item ID</param>
 /// <returns>Payment line item for an organisation</returns>
 public PaymentToOrganisationBatchLineItem GetPaymentToOrganisationBatchLineItem(Guid batchLineItemId)
 {
     using (var db = new GenerousAPIEntities())
     {
         return(db.PaymentToOrganisationBatchLineItems.Where(x => x.Id == batchLineItemId).SingleOrDefault <PaymentToOrganisationBatchLineItem>());
     }
 }
 /// <summary>
 /// Assigns batch line items to approved Donations
 /// </summary>
 public void PlayBackPaymentToOrganisationBatchTransactionLog()
 {
     using (var db = new GenerousAPIEntities())
     {
         db.AssignBatchLineItemToApprovedDonations();
     }
 }
 public OrganisationFeeProcessing GetOrganisationFeeProcessingSettings(int organisationId)
 {
     using (var db = new GenerousAPIEntities())
     {
         return(db.OrganisationFeeProcessings.Where(x => x.OrganisationId == organisationId).SingleOrDefault <OrganisationFeeProcessing>());
     }
 }
Exemple #11
0
        /// <summary>
        /// Delete a payment profile for a donor
        /// </summary>
        /// <param name="paymentProfileTokenId">Payment profile token id</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse DeletePaymentProfile(string paymentProfileTokenId)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var           paymentProfile = db.PaymentProfiles.Where(x => x.TokenId == paymentProfileTokenId).SingleOrDefault();
                    DbEntityEntry dbEntityEntry  = db.Entry(paymentProfile);

                    if (dbEntityEntry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.PaymentProfiles.Attach(paymentProfile);
                    }

                    db.PaymentProfiles.Remove(paymentProfile);
                    db.SaveChanges();
                }

                response.Message   = "Payment profile successfully deleted";
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
 /// <summary>
 /// Assigns the donation batch to approved donations
 /// </summary>
 /// <param name="batch">Batch donation details</param>
 public void AssignBatchToApprovedDonations(PaymentToOrganisationBatch batch)
 {
     using (var db = new GenerousAPIEntities())
     {
         db.AssignBatchToApprovedDonations(batch.Id);
     }
 }
Exemple #13
0
        /// <summary>
        /// Update the Transaction List with the donation details
        /// </summary>
        /// <param name="donationTransList">Donation Transaction List</param>
        public void UpdateDonationTransactionList(IEnumerable <TransactionDetail> donationTransList)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    foreach (TransactionDetail trans in donationTransList)
                    {
                        try
                        {
                            db.Entry(trans).State = System.Data.Entity.EntityState.Modified;
                        }
                        catch (Exception ex)
                        {
                            //Common.Helper.LogException(ex);
                        }
                    }

                    db.SaveChanges(); //batching multiple updates
                }

                //create log entries for multiple transactions
                //CreateTransactionLogEntries(donationTransList);
            }
            catch (Exception ex)
            {
                //Common.Helper.LogException(ex);
            }
        }
Exemple #14
0
        /// <summary>
        /// Get list of expiring credit cards for an organisation
        /// </summary>
        /// <param name="organisationId">Organisation Id to get details for</param>
        /// <param name="ExpiryMonth">Expiring month</param>
        /// <param name="ExpiryYear">Expiring year</param>
        /// <returns>Collection of contact details</returns>
        public List <ContactDetailsDTO> GetExpiringCreditCardInfoForOrganisation(int organisationId, int expiryMonth, int expiryYear)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var paymentProfilesWithExpiringCards = from cardDetailsForOrganisation in db.ExpiringCreditCardsForOrganisations
                                                           where cardDetailsForOrganisation.OrganisationId == organisationId &&
                                                           cardDetailsForOrganisation.ExpiryMonth == expiryMonth &&
                                                           cardDetailsForOrganisation.ExpiryYear == expiryYear
                                                           select new ContactDetailsDTO
                    {
                        CustomerFirstName = cardDetailsForOrganisation.CustomerFirstName,
                        CustomerLastName  = cardDetailsForOrganisation.CustomerLastName,
                        CardNumberMask    = cardDetailsForOrganisation.CardNumberMask,
                        ExpiryMonth       = cardDetailsForOrganisation.ExpiryMonth.ToString(),
                        ExpiryYear        = cardDetailsForOrganisation.ExpiryYear.ToString(),
                        TokenId           = cardDetailsForOrganisation.CardTokenId
                    };

                    return(paymentProfilesWithExpiringCards.ToList());
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #15
0
 /// <summary>
 /// Get donors payment profile details
 /// </summary>
 /// <param name="paymentProfileTokenId">Payment profile token id</param>
 /// <returns>Donor payment profile details</returns>
 public PaymentProfileDTO GetPaymentProfile(string paymentProfileTokenId)
 {
     using (var db = new GenerousAPIEntities())
     {
         return((from paymentProfile in db.PaymentProfiles
                 where paymentProfile.TokenId == paymentProfileTokenId
                 select new PaymentProfileDTO
         {
             TransactionMode = (BusinessEntities.TransactionMode)paymentProfile.TransactionMode,
             CustomerFirstName = paymentProfile.CustomerFirstName,
             CustomerLastName = paymentProfile.CustomerLastName,
             BillingAddress = paymentProfile.BillingAddress,
             BillingCity = paymentProfile.BillingCity,
             BillingState = paymentProfile.BillingState,
             Zip = paymentProfile.PostalCode,
             AccountNumber = paymentProfile.BankAccountNumber,
             CardNumber = paymentProfile.CardNumber,
             ExpirationMonth = paymentProfile.CardExpiryMonth,
             ExpirationYear = paymentProfile.CardExpiryYear,
             BankName = paymentProfile.BankName,
             RoutingNumber = paymentProfile.BSBNumber,
             AccountType = paymentProfile.AccountType,
             CardType = paymentProfile.CardType,
             SecurityCode = paymentProfile.CardSerurityNumber
         }).SingleOrDefault());
     }
 }
Exemple #16
0
        // <summary>
        /// Get when a card is expiring for the token
        /// </summary>
        /// <param name="ExpiryMonth">tokenId of payment profile</param>
        /// <returns>Donor payment profile details</returns>
        public ContactDetailsDTO GetCardExpiryForTokenId(string tokenId)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var paymentProfilesWithExpiringCards = from paymentProfiles in db.PaymentProfiles
                                                           where paymentProfiles.TokenId == tokenId &&
                                                           paymentProfiles.IsActive == true
                                                           select new ContactDetailsDTO
                    {
                        CustomerFirstName = paymentProfiles.CustomerFirstName,
                        CustomerLastName  = paymentProfiles.CustomerLastName,
                        TokenId           = paymentProfiles.TokenId,
                        ExpiryMonth       = paymentProfiles.CardExpiryMonth,
                        ExpiryYear        = paymentProfiles.CardExpiryYear,
                        CardNumberMask    = paymentProfiles.CardNumber
                    };

                    return(paymentProfilesWithExpiringCards.FirstOrDefault());
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #17
0
        /// <summary>
        /// Get active payment profile details for cards that are expiring
        /// </summary>
        /// <param name="ExpiryMonth">Expiring month</param>
        /// <param name="ExpiryYear">Expiring year</param>
        /// <returns>Donor payment profile details</returns>
        public List <ContactDetailsDTO> GetExpiringCards(string expiryMonth, string expiryYear)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var paymentProfilesWithExpiringCards = from paymentProfiles in db.PaymentProfiles
                                                           where paymentProfiles.CardExpiryMonth == expiryMonth &&
                                                           paymentProfiles.CardExpiryYear == expiryYear &&
                                                           paymentProfiles.IsActive == true
                                                           select new ContactDetailsDTO
                    {
                        CustomerFirstName = paymentProfiles.CustomerFirstName,
                        CustomerLastName  = paymentProfiles.CustomerLastName,
                        TokenId           = paymentProfiles.TokenId,
                        ExpiryMonth       = expiryMonth,
                        ExpiryYear        = expiryYear,
                        CardNumberMask    = paymentProfiles.CardNumber
                    };

                    return(paymentProfilesWithExpiringCards.ToList());
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
        /// <summary>
        /// Get a collection of payment line items for an organisation
        /// </summary>
        /// <param name="listOfLineItemNumbers">List of line item numbers</param>
        /// <returns>Collection of payment line items<</returns>
        public List <PaymentToOrganisationBatchLineItem> GetPaymentToOrganisationBatchLineItemsByLineItemNumbers(List <long> listOfLineItemNumbers)
        {
            using (var db = new GenerousAPIEntities())
            {
                var query = from lineItem in db.PaymentToOrganisationBatchLineItems
                            where listOfLineItemNumbers.Contains(lineItem.LineItemNumber)
                            select lineItem;

                return(query.ToList <PaymentToOrganisationBatchLineItem>());
            }
        }
        /// <summary>
        /// Get a collection of payment line items for an organisation
        /// </summary>
        /// <param name="listOfIds">List of line item ids</param>
        /// <returns>Collection of payment line items</returns>
        public List <PaymentToOrganisationBatchLineItem> GetPaymentToOrganisationBatchLineItemsByIds(List <Guid> listOfIds)
        {
            using (var db = new GenerousAPIEntities())
            {
                var query = from lineItem in db.PaymentToOrganisationBatchLineItems
                            where listOfIds.Contains(lineItem.Id)
                            select lineItem;

                return(query.ToList <PaymentToOrganisationBatchLineItem>());
            }
        }
        /// <summary>
        /// Save new batch line items
        /// </summary>
        /// <param name="batchLineItemList">Collection of line items to save</param>
        public void CreatePaymentToOrganisationBatchLineItems(List <PaymentToOrganisationBatchLineItem> batchLineItemList)
        {
            using (var db = new GenerousAPIEntities())
            {
                db.PaymentToOrganisationBatchLineItems.AddRange(batchLineItemList);
                db.SaveChanges();
            }

            //create log entries for multiple transactions
            CreateTransactionLogEntries(batchLineItemList);
        }
        /// <summary>
        /// Get a collection of of transactions associated with the batch id
        /// </summary>
        /// <param name="batch">Batch ID</param>
        /// <returns>Donations in the batch</returns>
        public IEnumerable <TransactionDetail> GetDonationTransactionsAssignedToBatch(PaymentToOrganisationBatch batch)
        {
            using (var db = new GenerousAPIEntities())
            {
                var query = from t in db.TransactionDetails
                            where t.PaymentToOrganisationBatchId == batch.Id
                            select t;

                return(query.ToList <TransactionDetail>());
            }
        }
        /// <summary>
        /// Check if there are any dontaions that are not assigned to a batch
        /// </summary>
        /// <returns>True if donations are not assigned to a batch but are approved, false otherwise</returns>
        public bool AreThereAny_APPROVED_DonationTransactions_NotAssigned_To_Any_Batch()
        {
            int  count          = 0;
            byte approvedStatus = (byte)PaymentProcessStatus.Approved;

            using (var db = new GenerousAPIEntities())
            {
                count = db.TransactionDetails.Where(x => x.PaymentToOrganisationBatchId == null && x.ProcessStatusId.Value == approvedStatus && x.IsValidForPaymentToOrganisation.Value).Count();
            }

            return(count > 0);
        }
        /// <summary>
        /// Get a collection of payment line items for an organisation by bank account id
        /// </summary>
        /// <param name="bankAccountId">bank account id</param>
        /// <returns>Collection of payment line items</returns>
        public List <PaymentToOrganisationBatchLineItem> GetBankVerificationPaymenBatchLineItems(Guid bankAccountId)
        {
            using (var db = new GenerousAPIEntities())
            {
                var query = from lineItem in db.PaymentToOrganisationBatchLineItems
                            where lineItem.BankAccountId == bankAccountId &&
                            lineItem.IsBankVerification == true
                            select lineItem;

                return(query.ToList <PaymentToOrganisationBatchLineItem>());
            }
        }
        /// <summary>
        /// Get collection of batch items to process
        /// </summary>
        /// <param name="batch">Batch items</param>
        /// <param name="dateTimeToBeProcessed">Process date time</param>
        /// <returns>Collection of batch items to process</returns>
        public IEnumerable <PaymentToOrganisationBatchLineItem> GetPaymentToOrganisationBatchLineItems_ForProcessing(PaymentToOrganisationBatch batch, DateTime dateTimeToBeProcessed)
        {
            using (var db = new GenerousAPIEntities())
            {
                var lineItemList = from lineItem in db.PaymentToOrganisationBatchLineItems
                                   where
                                   lineItem.BatchId == batch.Id &&
                                   lineItem.ProcessDateTime <= dateTimeToBeProcessed &&
                                   lineItem.DoNotProcess == false
                                   select lineItem;

                return(lineItemList.ToList <PaymentToOrganisationBatchLineItem>());
            }
        }
Exemple #25
0
 /// <summary>
 /// Get Bank account details
 /// </summary>
 /// <param name="bankAccountId">Guid iD of bank</param>
 /// <returns>Bank account details</returns>
 public BankAccount GetBankAccountById(System.Guid bankAccountId)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             var bankAccount = db.BankAccounts.SingleOrDefault(x => x.BankAccountId == bankAccountId);
             return(bankAccount);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        /// <summary>
        /// Updates the the batch line item list
        /// </summary>
        /// <param name="batchLineItemList">Line items</param>
        public void UpdatePaymentToOrganisationBatchLineItemList(List <PaymentToOrganisationBatchLineItem> batchLineItemList)
        {
            using (var db = new GenerousAPIEntities())
            {
                foreach (PaymentToOrganisationBatchLineItem lineItem in batchLineItemList)
                {
                    db.Entry(lineItem).State = System.Data.Entity.EntityState.Modified;
                }

                db.SaveChanges(); //batching multiple updates
            }

            //create log entries for multiple transactions
            CreateTransactionLogEntries(batchLineItemList);
        }
Exemple #27
0
 /// <summary>
 /// Save Expiring Credit Card Detais
 /// </summary>
 /// <param name="expiringCardDetails">Details of cards</param>
 public void SaveExpiringCreditCardDetais(ExpiringCreditCardsForOrganisation expiringCardDetails)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.ExpiringCreditCardsForOrganisations.Add(expiringCardDetails);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
Exemple #28
0
 /// <summary>
 /// Create a new fee processing record
 /// </summary>
 /// <param name="processFee"></param>
 public void CreateOrganisationStandardFees(OrganisationStandardFee standFees)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.OrganisationStandardFees.Add(standFees);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
Exemple #29
0
 /// <summary>
 /// Update the organisation fee processing record
 /// </summary>
 /// <param name="processedFee"></param>
 public void UpdateOrganisationFeeStandardPrices(OrganisationStandardFee standFees)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.Entry(standFees).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
Exemple #30
0
 /// <summary>
 /// Create a new fee processing record
 /// </summary>
 /// <param name="processFee"></param>
 public void CreateOrganisationFeeProces(OrganisationFeeProcessing processFee)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.OrganisationFeeProcessings.Add(processFee);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }