예제 #1
0
        public ActionResult DoGiving()
        {
            string date = Request.QueryString.AllKeys.Contains("date") ? Request.QueryString["date"] : null;

            if (date.HasValue() && DateTime.TryParse(date, out DateTime parsedDate))
            {
                Util.DateSimulation = true;
                Util.Today          = parsedDate;
            }
            ManagedGiving.DoAllGiving(CurrentDatabase);
            Util.ResetToday();
            Util.DateSimulation = false;
            return(Content("done"));
        }
예제 #2
0
        private void PopulateSetup(ManagedGiving rg)
        {
            RepeatPattern = rg.SemiEvery != "S" ? rg.Period : rg.SemiEvery;
            SemiEvery     = rg.SemiEvery;
            StartWhen     = rg.StartWhen;
            StopWhen      = null; //rg.StopWhen;
            Day1          = rg.Day1;
            Day2          = rg.Day2;
            EveryN        = rg.EveryN;
            Period        = rg.Period;
            foreach (var ra in person.RecurringAmounts.AsEnumerable())
            {
                FundItem.Add(ra.FundId, ra.Amt);
            }

            NextDate = rg.NextDate;
        }
예제 #3
0
 public ActionResult DoGiving()
 {
     ManagedGiving.DoAllGiving(DbUtil.Db);
     return(Content("done"));
 }
예제 #4
0
        public ActionResult RunRecurringGiving()
        {
            var count = ManagedGiving.DoAllGiving(DbUtil.Db);

            return(Content(count.ToString()));
        }
예제 #5
0
        public void Update()
        {
            var gateway = OnlineRegModel.GetTransactionGateway();

            if (gateway == "authorizenet")
            {
                var au = new AuthorizeNet(DbUtil.Db, testing);
                au.AddUpdateCustomerProfile(pid,
                                            Type,
                                            Cardnumber,
                                            Expires,
                                            Cardcode,
                                            Routing,
                                            Account);
            }
            else if (gateway == "sage")
            {
                var sg = new SagePayments(DbUtil.Db, testing);
                sg.storeVault(pid,
                              Type,
                              Cardnumber,
                              Expires,
                              Cardcode,
                              Routing,
                              Account,
                              giving: true);
            }
            else
            {
                throw new Exception("ServiceU not supported");
            }

            var mg = person.ManagedGiving();

            if (mg == null)
            {
                mg = new ManagedGiving();
                person.ManagedGivings.Add(mg);
            }
            mg.SemiEvery = SemiEvery;
            mg.Day1      = Day1;
            mg.Day2      = Day2;
            mg.EveryN    = EveryN;
            mg.Period    = Period;
            mg.StartWhen = StartWhen;
            mg.StopWhen  = StopWhen;
            mg.NextDate  = mg.FindNextDate(DateTime.Today);

            var pi = person.PaymentInfo();

            pi.FirstName     = FirstName.Truncate(50);
            pi.MiddleInitial = Middle.Truncate(10);
            pi.LastName      = LastName.Truncate(50);
            pi.Suffix        = Suffix.Truncate(10);
            pi.Address       = Address.Truncate(50);
            pi.City          = City.Truncate(50);
            pi.State         = State.Truncate(10);
            pi.Zip           = Zip.Truncate(15);
            pi.Phone         = Phone.Truncate(25);

            var q = from ra in DbUtil.Db.RecurringAmounts
                    where ra.PeopleId == pid
                    select ra;

            DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q);
            DbUtil.Db.SubmitChanges();
            foreach (var c in FundItemsChosen())
            {
                var ra = new RecurringAmount
                {
                    PeopleId = pid,
                    FundId   = c.fundid,
                    Amt      = c.amt
                };
                DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra);
            }
            DbUtil.Db.SubmitChanges();
        }
