示例#1
0
        public int Execute(BankAccount bankAccount, Guid updatedByUserId)
        {
            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.Id, bankAccount.Id),
                DbHelper.CreateParameter(Parameters.BankName, bankAccount.BankName),
                DbHelper.CreateParameter(Parameters.BankCode, bankAccount.BankCode),
                DbHelper.CreateParameter(Parameters.AccountName, bankAccount.AccountName),
                DbHelper.CreateParameter(Parameters.AccountNumber, bankAccount.AccountNumber),
                DbHelper.CreateParameter(Parameters.IBAN, bankAccount.IBAN),
                DbHelper.CreateParameter(Parameters.BIC, bankAccount.BIC),
                DbHelper.CreateParameter(Parameters.BranchName, bankAccount.BranchName),
                DbHelper.CreateParameter(Parameters.AddressLine1, bankAccount.AddressLine1),
                DbHelper.CreateParameter(Parameters.AddressLine2, bankAccount.AddressLine2),
                DbHelper.CreateParameter(Parameters.AddressLine3, bankAccount.AddressLine3),
                DbHelper.CreateParameter(Parameters.City, bankAccount.City),
                DbHelper.CreateParameter(Parameters.StateProvinceId, bankAccount.StateProvinceId),
                DbHelper.CreateParameter(Parameters.PostCode, bankAccount.PostCode),
                DbHelper.CreateParameter(Parameters.CountryId, bankAccount.CountryId),
                DbHelper.CreateParameter(Parameters.UpdatedByUserId, updatedByUserId),
            };

            return DbHelper.ExecuteNonQueryCommand(this, parameters);
        }
示例#2
0
        public int? Execute(BankAccount bankAccount, Guid updatedByUserId)
        {
            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.BankName, bankAccount.BankName),
                DbHelper.CreateParameter(Parameters.BankCode, bankAccount.BankCode),
                DbHelper.CreateParameter(Parameters.AccountName, bankAccount.AccountName),
                DbHelper.CreateParameter(Parameters.AccountNumber, bankAccount.AccountNumber),
                DbHelper.CreateParameter(Parameters.IBAN, bankAccount.IBAN),
                DbHelper.CreateParameter(Parameters.BIC, bankAccount.BIC),
                DbHelper.CreateParameter(Parameters.BranchName, bankAccount.BranchName),
                DbHelper.CreateParameter(Parameters.AddressLine1, bankAccount.AddressLine1),
                DbHelper.CreateParameter(Parameters.AddressLine2, bankAccount.AddressLine2),
                DbHelper.CreateParameter(Parameters.AddressLine3, bankAccount.AddressLine3),
                DbHelper.CreateParameter(Parameters.City, bankAccount.City),
                DbHelper.CreateParameter(Parameters.StateProvinceId, bankAccount.StateProvinceId),
                DbHelper.CreateParameter(Parameters.PostCode, bankAccount.PostCode),
                DbHelper.CreateParameter(Parameters.CountryId, bankAccount.CountryId),
                DbHelper.CreateParameter(Parameters.UpdatedByUserId, updatedByUserId),
            };

            // out parameters
            SqlParameter outputId;
            parameters.Add(outputId = DbHelper.CreateParameterOut<int>(OutParameters.Id, SqlDbType.Int));

            DbHelper.ExecuteNonQueryCommand(this, parameters);

            return DbHelper.ParameterValue<int?>(outputId);
        }
示例#3
0
            public void UpdateBusinessMerchantDetails()
            {
                const int BUSINESS_ID = 1;
                var bankAccount = new BankAccount();
                var merchantDetails = new MerchantDetails();
                merchantDetails.Password = "******";

                var businessDao = MockRepository.GenerateMock<IBusinessDao>();
                var businessEventDao = MockRepository.GenerateMock<IBusinessEventDao>();
                businessManager.BusinessDao = businessDao;
                businessManager.BusinessEventDao = businessEventDao;

                businessDao.Expect(x => x.CreateMerchantBankAccount(bankAccount)).Return(0);
                businessEventDao.Expect(z => z.Create(new BusinessEvent() { BusinessId = BUSINESS_ID }));
                businessDao.Expect(x => x.CreateMerchantDetails(merchantDetails)).Return(0);
                businessEventDao.Expect(z => z.Create(new BusinessEvent() { BusinessId = BUSINESS_ID }));

                businessManager.UpdateBusinessMerchantDetails(BUSINESS_ID, merchantDetails, bankAccount);
                businessDao.VerifyAllExpectations();
                //Needs fixing to uncomment this: 
                businessEventDao.VerifyAllExpectations();
            }
