Esempio n. 1
0
        private void Validate_Click(object sender, EventArgs e)
        {
            string cardNum = textBox1.Text;

            if (CreditCardUtility.IsValidNumber(cardNum))
            {
                CreditCardTypeType?cardType    = CreditCardUtility.GetCardTypeFromNumber(cardNum);
                string             strCardType = (cardType == null) ? "Unknown" : cardType.ToString();

                MessageBox.Show("You have entered a valid card number. The card type is {0}." + strCardType);
            }
            else
            {
                MessageBox.Show("Card failed Luhn test. Please enter a valid card number.");
            }
        }
Esempio n. 2
0
    protected void btnValidate_Click(object sender, EventArgs e)
    {
        if (txtCard.Text.Length > 0)
        {
            string cardNum = txtCard.Text.Trim();

            if (CreditCardUtility.IsValidNumber(cardNum))
            {
                CreditCardTypeType?cardType    = CreditCardUtility.GetCardTypeFromNumber(cardNum);
                string             strCardType = (cardType == null) ? "Unknown" : cardType.ToString();

                showMessage(String.Format("You have entered a valid card number. The card type is {0}.", strCardType), true);
            }
            else
            {
                showMessage("Card failed Luhn test. Please enter a valid card number.", false);
            }
        }
        else
        {
            showMessage("Please enter a card number first.", false);
        }
    }
Esempio n. 3
0
    //end TimeButton
    public void OnReserveAuctionButtonClicked()
    {
        //check the user has choosen the time slot
        slots.Sort();
        for (int i = 0; i < slots.Count - 1; i++)
        {
            if (slots [i] - slots [i + 1] == -1)
            {
                continue;
            }
            else
            {
                //message they should be consequantive
                ErrorMessage.text = "The slots should be consequantive";
                return;
            }
        }
        if (slots.Count == 0)
        {
            //erroe message
            ErrorMessage.text = "You Forget to choose time slots for your auction";
            return;
        }
        aucName = AucName.text;
        //check name
        if (string.IsNullOrEmpty(aucName))
        {
            //erroe message
            ErrorMessage.text = "The auction name is required";
            return;
        }
        if (aucName.Length > 15)
        {
            //erroe message
            ErrorMessage.text = "The auction name should be less than 15 character";
            return;
        }
        aucType = AucType.options [AucType.value].text;
        card    = Card.text;
        //check card naumer
        if (string.IsNullOrEmpty(card))
        {
            //erroe message
            ErrorMessage.text = "The credit card number is required";
            return;
        }
        if (CardEndYear.value == 0)
        {
            ErrorMessage.text = "The credit card (End Year) is required";
            return;
        }
        if (CardEndMonth.value == 0)
        {
            ErrorMessage.text = "The credit card (End Month) is required";
            return;
        }
        if (!CreditCardUtility.IsValidNumber(card))
        {
            ErrorMessage.text = "The credit card number is invalid";
            return;
        }
        cardEndMonth = CardEndMonth.options [CardEndMonth.value].text;
        cardEndYear  = CardEndYear.options [CardEndYear.value].text;
        aucDate      = AucDate.options [AucDate.value].text;
        aucTime      = "";
        aucTime      = slots [0] + "," + slots [slots.Count - 1];
        //we ended the check steps
        //enableInterface(false);

        {
            ISFSObject objOut = new SFSObject();
            objOut.PutUtfString("aucName", aucName);
            objOut.PutUtfString("aucType", aucType);
            objOut.PutUtfString("card", card);
            objOut.PutUtfString("cardEndMonth", cardEndMonth);
            objOut.PutUtfString("cardEndYear", cardEndYear);
            objOut.PutUtfString("aucDate", aucDate);
            objOut.PutUtfString("aucTime", aucTime);
            objOut.PutUtfString("cardType", CreditCardUtility.GetType(card));

            NetworkManager.Instance.sendReserveAuction(objOut);
        }
    }
