Esempio n. 1
0
        private Transaction ProcessPaymentTransaction(OnlineRegModel m, PaymentForm pf)
        {
            Transaction ti = null;
            if (m != null && m.Transaction != null)
                ti = PaymentForm.CreateTransaction(DbUtil.Db, m.Transaction, pf.AmtToPay);
            else
                ti = pf.CreateTransaction(DbUtil.Db);

            int? pid = null;
            if (m != null)
            {
                m.ParseSettings();
                var terms = Util.PickFirst(m.Terms, "");
                if (terms.HasValue())
                    ViewData["Terms"] = terms;
                pid = m.UserPeopleId;
                if (m.TranId == null)
                    m.TranId = ti.Id;
            }

            if (!pid.HasValue)
            {
                var pds = DbUtil.Db.FindPerson(pf.First, pf.Last, null, pf.Email, pf.Phone);
                if (pds.Count() == 1)
                    pid = pds.Single().PeopleId.Value;
            }
            TransactionResponse tinfo;
            var gateway = OnlineRegModel.GetTransactionGateway();
            if (gateway == "authorizenet")
                if (pf.SavePayInfo == true)
                {
                    var anet = new AuthorizeNet(DbUtil.Db, pf.testing);
                    tinfo = anet.createCustomerProfileTransactionRequest(
                        pid ?? 0,
                        pf.AmtToPay ?? 0,
                        pf.Description,
                        pf.TranId ?? 0);
                }
                else
                    if (pf.Type == "B")
                        tinfo = OnlineRegModel.PostECheck(
                            pf.Routing, pf.Account,
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.First, pf.Last,
                            pf.Address, pf.City, pf.State, pf.Zip,
                            pf.testing);
                    else
                        tinfo = OnlineRegModel.PostTransaction(
                            pf.CreditCard, pf.CCV,
                            Payments.NormalizeExpires(pf.Expires),
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.Last,
                            pf.Address, pf.City, pf.State, pf.Zip,
                            pf.testing);
            else if (gateway == "sage")
                if (pf.SavePayInfo == true)
                {
                    var sage = new SagePayments(DbUtil.Db, pf.testing);
                    tinfo = sage.createVaultTransactionRequest(
                        pid ?? 0,
                        pf.AmtToPay ?? 0,
                        pf.Description,
                        ti.Id,
                        pf.Type);
                }
                else
                    if (pf.Type == "B")
                        tinfo = OnlineRegModel.PostVirtualCheckTransactionSage(
                            pf.Routing, pf.Account,
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix,
                            pf.Address, pf.City, pf.State, pf.Zip, pf.Phone,
                            pf.testing);
                    else
                        tinfo = OnlineRegModel.PostTransactionSage(
                            pf.CreditCard, pf.CCV,
                            Payments.NormalizeExpires(pf.Expires),
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix,
                            pf.Address, pf.City, pf.State, pf.Zip, pf.Phone,
                            pf.testing);

            else
                throw new Exception("unknown gateway " + gateway);

            ti.TransactionId = tinfo.TransactionId;
            if (ti.Testing == true && !ti.TransactionId.Contains("(testing)"))
                ti.TransactionId += "(testing)";
            ti.Approved = tinfo.Approved;
            if (ti.Approved == false)
            {
                ti.Amtdue += ti.Amt;
                if (m != null && m.OnlineGiving())
                    ti.Amtdue = 0;
            }
            ti.Message = tinfo.Message;
            ti.AuthCode = tinfo.AuthCode;
            ti.TransactionDate = DateTime.Now;
            DbUtil.Db.SubmitChanges();
            return ti;
        }
