Ejemplo n.º 1
0
        public ActionResult YourAccount()
        {
            Customer    customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
            Shipping    ship     = null;
            Billing     bill     = null;
            Credit_Card card     = null;

            try
            {
                ship = db.Shippings.Where(x => x.CustomerID == customer.CustomerID).First();
            } catch (Exception e)
            {
            }

            try
            {
                bill = db.Billings.Where(x => x.CustomerID == customer.CustomerID).First();
            } catch (Exception e)
            {
            }

            try
            {
                card = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
            }
            catch (Exception e)
            {
            }

            InvoiceModel invoice = new InvoiceModel();

            invoice.Invoices = new List <Invoice>();


            if (card != null)
            {
                var invoices = db.Invoices.Where(x => x.CardID == card.CardID);
                foreach (var item in invoices)
                {
                    invoice.Invoices.Add(item);
                }
                invoice.CardID = card.CardID;
                invoice.Card   = card;
            }
            if (ship != null)
            {
                invoice.ShippingID = ship.ShipID;
                invoice.Shipping   = ship;
            }
            if (bill != null)
            {
                invoice.Billing   = bill;
                invoice.BillingID = bill.BillID;
            }
            invoice.CustomerID = customer.CustomerID;



            return(View(invoice));
        }
Ejemplo n.º 2
0
        //
        // This method is designed to load prompts for type "O" - optional data for fleet cards
        // type "F" - fuel prompts are loaded along with the profile in Loadprofile method (card profile class)
        /// <summary>
        /// Method to load prompts
        /// </summary>
        /// <param name="cardPrompts">Card prompts</param>
        /// <param name="cc">Credit card</param>
        /// <param name="profileId">Profile Id</param>
        public void Load_Prompts(ref CardPrompts cardPrompts, Credit_Card cc, string profileId)
        {
            //2013 11 08 - Reji - Wex Fleet Card Integration
            var profPromptLinkClause = " And 1=2 ";

            if (cc != null)
            {
                if (!string.IsNullOrEmpty(cc.Crd_Type))
                {
                    profPromptLinkClause = "";
                }


                if (cc.Crd_Type == "F" && cc.GiftType.ToUpper() == "W")
                {
                    // profPromptLinkClause = ProfPromptLinkList(cc, profileId);
                }
            }

            var prompts = _cardService.LoadCardPrompts(profileId);

            //2013 11 08 - Reji - Wex Fleet Card Integration - End

            foreach (var prompt in prompts)
            {
                cardPrompts.Add(prompt.MaxLength, prompt.MinLength, prompt.PromptMessage, prompt.PromptSeq, prompt.PromptID, "", prompt.PromptID.ToString());
            }
        }
        /// <summary>
        /// Method to set close batch number
        /// </summary>
        /// <param name="cc">Credit card</param>
        public void SetCloseBatchNumber(Credit_Card cc)
        {
            //Save to the CloseBatch table
            _connection = new SqlConnection(GetConnectionString(DataSource.CSCTrans));
            if (_connection.State == ConnectionState.Closed)
            {
                _connection.Open();
            }
            _dataTable = new DataTable();
            _adapter   = new SqlDataAdapter("select * from CloseBatch", _connection);
            _adapter.Fill(_dataTable);

            var fields = _dataTable.NewRow();

            fields["BatchNumber"] = cc.Sequence_Number;
            fields["TerminalID"]  = cc.TerminalID;
            fields["BatchDate"]   = cc.Trans_Date;
            fields["BatchTime"]   = cc.Trans_Time;
            fields["Report"]      = cc.Report;
            _dataTable.Rows.Add(fields);
            SqlCommandBuilder builder = new SqlCommandBuilder(_adapter);

            _adapter.InsertCommand = builder.GetInsertCommand();
            _adapter.Update(_dataTable);
            _connection.Close();
            _adapter?.Dispose();

            //Update all the Tills and Trans for this TerminalID
            UpdateTables(cc, DataSource.CSCTills);
            UpdateTables(cc, DataSource.CSCTrans);
        }
