コード例 #1
0
        public void CreateSubAccount_InvalidSecretKey_ReturnsError()
        {
            // Arrange
            string bankCode              = AppConstants.ACCESS_BANK_CODE;
            string accountNumber         = AppConstants.VALID_ACCESSBANK_ACCOUNT_NUMBER;
            string businessName          = AppConstants.SAMPLE_BUSINESS_NAME;
            string businessEmail         = AppConstants.SAMPLE_EMAIL;
            double splitValue            = 0.5;
            string businessContact       = AppConstants.SAMPLE_CUSTOMER_NAME;
            string businessContactMobile = AppConstants.SAMPLE_PHONE_NUMBER;
            string businessMobile        = AppConstants.SAMPLE_PHONE_NUMBER;

            var flutterwaveSecretKey = "";

            _subAccounts = new SubAccounts(new FlutterwaveApi(flutterwaveSecretKey));

            // Act
            var result = _subAccounts.CreateSubAccount(bankCode,
                                                       accountNumber,
                                                       businessName,
                                                       businessEmail,
                                                       Country.Nigeria,
                                                       SplitType.Percentage,
                                                       splitValue,
                                                       businessContact,
                                                       businessContactMobile,
                                                       businessMobile);

            // Assert
            Assert.NotNull(result);
            Assert.IsType <CreateSubAccountResponse>(result);
            Assert.Equal(expected: AppConstants.ERROR_STATUS, actual: result.Status);
            Assert.Equal(expected: AppConstants.INVALID_AUTHORIZATION_KEY_ERROR_MESSAGE, actual: result.Message);
            Assert.Null(result.Data);
        }
コード例 #2
0
        public SubAccountsTests()
        {
            // Get rave secret key from environmental variables
            var flutterwaveSecretKey = Environment.GetEnvironmentVariable("FLUTTERWAVESECRETKEY");

            _subAccounts = new SubAccounts(new FlutterwaveApi(flutterwaveSecretKey));
        }
コード例 #3
0
        public string GetSubAccountDisplayForSplit(Split split)
        {
            if (string.IsNullOrWhiteSpace(split.SubAccount))
            {
                return(string.Empty);
            }

            var subAccount =
                SubAccounts.FirstOrDefault(x => x.AccountNumber == split.Account && x.SubAccountNumber == split.SubAccount);

            return(subAccount == null ? split.SubAccount : string.Format("{0} ({1})", subAccount.Name, subAccount.SubAccountNumber));
        }
コード例 #4
0
 private bool Parse(int srNo, string block, string[] saperator)
 {
     try
     {
         int                iCount      = 0;
         StringBuilder      newSubBlock = new StringBuilder();
         TransactionAccount subAccount;
         string             subAccountNumber = string.Empty;
         using (StringReader reader = new StringReader(block))
         {
             string line;
             bool   subAccountStarted = false;
             while ((line = reader.ReadLine()) != null)
             {
                 //Considering "010100" sub account as main account
                 if (line.StartsWith("010001"))
                 {
                     AccountNumber = Util.ReplacePrefixZeros(line.ToString().Substring(33, 17));
                 }
                 if (line.StartsWith("010100"))
                 {
                     subAccountStarted = true;
                     iCount++;
                     if (iCount == 1)
                     {
                         subAccountNumber = Util.ReplacePrefixZeros(line.ToString().Substring(33, 17));
                     }
                     else
                     {
                         subAccount = new TransactionAccount(iCount, newSubBlock);
                         subAccount.AccountNumber = subAccountNumber;
                         SubAccounts.Add(subAccount);
                         subAccountNumber = Util.ReplacePrefixZeros(line.ToString().Substring(33, 17));
                         newSubBlock      = new StringBuilder();
                     }
                 }
                 if (subAccountStarted)
                 {
                     newSubBlock.AppendLine(line);
                 }
             }
         }
         subAccount = new TransactionAccount(iCount, newSubBlock);
         subAccount.AccountNumber = subAccountNumber;
         SubAccounts.Add(subAccount);
         return(true);
     }
     catch (Exception ex) { return(false); }
 }
コード例 #5
0
        public void GetSubAccounts_InvalidSecretKey_ReturnsError()
        {
            // Arrange
            var flutterwaveSecretKey = "";

            _subAccounts = new SubAccounts(new FlutterwaveApi(flutterwaveSecretKey));

            // Act
            var result = _subAccounts.GetSubAccounts();

            // Assert
            Assert.NotNull(result);
            Assert.IsType <GetSubAccountsResponse>(result);
            Assert.Equal(expected: AppConstants.ERROR_STATUS, actual: result.Status);
            Assert.Equal(expected: AppConstants.INVALID_AUTHORIZATION_KEY_ERROR_MESSAGE, actual: result.Message);
            Assert.Null(result.Data);
        }