public EmptyResult OrderNotification(PayPalCheckoutInfo info)
        {
            byte[] parameters = Request.BinaryRead(Request.ContentLength);
            var accepted = _reservations.ProcessReservationPayment(info, parameters);

            return new EmptyResult();
        }
Beispiel #2
0
        public static string OrderNotFoundNotification(PayPalCheckoutInfo info)
        {
            var sb = new StringBuilder();

            sb.Append(@"<h4>Order Not Found Notification</h4>");
            sb.Append(@"<p>A recent PayPal payment notification recieved by the Moore Batting Cage website was not able to be matched with a pending order. ");
            sb.Append(@"This is most likely due to a problem with the web site, and the system administrator should be notified. ");
            sb.Append(@"The data received in the payment notification is listed below.</p>");
            sb.Append(@"<h4>PayPal Information</h4><p>");
            sb.Append(@"Transaction ID: ");
            sb.Append(info.txn_id);
            sb.Append(@"<br/>");
            sb.Append(@"Reservation/Order ID: ");
            sb.Append(info.custom);
            sb.Append(@"<br/>");
            sb.Append(@"Customer First Name: ");
            sb.Append(info.first_name);
            sb.Append(@"<br/>");
            sb.Append(@"Customer Last Name: ");
            sb.Append(info.last_name);
            sb.Append(@"<br/>");
            sb.Append(@"Customer Email: ");
            sb.Append(info.payer_email);
            sb.Append(@"<br/>");
            sb.Append(@"Payment Total: ");
            sb.Append(info.Total);
            sb.Append(@"<br/>");
            return(sb.ToString());
        }
Beispiel #3
0
        public void SendOrderNotFoundNotification(PayPalCheckoutInfo info)
        {
            //TODO: Add actual business email
            var email = EmailTemplates.OrderNotFoundNotification(info);

            EmailHelper.SendEmail("*****@*****.**", "Moore Batting Cage", "Order Not Found Notification", email);
        }
    public HttpStatusCodeResult Receive(PayPalCheckoutInfo info)
    {
        //Fire and forget verification task
        Task.Run(() => VerifyTask(Request, info.Memo));

        //Reply back a 200 code
        return(new HttpStatusCodeResult(HttpStatusCode.OK));
    }
Beispiel #5
0
        public bool ProcessReservationPayment(PayPalCheckoutInfo info, byte[] parameters)
        {
            var accepted = false;

            var model = new PayPalListenerModel();

            model.PayPalCheckoutInfo = info;

            if (parameters != null)
            {
                model.ProcessParameters(parameters);
            }

            if (model.IsVerified && model.IsPaymentCompleted)
            {
                int reservationId;
                if (!Int32.TryParse(info.custom, out reservationId))
                {
                    SendOrderNotFoundNotification(info);
                    return(accepted);
                }

                var reservation = GetReservation(reservationId);

                if (reservation == null)
                {
                    SendOrderNotFoundNotification(info);
                    return(accepted);
                }
                reservation.TransactionId = info.txn_id;
                reservation.AmountPaid    = info.Total;
                var isPaymentValid = reservation.AmountPaid == reservation.OrderTotal;


                if (!isPaymentValid)
                {
                    reservation.Status = _appdb.RejectedStatus;
                    SendInvalidPaymentNotifications(reservation);
                }
                else
                {
                    reservation.Status = _appdb.AcceptedStatus;
                    accepted           = true;
                    reservation.PaymentCompletedTimestamp = info.TrxnDate;
                    ContactManager.AddContact(reservation.CustomerInfo);
                    //TODO: Brivo API
                }

                _appdb.SaveChanges();
            }

            return(accepted);
        }
Beispiel #6
0
        public EmptyResult PayPalPaymentNotification(PayPalCheckoutInfo payPalCheckoutInfo)
        {
            PayPalListenerModel model = new PayPalListenerModel();

            model._PayPalCheckoutInfo = payPalCheckoutInfo;
            byte[] parameters = Request.BinaryRead(Request.ContentLength);

            if (parameters != null)
            {
                model.GetStatus(parameters);
            }
            return(new EmptyResult());
        }
Beispiel #7
0
        public ActionResult Index(PayPalCheckoutInfo payPalCheckoutInfo)
        {
            PayPalListenerModel model = new PayPalListenerModel();

            model._PayPalCheckoutInfo = payPalCheckoutInfo;
            byte[] parameters = Request.BinaryRead(Request.ContentLength);

            if (parameters != null && parameters.Length > 0)
            {
                model.GetStatus(parameters);
                db.PayPalListenerModels.Add(model);
                string request = model._PayPalCheckoutInfo.memo;
                foreach (var z in db.PayPalListenerModels.ToList())
                {
                    if (z._PayPalCheckoutInfo.txn_id == model._PayPalCheckoutInfo.txn_id)
                    {
                        db.PayPalListenerModels.Remove(model);
                    }
                }
                db.SaveChanges();
                return(new EmptyResult());
            }
            return(View());
        }