Exemplo n.º 1
0
        public TransactionResponse GetCount(string securityToken, string accountNumber)
        {
            var response = new TransactionResponse();

            if (!string.IsNullOrEmpty(securityToken))
            {
                try
                {
                    UDIGenInq generalInquiry = new UDIGenInq();
                    if (generalInquiry.VerifySecurityToken(securityToken, accountNumber))
                    {
                        if (!string.IsNullOrEmpty(_connectionString))
                        {
                            using (var conn = new SqlConnection(_connectionString))
                            {
                                try
                                {
                                    conn.Open();
                                    var cmd = new SqlCommand("spSelectTransactionCount", conn);
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.Add("@AccountNoTransferTo", SqlDbType.VarChar).Value = accountNumber;
                                    int count = Convert.ToInt32(cmd.ExecuteScalar());
                                    response.Count        = count;
                                    response.ResponseCode = Convert.ToInt32(TransactionStatus.Success).ToString().PadLeft(2, '0');
                                }
                                catch (Exception ex)
                                {
                                    Utility.LogMessage("GetTransactionsCount Error for Account Number - " + accountNumber + "-" + ex.ToString());
                                    response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                                }
                                finally
                                {
                                    conn.Close();
                                }
                            }
                        }
                    }
                    else
                    {
                        response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0') + " OR " + Convert.ToInt16(TransactionStatus.NoAccountFound).ToString().PadLeft(2, '0');
                    }
                }
                catch (Exception ex)
                {
                    Utility.LogMessage("Error Occurred while get the Transaction count- AccountNumber-" + accountNumber + "-" + ex.Message.ToString());
                    response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                }
            }
            else
            {
                response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
            }
            return(response);
        }
Exemplo n.º 2
0
        public TransactionResponse GetTransactionDetails(string securityToken, int transactionId)
        {
            var response = new TransactionResponse();


            Transaction transaction = null;

            if (!string.IsNullOrEmpty(securityToken))
            {
                try
                {
                    UDIGenInq generalInquiry = new UDIGenInq();
                    string    accountNumber  = string.Empty;
                    transaction = GetTransaction(transactionId);
                    if (generalInquiry.VerifySecurityToken(securityToken, transaction.AccountNoTransferTo))
                    {
                        response.TransactionObj = transaction;
                        response.ResponseCode   = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                    }
                    else
                    {
                        response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0') + " OR " + Convert.ToInt16(TransactionStatus.NoAccountFound).ToString().PadLeft(2, '0');
                    }
                }
                catch (Exception ex)
                {
                    Utility.LogMessage("SecurityToken is empty for TransactionID :" + transactionId + "-" + ex.Message);
                    response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                }
            }
            else
            {
                Utility.LogMessage("SecurityToken is empty for TransactionID :" + transactionId);
                response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
            }
            return(response);
        }