示例#4
0
        /// <summary>
        /// Modify Settlement Details
        /// </summary>
        /// <param name="bankAccount">Bank Account</param>
        /// /// <param name="businessId">Business Id</param>
        /// <returns>true if modification succeeds</returns>
        public bool ModifySettlementDetails(long businessId, BankAccount bankAccount)
        {
            var updateAccountResult = true;
            var updateBusinessResult = true;

            if (bankAccount == null)
            {
                throw new ArgumentNullException("bankAccount");
            }

            using (var tx = new BusinessTransaction())
            {
                // update or insert bank account info
                updateAccountResult = ProcessBankAccount(businessId, bankAccount, BankAccountType.Settlement);
                // update business table with merchant details and bank account
                updateBusinessResult = businessDao.ModifyBusinessBankAccount(businessId, bankAccount.Id);

                tx.Commit();
            }

            return updateAccountResult && updateBusinessResult;
        }
示例#5
0
        /// <summary>
        ///  Update Merchant Details
        /// </summary>
        /// <param name="businessId">businessId</param>
        /// <param name="merchantDetails">MerchantDetails</param>
        /// <param name="bankAccount">BankAccount</param>
        /// <returns>true if modification succeeds</returns>
        public bool UpdateBusinessMerchantDetails(long businessId, MerchantDetails merchantDetails, BankAccount bankAccount)
        {
            var updateMerchantDetailsResult = true;
            var updateMerchantAccountResult = true;
            var updateBusinessMerchantDetailsResult = true;
            var updateStatusCodeResult = true;

            using (var tx = new BusinessTransaction())
            {
               
                if (merchantDetails.MerchantStatusCode == MerchantStatusEnum.EviivoMerchant.GetCode() ||
                    merchantDetails.MerchantStatusCode == MerchantStatusEnum.InterimMerchant.GetCode())
                {
                    var updateMerchantStatusCode = ProcessMerchantStatusCode(businessId,merchantDetails.MerchantStatusCode);
                    tx.Commit();
                    return updateMerchantStatusCode;

                }
                // encrypt before persisting to database
                merchantDetails.Password = DesCrypto.TripleDESEncrypt(merchantDetails.Password);
                merchantDetails.PasswordExpiry = DateTime.Now.AddMonths(12);
              

                // update merchant status code
                updateStatusCodeResult = ProcessMerchantStatusCode(businessId, merchantDetails.MerchantStatusCode);
                // update or insert merchant details info
                updateMerchantDetailsResult = ProcessMerchantDetails(businessId, merchantDetails);

                // update or insert merchant bank account info only if merchant account is different from settlement account
                if (!merchantDetails.UseSettlementAccount)
                {
                   updateMerchantAccountResult = ProcessBankAccount(businessId, bankAccount, BankAccountType.Merchant);
                }
                // update business table with merchant details and bank account
                updateBusinessMerchantDetailsResult = businessDao.UpdateBusinessMerchantDetails(businessId, merchantDetails.Id, bankAccount.Id);
                tx.Commit();
            }
            return updateStatusCodeResult && updateBusinessMerchantDetailsResult && updateMerchantDetailsResult && updateMerchantAccountResult;
        }
示例#6
0
        /// <summary>
        /// Process BankAccount
        /// </summary>
        /// <param name="businessId">BusinessId</param>
        /// <param name="bankAccount">BankAccount</param>
        /// <param name="bankAccountType">BankAccountType</param>
        /// <returns>true if processing of business account succeeds</returns>
        private bool ProcessBankAccount(long businessId, BankAccount bankAccount, BankAccountType bankAccountType)
        {
            if (bankAccount.Id == default(int))
            {
                var newMerchantAccountId = default(int);
                
                // write merchant bank account to table
                newMerchantAccountId = businessDao.CreateMerchantBankAccount(bankAccount);

                // determine business event code based on bank account type
                string businessEventCode = bankAccountType == BankAccountType.Merchant ? BusinessEventTypesEnum.MerchantBankAccountCreated.GetCode() :
                    bankAccountType == BankAccountType.Settlement ? BusinessEventTypesEnum.SettlementBankAccountCreated.GetCode() : string.Empty;

                // write business event to event table
                businessEventDao.Create(new BusinessEvent
                {
                    BusinessId = businessId,
                    EventType = new EnumEntity { Code = businessEventCode },
                    Reference = newMerchantAccountId.ToString()
                });

                bankAccount.Id = newMerchantAccountId;
                return newMerchantAccountId != default(int);
                
            }
            else
            {
                bool modifyAccountResult =  businessDao.ModifyBankAccount(bankAccount);

                // determine business event code based on bank account type
                string businessEventCode = bankAccountType == BankAccountType.Merchant ? BusinessEventTypesEnum.MerchantBankAccountModified.GetCode() :
                    bankAccountType == BankAccountType.Settlement ? BusinessEventTypesEnum.SettlementBankAccountModified.GetCode() : string.Empty;

                // write business event to event table
                businessEventDao.Create(new BusinessEvent
                {
                    BusinessId = businessId,
                    EventType = new EnumEntity { Code = businessEventCode },
                    Reference = bankAccount.Id.ToString()
                });

                return modifyAccountResult;
            }
        }