Esempio n. 2
0
        public ActionResult ProcessPayment(PaymentForm pf)
        {
            if (Session["FormId"] != null)
                if ((Guid)Session["FormId"] == pf.FormId)
                    return Content("Already submitted");
            OnlineRegModel m = null;
            var ed = DbUtil.Db.ExtraDatas.SingleOrDefault(e => e.Id == pf.DatumId);
            if (ed != null)
                m = Util.DeSerialize<OnlineRegModel>(ed.Data);

            if(m != null && m.History.Contains("ProcessPayment"))
                    return Content("Already submitted");

            if (pf.AmtToPay < 0) pf.AmtToPay = 0;
            if (pf.Donate < 0) pf.Donate = 0;

            pf.AllowCoupon = false;

            SetHeaders(pf.OrgId ?? 0);
            ViewBag.Url = pf.Url;
            ViewBag.timeout = INT_timeout;

            if ((pf.AmtToPay ?? 0) <= 0 && (pf.Donate ?? 0) <= 0)
            {
                DbUtil.Db.SubmitChanges();
                ModelState.AddModelError("form", "amount zero");
                return View("ProcessPayment", pf);
            }

            try
            {
                if (pf.Type == "B")
                    Payments.ValidateBankAccountInfo(ModelState, pf.Routing, pf.Account);
                if (pf.Type == "C")
                    Payments.ValidateCreditCardInfo(ModelState, pf.CreditCard, pf.Expires, pf.CCV);

                if (!ModelState.IsValid)
                    return View("ProcessPayment", pf);

                if (pf.IsLoggedIn == true && pf.SavePayInfo == true)
                {
                    var gateway = OnlineRegModel.GetTransactionGateway();
                    if (gateway == "authorizenet")
                    {
                        var au = new AuthorizeNet(DbUtil.Db, m.testing ?? false);
                        if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X"))
                            || (pf.Type == "C" && !pf.CreditCard.StartsWith("X")))
                            au.AddUpdateCustomerProfile(m.UserPeopleId.Value,
                                pf.Type,
                                pf.CreditCard,
                                Payments.NormalizeExpires(pf.Expires),
                                pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV,
                                pf.Routing,
                                pf.Account);
                    }
                    else if (gateway == "sage")
                    {
                        var sg = new CmsData.SagePayments(DbUtil.Db, m.testing ?? false);
                        if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X"))
                            || (pf.Type == "C" && !pf.CreditCard.StartsWith("X")))
                            sg.storeVault(m.UserPeopleId.Value,
                                          pf.Type,
                                          pf.CreditCard,
                                          Payments.NormalizeExpires(pf.Expires),
                                          pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV,
                                          pf.Routing,
                                          pf.Account,
                                          pf.IsGiving == true);
                    }
                    else
                        throw new Exception("ServiceU not supported");

                }
                var ti = ProcessPaymentTransaction(m, pf);

                if (ti.Approved == false)
                {
                    ModelState.AddModelError("form", ti.Message);
                    return View("ProcessPayment", pf);
                }
                if (m != null)
                {
                    m.TranId = ti.Id;
                    m.History.Add("ProcessPayment");
                    ed.Data = Util.Serialize<OnlineRegModel>(m);
                    ed.Completed = true;
                    DbUtil.Db.SubmitChanges();
                }
                Session["FormId"] = pf.FormId;
                if (pf.DatumId > 0)
                {
                    confirm = ConfirmTransaction(m, ti.TransactionId);
                    if (confirm.StartsWith("error:"))
                    {
                        TempData["error"] = confirm.Substring(6);
                        return Redirect("/Error");
                    }
                    return View(confirm);
                }

                ConfirmDuePaidTransaction(ti, ti.TransactionId, sendmail: true);
                return View("ConfirmDuePaid", ti);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
                return View("ProcessPayment", pf);
            }
        }
