Ejemplo n.º 1
0
        private bool verifyAccount(CCAccount myAccount, CCCustomer myCustomer)
        {
            bool verified = false;

            //get specific account row from db
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "CCGetSpecificAccount";
            objCommand.Parameters.AddWithValue("@ccNum", myAccount.CCNum);
            objDB.GetDataSetUsingCmdObj(objCommand);

            //gather required fields
            string lastName  = objDB.GetField("lastName", 0).ToString();
            string firstName = objDB.GetField("firstName", 0).ToString();
            string zip       = objDB.GetField("zip", 0).ToString();
            string ccNum     = objDB.GetField("ccNum", 0).ToString();
            string expDate   = objDB.GetField("expDate", 0).ToString();
            string cvc       = objDB.GetField("cvc", 0).ToString();
            string status    = objDB.GetField("status", 0).ToString();

            //compare each account field with db field
            if (status == "Active" && lastName == myCustomer.LastName && firstName == myCustomer.FirstName && zip == myCustomer.Zip && ccNum == myAccount.CCNum && expDate == myAccount.ExpDate && cvc == myAccount.Cvc)
            {
                verified = true;
            }

            return(verified);
        }
Ejemplo n.º 2
0
        public string updateCustomer(ref CCCustomer myCustomer, int apiKey)
        {
            string updateStatus = "failed to update customer";

            if (apiKey == API_KEY)
            {
                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "CCUpdateCustomer";
                objCommand.Parameters.AddWithValue("@custID", Int32.Parse(myCustomer.CustID));
                objCommand.Parameters.AddWithValue("@lastName", myCustomer.LastName);
                objCommand.Parameters.AddWithValue("@firstName", myCustomer.FirstName);
                objCommand.Parameters.AddWithValue("@streetAddress", myCustomer.StreetAddress);
                objCommand.Parameters.AddWithValue("@city", myCustomer.City);
                objCommand.Parameters.AddWithValue("@state", myCustomer.State);
                objCommand.Parameters.AddWithValue("@zip", myCustomer.Zip);
                objCommand.Parameters.AddWithValue("@ssn", myCustomer.SSN);
                objCommand.Parameters.AddWithValue("@phone", myCustomer.Phone);

                if (objDB.DoUpdateUsingCmdObj(objCommand) != -1)
                {
                    updateStatus = "successfully updated customer";
                }
            }

            return(updateStatus);
        }
Ejemplo n.º 3
0
        //add account event handler
        protected void btnAddAccount_Click(object sender, EventArgs e)
        {
            if (validateInputs())
            {
                CreditCardSvc.CCAccount myAccount = new CreditCardSvc.CCAccount();

                myAccount.CCNum   = txtCCNum.Text;
                myAccount.CCType  = ddlCCType.SelectedValue;
                myAccount.CustID  = ddlCustomer.SelectedValue;
                myAccount.Cvc     = txtCVC.Text;
                myAccount.ExpDate = txtDate.Value;
                myAccount.Limit   = txtAmount.Value;

                CCCustomer tempCustomer = new CCCustomer();

                tempCustomer.LastName = ddlCustomer.SelectedItem.Text;

                int clientVerificationCode = ccProc.generateVerificationCode(tempCustomer);

                lblDisplay.Text    = pxy.addAccount(clientVerificationCode, Int32.Parse(myAccount.CustID), ref myAccount, API_KEY);
                lblDisplay.Visible = true;

                populateAccounts();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (validateInputs())
            {
                CCCustomer myCustomer = new CCCustomer();
                myCustomer.LastName = txtLastName.Text;
                //generate verification code
                int clientVerificationCode = ccProc.generateVerificationCode(myCustomer);

                string[] transactionArray = new string[9];

                //assign values to transaction array
                transactionArray[LNAME_INDEX] = txtLastName.Text;
                transactionArray[FNAME_INDEX] = txtFirstName.Text;
                transactionArray[CCNUM_INDEX] = txtCCNum.Text;
                transactionArray[DATE_INDEX]  = txtDate.Value;
                transactionArray[CVC_INDEX]   = txtCVC.Text;
                transactionArray[ZIP_INDEX]   = txtZip.Text;
                transactionArray[TYPE_INDEX]  = ddlTransactionType.SelectedValue;
                transactionArray[AMT_INDEX]   = txtAmount.Value;
                transactionArray[CODE_INDEX]  = clientVerificationCode.ToString();

                //process transaction from web service, receive return array
                string[] transactionReturnInfo = pxy.processTransaction(ref transactionArray, API_KEY);

                string acceptOrDecline = transactionReturnInfo[ACCEPTORDECLINE_INDEX];
                string transactionCode = transactionReturnInfo[TRANSACTIONCODE_INDEX];
                string transactionDate = transactionReturnInfo[TRANSACTIONDATE_INDEX];
                string transactionTime = transactionReturnInfo[TRANSACTIONTIME_INDEX];

                string status = "";

                if (transactionCode == "1")
                {
                    status             = "Thank you for your business. The order was completed successfully.";
                    lblStatus.CssClass = "alert alert-success";
                }
                else if (transactionCode == "2")
                {
                    status             = "The credit card transaction was declined -  Please enter another credit card to complete this order.";
                    lblStatus.CssClass = "alert alert-danger";
                }
                else if (transactionCode == "3")
                {
                    status = "There was an error with the transaction. Please review the Credit Card infomation you entered " +
                             "or enter another credit card to complete the transaction.";
                    lblStatus.CssClass = "alert alert-danger";
                }
                else
                {
                    status             = "There was a problem with the credit card transaction. Unknown response code.";
                    lblStatus.CssClass = "alert alert-danger";
                }
                lblStatus.Text     = status;
                lblStatus.Visible  = true;
                lblDisplay.Visible = true;
                lblDisplay.Text    = "Transaction: " + acceptOrDecline + " - Return Code: " + transactionCode + " - " + transactionDate + " - " + transactionTime;
            }
        }
Ejemplo n.º 5
0
        public string addAccount(int clientVerificationCode, int custID, ref CCAccount myAccount, int apiKey)
        {
            string addStatus = "failed to add account";

            //create customer to match client input
            CCCustomer myCustomer = new CCCustomer();

            //pull specified customer from database
            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "CCGetSpecificCustomer";
            objCommand.Parameters.AddWithValue("@custID", custID);

            DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand);

            //set property
            myCustomer.LastName = objDB.GetField("lastName", 0).ToString();

            //create server verification code
            int serverVerificationCode = ccProc.generateVerificationCode(myCustomer);

            //check against client verfication code -- if match add account
            if (clientVerificationCode == serverVerificationCode && apiKey == API_KEY)
            {
                SqlCommand objCommand1 = new SqlCommand();
                objCommand1.CommandType = CommandType.StoredProcedure;
                objCommand1.CommandText = "CCAddAccount";
                objCommand1.Parameters.AddWithValue("@ccNum", myAccount.CCNum);
                objCommand1.Parameters.AddWithValue("@ccType", myAccount.CCType);
                objCommand1.Parameters.AddWithValue("@custID", custID);
                objCommand1.Parameters.AddWithValue("@cvc", Int32.Parse(myAccount.Cvc));
                objCommand1.Parameters.AddWithValue("@expDate", myAccount.ExpDate);
                decimal limit;
                Decimal.TryParse(myAccount.Limit, out limit);
                objCommand1.Parameters.AddWithValue("@limit", limit);

                if (objDB.DoUpdateUsingCmdObj(objCommand1) != -1)
                {
                    addStatus = "successfully added account";
                }
            }

            return(addStatus);
        }
