Exemple #1
0
        public ActionResult Payment(ItemPayPal model)
        {
            if (model != null && model.Price > 0)
            {
                if (AppSettings.IsPaymentTest)
                {
                    model.Price = AppSettings.PaymentAmount;
                }

                model.Description = model.Name ?? "Donación";
                model.Quantity    = 1;

                List <ItemPayPal> items = new List <ItemPayPal> {
                    model
                };
                var        token             = _paymentCore.GenerateOrder(items);
                HttpCookie payPalTokenCookie = new HttpCookie("_c3P-Pt5", token)
                {
                    Expires = DateTime.Now.AddMinutes(10)
                };
                Response.Cookies.Add(payPalTokenCookie);
                return(Redirect(string.Concat(AppSettings.PayPalUrl, token)));
            }

            TempData["type"]    = "warning";
            TempData["message"] = Messages.PaymentWrong;
            return(RedirectToHome());
        }
Exemple #2
0
        public ActionResult Payment(ItemPayPal model)
        {
            var element = _presents.FirstOrDefault(x => x.Key.Equals(model.Key));

            if (element != null)
            {
                if (AppSettings.IsPaymentTest)
                {
                    model.Price = AppSettings.PaymentAmount;
                }
                else
                {
                    model.Price = element.Total;
                }

                if (model.Price > 0)
                {
                    model.Description = model.Name;
                    model.Quantity    = 1;

                    List <ItemPayPal> items = new List <ItemPayPal> {
                        model
                    };
                    var        token             = GenerateOrder(items);
                    HttpCookie payPalTokenCookie = new HttpCookie("_c3P-Pt5", token)
                    {
                        Expires = DateTime.Now.AddMinutes(10)
                    };
                    Response.Cookies.Add(payPalTokenCookie);
                    TempData["email"] = model.Email;
                    return(Redirect(string.Concat(AppSettings.PayPalUrl, token)));
                }
            }
            TempData["message"] = Messages.PaymentWrong;
            return(RedirectToAction("Present", "Present"));
        }