예제 #6
0
        public void Update()
        {
            var db = DbUtil.Db;
            // first check for total amount greater than zero.
            // if so we skip everything except updating the amounts.
            var chosenFunds = FundItemsChosen().ToList();

            if (chosenFunds.Sum(f => f.amt) > 0)
            {
                var pi = person.PaymentInfo();
                if (pi == null)
                {
                    pi = new PaymentInfo();
                    person.PaymentInfos.Add(pi);
                }
                pi.SetBillingAddress(FirstName, Middle, LastName, Suffix, Address, Address2, City, State, Country, Zip, Phone);

                // first need to do a $1 auth if it's a credit card and throw any errors we get back
                // from the gateway.
                var vaultSaved = false;
                var gateway    = db.Gateway(testing);
                if (Type == PaymentType.CreditCard)
                {
                    // perform $1 auth.
                    // need to randomize the $1 amount because some gateways will reject same auth amount
                    // subsequent times per user.
                    var random    = new Random();
                    var dollarAmt = (decimal)random.Next(100, 199) / 100;

                    TransactionResponse transactionResponse;
                    if (CreditCard.StartsWith("X"))
                    {
//                        // store payment method in the gateway vault first before doing the auth.
//                          If it starts with X, we should not be storing it in the vault.
//                        gateway.StoreInVault(pid, Type, CreditCard, Expires, CVV, Routing, Account, giving: true);
                        vaultSaved          = true; // prevent it from saving later
                        transactionResponse = gateway.AuthCreditCardVault(pid, dollarAmt, "Recurring Giving Auth", 0);
                    }
                    else
                    {
                        var pf = new PaymentForm()
                        {
                            CreditCard = CreditCard,
                            First      = FirstName,
                            Last       = LastName
                        };
                        if (IsCardTester(pf, "ManagedGiving"))
                        {
                            throw new Exception("Found Card Tester");
                        }
                        transactionResponse = gateway.AuthCreditCard(pid, dollarAmt, CreditCard, Expires,
                                                                     "Recurring Giving Auth", 0, CVV, string.Empty,
                                                                     FirstName, LastName, Address, Address2, City, State, Country, Zip, Phone);
                    }

                    if (!transactionResponse.Approved)
                    {
                        throw new Exception(transactionResponse.Message);
                    }

                    // if we got this far that means the auth worked so now let's do a void for that auth.
                    var voidResponse = gateway.VoidCreditCardTransaction(transactionResponse.TransactionId);
                }

                // store payment method in the gateway vault if not already saved.
                if (!vaultSaved)
                {
                    gateway.StoreInVault(pid, Type, CreditCard, Expires, CVV, Routing, Account, giving: true);
                }

                // save all the managed giving data.
                var mg = person.ManagedGiving();
                if (mg == null)
                {
                    mg = new ManagedGiving();
                    person.ManagedGivings.Add(mg);
                }
                mg.SemiEvery = SemiEvery;
                mg.Day1      = Day1;
                mg.Day2      = Day2;
                mg.EveryN    = EveryN;
                mg.Period    = Period;
                mg.StartWhen = StartWhen;
                mg.StopWhen  = StopWhen;
                mg.NextDate  = mg.FindNextDate(DateTime.Today);
            }

            db.RecurringAmounts.DeleteAllOnSubmit(person.RecurringAmounts);
            db.SubmitChanges();

            person.RecurringAmounts.AddRange(chosenFunds.Select(c => new RecurringAmount {
                FundId = c.fundid, Amt = c.amt
            }));
            db.SubmitChanges();
        }
예제 #7
0
        public ActionResult RunRecurringGiving()
        {
            var count = ManagedGiving.DoAllGiving(CurrentDatabase);

            return(Content(count.ToString()));
        }
예제 #8
0
 public ActionResult DoGiving()
 {
     ManagedGiving.DoAllGiving(CurrentDatabase);
     return(Content("done"));
 }
예제 #9
0
        public ActionResult ManageGiving(ManageGivingModel m)
        {
            SetHeaders(m.orgid);
            RemoveNonDigitsIfNecessary(m);
            m.ValidateModel(ModelState);
            if (!ModelState.IsValid)
            {
                return(View(m));
            }
            try
            {
                var gateway = OnlineRegModel.GetTransactionGateway();
                if (gateway == "authorizenet")
                {
                    var au = new AuthorizeNet(DbUtil.Db, m.testing);
                    au.AddUpdateCustomerProfile(m.pid,
                                                m.Type,
                                                m.Cardnumber,
                                                m.Expires,
                                                m.Cardcode,
                                                m.Routing,
                                                m.Account);
                }
                else if (gateway == "sage")
                {
                    var sg = new SagePayments(DbUtil.Db, m.testing);
                    sg.storeVault(m.pid,
                                  m.Type,
                                  m.Cardnumber,
                                  m.Expires,
                                  m.Cardcode,
                                  m.Routing,
                                  m.Account,
                                  giving: true);
                }
                else
                {
                    throw new Exception("ServiceU not supported");
                }

                var mg = m.person.ManagedGiving();
                if (mg == null)
                {
                    mg = new ManagedGiving();
                    m.person.ManagedGivings.Add(mg);
                }
                mg.SemiEvery = m.SemiEvery;
                mg.Day1      = m.Day1;
                mg.Day2      = m.Day2;
                mg.EveryN    = m.EveryN;
                mg.Period    = m.Period;
                mg.StartWhen = m.StartWhen;
                mg.StopWhen  = m.StopWhen;
                mg.NextDate  = mg.FindNextDate(DateTime.Today);

                var pi = m.person.PaymentInfo();
                pi.FirstName     = m.firstname.Truncate(50);
                pi.MiddleInitial = m.middleinitial.Truncate(10);
                pi.LastName      = m.lastname.Truncate(50);
                pi.Suffix        = m.suffix.Truncate(10);
                pi.Address       = m.address.Truncate(50);
                pi.City          = m.city.Truncate(50);
                pi.State         = m.state.Truncate(10);
                pi.Zip           = m.zip.Truncate(15);
                pi.Phone         = m.phone.Truncate(25);

                var q = from ra in DbUtil.Db.RecurringAmounts
                        where ra.PeopleId == m.pid
                        select ra;
                DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q);
                DbUtil.Db.SubmitChanges();
                foreach (var c in m.FundItemsChosen())
                {
                    var ra = new RecurringAmount
                    {
                        PeopleId = m.pid,
                        FundId   = c.fundid,
                        Amt      = c.amt
                    };
                    DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra);
                }
                DbUtil.Db.SubmitChanges();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
            }
            if (!ModelState.IsValid)
            {
                return(View(m));
            }
            TempData["managegiving"] = m;
            return(Redirect("ConfirmRecurringGiving"));
        }