示例#7
0
            public void ModifyMerchantAccount_ExpectSuccess()
            {
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBusinessesTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    var bankAccount = new BankAccount()
                    {
                        BankName = "testBankName",
                        BankCode = "testBankCode",
                        BIC = "BIC1234",
                        AccountName = "testAccountName",
                        AccountNumber = "12345ACC",
                        Id = 1
                    };

                    // Act
                    bool result = businessDao.ModifyBankAccount(bankAccount);

                    //Assert
                    Assert.IsTrue(result);

                }
            }
示例#8
0
            public void UpdateBusinessMerchantDetails_ExpectSuccess()
            {

                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBusinessesTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    const int BUSINESS_ID = 1;

                    // Arrange
                    var merchantDetails = new MerchantDetails()
                    {
                        MerchantId = "testmerchantId",
                        PasswordExpiry = DateTime.Now.AddMonths(10),
                        Is3DSecureAllowed = true,
                        IsAmexAllowed = true,
                        IsIvrAllowed = true,
                        IsPaypalAllowed = true,
                        Password = "******"
                    };

                    int newMerchantDetailId = businessDao.CreateMerchantDetails(merchantDetails);

                    var bankAccount = new BankAccount()
                    {
                        BankName = "testBankName",
                        BankCode = "testBankCode",
                        AccountName = "testAccountName",
                        AccountNumber = "12345ACC",
                        BIC = "BIC1234"
                    };


                    int newBankAccountId = businessDao.CreateMerchantBankAccount(bankAccount);


                    // Act 
                    bool result = businessDao.UpdateBusinessMerchantDetails(BUSINESS_ID, newMerchantDetailId, newBankAccountId);

                    // Assert
                    Assert.IsTrue(result);
                }
            }
示例#9
0
            public void CreateMerchantAccountTest_ExpectSuccess()
            {
                // Arrange
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBusinessesTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    var bankAccount = new BankAccount()
                    {
                        BankName = "testBankName",
                        BankCode = "testBankCode",
                        AccountName = "testAccountName",
                        AccountNumber = "12345ACC",
                        BIC = "BIC1234"
                    };

                 //Act
                 int newBankAccountId = businessDao.CreateMerchantBankAccount(bankAccount);

                 // Assert
                 Assert.IsTrue(newBankAccountId > 0, "Expect new business merchant bank account to be created");
                }
            }
示例#10
0
            public void CreateMerchantAccountWithMissingMandatoryAccountName_ExpectExpection()
            {
                // Arrange
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBusinessesTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    var bankAccount = new BankAccount()
                    {
                        BankName = "testBankName",
                        BankCode = "testBankCode",
                        AccountNumber = "12345ACC"
                    };

                  // Act
                  businessDao.CreateMerchantBankAccount(bankAccount);

                }

            }
示例#11
0
        /// <summary>
        /// Get settlement Bank Sort Code from eagle settlement bank account
        /// </summary>
        /// <returns></returns>
        private string GetBankAccountNumber(Country countryOfBusiness, BankAccount settlementBankAccount)
        {
            Helper.ArgumentNotNull(countryOfBusiness, "country of business");
            if (settlementBankAccount == null) { return null; }

            string bankAccountNumber = countryOfBusiness.IsoChar2Code == UK_ISO_CHAR2_CODE
                                           ? settlementBankAccount.AccountNumber
                                           : settlementBankAccount.IBAN;

            // handle size difference in fields in settlement
            return bankAccountNumber == null || bankAccountNumber.Length <= MAX_BANK_ACCOUNT_SIZE
                       ? bankAccountNumber
                       : bankAccountNumber.Substring(0, MAX_BANK_ACCOUNT_SIZE);
        }