Exemplo n.º 3
0
        public TransferFromAccount GetTransferFromAccount(string accountNumber, string securityToken)
        {
            TransferFromAccount fromAccount = null;

            if (!string.IsNullOrEmpty(accountNumber))
            {
                // Utility.LogMessage("INQ by user - " + userName + " - on Account No - "
                //    + Utility.MaskLoggingInfo(accountNumber, 6, 6));

                UDIGenInq generalInquiry = new UDIGenInq();
                generalInquiry.ProcessByAcct(securityToken, accountNumber);


                UDIBinInfo binInfo = new UDIBinInfo();
                binInfo.LookupInfoByAccountNumber(accountNumber);

                if (string.IsNullOrEmpty(generalInquiry.Message.Trim()))
                {
                    fromAccount = new TransferFromAccount()
                    {
                        AccountNoTransferTo = accountNumber,
                        CorpID             = generalInquiry.Corp.PadLeft(6, Convert.ToChar("0")),
                        InstID             = generalInquiry.InstID,
                        InstName           = string.IsNullOrEmpty(generalInquiry.InstName.Trim()) ? binInfo.InstName : generalInquiry.InstName,
                        ProdSub            = generalInquiry.Product,
                        HostSystem         = binInfo.HostSystem.ToUpper(),
                        AssociationID      = binInfo.Association,
                        CardHolderAddress1 = generalInquiry.Address1,
                        CardHolderAddress2 = generalInquiry.Address2,
                        CardHolderAddress3 = generalInquiry.Address3,
                        CardHolderCity     = generalInquiry.City,
                        CardHolderState    = generalInquiry.State,
                        CardHolderZip      = generalInquiry.Zip,
                        CardHolderPhone    = generalInquiry.HomePhone,

                        UDIResponse = new UDIResponse()
                        {
                            Plastic1Type         = generalInquiry.Plastic1Type,
                            TypeOfCard           = generalInquiry.CommercialCard,
                            Name1                = generalInquiry.Name1.Trim(),
                            Name2                = generalInquiry.Name2.Trim(),
                            Name3                = generalInquiry.Name3.Trim(),
                            Name4                = generalInquiry.Name4.Trim(),
                            BinOwner             = binInfo.BinOwner,
                            BlockCode            = !string.IsNullOrEmpty(generalInquiry.BlockCode) && generalInquiry.BlockCode.Length == 0 ? "_" : generalInquiry.BlockCode,
                            ReclassCode          = !string.IsNullOrEmpty(generalInquiry.ReclassCode) && generalInquiry.ReclassCode.Length == 0 ? "_" : generalInquiry.ReclassCode,
                            Embossing            = generalInquiry.EmbossingLine4,
                            AvailableAmount      = generalInquiry.AvailableAmount.FormatCurrency(),
                            AvailableCash        = generalInquiry.AvailableCashAmount.FormatCurrency(),
                            CardActivationStatus = generalInquiry.CardActvStatus,
                            PreviousAccount      = generalInquiry.CrossRefNo,
                        },
                    };

                    if (fromAccount.UDIResponse.TypeOfCard == "50" || fromAccount.UDIResponse.TypeOfCard == "51" || string.IsNullOrEmpty(fromAccount.UDIResponse.Name1.Trim()))
                    {
                        fromAccount.CardHolderName = fromAccount.UDIResponse.Name2;
                    }
                    else
                    {
                        fromAccount.CardHolderName = fromAccount.UDIResponse.Name1;
                    }

                    if (fromAccount.HostSystem == "FS" || fromAccount.HostSystem == "FM")
                    {
                        //tbs
                        if (generalInquiry.CurrExpireDate.Length >= 6)
                        {
                            fromAccount.UDIResponse.CurrExpireDate = generalInquiry.CurrExpireDate.Substring(4, 2)
                                                                     + generalInquiry.CurrExpireDate.Substring(2, 2);
                        }
                        else
                        {
                            fromAccount.UDIResponse.CurrExpireDate = generalInquiry.CurrExpireDate.Substring(2, 2)
                                                                     + generalInquiry.CurrExpireDate.Substring(0, 2);
                        }
                    }
                    else
                    {
                        //b2k
                        fromAccount.UDIResponse.CurrExpireDate = generalInquiry.CurrExpireDate;
                    }
                }
            }

            return(fromAccount);
        }
Exemplo n.º 4
0
        public TransactionResponse GetSelectTransactions(string securityToken, string accountNo)
        {
            var response = new TransactionResponse();


            if (!string.IsNullOrEmpty(securityToken))
            {
                try
                {
                    UDIGenInq generalInquiry = new UDIGenInq();
                    if (generalInquiry.VerifySecurityToken(securityToken, accountNo))
                    {
                        var selectTransactions = new List <SelectTransactions>();

                        if (!string.IsNullOrEmpty(_connectionString))
                        {
                            using (var conn = new SqlConnection(_connectionString))
                            {
                                try
                                {
                                    conn.Open();

                                    var cmd = new SqlCommand("spSelectTransactionGrid", conn);
                                    cmd.Parameters.Clear();
                                    cmd.CommandType = CommandType.StoredProcedure;
                                    cmd.Parameters.Add("@AccountNoTransferTo", SqlDbType.VarChar).Value = accountNo;

                                    var dr = cmd.ExecuteReader();

                                    while (dr.Read())
                                    {
                                        selectTransactions.Add(new SelectTransactions()
                                        {
                                            CanEdit             = dr.GetString(dr.GetOrdinal("Edit")) == "Edit" ? true : false,
                                            TransactionId       = dr.GetInt32(dr.GetOrdinal("TransactionID")),
                                            AccountNoTransferTo = dr.GetString(dr.GetOrdinal("AccountNoTransferTo")),
                                            TransactionDate     = dr.GetString(dr.GetOrdinal("TransactionDate")),
                                            AccountNoPayoff     = dr.GetString(dr.GetOrdinal("AccountNoPayOff")),
                                            Balance             = dr.GetDecimal(dr.GetOrdinal("Balance")),
                                            PayeeName           = dr.GetString(dr.GetOrdinal("PayeeName")),
                                            Status      = dr.GetString(dr.GetOrdinal("CurStatus")),
                                            ProcessDate = dr.GetString(dr.GetOrdinal("ProcessDate"))
                                        });
                                    }

                                    dr.Close();
                                    response.TransactionList = selectTransactions;
                                    response.ResponseCode    = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                                }
                                catch (Exception ex)
                                {
                                    Utility.LogMessage("Error in GetAllBTsForAccountNumber with Account Number " + accountNo + "-" + ex.Message.ToString());
                                    response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                                }
                                finally
                                {
                                    conn.Close();
                                }
                            }
                        }
                    }
                    else
                    {
                        response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0') + " OR " + Convert.ToInt16(TransactionStatus.NoAccountFound).ToString().PadLeft(2, '0');
                    }
                }
                catch (Exception)
                {
                    response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
                }
            }
            else
            {
                response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
            }

            return(response);
        }