Ejemplo n.º 4
0
        //   end



        //2013 11 08 - Reji - Wex Fleet Card Integration
        /// <summary>
        /// Method to get profile prompt ist
        /// </summary>
        /// <param name="cc">Credit card</param>
        /// <param name="profileId">Profile id</param>
        /// <returns>Profile prompt</returns>
        private string ProfPromptLinkList(Credit_Card cc, string profileId)
        {
            string returnValue;

            var promptCodeStr = cc.Track2.Replace(";" + cc.Cardnumber + "=", "").Replace("?", "");

            promptCodeStr = promptCodeStr.Substring(4, 1) + promptCodeStr.Substring(16, 1);

            if (!_policyManager.WEXEnabled)
            {
                returnValue = " And 1=2 ";
            }
            else if (promptCodeStr == "00")
            {
                returnValue = " And 1=2 ";
            }
            else if (string.IsNullOrEmpty(promptCodeStr))
            {
                returnValue = " AND A.PromptID=5009 ";
            }
            else
            {
                var cardPromptList = "0";
                //select [PromptID] from CardProfilePromptLink where CardPromptID='" & PromptCodeStr & "'

                cardPromptList = cardPromptList + _cardService.GetPromptIds(promptCodeStr, profileId);
                returnValue    = " AND A.PromptID in (" + cardPromptList + ") ";
            }
            return(returnValue);
        }
 public ActionResult DisplayUserInvoice(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     else
     {
         Invoice invoice = db.Invoices.Where(i => i.invoice_id == id).FirstOrDefault();
         int     user_id = db.Users.Where(u => u.username == this.User.Identity.Name).FirstOrDefault().user_id;
         if (invoice.user_id != user_id)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         else
         {
             User                    user        = db.Users.Where(u => u.user_id == user_id).FirstOrDefault();
             int                     address_id  = db.Invoice_Address.Where(a => a.invoice_id == invoice.invoice_id).FirstOrDefault().address_id;
             Address                 address     = db.Addresses.Where(a => a.address_id == address_id).FirstOrDefault();
             Credit_Card             credit_card = db.Credit_Card.Where(c => c.credit_card_id == invoice.credit_card_id).FirstOrDefault();
             IEnumerable <Line_Item> items       = db.Line_Item.Where(l => l.invoice_id == id).Include(l => l.Game).ToList();
             return(View(new UserInvoiceViewModel {
                 invoice = invoice, user = user, address = address, credit_card = credit_card, items = items
             }));
         }
     }
 }