Esempio n. 3
0
        //private string confirm;
        public ActionResult ProcessPayment(PaymentForm pf)
        {
            #if DEBUG
            #else
            if (Session["FormId"] != null)
                if ((Guid)Session["FormId"] == pf.FormId)
                    return Content("Already submitted");
            #endif
            OnlineRegModel m = null;
            var ed = DbUtil.Db.ExtraDatas.SingleOrDefault(e => e.Id == pf.DatumId);
            if (ed != null)
                m = Util.DeSerialize<OnlineRegModel>(ed.Data);

            #if DEBUG
            #else
            if(m != null && m.History.Contains("ProcessPayment") && !pf.PayBalance)
                    return Content("Already submitted");
            #endif

            if (pf.AmtToPay < 0) pf.AmtToPay = 0;
            if (pf.Donate < 0) pf.Donate = 0;

            pf.AllowCoupon = false;

            SetHeaders(pf.OrgId ?? 0);

            if ((pf.AmtToPay ?? 0) <= 0 && (pf.Donate ?? 0) <= 0)
            {
                DbUtil.Db.SubmitChanges();
                ModelState.AddModelError("form", "amount zero");
                return View("Payment/Process", pf);
            }

            try
            {
                if (pf.Type == "B")
                    Payments.ValidateBankAccountInfo(ModelState, pf.Routing, pf.Account);
                if (pf.Type == "C")
                    Payments.ValidateCreditCardInfo(ModelState, pf);

                if (!ModelState.IsValid)
                    return View("Payment/Process", pf);

                if (pf.IsLoggedIn == true && pf.SavePayInfo)
                {
                    var gateway = OnlineRegModel.GetTransactionGateway();
                    if (gateway == "authorizenet")
                    {
                        var au = new AuthorizeNet(DbUtil.Db, m.testing ?? false);
                        if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X"))
                            || (pf.Type == "C" && !pf.CreditCard.StartsWith("X")))
                            au.AddUpdateCustomerProfile(m.UserPeopleId.Value,
                                pf.Type,
                                pf.CreditCard,
                                DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"),
                                pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV,
                                pf.Routing,
                                pf.Account);
                    }
                    else if (gateway == "sage")
                    {
                        var sg = new CmsData.SagePayments(DbUtil.Db, m.testing ?? false);
                        if ((pf.Type == "B" && !pf.Routing.StartsWith("X") && !pf.Account.StartsWith("X"))
                            || (pf.Type == "C" && !pf.CreditCard.StartsWith("X")))
                            sg.storeVault(m.UserPeopleId.Value,
                                          pf.Type,
                                          pf.CreditCard,
                                          DbUtil.NormalizeExpires(pf.Expires).ToString2("MMyy"),
                                          pf.MaskedCCV != null && pf.MaskedCCV.StartsWith("X") ? pf.CCV : pf.MaskedCCV,
                                          pf.Routing,
                                          pf.Account,
                                          pf.IsGiving == true);
                    }
                    else
                        throw new Exception("ServiceU not supported");

                }
                if (pf.UseBootstrap)
                {
                    var r = AddressVerify.LookupAddress(pf.Address, "", "", "", pf.Zip);
                    if (r.Line1 != "error")
                    {
                        if (r.found == false)
                        {
                            ModelState.AddModelError("Zip",
                                r.address + ", to skip address check, Change the country to USA, Not Validated");
                            return View("Payment/Process", pf);
                        }
                        if (r.Line1 != pf.Address)
                            pf.Address = r.Line1;
                        if (r.City != (pf.City ?? ""))
                            pf.City = r.City;
                        if (r.State != (pf.State ?? ""))
                            pf.State = r.State;
                        if (r.Zip != (pf.Zip ?? ""))
                            pf.Zip = r.Zip;
                    }
                }
                var ti = ProcessPaymentTransaction(m, pf);

                if (ti.Approved == false)
                {
                    ModelState.AddModelError("form", ti.Message);
                    return View("Payment/Process", pf);
                }
                if (m != null)
                {
                    m.TranId = ti.Id;
                    m.History.Add("ProcessPayment");
                    ed.Data = Util.Serialize<OnlineRegModel>(m);
                    ed.Completed = true;
                    DbUtil.Db.SubmitChanges();
                }
                Session["FormId"] = pf.FormId;
                if (pf.DatumId > 0)
                {
                    try
                    {
                        var view = ConfirmTransaction(m, ti.TransactionId);
                        switch (view)
                        {
                            case ConfirmEnum.Confirm:
                                return View("Confirm", m);
                            case ConfirmEnum.ConfirmAccount:
                                return View("ConfirmAccount");
                        }
                    }
                    catch (Exception ex)
                    {
                        TempData["error"] = ex.Message;
                        return Redirect("/Error");
                    }
                }

                ConfirmDuePaidTransaction(ti, ti.TransactionId, sendmail: true);
                return View("PayAmtDue/Confirm", ti);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
                return View("Payment/Process", pf);
            }
        }
Esempio n. 4
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");
        }