Exemplo n.º 5
0
        public TransactionResponse Insert(Transaction transaction, string securityToken)
        {
            var response = new TransactionResponse();


            if (!string.IsNullOrEmpty(securityToken))
            {
                try
                {
                    UDIGenInq generalInquiry = new UDIGenInq();

                    if (!string.IsNullOrEmpty(transaction.AccountNoTransferTo))
                    {
                        TransferFromAccount fromAccount = GetTransferFromAccount(transaction.AccountNoTransferTo, securityToken);

                        transaction.FromAccount = fromAccount;

                        if (!string.IsNullOrEmpty(_connectionString) &&
                            transaction != null && transaction.FromAccount != null &&
                            !string.IsNullOrEmpty(transaction.AccountNoPayOff))
                        {
                            try
                            {
                                bool authorize = false;

                                string logMessage = "Transfer From Account "
                                                    + Utility.MaskLoggingInfo(transaction.FromAccount.AccountNoTransferTo, 6, 6)
                                                    + " To Account " + Utility.MaskLoggingInfo(transaction.AccountNoPayOff, 6, 6)
                                                    + " for $" + transaction.Balance;

                                Utility.LogMessage("BT by user - " + transaction.UserID + logMessage);


                                //new transaction
                                authorize = true;
                                transaction.ActionTaken = "T";

                                //check for duplicate transaction
                                response.PossibleDuplicate = IsDuplicateTransaction(
                                    transaction.AccountNoTransferTo, transaction.AccountNoPayOff, transaction.Balance);


                                if (authorize)
                                {
                                    var authRequest = new AuthRequest()
                                    {
                                        AccountNoPayOff     = transaction.AccountNoPayOff,
                                        AccountNoTransferTo = transaction.AccountNoTransferTo,
                                        AccountType         = transaction.FromAccount.UDIResponse.Plastic1Type,
                                        Balance             = transaction.Balance,
                                        CurrExpireDate      = transaction.FromAccount.UDIResponse.CurrExpireDate,
                                        PostingIndicator    = transaction.ProcessingType,
                                        SecurityToken       = securityToken
                                    };

                                    var authResponse = Utility.Authorize(authRequest);

                                    if (authResponse != null && authResponse.AuthCode == "00")
                                    {
                                        response.ResponseCode = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                                    }
                                    else
                                    {
                                        transaction.ActionTaken = "F";
                                        response.ResponseCode   = Convert.ToInt16(TransactionStatus.Declined).ToString().PadLeft(2, '0');
                                    }
                                }

                                // if after 7 pm add day
                                transaction.PostingDate = (DateTime.Now.Hour > 19)
                                    ? DateTime.Now.AddDays(1).ToShortDateString()
                                    : DateTime.Now.ToShortDateString();

                                response.TransactionID = InsertTransaction(transaction);

                                response.ResponseCode = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                            }
                            catch (Exception ex)
                            {
                                Utility.LogMessage("Error Occurred while new Balance Transfer: AccountNumber-" + transaction.AccountNoTransferTo + "-" + ex.Message.ToString());
                                transaction.ActionTaken = "F";
                                response.ResponseCode   = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                            }
                        }
                    }
                    else
                    {
                        response.ResponseCode = Convert.ToInt16(TransactionStatus.NoAccountFound).ToString().PadLeft(2, '0');
                    }
                }
                catch (Exception ex)
                {
                    Utility.LogMessage("Error Occurred while new Balance Transfer: AccountNumber-" + transaction.AccountNoTransferTo + "-" + ex.Message.ToString());
                    response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                }
            }
            else
            {
                response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
            }

            return(response);
        }