Ejemplo n.º 6
0
        public ActionResult Checkout(string Name)
        {
            Customer customer = db.Customers.Where(x => x.Username == Name).First();

            //see if they have a shipping address
            try
            {
                Shipping ship = db.Shippings.Where(x => x.CustomerID == customer.CustomerID).First();
            } catch (Exception e)
            {
                //RedirectToRoute("Shipping/Create");
                return(RedirectToAction("CreateForCheckout", "Shipping", null));
            }
            //see if they have a billing address
            try
            {
                Billing bill = db.Billings.Where(x => x.CustomerID == customer.CustomerID).First();
            }
            catch (Exception e)
            {
                return(RedirectToAction("CreateForCheckout", "Billing", null));
            }
            //see if they have a credit card
            try
            {
                Credit_Card card = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
            }
            catch (Exception e)
            {
                return(RedirectToAction("CreateForCheckout", "CreditCard", null));
            }
            return(RedirectToAction("ReviewInvoice", "Invoice", null));
        }
        /// <summary>
        /// Method to initialise pin pad
        /// </summary>
        /// <param name="cc"></param>
        /// <param name="emvProcess"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        private bool InitializePinpad(ref Credit_Card cc, bool emvProcess, out ErrorMessage error)
        {
            bool   returnValue  = false;
            object processTimer = null;

            SendToTps("InitInside" + "," + "Debit" + ",1,,,,,,,,,,,,,,,,", ref cc, emvProcess);

            processTimer = DateAndTime.Timer;
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            error = new ErrorMessage
            {
                MessageStyle = _resourceManager.CreateMessage(offSet, 0, 8139, null, CriticalOkMessageType)
            };

            while (Convert.ToInt32(DateAndTime.Timer - Convert.ToDouble(processTimer)) < 90)
            {
                if (cc.Response.Length > 0)
                {
                    break;
                }
            }
            returnValue = cc.Response.ToUpper() == "APPROVED";
            return(returnValue);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Credit_Card credit_Card = db.Credit_Card.Find(id);

            db.Credit_Card.Remove(credit_Card);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        // This test is responsible for checking the constructor
        public void Credit_CardTest_ConstructorWithNoValues_ShouldPass()
        {
            // Arrange
            // Act
            Credit_Card creditCard = new Credit_Card();

            // Assert
            Assert.IsNotNull(creditCard);
        }
Ejemplo n.º 10
0
        public ActionResult ReviewInvoice()
        {
            Customer     customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
            Shopping     cart     = db.Shoppings.Where(x => x.CustomerID == customer.CustomerID).First();
            Shipping     ship     = db.Shippings.Where(x => x.CustomerID == customer.CustomerID).First();
            Billing      bill     = db.Billings.Where(x => x.CustomerID == customer.CustomerID).First();
            Credit_Card  card     = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
            List <Book>  results  = new List <Book>();
            InvoiceModel invoice  = new InvoiceModel();

            invoice.Prices     = new List <decimal>();
            invoice.Amounts    = new List <int>();
            invoice.Publishers = new List <string>();

            using (SqlConnection connection = new SqlConnection("data source=cs.cofo.edu;initial catalog=gvaught;persist security info=True;user id=gvaught;password=beargav;MultipleActiveResultSets=True;App=EntityFramework"))
            {
                SqlCommand cmd = new SqlCommand("usp_GetCart", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter p1 = new SqlParameter("@cartID", SqlDbType.Int);
                SqlParameter p2 = new SqlParameter("@custID", SqlDbType.Int);
                p1.Value = cart.CartID;
                p2.Value = customer.CustomerID;
                cmd.Parameters.Add(p1);
                cmd.Parameters.Add(p2);
                connection.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Book book = new Book();
                    book.BookID      = (int)dr["BookID"];
                    book.Title       = (string)dr["Title"];
                    book.ISBN        = (string)dr["ISBN"];
                    book.PublisherID = (int)dr["PublisherID"];
                    book.PublishYear = (int)dr["PublishYear"];
                    book.PageNum     = (int)dr["PageNum"];
                    book.Language    = (string)dr["Language"];
                    book.Edition     = (int)dr["Edition"];
                    book.CoverType   = (string)dr["CoverType"];
                    invoice.Prices.Add((decimal)dr["Price"]);
                    invoice.Amounts.Add((int)dr["Amount"]);
                    int pubID = (int)dr["PublisherID"];
                    invoice.Publishers.Add(db.Publishers.Where(x => x.PublisherID == pubID).First().Name);
                    results.Add(book);
                }
                connection.Close();
            }

            invoice.Books      = results.ToList();
            invoice.Cart       = cart;
            invoice.Shipping   = ship;
            invoice.Billing    = bill;
            invoice.Card       = card;
            invoice.TotalPrice = cart.TotalPrice;

            return(View(invoice));
        }
        /// <summary>
        /// Method to update tables
        /// </summary>
        /// <param name="creditCard">Credit card</param>
        /// <param name="dataSource">Data source</param>
        private void UpdateTables(Credit_Card creditCard, DataSource dataSource)
        {
            string strSql = "";

            if (Information.IsDBNull(creditCard.Trans_Date))
            {
                creditCard.Trans_Date = DateAndTime.Today;
            }
            strSql = "UPDATE  CardTenders " + " SET BatchNumber=\'" + creditCard.Sequence_Number + "\' ," + " BatchDate = \'" + creditCard.Trans_Date.ToString("yyyyMMdd") + "\' " + " Where CardTenders.CallTheBank = 1 AND " + " CardTenders.TerminalID = \'" + creditCard.TerminalID + "\'  AND " + " CardTenders.BatchNumber IS NULL AND CardTenders.Result = \'0\'";
            Execute(strSql, dataSource);
        }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "CardID,CustomerID,Number,ExpDate,CCV,CreditType")] Credit_Card credit_Card)
 {
     if (ModelState.IsValid)
     {
         Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
         db.usp_editCard(credit_Card.CardID, customer.CustomerID, credit_Card.Number, credit_Card.ExpDate, credit_Card.CCV, credit_Card.CreditType);
         return(RedirectToAction("YourAccount", "Account", null));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", credit_Card.CustomerID);
     return(View(credit_Card));
 }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "credit_card_id,user_id,card_number,expiry_date,is_expired,is_flagged")] Credit_Card credit_Card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(credit_Card).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.user_id = new SelectList(db.Users, "user_id", "username", credit_Card.user_id);
     return(View(credit_Card));
 }
