Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //Display test credit card numbers
         this.lblMc.Text   = CreditCardUtility.GetCardTestNumber(CreditCardTypeType.MasterCard).Replace(" ", "-");
         this.lblVisa.Text = CreditCardUtility.GetCardTestNumber(CreditCardTypeType.Visa).Replace(" ", "-");
         this.lblDisc.Text = CreditCardUtility.GetCardTestNumber(CreditCardTypeType.Discover).Replace(" ", "-");
         this.lblAmex.Text = CreditCardUtility.GetCardTestNumber(CreditCardTypeType.Amex).Replace(" ", "-");
     }
 }
Beispiel #2
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.");
            }
        }
Beispiel #3
0
        public CreateSaleRequest MapSaleRequest(Partner partner)
        {
            var buyer             = new Buyer();
            var transaction       = new CreditCardTransaction();
            var createSaleRequest = new CreateSaleRequest();

            buyer.Email = partner.Email;
            buyer.Name  = partner.Name;

            ExpiryDateStruct expiryDate = new ExpiryDateStruct();

            expiryDate.Month = partner.CreditCard.ExpiryDate.Substring(0, 2);  // MONTH_LENTH = 2
            expiryDate.Year  = partner.CreditCard.ExpiryDate.Substring(2 + 3); // MONTH_LENTH+1 + space + /

            var computedBrand = CreditCardUtility.GetBrandByNumber(partner.CreditCard.Number);

            // Cria a transação
            transaction.AmountInCents = partner.Plan;
            transaction.CreditCard    = new GatewayApiClient.DataContracts.CreditCard();
            transaction.CreditCard.CreditCardBrand  = computedBrand;
            transaction.CreditCard.CreditCardNumber = partner.CreditCard.Number;
            transaction.CreditCard.ExpMonth         = Convert.ToInt16(expiryDate.Month);
            transaction.CreditCard.ExpYear          = Convert.ToInt16(expiryDate.Year);
            transaction.CreditCard.HolderName       = partner.Name;
            transaction.CreditCard.SecurityCode     = partner.CreditCard.Cvv;
            transaction.InstallmentCount            = 1;
            transaction.Recurrency = new Recurrency()
            {
                DateToStartBilling = DateTime.Now,
                Frequency          = FrequencyEnum.Monthly,
                Interval           = 1,
                Recurrences        = 0
            };

            // Adiciona a transação na requisição.
            createSaleRequest.CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction });
            createSaleRequest.Order = new Order();

            return(createSaleRequest);
        }
Beispiel #4
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);
        }
    }
Beispiel #5
0
        private decimal TotalAmountToPay(CreditCardTypeType cardType, string paymentMethod)
        {
            CreditCardTypeType CardType   = paymentMethod == "eCheck" ? CreditCardTypeType.eCheck : cardType;
            HttpCookie         authCookie = Request.Cookies[".BGBCProducts"];
            decimal            total      = 0;

            if (authCookie != null)
            {
                string[] ids = authCookie.Value.ToString().Split(',');
                IEnumerable <Product> list = _repository.Get();
                foreach (var item in list)
                {
                    if (Array.Exists(ids, e => e == item.ProductID.ToString()))
                    {
                        total = total + (decimal)item.Price;
                    }
                }

                decimal fee = CreditCardUtility.PaymentCaliculation(CardType, total);
                decimal tax = Math.Round((total * (8.25m / 100)), 2);
                total = total + tax + fee;
            }
            return(total);
        }
Beispiel #6
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);
        }
    }
Beispiel #7
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));
        }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //try
        //{
        if (Session["user"] == null)
        {
            Response.Redirect("login.aspx");
        }

        string orderid      = Request.QueryString["OrderID"].ToString();
        Order  order        = new Order();
        Order  orderDetails = null;

        orderDetails = order.getOrderOrderID(orderid);

        string custEmail = Session["user"].ToString();



        if (orderDetails == null)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                "alert('Order not found'); window.location='" +
                                                Request.ApplicationPath + "account.aspx';", true);
            //show error
        }
        else
        {
            if (custEmail != orderDetails.CustEmail)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('You are not allowed to access'); window.location='" +
                                                    Request.ApplicationPath + "account.aspx';", true);
            }
            else
            {
                orderid_lbl.Text = orderDetails.OrderID;
                date_lbl.Text    = orderDetails.OrderDate;
                status_lbl.Text  = orderDetails.OrderStatus;

                email_lbl.Text    = orderDetails.CustEmail;
                postal_lbl.Text   = orderDetails.Postal;
                address_lbl.Text  = orderDetails.Address;
                city_lbl.Text     = orderDetails.City;
                type_lbl.Text     = orderDetails.DeliveryType;
                tracking_lbl.Text = orderDetails.TrackingID;

                emailtxt.Text     = orderDetails.CustEmail;
                addresstxt.Text   = orderDetails.Address;
                postaltxt.Text    = orderDetails.Postal;
                orderDatetxt.Text = orderDetails.OrderDate;
                ordernotxt.Text   = orderDetails.OrderID;

                var    ccNo     = orderDetails.CcNo;
                String cardType = CreditCardUtility.GetTypeName(ccNo);
                cardtype.Text = cardType;


                var lastDigits = ccNo.Substring(ccNo.Length - 4, 4);
                cardNo.Text = "• • • •" + lastDigits;
                showOrderDetails();

                decimal sum = 0;
                for (int i = 0; i < gvUser.Rows.Count; ++i)
                {
                    sum += Convert.ToDecimal(gvUser.Rows[i].Cells[4].Text);
                }
                lbl_TotalPrice.Text = sum.ToString();
            }
        }
        //}
        //catch
        //{
        //    Response.Redirect("error.aspx");
        //}
    }