Ejemplo n.º 6
0
        public string[] processTransaction(ref string[] transactionInfo, int apiKey)
        {
            //create customer, transaction, and account objects
            CCCustomer    myCustomer    = new CCCustomer();
            CCAccount     myAccount     = new CCAccount();
            CCTransaction myTransaction = new CCTransaction();

            //initialize return values
            myTransaction.Date = "";
            myTransaction.Time = "";
            string acceptOrDecline = "Decline";
            string transactionCode = "0";


            //retrieve and assign verification codes
            myCustomer.LastName = transactionInfo[LNAME_INDEX];
            string serverVerificationCode = ccProc.generateVerificationCode(myCustomer).ToString();
            string clientVerificationCode = transactionInfo[CODE_INDEX];

            //check if verification codes match, if so -- proceed with account verification
            if (serverVerificationCode == clientVerificationCode && apiKey == API_KEY)
            {
                //assign values to customer and account objects
                myCustomer.FirstName = transactionInfo[FNAME_INDEX];
                myCustomer.Zip       = transactionInfo[ZIP_INDEX];
                myAccount.CCNum      = transactionInfo[CCNUM_INDEX];
                myAccount.ExpDate    = transactionInfo[DATE_INDEX];
                myAccount.Cvc        = transactionInfo[CVC_INDEX];



                //verify account information, if so -- process transaction
                if (verifyAccount(myAccount, myCustomer))
                {
                    myTransaction.Amount = transactionInfo[AMT_INDEX];
                    myTransaction.Type   = transactionInfo[TYPE_INDEX];
                    myTransaction.Date   = DateTime.Today.ToString("MM/dd/yyyy");
                    myTransaction.Time   = DateTime.Now.ToString("HH:mm");

                    //check for transaction type -- perform desired transaction
                    if (myTransaction.Type == "Payment")
                    {
                        transactionCode = makePayment(myAccount, myTransaction);

                        if (transactionCode == "1") //successful transaction
                        {
                            acceptOrDecline = "Accept";
                        }
                    }
                    else if (myTransaction.Type == "Purchase")
                    {
                        transactionCode = chargeAccount(myAccount, myTransaction);

                        if (transactionCode == "1") //successful transaction
                        {
                            acceptOrDecline = "Accept";
                        }
                    }
                    else
                    {
                        transactionCode = "99"; //unknown transaction type
                    }
                }
                else
                {
                    transactionCode = "3"; //account information invalid (unverified)
                }
            }
            else
            {
                //verification string invalid
            }

            //assign values to return array
            string[] transactionReturnInfo = new string[4];
            transactionReturnInfo[ACCEPTORDECLINE_INDEX] = acceptOrDecline;
            transactionReturnInfo[TRANSACTIONCODE_INDEX] = transactionCode;
            transactionReturnInfo[TRANSACTIONDATE_INDEX] = myTransaction.Date;
            transactionReturnInfo[TRANSACTIONTIME_INDEX] = myTransaction.Time;



            //return transaction array
            return(transactionReturnInfo);
        }