Exemple #1
0
        protected void SubmitPayment(object sender, EventArgs e)
        {
            clearShoppingCart();

            //Assign the values for the properties we need to pass to the service
            String AppId          = ConfigurationManager.AppSettings["CreditAppId"];
            String SharedKey      = ConfigurationManager.AppSettings["CreditAppSharedKey"];
            String AppTransId     = "20";
            String AppTransAmount = Session["PurchaseTotal"].ToString();

            // Hash the values so the server can verify the values are original
            String hash = HttpUtility.UrlEncode(CreditAuthorizationClient.GenerateClientRequestHash(SharedKey, AppId, AppTransId, AppTransAmount));

            //Create the URL and  concatenate  the Query String values
            String url = "http://ectweb2.cs.depaul.edu/ECTCreditGateway/Authorize.aspx";

            url = url + "?AppId=" + AppId;
            url = url + "&TransId=" + AppTransId;
            url = url + "&AppTransAmount=" + AppTransAmount;
            url = url + "&AppHash=" + hash;

            //Redirect the User to the Service
            Response.Redirect(url);

            // Response.Redirect("OrderHistory.aspx");
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                AppUser user = UserManager.FindByEmail(model.Email);
                if (user != null)
                {
                    ModelState.AddModelError("", "User with this email address has already existed! Please try another email address!");
                    return(View(model));
                }
                user = UserManager.FindByName(model.UserName);
                if (user != null)
                {
                    ModelState.AddModelError("", "The User Name you specified is already existing! Please try with another user name!");
                    return(View(model));
                }
                Session["Register"] = model;
                //Assign the values for the properties we need to pass to the service
                String AppId          = ConfigurationHelper.GetAppId();
                String SharedKey      = ConfigurationHelper.GetSharedKey();
                String AppTransId     = "20";
                String AppTransAmount = "";
                if (model.Membership.Equals("Regular"))
                {
                    AppTransAmount = "49.99";
                }
                else
                {
                    AppTransAmount = "99.99";
                }

                // Hash the values so the server can verify the values are original
                String hash = HttpUtility.UrlEncode(CreditAuthorizationClient.GenerateClientRequestHash(SharedKey, AppId, AppTransId, AppTransAmount));

                //Create the URL and  concatenate  the Query String values
                String url = "http://ectweb2.cs.depaul.edu/ECTCreditGateway/Authorize.aspx";
                url = url + "?AppId=" + AppId;
                url = url + "&TransId=" + AppTransId;
                url = url + "&AppTransAmount=" + AppTransAmount;
                url = url + "&AppHash=" + hash;

                return(Redirect(url));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #3
0
        public void RedirectUser()
        {
            if (Session["ID"] != null)
            {
                int    id = Convert.ToInt32(Session["ID"]);
                int    orderId;
                double price;

                using (AABZContext context = new AABZContext())
                {
                    //This ensures that order is the most recent order the user has made.
                    Order order = (from o in context.Orders
                                   where o.user_id == id
                                   orderby o.Id descending
                                   select o).FirstOrDefault();
                    orderId = order.Id;
                    int        userId = Convert.ToInt32(Session["ID"].ToString());
                    Model.Cart cart   = (from c in context.Carts
                                         where c.user_id == userId
                                         select c).FirstOrDefault();
                    context.ProductsCarts.RemoveRange(context.ProductsCarts.Where(x => x.cart_id == cart.user_id));
                    context.SaveChanges();
                    price = getTotalOrderCost(order);
                }

                //Assign the values for the properties we need to pass to the service
                String AppId          = System.Configuration.ConfigurationManager.AppSettings["CreditAppId"];
                String SharedKey      = System.Configuration.ConfigurationManager.AppSettings["CreditAppSharedKey"];
                String AppTransId     = orderId.ToString();
                String AppTransAmount = price.ToString();

                // Hash the values so the server can verify the values are original
                String hash = HttpUtility.UrlEncode(CreditAuthorizationClient.GenerateClientRequestHash(SharedKey, AppId, AppTransId, AppTransAmount));

                //Create the URL and  concatenate  the Query String values
                String url = "http://ectweb2.cs.depaul.edu/ECTCreditGateway/Authorize.aspx";
                url = url + "?AppId=" + AppId;
                url = url + "&TransId=" + AppTransId;
                url = url + "&AppTransAmount=" + AppTransAmount;
                url = url + "&AppHash=" + hash;

                //Redirect the User to the Service
                //Response.Redirect(url);
                Response.Redirect("~/OrderHistory.aspx");
            }
        }
Exemple #4
0
        public ActionResult InitiateCreditTransaction(double transAmount, int orderId)
        {
            //Assign the values for the properties we need to pass to the service
            String AppId          = ConfigurationManager.AppSettings["CreditAppId"];
            String SharedKey      = ConfigurationManager.AppSettings["CreditAppSharedKey"];
            String AppTransId     = orderId.ToString();     // "20";
            String AppTransAmount = transAmount.ToString(); //"12.50";

            // Hash the values so the server can verify the values are original
            String hash = HttpUtility.UrlEncode(CreditAuthorizationClient.GenerateClientRequestHash(SharedKey, AppId, AppTransId, AppTransAmount));

            //Create the URL and  concatenate  the Query String values
            String url = "http://ectweb2.cs.depaul.edu/ECTCreditGateway/Authorize.aspx";

            url = url + "?AppId=" + AppId;
            url = url + "&TransId=" + AppTransId;
            url = url + "&AppTransAmount=" + AppTransAmount;
            url = url + "&AppHash=" + hash;

            return(Redirect(url));
        }
        public ActionResult PlaceOrder(CheckoutViewModel value)
        {
            ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

            if (cart == null)
            {
                ViewBag.Message = "Your cart is empty!";
                return(View("Index", "ShoppingCart"));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.Message = "Please provide valid shipping address!";
                return(View("Checkout", "ShoppingCart"));
            }

            Session["Checkout"] = value;

            //Assign the values for the properties we need to pass to the service
            String AppId          = ConfigurationHelper.GetAppId2();
            String SharedKey      = ConfigurationHelper.GetSharedKey2();
            String AppTransId     = "20";
            String AppTransAmount = cart.GetTotalValue().ToString();

            // Hash the values so the server can verify the values are original
            String hash = HttpUtility.UrlEncode(CreditAuthorizationClient.GenerateClientRequestHash(SharedKey, AppId, AppTransId, AppTransAmount));

            //Create the URL and  concatenate  the Query String values
            String url = "http://ectweb2.cs.depaul.edu/ECTCreditGateway/Authorize.aspx";

            url = url + "?AppId=" + AppId;
            url = url + "&TransId=" + AppTransId;
            url = url + "&AppTransAmount=" + AppTransAmount;
            url = url + "&AppHash=" + hash;

            return(Redirect(url));
        }