public ActionResult SecureCheckout()
        {
            // If User is not logged in send to login
            if (Session["USERINFO"] == null)
            {
                return RedirectToAction("LogOn", new { ReturnUrl = Request.Url.PathAndQuery });
            }

            // Check for uconnactivation
            string uconnActivation = System.Configuration.ConfigurationManager.AppSettings["UCONNACTIVATION"];

            if (uconnActivation == "YES")
            {
                string canContinue = Request.QueryString["checkout"];

                if (canContinue != "1go")
                {
                    return RedirectToAction("UconnActivation", "Account", new { checkout = 1 });
                }

            }
            string url = Request.Url.Host.ToString();

            if (!Request.Url.Port.Equals(null))
            {
                url += ":" + Request.Url.Port.ToString();
            }

            // Check for items in cart
            if (Session["Total"] == null)
            {
                return RedirectToAction("Checkout", "Account");
            }

            // Check for element payment
            string elementEnabled = System.Configuration.ConfigurationManager.AppSettings["USE_ELEMENT_PS"];

            if (elementEnabled == "YES")
            {
                if (Request.HttpMethod != "POST")
                {
                    ElementUtil element = new ElementUtil();
                    string path = element.TransactionPath(url);
                    string total = Session["Total"].ToString();

                    ElementResponseModel elementResponse = element.SetupTransaction(Session["USERINFO"] as UserModel, total, path);
                    Session["valcodebefore"] = elementResponse.ValidationCode;
                    ViewData["tansactionUrl"] = elementResponse.GetTransactionURL();
                }
            }

            // If we got this far, something failed, redisplay form
            return View();
        }
        public ActionResult ProcessTransaction()
        {
            // Check for user login status
            if (Session["USERINFO"] == null)
            {
                throw new Exception("Error: Not logged in.");
            }

            // Set variables
            UserModel user = Session["USERINFO"] as UserModel;
            string paymentAccountId = Request.QueryString["PaymentAccountID"].ToString();
            string lastFour = Request.QueryString["LastFour"].ToString();
            string validationCode = Request.QueryString["ValidationCode"].ToString();
            string validcodes = System.Configuration.ConfigurationManager.AppSettings["elementps_acceptable_avscodes"] as string; // TODO: Make function for extracting web.config data

            // Do AVS check through element
            ElementUtil element = new ElementUtil();
            string avsRespCode = element.PerformAVSCheck(user, paymentAccountId);

            // Verify response from element
            if ((Request.QueryString["HostedPaymentStatus"].ToString() == "Complete") && (validcodes.IndexOf(avsRespCode) >= 0))
            {
                ViewData["ElementResponse"] = "Your order has been received. You will not be charged until the order has been processed.";

                // TODO: Make this look better
                // Process order through IWEB.PAYMENT
                ProcessElementOrder(
                    System.Configuration.ConfigurationManager.AppSettings["STOREID"] as string, // Store id
                    Session["CONFNUMBER"].ToString(), // Conf number
                    "", // Gift card numbers
                    user.UserName, // user id
                    paymentAccountId,
                    "", // Card id
                    lastFour, // last four
                    "", // exp Date
                    "", // Promo codes
                    validationCode, // paytype
                    "" // Substitutions
                );

                // TODO: Do this better
                // Destroy cart
                Session["CARTITEMS"] = null;
            }
            else
            {
                ViewData["ElementResponse"] = "There was an error processing this transaction.";
            }

            return View();
        }