示例#1
0
        bool AmountPaidIsValid(Order order, decimal amountPaid)
        {
            //pull the order
            bool result = true;

            if (order != null)
            {
                if (order.Total > amountPaid)
                {
                    //_logger.Warn("Invalid order Amount to PDT/IPN: " + order.ID + "; Actual: " + amountPaid.ToString("C") + "; Should be: " + order.Total.ToString("C") + "user IP is " + Request.UserHostAddress);
                    result = false;
                }
            }
            else
            {
                //_logger.Warn("Invalid order ID passed to PDT/IPN; user IP is " + Request.UserHostAddress);
            }
            return result;
        }
示例#2
0
        public ActionResult IPN()
        {
            var formVals = new Dictionary<string, string>();
            formVals.Add("cmd", "_notify-validate");

            string response = GetPayPalResponse(formVals, true);

            if (response == "VERIFIED")
            {

                string transactionID = Request["txn_id"];
                string sAmountPaid = Request["mc_gross"];
                string orderID = Request["custom"];

                //_logger.Info("IPN Verified for order " + orderID);

                //validate the order
                Decimal amountPaid = 0;
                Decimal.TryParse(sAmountPaid, out amountPaid);

                //Order order = _orderService.GetOrder(new Guid(orderID));
                Order order = new Order() { ID = orderID };
                //check the Amount paid

                if (AmountPaidIsValid(order, amountPaid))
                {

                    var add = new Address
                                  {
                                      FirstName = Request["first_name"],
                                      LastName = Request["last_name"],
                                      Email = Request["payer_email"],
                                      Street1 = Request["address_street"],
                                      City = Request["address_city"],
                                      StateOrProvince = Request["address_state"],
                                      Country = Request["address_country"],
                                      Zip = Request["address_zip"],
                                      UserName = order.UserName
                                  };

                    //process itPAY
                    try
                    {
                        //_pipeline.AcceptPalPayment(order, transactionID, amountPaid);
                        //_logger.Info("IPN Order successfully transacted: " + orderID);
                        //return RedirectToAction("Success", "Paypal", new { order = order});
                        return View("Return");
                    }
                    catch
                    {
                        //HandleProcessingError(order, x);
                        return View("Return");
                    }
                }
                else
                {
                    //let fail - this is the IPN so there is no viewer
                }
            }

            return View("Return");
        }
示例#3
0
 public ActionResult Success(Order order)
 {
     return View(order);
 }