Esempio n. 4
0
        public ActionResult Checkoutconfirm(Models.Checkout checkout)
        {
            if (!Request.IsAuthenticated) //For login user password is not required
            {
                if (string.IsNullOrEmpty(checkout.ChoosePassword))
                {
                    ModelState.AddModelError("ChoosePassword", "The password field is required");
                    ModelState.AddModelError("ConfirmPassword", "The password field is required");
                }
                else if (checkout.ChoosePassword.Length > 20 || checkout.ChoosePassword.Length < 6)
                {
                    ModelState.AddModelError("ConfirmPassword", "The field New Password must be a string with a minimum length of 6 and a maximum length of 20");
                }
            }

            BGBC.Core.ModelDataValidation.Instance.AlphaNumeric(ModelState, checkout.BillingAddress, true, "Billing Address", "BillingAddress");
            BGBC.Core.ModelDataValidation.Instance.AlphaNumeric(ModelState, checkout.BillingAddress_2, false, "Billing Address 2", "BillingAddress_2");
            BGBC.Core.ModelDataValidation.Instance.Alpha(ModelState, checkout.BillingCty, true, "Billing City", "BillingCty");
            BGBC.Core.ModelDataValidation.Instance.Alpha(ModelState, checkout.BillingState, true, "Billing State", "BillingState");
            BGBC.Core.ModelDataValidation.Instance.Zip(ModelState, checkout.BillingZip, true, "Billing Zip", "BillingZip");

            if (!checkout.ServiceBillingAddressSame)
            {
                BGBC.Core.ModelDataValidation.Instance.AlphaNumeric(ModelState, checkout.ServiceAddress, true, "Service Address", "ServiceAddress");
                BGBC.Core.ModelDataValidation.Instance.AlphaNumeric(ModelState, checkout.ServiceAddress_2, false, "Service Address 2", "ServiceAddress_2");
                BGBC.Core.ModelDataValidation.Instance.Alpha(ModelState, checkout.ServiceCty, true, "Service City", "ServiceCty");
                BGBC.Core.ModelDataValidation.Instance.Alpha(ModelState, checkout.ServiceState, true, "Service State", "ServiceState");
                BGBC.Core.ModelDataValidation.Instance.Zip(ModelState, checkout.ServiceZip, true, "Service Zip", "ServiceZip");
            }

            if (checkout.PaymentMethod == "eCheck")
            {
                if (string.IsNullOrEmpty(checkout.BankAccountType))
                {
                    ModelState.AddModelError("BankAccountType", "The Bank Account Type field is required.");
                }

                if (!string.IsNullOrEmpty(checkout.BankRoutingNumber))
                {
                    if (checkout.BankRoutingNumber.Trim().Length != 9)
                    {
                        ModelState.AddModelError("BankRoutingNumber", "Please enter a valid routing number");
                    }
                }
                else
                {
                    ModelState.AddModelError("BankRoutingNumber", "Please enter a valid routing number");
                }
                if (!string.IsNullOrEmpty(checkout.BankAccountNumber))
                {
                    if (checkout.BankAccountNumber.Trim().Length != 7)
                    {
                        ModelState.AddModelError("BankAccountNumber", "Please enter a valid account number");
                    }
                }
                else
                {
                    ModelState.AddModelError("BankAccountNumber", "Please enter a valid account number");
                }
            }
            else
            {
                if (string.IsNullOrEmpty(checkout.CardNo))
                {
                    ModelState.AddModelError("CardNo", "The Card No field is required.");
                }
                if (string.IsNullOrEmpty(checkout.CVV))
                {
                    ModelState.AddModelError("CVV", "The Card CVV field is required.");
                }

                if (!string.IsNullOrEmpty(checkout.CardNo))
                {
                    if (checkout.CardNo.Trim().Length > 0)
                    {
                        if (CreditCardUtility.IsValidNumber(checkout.CardNo))
                        {
                            if (!string.IsNullOrEmpty(checkout.CVV))
                            {
                                CreditCardTypeType?cardType = CreditCardUtility.GetCardTypeFromNumber(checkout.CardNo);
                                if (cardType == null)
                                {
                                    ModelState.AddModelError("CardNo", "Please enter a valid card number");
                                }
                                else
                                {
                                    checkout.CardType = (CreditCardTypeType)cardType;
                                    if (cardType == CreditCardTypeType.Amex && checkout.CVV.Trim().Length != 4)
                                    {
                                        ModelState.AddModelError("CVV", "Please enter a valid CVV number");
                                    }
                                    else if (cardType != CreditCardTypeType.Amex && checkout.CVV.Trim().Length != 3)
                                    {
                                        ModelState.AddModelError("CVV", "Please enter a valid CVV number");
                                    }
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("CardNo", "Please enter a valid card number");
                        }
                    }
                }
            }

            var query = from state in ModelState.Values
                        from error in state.Errors
                        select error.ErrorMessage;

            var errorList = query.ToList();
            var allErrors = ModelState.Values.SelectMany(v => v.Errors);

            checkout.OrderTotal = TotalAmountToPay(checkout.CardType, checkout.PaymentMethod);
            if (ModelState.IsValid)
            {
                if (!Request.IsAuthenticated)
                {
                    User user = _userRepository.Find(checkout.Email);
                    if (user != null)
                    {
                        ModelState.AddModelError("Email", "Email is already exists");
                    }
                    else
                    {
                        TempData["cartdata"] = checkout;
                        return(View(checkout));
                    }
                }
                else
                {
                    TempData["cartdata"] = checkout;
                    return(View(checkout));
                }
            }
            checkoutDropDown();
            return(View("Checkout", checkout));
        }