Esempio n. 5
0
        public int DoGiving(CMSDataContext Db)
        {
            var          gateway = Db.Setting("TransactionGateway", "");
            AuthorizeNet anet    = null;
            SagePayments sage    = null;

            if (gateway == "AuthorizeNet")
            {
                anet = new AuthorizeNet(Db, testing: false);
            }
            else if (gateway == "Sage")
            {
                sage = new SagePayments(Db, testing: false);
            }
            else
            {
                return(0);
            }

            TransactionResponse ret = null;
            var total = (from a in Db.RecurringAmounts
                         where a.PeopleId == PeopleId
                         where a.ContributionFund.FundStatusId == 1
                         select a.Amt).Sum();

            if (!total.HasValue || total == 0)
            {
                return(0);
            }

            var preferredtype = (from pi in Db.PaymentInfos
                                 where pi.PeopleId == PeopleId
                                 select pi.PreferredGivingType).Single();

            var t = new Transaction
            {
                TransactionDate    = DateTime.Now,
                TransactionId      = "started",
                First              = Person.FirstName,
                MiddleInitial      = Person.MiddleName.Truncate(1) ?? "",
                Last               = Person.LastName,
                Suffix             = Person.SuffixCode,
                Amt                = total,
                Description        = "Recurring Giving",
                Testing            = false,
                TransactionGateway = gateway,
                Financeonly        = true
            };

            Db.Transactions.InsertOnSubmit(t);
            Db.SubmitChanges();

            if (gateway == "AuthorizeNet")
            {
                ret = anet.createCustomerProfileTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id);
            }
            else
            {
                ret = sage.createVaultTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id, preferredtype);
            }
            t.TransactionPeople.Add(new TransactionPerson {
                PeopleId = PeopleId, Amt = total
            });

            t.Message       = ret.Message;
            t.AuthCode      = ret.AuthCode;
            t.Approved      = ret.Approved;
            t.TransactionId = ret.TransactionId;
            var systemEmail = Db.Setting("SystemEmailAddress", "*****@*****.**");

            var contributionemail = (from ex in Person.PeopleExtras
                                     where ex.Field == "ContributionEmail"
                                     select ex.Data).SingleOrDefault();

            if (contributionemail.HasValue())
            {
                contributionemail = contributionemail.Trim();
            }
            if (!Util.ValidEmail(contributionemail))
            {
                contributionemail = Person.FromEmail;
            }
            var gift   = Db.Setting("NameForPayment", "gift");
            var church = Db.Setting("NameOfChurch", Db.CmsHost);

            if (ret.Approved)
            {
                var q = from a in Db.RecurringAmounts
                        where a.PeopleId == PeopleId
                        select a;

                foreach (var a in q)
                {
                    if (a.ContributionFund.FundStatusId == 1 && a.Amt > 0)
                    {
                        Person.PostUnattendedContribution(Db,
                                                          a.Amt ?? 0,
                                                          a.FundId,
                                                          "Recurring Giving", pledge: false);
                    }
                }
                var tot = q.Where(aa => aa.ContributionFund.FundStatusId == 1).Sum(aa => aa.Amt);
                NextDate = FindNextDate(DateTime.Today.AddDays(1));
                Db.SubmitChanges();
                if (tot > 0)
                {
                    Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
                                 "Recurring {0} for {1}".Fmt(gift, church),
                                 "Your payment of ${0:N2} was processed this morning.".Fmt(tot),
                                 Util.ToMailAddressList(contributionemail), 0, null);
                }
            }
            else
            {
                Db.SubmitChanges();
                var failedGivingMessage = Db.ContentHtml("FailedGivingMessage", Resources.ManagedGiving_FailedGivingMessage);
                var adminEmail          = Db.Setting("AdminMail", systemEmail);
                Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
                             "Recurring {0} failed for {1}".Fmt(gift, church),
                             failedGivingMessage.Replace("{first}", Person.PreferredName),
                             Util.ToMailAddressList(contributionemail), 0, null);
                foreach (var p in Db.FinancePeople())
                {
                    Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(adminEmail),
                                 "Recurring Giving Failed on " + Db.CmsHost,
                                 "<a href='{0}Manage/Transactions/Index/{2}'>message: {1}, tranid:{2}</a>".Fmt(Db.CmsHost, ret.Message, t.Id),
                                 Util.ToMailAddressList(p.EmailAddress), 0, null);
                }
            }
            return(1);
        }