Ejemplo n.º 14
0
        public async Task <SubscriptionResponse> CreateSignature(Address address, Credit_Card creditCard, string cpf, DateTime birth,
                                                                 string email, string fullname, string phone_area_code, string phone_number, string codePlan, string id, string clientId)
        {
            try
            {
                Wirecard.WirecardClient WC = null;
                WC = await SetAmbiente(WC);

                var birthdate_day   = birth.Day.ToString();
                var birthdate_month = birth.Month.ToString();
                var birthdate_year  = birth.Year.ToString();

                var subscriber = await WC.Signature.CreateSubscriptions(new SubscriptionRequest()
                {
                    Plan = new Plan()
                    {
                        Name = codePlan,
                        Code = codePlan
                    },
                    Code           = id,
                    Payment_Method = "CREDIT_CARD",
                    Customer       = new Customer()
                    {
                        Email           = email,
                        Phone_Number    = phone_number,
                        Phone_Area_Code = phone_area_code,
                        FullName        = creditCard.Holder_Name,
                        Address         = address,
                        BirthDate       = birth.ToString("dd/MM/YYYY"),
                        Phone           = new Phone()
                        {
                            AreaCode    = phone_area_code,
                            CountryCode = "55",
                            Number      = phone_number
                        },
                        Billing_Info = new Billing_Info()
                        {
                            Credit_Card = creditCard
                        },
                        Code            = clientId,
                        Cpf             = cpf,
                        BirthDate_Day   = Convert.ToInt32(birthdate_day),
                        BirthDate_Month = birthdate_month,
                        BirthDate_Year  = Convert.ToInt32(birthdate_year)
                    }
                }, true);

                return(subscriber);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 15
0
        public ActionResult Create([Bind(Include = "credit_card_id,user_id,card_number,expiry_date,is_expired,is_flagged")] Credit_Card credit_Card)
        {
            if (ModelState.IsValid)
            {
                db.Credit_Card.Add(credit_Card);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.user_id = db.Users.Where(u => u.username == this.User.Identity.Name).FirstOrDefault().user_id;
            return(View(credit_Card));
        }
        /// <summary>
        /// Method to send to TPS
        /// </summary>
        /// <param name="strRequest"></param>
        /// <param name="cc"></param>
        /// <param name="emvProcess"></param>
        /// <returns></returns>
        private bool SendToTps(string strRequest, ref Credit_Card cc, bool emvProcess)
        {
            short retry = 0;
            bool  isWex = false;

            while (retry < 3) //From Table
            {
                if (_client.Connected)
                {
                    object sendStringSuf = "," + "END-DATA";
                    if (cc != null)
                    {
                        if ((cc.Crd_Type == "F" && cc.GiftType.ToUpper() == "W") || cc.Crd_Type == "WEX")
                        {
                            isWex = true;
                        }
                    }

                    if (isWex)
                    {
                        object startHeader = 0x1;

                        object sequenceNumber = 0x1;
                        var    endTransmit    = (byte)0x4;


                        strRequest    = startHeader + System.Convert.ToString(sequenceNumber) + (strRequest.Length.ToString("0000") + strRequest); // For WEX TPS Specific
                        sendStringSuf = endTransmit;
                    }
                    WriteToLogFile("Send to STPS: " + strRequest + Convert.ToString(sendStringSuf));

                    _client.Send(Encoding.ASCII.GetBytes(strRequest + Convert.ToString(sendStringSuf)));
                    Variables.Sleep(200);
                    var response = string.Empty;
                    if (_client.Available > 0)
                    {
                        byte[] data = new byte[2048];
                        _client.Receive(data);
                        response = Encoding.UTF8.GetString(data);
                    }
                    if (!string.IsNullOrEmpty(response))
                    {
                        WriteToLogFile("Received from STPS: " + response);
                        GetResponse(response, ref cc, emvProcess);
                    }
                    return(true);
                }
                GetConnection();
                retry++;
            }
            return(false);
        }
Ejemplo n.º 17
0
        // This test is responsible for checking the expiry_date field
        public void Credit_CardTest_ExpiryDateWithCorrectType_ShouldPass()
        {
            // Arrange
            Credit_Card creditCard = new Credit_Card();
            DateTime    expected   = new DateTime(2020, 1, 3);
            DateTime    actual     = new DateTime();

            // Act
            creditCard.expiry_date = expected;

            // Assert
            actual = creditCard.expiry_date;
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 18
0
        // This test is responsible for checking the isFlagged field
        public void Credit_CardTest_IsFlaggedWithCorrectType_ShouldPass()
        {
            // Arrange
            Credit_Card creditCard = new Credit_Card();
            bool        expected   = true;
            bool        actual;

            // Act
            creditCard.is_flagged = expected;

            // Assert
            actual = creditCard.is_flagged;
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 19
0
        // This test is responsible for checking the credit_card_id field
        public void Credit_CardTest_CreditCardIDWithCorrectType_ShouldPass()
        {
            // Arrange
            Credit_Card creditCard = new Credit_Card();
            int         expected   = 9;
            int         actual;

            // Act
            creditCard.credit_card_id = expected;

            // Assert
            actual = creditCard.credit_card_id;
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 20
0
        // This test is responsible for checking the card_number field
        public void Credit_CardTest_CardNumberWithCorrectType_ShouldPass()
        {
            // Arrange
            Credit_Card creditCard = new Credit_Card();
            long        expected   = 9002332232323232;
            long        actual;

            // Act
            creditCard.card_number = expected;

            // Assert
            actual = creditCard.card_number;
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 21
0
        // GET: CreditCard/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Credit_Card credit_Card = db.Credit_Card.Find(id);

            if (credit_Card == null)
            {
                return(HttpNotFound());
            }
            return(View(credit_Card));
        }
Ejemplo n.º 22
0
        // GET: CreditCard/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Credit_Card credit_Card = db.Credit_Card.Find(id);

            if (credit_Card == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", credit_Card.CustomerID);
            return(View(credit_Card));
        }
        // GET: Credit_Card/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Credit_Card credit_Card = db.Credit_Card.Find(id);

            if (credit_Card == null)
            {
                return(HttpNotFound());
            }
            ViewBag.User_Id = new SelectList(db.AspNetUsers, "Id", "Email", credit_Card.User_Id);
            return(View(credit_Card));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Credit_Card credit_Card = db.Credit_Card.Find(id);

            db.Credit_Card.Remove(credit_Card);
            db.SaveChanges();
            if (User.IsInRole("Administrator"))
            {
                return(RedirectToAction(actionName: "Index"));
            }
            else
            {
                return(RedirectToAction(actionName: "Index", controllerName: "Manage", routeValues: null));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// method to get the card profile prompts
        /// </summary>
        /// <param name="prompts"></param>
        /// <param name="cc"></param>
        /// <param name="profileId"></param>
        public void GetProfilePrompts(ref CardPrompts prompts, Credit_Card cc, string profileId)
        {
            var promptCodeString = cc.Track2?.Replace(";" + cc.Cardnumber + "=", "").Replace("?", "");

            promptCodeString = promptCodeString?.Substring(4, 1) + promptCodeString?.Substring(promptCodeString.Length - 1, 1);
            if (promptCodeString == "00")
            {
                return;
            }
            if (string.IsNullOrEmpty(promptCodeString))
            {
                prompts.Add(20, 3, "Enter Card Data ", 1, 5009, "", "");
                return;
            }
            _wexService.GetCardProfilePrompts(ref prompts, promptCodeString, profileId);
        }
 public ActionResult Edit([Bind(Include = "Id,User_Id,State,City,Zip_code,Card_number")] Credit_Card credit_Card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(credit_Card).State = EntityState.Modified;
         db.SaveChanges();
         if (User.IsInRole("Administrator"))
         {
             return(RedirectToAction(actionName: "Index"));
         }
         else
         {
             return(RedirectToAction(actionName: "Index", controllerName: "Manage", routeValues: null));
         }
     }
     ViewBag.User_Id = new SelectList(db.AspNetUsers, "Id", "Email", credit_Card.User_Id);
     return(View(credit_Card));
 }
Ejemplo n.º 27
0
        public ActionResult Create([Bind(Include = "BillID,CustomerID,Street,City,State,Zip")] Billing billing)
        {
            if (ModelState.IsValid)
            {
                Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
                db.usp_AddBilling(customer.CustomerID, billing.Street, billing.City, billing.State, billing.Zip);
                try
                {
                    Credit_Card card = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
                } catch (Exception e)
                {
                    return(RedirectToAction("CreateForCheckout", "CreditCard", null));
                }
                return(RedirectToAction("Index", "Invoice", null));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", billing.CustomerID);
            return(View(billing));
        }
Ejemplo n.º 28
0
        public ActionResult Create(Shipping shipping)
        {
            if (ModelState.IsValid)
            {
                Customer customer = db.Customers.Where(x => x.Username == User.Identity.Name).First();
                db.usp_AddShipping(customer.CustomerID, shipping.Street, shipping.City, shipping.State, shipping.Zip);
                if (shipping.BillingIsSame)
                {
                    db.usp_AddBilling(customer.CustomerID, shipping.Street, shipping.City, shipping.State, shipping.Zip);
                }
                else
                {
                    //see if user has billing address
                    try
                    {
                        Billing billing = db.Billings.Where(x => x.CustomerID == customer.CustomerID).First();
                    }
                    catch (Exception e)
                    {
                        return(RedirectToAction("Create", "Billing", null));
                    }
                }

                //see if user has credit card
                try
                {
                    Credit_Card card = db.Credit_Card.Where(x => x.CustomerID == customer.CustomerID).First();
                }
                catch (Exception e)
                {
                    return(RedirectToAction("CreateForCheckout", "CreditCard", null));
                }

                return(RedirectToAction("Index"));
            }

            return(View(shipping));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// method to analyse the response from the WEX server
        /// </summary>
        /// <param name="receivedStr"></param>
        /// <param name="cc"></param>
        public void AnalyseWexResponse(string receivedStr, ref Credit_Card cc)
        {
            if (GetTagValue(receivedStr, "Transaction", "Type").ToUpper() == "CLOSEBATCH")
            {
                cc.Response = GetTagValue(receivedStr, "Response", "Type").ToUpper();
                cc.Report   = GetTagValue(receivedStr, "Report");
                if (cc.Report != "")
                {
                    cc.Report = cc.Report.Replace("<![CDATA[", "");
                }
                if (cc.Report != "")
                {
                    cc.Report = cc.Report.Replace("]]>", "");
                }
                cc.Sequence_Number = GetTagValue(receivedStr, "BATCHNUMBER");
                if (cc.Response.ToUpper() == "BATCH SETTLED")
                {
                    cc.Response = "APPROVED";
                }
            }
            else
            {
                cc.Response = GetTagValue(receivedStr, "Response", "Type").ToUpper();
                if (GetTagValue(receivedStr, "Response", "Type").ToUpper() == "APPROVED")
                {
                    if (string.Format("{0:0.000}", cc.Trans_Amount) == GetTagValue(receivedStr, "Amount"))
                    {
                        if (Chaps_Main.SA.Sale_Num == double.Parse(GetTagValue(receivedStr, "invoiceno")))
                        {
                            cc.Sequence_Number = GetTagValue(receivedStr, "PDSN");
                            cc.Response        = "APPROVED";
                        }
                        else
                        {
                            cc.Response = "INVOICE NOT MATCHING";
                        }
                    }
                    else
                    {
                        cc.Response = "AMOUNT NOT MATCHING";
                    }
                }
            }

            if (cc.Response == "APPROVED")
            {
                var dateTime = System.DateTime.FromOADate(DateAndTime.Today.ToOADate() + DateAndTime.TimeOfDay.ToOADate());

                if (GetTagValue(receivedStr, "TransDate") != "")
                {
                    dateTime = DateTime.Parse(GetTagValue(receivedStr, "TransDate").Trim().Substring(0, 19).ToUpper().Replace("T", " "));
                }
                if (GetTagValue(receivedStr, "Date") != "" && GetTagValue(receivedStr, "Time") != "")
                {
                    dateTime = DateTime.Parse(GetTagValue(receivedStr, "Date") + " " + GetTagValue(receivedStr, "Time"));
                }
                cc.Trans_Date      = dateTime.Date;
                cc.Trans_Time      = dateTime;
                cc.ApprovalCode    = GetTagValue(receivedStr, "ApprovalCode");
                cc.TerminalID      = GetTagValue(receivedStr, "TerminalID");
                cc.Receipt_Display = cc.Response;
                cc.Result          = "W";
            }
            modTPS.cc = cc;
        }
        /// <summary>
        /// Method to get response
        /// </summary>
        /// <param name="strResponse"></param>
        /// <param name="cc"></param>
        /// <param name="emvProcess"></param>
        /// <returns></returns>
        private string GetResponse(string strResponse, ref Credit_Card cc, bool emvProcess)
        {
            string returnValue = string.Empty;

            WriteToLogFile("GetResponse procedure response is " + cc.Response);
            cc.Response = GetStrPosition(strResponse, (short)15).Trim().ToUpper();
            if (string.IsNullOrEmpty(strResponse))
            {
                return(returnValue);
            }
            if (emvProcess) //EMVVERSION 'Added May4,2010
            {
                cc.Card_Swiped = cc.ManualCardProcess == false;
            }
            cc.Result = GetStrPosition(strResponse, 16).Trim();
            cc.Authorization_Number = GetStrPosition(strResponse, 17).Trim().ToUpper();
            cc.ResponseCode         = GetStrPosition(strResponse, 29).Trim().ToUpper();
            //  EMVVERSION
            if (emvProcess) //EMVVERSION
            {
                cc.Crd_Type = GetStrPosition(strResponse, 2).Trim().Substring(0, 1);
                _creditCardManager.SetTrack2(ref cc, GetStrPosition(strResponse, 12).Trim().ToUpper());
                cc.Swipe_String = cc.Track2;
            }
            //shiny end-EMVVERSION



            var strSeq = GetStrPosition(strResponse, 5).Trim();

            if (_policyManager.BankSystem != "Moneris")
            {
                cc.Sequence_Number = string.IsNullOrEmpty(strSeq) ? "" : strSeq.Substring(0, strSeq.Length - 1);
            }
            else //Moneris
            {
                cc.Sequence_Number = strSeq;
            }


            cc.TerminalID   = GetStrPosition(strResponse, 8).Trim();
            cc.DebitAccount = GetStrPosition(strResponse, 11).Trim();
            var strDate = GetStrPosition(strResponse, 21).Trim();

            //Nancy changed,10/21/02
            if (string.IsNullOrEmpty(strDate))
            {
                cc.Trans_Date = DateTime.Now;
            }
            else
            {
                try
                {
                    cc.Trans_Date = DateTime.Parse(strDate);
                }
                catch (Exception)
                {
                    cc.Trans_Date = DateTime.Now;
                }
            }
            var strTime = GetStrPosition(strResponse, (short)22).Trim();

            if (string.IsNullOrEmpty(strTime))
            {
                cc.Trans_Time = DateTime.Parse(DateTime.Now.ToString("hhmmss"));
            }
            else
            {
                try
                {
                    cc.Trans_Time = DateTime.Parse(strTime);
                }
                catch (Exception)
                {
                    cc.Trans_Time = DateTime.Parse(DateTime.Now.ToString("hhmmss"));
                }
            }
            //    cc.Trans_Date = Trim(GetStrPosition(strResponse, 21))
            //    cc.Trans_Time = Trim(GetStrPosition(strResponse, 22))
            cc.ApprovalCode    = GetStrPosition(strResponse, 18).Trim();
            cc.Receipt_Display = GetStrPosition(strResponse, 23).Trim();

            //    cc.Report = Trim(GetStrPosition(strResponse, 30))
            if (emvProcess) //EMVVERSION
            {
                cc.Report      = GetStrPosition(strResponse, 31).Trim();
                cc.BankMessage = GetStrPosition(strResponse, 30).Trim();
            }
            else
            {
                cc.Report = GetStrPosition(strResponse, 30).Trim();
            }

            // Nicolette added next lines
            if (cc.AskVechicle)
            {
                _creditCardManager.SetVehicleNumber(ref cc, GetStrPosition(strResponse, 33).Trim());
            }
            if (cc.AskIdentificationNo)
            {
                _creditCardManager.SetIdNumber(ref cc, GetStrPosition(strResponse, 34).Trim());
            }
            if (cc.AskDriverNo)
            {
                _creditCardManager.SetDriverNumber(ref cc, GetStrPosition(strResponse, 34).Trim());
            }
            if (cc.AskOdometer)
            {
                _creditCardManager.SetOdoMeter(ref cc, GetStrPosition(strResponse, 35).Trim());
            }

            if (!_policyManager.EMVVersion) //  this is for pinpad swipe
            {
                if (cc.Track2 == "" && GetStrPosition(strResponse, 12) != "")
                {
                    //        12/20/06 end
                    _creditCardManager.SetTrack2(ref cc, GetStrPosition(strResponse, 12).Trim());
                }
            }

            _creditCardManager.SetIdNumber(ref cc, GetStrPosition(strResponse, 3).Trim());
            if (emvProcess == false) //EMVVERSION '
            {
                if (GetStrPosition(strResponse, 1).Trim().ToUpper() == "SWIPEINSIDE")
                {
                    cc.Card_Swiped = (GetStrPosition(strResponse, 15).Trim().ToUpper() == "SWIPED");
                }
            }
            if (emvProcess)                                       // 31 position is card name
            {
                cc.Name = GetStrPosition(strResponse, 33).Trim(); // Trim(GetStrPosition(strResponse, 32))
            }

            return(returnValue);
        }