コード例 #1
0
        public ActionResult CompletePayPalCheckout(string token = "", string payerID = "") {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = ViewBag.customer;
            customer.GetFromStorage(ctx);
            if (!customer.Cart.Validate()) {
                return RedirectToAction("Index", "Cart");
            }
            if (customer.Cart.GetPaymentID() > 0) {
                UDF.ExpireCart(ctx, customer.ID);
                return RedirectToAction("Index", "Cart");
            }
            if (customer.Cart.GetStatus().statusID != (int)OrderStatuses.PaymentPending) {
                UDF.ExpireCart(ctx, customer.ID);
                return RedirectToAction("Index", "Cart");
            };
            decimal total = customer.Cart.getTotal();
            Paypal p = new Paypal();
            string confirmationKey = p.ECDoExpressCheckout(token, payerID, total.ToString(), customer.Cart);
            if (confirmationKey == "Success") {
                customer.Cart.AddPayment("PayPal", token, "Complete");
                customer.Cart.SetStatus((int)OrderStatuses.PaymentComplete);
                customer.Cart.SendConfirmation(ctx);
                customer.Cart.SendInternalOrderEmail(ctx);
                int cartid = customer.Cart.ID;

                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(ctx, customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                return RedirectToAction("Complete", new { id = cartid });
            } else {
                return RedirectToAction("Index", new { message = "Your PayPal Transaction Could not be processed. Try Again." });
            }

        }
コード例 #2
0
        public ActionResult PayPalCheckout(string token = "", string payerID = "") {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = ViewBag.customer;
            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage(ctx);

            // Create Cart object from customer
            customer.BindAddresses();
            Cart cart = customer.Cart;

            // Get the parts from this Cart
            cart.GetParts();

            ViewBag.showTotal = true;
            ViewBag.showQty = false;
            ViewBag.cart = cart;
            ViewBag.message = TempData["message"];
            Paypal p = new Paypal();
            PayPalResponse paypalResponse = p.ECGetExpressCheckout(token);
            if (paypalResponse.acknowledgement == "Success") {
                ViewBag.paypalResponse = paypalResponse;
                return View();
            }
            return RedirectToAction("Index", new { message = "Your PayPal Transaction Could not be processed. Try Again." });
        }
コード例 #3
0
 public ActionResult PayPal() {
     HttpContext ctx = System.Web.HttpContext.Current;
     Customer customer = ViewBag.customer;
     customer.GetFromStorage(ctx);
     if (!customer.Cart.Validate()) {
         return RedirectToAction("Index", "Cart");
     }
     if (customer.Cart.GetPaymentID() > 0) {
         UDF.ExpireCart(ctx, customer.ID);
         return RedirectToAction("Index", "Cart");
     }
     Paypal p = new Paypal();
     string token = p.ECSetExpressCheckout(customer.Cart);
     if (!token.ToLower().Contains("failure")) {
         customer.Cart.SetStatus((int)OrderStatuses.PaymentPending);
         customer.Cart.paypalToken = token;
         if (Request.Url.Host.Contains("127.0.0") || Request.Url.Host.Contains("localhost")) {
             return Redirect("https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=" + token);
         } else {
             return Redirect("https://www.paypal.com/webscr?cmd=_express-checkout&token=" + token);
         }
     } else {
         return RedirectToAction("Index", new { message = "There was a problem with your PayPal transaction. " + token });
     }
 }
コード例 #4
0
        public ActionResult PayPalCheckout(string token = "", string payerID = "")
        {
            Customer customer = ViewBag.customer;
            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage();
            if (!customer.LoggedIn()) {
                return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
            }

            // Create Cart object from customer
            customer.BindAddresses();
            Cart cart = customer.Cart;

            // Get the parts from this Cart
            cart.GetParts();

            ViewBag.showShipping = true;
            ViewBag.cart = cart;
            ViewBag.message = TempData["message"];
            Paypal p = new Paypal();
            PayPalResponse paypalResponse = p.ECGetExpressCheckout(token);
            if (paypalResponse.acknowledgement == "Success") {
                ViewBag.paypalResponse = paypalResponse;
                return View();
            }
            return RedirectToAction("Index", new { message = "Your PayPal Transaction Could not be processed. Try Again." });
        }
コード例 #5
0
 public ActionResult PayPal()
 {
     Customer customer = ViewBag.customer;
     customer.GetFromStorage();
     if (!customer.LoggedIn()) {
         return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
     }
     if (customer.Cart.payment_id > 0) {
         UDF.ExpireCart(customer.ID);
         return RedirectToAction("Index", "Cart");
     }
     Paypal p = new Paypal();
     string token = p.ECSetExpressCheckout(customer.Cart);
     if (!token.ToLower().Contains("failure")) {
         customer.Cart.paypalToken = token;
         if (Request.Url.Host.Contains("127.0.0") || Request.Url.Host.Contains("localhost")) {
             return Redirect("https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=" + token);
         } else {
             return Redirect("https://www.paypal.com/webscr?cmd=_express-checkout&token=" + token);
         }
     } else {
         return RedirectToAction("Index", new { message = "There was a problem with your PayPal transaction. " + token });
     }
 }
コード例 #6
0
        public ActionResult CompletePayPalCheckout(string token = "", string payerID = "")
        {
            Customer customer = ViewBag.customer;
            customer.GetFromStorage();
            if (!customer.LoggedIn()) {
                return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
            }
            decimal total = customer.Cart.getTotal();
            Paypal p = new Paypal();
            string confirmationKey = p.ECDoExpressCheckout(token, payerID, total.ToString(), customer.Cart);
            if (confirmationKey == "Success") {
                customer.Cart.AddPayment("PayPal", token, "Complete");
                customer.Cart.SendConfirmation();
                int cartid = customer.Cart.ID;

                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                EDI edi = new EDI();
                edi.CreatePurchaseOrder(cartid);
                return RedirectToAction("Complete", new { id = cartid });
            } else {
                return RedirectToAction("Index", new { message = "Your PayPal Transaction Could not be processed. Try Again." });
            }
        }