//
 // GET: /Payment/
 public void Index()
 {
     var checkout = TempData["checkoutInfo"] as Checkout;
     var cart = Session["Cart"] as List<CartItem>;
     var paypal = new PayPalManagement
     {
         Checkout = checkout,
         WebResponse = Response,
         CancelUrl = Url.Action("PaymentCancellation", null, null, Request.Url.Scheme),
         CheckoutReturnUrl = Url.Action("PaymentReceived", null, null, Request.Url.Scheme),
         Cart = cart
     };
     TempData["checkoutInfo"] = checkout;
     paypal.SetQuickCheckOut();
 }
        public ActionResult PaymentReceived(string token, string payerId)
        {
            var checkout = TempData["checkoutInfo"] as Checkout;
            var cart = Session["Cart"] as List<CartItem>;
            var payPalManagement = new PayPalManagement
            {
                Checkout = checkout,
                WebResponse = Response,
                CancelUrl = Url.Action("PaymentCancellation"),
                CheckoutReturnUrl = Url.Action("PaymentReceived"),
                Cart = cart
            };
            TempData["checkoutInfo"] = checkout;
            var response = payPalManagement.DoExpressCheckout(Response, token);
            if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0))
            {
                return PaymentFailed(response.Errors.Select(x => x.LongMessage));
            }

            return PaymentResponseSuccess(response, checkout, cart);
        }