Esempio n. 6
0
        public int DoGiving(CMSDataContext Db)
        {
            var gateway = Db.Setting("TransactionGateway", "");
            AuthorizeNet anet = null;
            SagePayments sage = null;
            if (gateway == "AuthorizeNet")
                anet = new AuthorizeNet(Db, testing: false);
            else if (gateway == "Sage")
                sage = new SagePayments(Db, testing: false);
            else
                return 0;

            TransactionResponse ret = null;
            var total = (from a in Db.RecurringAmounts
                         where a.PeopleId == PeopleId
                         where a.ContributionFund.FundStatusId == 1
                         select a.Amt).Sum();

            if (!total.HasValue || total == 0)
                return 0;

            var preferredtype = (from pi in Db.PaymentInfos
                                 where pi.PeopleId == PeopleId
                                 select pi.PreferredGivingType).Single();

            var t = new Transaction
            {
                TransactionDate = DateTime.Now,
                TransactionId = "started",
                First = Person.FirstName,
                MiddleInitial = Person.MiddleName.Truncate(1) ?? "",
                Last = Person.LastName,
                Suffix = Person.SuffixCode,
                Amt = total,
                Description = "Recurring Giving",
                Testing = false,
                TransactionGateway = gateway,
                Financeonly = true
            };
            Db.Transactions.InsertOnSubmit(t);
            Db.SubmitChanges();

            if (gateway == "AuthorizeNet")
                ret = anet.createCustomerProfileTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id);
            else
                ret = sage.createVaultTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id, preferredtype);
            t.TransactionPeople.Add(new TransactionPerson { PeopleId = PeopleId, Amt = total });

            t.Message = ret.Message;
            t.AuthCode = ret.AuthCode;
            t.Approved = ret.Approved;
            t.TransactionId = ret.TransactionId;
            var systemEmail = Db.Setting("SystemEmailAddress", "*****@*****.**");

            var contributionemail = (from ex in Person.PeopleExtras
                                     where ex.Field == "ContributionEmail"
                                     select ex.Data).SingleOrDefault();
            if (contributionemail.HasValue())
                contributionemail = contributionemail.Trim();
            if (!Util.ValidEmail(contributionemail))
                contributionemail = Person.FromEmail;
            var gift = Db.Setting("NameForPayment", "gift");
            var church = Db.Setting("NameOfChurch", Db.CmsHost);
            if (ret.Approved)
            {
                var q = from a in Db.RecurringAmounts
                        where a.PeopleId == PeopleId
                        select a;

                foreach (var a in q)
                {
                    if (a.ContributionFund.FundStatusId == 1 && a.Amt > 0)
                        Person.PostUnattendedContribution(Db,
                            a.Amt ?? 0,
                            a.FundId,
                            "Recurring Giving", pledge: false);
                }
                var tot = q.Where(aa => aa.ContributionFund.FundStatusId == 1).Sum(aa => aa.Amt);
                NextDate = FindNextDate(DateTime.Today.AddDays(1));
                Db.SubmitChanges();
                if (tot > 0)
                {
                    Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
                                 "Recurring {0} for {1}".Fmt(gift, church),
                                 "Your payment of ${0:N2} was processed this morning.".Fmt(tot),
                                 Util.ToMailAddressList(contributionemail), 0, null);
                }
            }
            else
            {
                Db.SubmitChanges();
                var failedGivingMessage = Db.ContentHtml("FailedGivingMessage", Resources.ManagedGiving_FailedGivingMessage);
                var adminEmail = Db.Setting("AdminMail", systemEmail);
                Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
                        "Recurring {0} failed for {1}".Fmt(gift, church),
                        failedGivingMessage.Replace("{first}", Person.PreferredName),
                        Util.ToMailAddressList(contributionemail), 0, null);
                foreach (var p in Db.FinancePeople())
                    Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(adminEmail),
                        "Recurring Giving Failed on " + Db.CmsHost,
                        "<a href='{0}Transactions/{2}'>message: {1}, tranid:{2}</a>".Fmt(Db.CmsHost, ret.Message, t.Id),
                        Util.ToMailAddressList(p.EmailAddress), 0, null);
            }
            return 1;
        }
Esempio n. 7
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();
        }