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 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.º 4
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);
        }