示例#12
0
 /// <summary>
 /// Get settlement Bank Sort Code from eagle settlement bank account
 /// </summary>
 /// <returns></returns>
 private string GetBankSortCode(Country countryOfBusiness, BankAccount settlementBankAccount)
 {
     Helper.ArgumentNotNull(countryOfBusiness, "country of business");
     if (settlementBankAccount == null) { return null; }
     
     return countryOfBusiness.IsoChar2Code == UK_ISO_CHAR2_CODE ? settlementBankAccount.BankCode : settlementBankAccount.BIC;
 }
示例#13
0
        /// <summary>
        /// Set contact information on NewProvider Model
        /// </summary>
        /// <param name="provider">NewProvider</param>
        /// <param name="business">business</param>
        /// <param name="primaryContact">primaryContact</param>
        /// <param name="settlementBankAccount">settlementBankAccount</param>
        private void SetBusinessInfoOnNewProviderModel(NewProvider provider, Model.Business.Business business, BusinessContactPerson primaryContact, BankAccount settlementBankAccount)
        {

            Helper.ArgumentNotNull(provider, "provider");
            Helper.ArgumentNotNull(business, "business");
            Country countryOfBusiness = countryDao.GetByBusiness(business.Id);

            provider.NewProviderId = Helper.LongToGuid(business.Id).ToString();
            provider.ContactInformation = CreateContactInformation(business);
            provider.ModificationDate = business.UpdatedDateTime;
            provider.RefCode = business.ReferenceCode;
            provider.ShortName = business.ShortName;
            provider.FullName = business.Name;
            provider.MerchantId = settlementHelper.GetMerchantIdForNewProviderModel(business).Result;
            provider.AccountHolder = primaryContact != null ? GetAccountHolder(primaryContact) : string.Empty;
            provider.TaxStatus = business.IsTaxRegistered;

            provider.BankSortCode = GetBankSortCode(countryOfBusiness, settlementBankAccount);
            provider.BankAccountNumber = GetBankAccountNumber(countryOfBusiness, settlementBankAccount);
            provider.BankAccountName = settlementBankAccount != null ? settlementBankAccount.AccountName : null;

            provider.SupplyPartnerReferenceCode = SUPPLY_PARTNER_ID;
            provider.SupplyPartner = SUPPLY_PARTNER_ID;
            provider.Status = GetProviderStatus(business.BusinessStatus.Code);
            provider.IsMerchant = business.MerchantStatusEnum == MerchantStatusEnum.OwnMerchant;

        }
示例#14
0
 /// <summary>
 /// Modify Bank Account
 /// </summary>
 /// <param name="bankAccount">BankAccount</param>
 /// <returns>true if modification succeeds</returns>
 public bool ModifyBankAccount(BankAccount bankAccount)
 {
     var updatedByUserId = AuditFieldsHelper.GetUserId();
     var rowsAffected = new StoredProcedures.Business.UpdateBankAccountMapper().Execute(bankAccount, updatedByUserId);
     return rowsAffected > 0;
 }
示例#15
0
        /// <summary>
        /// Create Merchant Bank Account
        /// </summary>
        /// <param name="bankAccount">BankAccount</param>
        /// <returns>Id of created Bank Account</returns>
        public int CreateMerchantBankAccount(BankAccount bankAccount)
        {
            try
            {
                var updatedByUserId = AuditFieldsHelper.GetUserId();
                var bankAccountId = new StoredProcedures.Business.InsertBankAccountMapper().Execute(bankAccount, updatedByUserId);

                if (bankAccountId.HasValue == false)
                {
                    throw new PrimaryKeyNotSetException(ErrorFactory.CreateAndLogError(Errors.SRVEX30100, "BusinessDao.CreateMerchantBankAccount", 
                        additionalDescriptionParameters: new object[] { bankAccount.Id }));
                }

                return bankAccountId.Value;
            }
            catch (SqlException exception)
            {
                throw new ExpectedResultException(ErrorFactory.CreateAndLogError(Errors.SRVEX30099, "BusinessDao.CreateMerchantBankAccount",
                    additionalDescriptionParameters: new object[] { exception.Message }, 
                    arguments: new object[] { typeof(BankAccount).Name, bankAccount.Id }));
            }
        }