Beispiel #1
0
        // adds postage address for checkout
        public int addPostageAddress(PostageAddress address)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["JerseyZoneDBConnectionString"].ConnectionString;
            int    rows;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("uspAddPostageAddress", connection);

                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@addressStreet", address.addressStreet);
                command.Parameters.AddWithValue("@addressPostal", address.addressPostal);
                command.Parameters.AddWithValue("@addressCity", address.addressCity);
                command.Parameters.AddWithValue("@addressCountry", address.addressCountry);
                command.Parameters.AddWithValue("@addressState", address.addressState);
                command.Parameters.AddWithValue("@addressPostCode", address.addressPostCode);
                command.Parameters.AddWithValue("@FK_userID", address.FK_userID);

                connection.Open();

                rows = command.ExecuteNonQuery();
            }

            return(rows);
        }
Beispiel #2
0
        // makes payment
        protected void MakePayment(object sender, EventArgs e)
        {
            if (IsValid)
            {
                Accounts userAccount = Session["CurrentAccount"] as Accounts;

                // adds address
                PostageAddress address = new PostageAddress
                {
                    addressStreet   = txtCustomerAddress.Text,
                    addressPostal   = txtOptionalAddress.Text,
                    addressCity     = txtCity.Text,
                    addressCountry  = ddlCountry.SelectedValue,
                    addressState    = ddlStateTerritory.SelectedValue,
                    addressPostCode = Convert.ToInt32(txtPostCode.Text),
                    FK_userID       = userAccount.userID
                };

                PostageAddress.addPostageAddress(address);

                lblResult.Text = "";

                Payment payment = new Payment(Session["ShoppingCart"] as ShoppingCart, Session["CurrentAccount"] as Accounts, Session["PostageOption"] as PostageOption);


                string[] card = { cardName.Text, cardNumber.Text, txtCVV.Text, txtExpiryDate.Text };


                TransactionResult result = payment.processPayment(card);

                Session["Result"] = result;

                // checks the outcome of the payment
                switch (result)
                {
                case TransactionResult.Approved:
                    int rows = Payment.addNewOrder(payment, card);
                    Response.Redirect("~/UL/Confirmed");
                    break;

                case TransactionResult.Declined:
                    lblResult.Text = "Card reports insufficient funds";
                    break;

                case TransactionResult.InvalidCard:
                    lblResult.Text = "Card is invalid";
                    break;

                case TransactionResult.InvalidExpiry:
                    lblResult.Text = "Invalid card expiry date";
                    break;

                case TransactionResult.ConnectionFailure:
                    lblResult.Text = "Connection failed while processing";
                    break;
                }
            }
        }