Exemplo n.º 6
0
        public TransactionResponse UpdateOrDelete(Transaction transaction, string securityToken)
        {
            var response = new TransactionResponse();


            if (!string.IsNullOrEmpty(_connectionString) &&
                transaction != null && transaction.TransactionID.ToString().Length > 0)
            {
                if (!string.IsNullOrEmpty(securityToken))
                {
                    try
                    {
                        Transaction oldTransaction = GetTransaction(transaction.TransactionID);

                        UDIGenInq generalInquiry = new UDIGenInq();
                        if (generalInquiry.VerifySecurityToken(securityToken, oldTransaction.AccountNoTransferTo))
                        {
                            try
                            {
                                bool authorize = false;

                                if (transaction.Action.Equals('U'))
                                {
                                    //updating the transaction
                                    if ((oldTransaction.ProcessFlag.ToString().Equals("False")) && (oldTransaction.ActionTaken.Equals("E") || oldTransaction.ActionTaken.Equals("T") || oldTransaction.ActionTaken.Equals("F")))
                                    {
                                        response.ResponseCode = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');

                                        //always authorize if amount is changed
                                        if (transaction.Balance > 0)
                                        {
                                            authorize = (oldTransaction.Balance != transaction.Balance);
                                        }


                                        if (authorize)
                                        {
                                            TransferFromAccount fromAccount = GetTransferFromAccount(oldTransaction.AccountNoTransferTo, securityToken);
                                            transaction.FromAccount = fromAccount;
                                            var authRequest = new AuthRequest()
                                            {
                                                AccountNoPayOff     = transaction.AccountNoPayOff,
                                                AccountNoTransferTo = transaction.FromAccount.AccountNoTransferTo,
                                                AccountType         = transaction.FromAccount.UDIResponse.Plastic1Type,
                                                Balance             = transaction.Balance,
                                                CurrExpireDate      = transaction.FromAccount.UDIResponse.CurrExpireDate,
                                                PostingIndicator    = transaction.ProcessingType,
                                                SecurityToken       = securityToken
                                            };

                                            var authResponse = Utility.Authorize(authRequest);

                                            if (authResponse != null && authResponse.AuthCode == "00")
                                            {
                                                response.ResponseCode = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                                            }
                                            else
                                            {
                                                transaction.ActionTaken = "F";
                                                response.ResponseCode   = Convert.ToInt16(TransactionStatus.Declined).ToString().PadLeft(2, '0');
                                            }
                                        }

                                        // if after 7 pm add day
                                        transaction.PostingDate = (DateTime.Now.Hour > 19)
                                                ? DateTime.Now.AddDays(1).ToShortDateString()
                                                : DateTime.Now.ToShortDateString();

                                        transaction.UserID     = transaction.UserID.ToUpper();
                                        response.TransactionID = UpdateTransaction(transaction);
                                        response.ResponseCode  = Convert.ToInt16(TransactionStatus.Success).ToString().PadLeft(2, '0');
                                    }
                                    else
                                    {
                                        response.ResponseCode = Convert.ToInt16(TransactionStatus.BTCannotBeModified).ToString().PadLeft(2, '0');
                                    }
                                }
                                else
                                {
                                    if (oldTransaction.ProcessFlag.ToString().Equals("False") && !oldTransaction.ActionTaken.Equals("D"))
                                    {
                                        response = Delete(transaction, oldTransaction.UserID);
                                    }
                                    else
                                    {
                                        response.ResponseCode = Convert.ToInt16(TransactionStatus.BTCannotBeModified).ToString().PadLeft(2, '0');
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Utility.LogMessage("Error Occurred while update Balance Transfer: TransactionID-" + transaction.TransactionID + "-" + ex.Message.ToString());
                                transaction.ActionTaken = "F";
                                response.ResponseCode   = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                            }
                        }
                        else
                        {
                            response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
                        }
                    }
                    catch (Exception ex)
                    {
                        Utility.LogMessage("Error Occurred while update Balance Transfer: TransactionID-" + transaction.TransactionID + "-" + ex.Message.ToString());
                        response.ResponseCode = Convert.ToInt16(TransactionStatus.UnexpectedError).ToString().PadLeft(2, '0');
                    }
                }
                else
                {
                    response.ResponseCode = Convert.ToInt16(TransactionStatus.SecurityTokenInvalid).ToString().PadLeft(2, '0');
                }
            }

            return(response);
        }