Exemplo n.º 1
0
        public static Transaction CreateTransaction(CMSDataContext Db, Transaction t, decimal?amount)
        {
            var amtdue = t.Amtdue != null ? t.Amtdue - (amount ?? 0) : null;
            var ti     = new Transaction
            {
                Name               = t.Name,
                First              = t.First,
                MiddleInitial      = t.MiddleInitial,
                Last               = t.Last,
                Suffix             = t.Suffix,
                Donate             = t.Donate,
                Amtdue             = amtdue,
                Amt                = amount,
                Emails             = Util.FirstAddress(t.Emails).Address,
                Testing            = t.Testing,
                Description        = t.Description,
                OrgId              = t.OrgId,
                Url                = t.Url,
                Address            = t.Address,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(),
                City               = t.City,
                State              = t.State,
                Zip                = t.Zip,
                DatumId            = t.DatumId,
                Phone              = t.Phone,
                OriginalId         = t.OriginalId ?? t.Id,
                Financeonly        = t.Financeonly,
                TransactionDate    = DateTime.Now,
            };

            Db.Transactions.InsertOnSubmit(ti);
            Db.SubmitChanges();
            return(ti);
        }
Exemplo n.º 2
0
        public static PaymentForm CreatePaymentFormForBalanceDue(Transaction ti)
        {
            PaymentInfo pi = null;

            if (ti.Person != null && string.Equals(OnlineRegModel.GetTransactionGateway(),
                                                   "Sage", StringComparison.InvariantCultureIgnoreCase))
            {
                pi = ti.Person.PaymentInfos.FirstOrDefault();
            }
            if (pi == null)
            {
                pi = new PaymentInfo();
            }
            var pf = new PaymentForm
            {
                PayBalance  = true,
                AmtToPay    = ti.Amtdue ?? 0,
                Amtdue      = ti.Amtdue ?? 0,
                AllowCoupon = true,
                AskDonation = false,
                Description = ti.Description,
                OrgId       = ti.OrgId,
                OriginalId  = ti.OriginalId,
                Email       = Util.FirstAddress(ti.Emails).Address,

                First         = ti.First,
                MiddleInitial = ti.MiddleInitial.Truncate(1) ?? "",
                Last          = ti.Last,
                Suffix        = ti.Suffix,

                Phone   = ti.Phone,
                Address = ti.Address,
                City    = ti.City,
                State   = ti.State,
                Zip     = ti.Zip,
                timeout = 6000000,
                testing = ti.Testing ?? false,
                TranId  = ti.Id,
#if DEBUG2
                CreditCard = "4111111111111111",
                CCV        = "123",
                Expires    = "1015",
                Routing    = "056008849",
                Account    = "12345678901234"
#else
                CreditCard  = pi.MaskedCard,
                MaskedCCV   = Util.Mask(new StringBuilder(pi.Ccv), 0),
                CCV         = pi.Ccv,
                Expires     = pi.Expires,
                Account     = pi.MaskedAccount,
                Routing     = pi.Routing,
                SavePayInfo =
                    (pi.MaskedAccount != null && pi.MaskedAccount.StartsWith("X")) ||
                    (pi.MaskedCard != null && pi.MaskedCard.StartsWith("X")),
#endif
            };

            pf.Type = pf.NoEChecksAllowed ? "C" : "";
            return(pf);
        }
Exemplo n.º 3
0
 public TransactionsModel()
 {
     Pager           = new PagerModel2(Count);
     Pager.Sort      = "Date";
     Pager.Direction = "desc";
     finance         = HttpContext.Current.User.IsInRole("Finance");
     isSage          = OnlineRegModel.GetTransactionGateway() == "sage";
     admin           = HttpContext.Current.User.IsInRole("Admin") || HttpContext.Current.User.IsInRole("ManageTransactions");
 }
Exemplo n.º 4
0
        public ManageGivingModel()
        {
            HeadingLabel = DbUtil.Db.Setting("ManageGivingHeaderLabel", "Giving Opportunities");
            //testing = ConfigurationManager.AppSettings["testing"].ToBool();
#if DEBUG2
            testing = true;
#endif
            NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
            NoEChecksAllowed     = OnlineRegModel.GetTransactionGateway() != "sage";
        }
Exemplo n.º 5
0
        public Transaction CreateTransaction(CMSDataContext Db, decimal?amount = null, OnlineRegModel m = null)
        {
            if (!amount.HasValue)
            {
                amount = AmtToPay;
            }
            decimal?amtdue = null;

            if (Amtdue > 0)
            {
                amtdue = Amtdue - (amount ?? 0);
            }
            var ti = new Transaction
            {
                First              = First,
                MiddleInitial      = MiddleInitial.Truncate(1) ?? "",
                Last               = Last,
                Suffix             = Suffix,
                Donate             = Donate,
                Regfees            = AmtToPay,
                Amt                = amount,
                Amtdue             = amtdue,
                Emails             = Email,
                Testing            = testing,
                Description        = Description,
                OrgId              = OrgId,
                Url                = URL,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(),
                Address            = Address.Truncate(50),
                Address2           = Address2.Truncate(50),
                City               = City,
                State              = State,
                Country            = Country,
                Zip                = Zip,
                DatumId            = DatumId,
                Phone              = Phone.Truncate(20),
                OriginalId         = OriginalId,
                Financeonly        = FinanceOnly,
                TransactionDate    = DateTime.Now,
                PaymentType        = Type,
                LastFourCC         = Type == PaymentType.CreditCard ? CreditCard.Last(4) : null,
                LastFourACH        = Type == PaymentType.Ach ? Account.Last(4) : null
            };

            Db.Transactions.InsertOnSubmit(ti);
            Db.SubmitChanges();
            if (OriginalId == null) // first transaction
            {
                ti.OriginalId = ti.Id;
            }
            return(ti);
        }
Exemplo n.º 6
0
        private void CheckBatchDates(DateTime start, DateTime end)
        {
            if (OnlineRegModel.GetTransactionGateway() != "sage")
            {
                return;
            }
            var sage    = new SagePayments(DbUtil.Db, false);
            var bds     = sage.SettledBatchSummary(start, end, true, true);
            var batches = from batch in bds.Tables[0].AsEnumerable()
                          select new
            {
                date      = batch["date"].ToDate().Value.AddHours(4),
                reference = batch["reference"].ToString(),
                type      = batch["type"].ToString()
            };

            foreach (var batch in batches)
            {
                if (DbUtil.Db.CheckedBatches.Any(tt => tt.BatchRef == batch.reference))
                {
                    continue;
                }

                var ds = sage.SettledBatchListing(batch.reference, batch.type);

                var items = from r in ds.Tables[0].AsEnumerable()
                            select new
                {
                    settled   = r["settle_date"].ToDate().Value.AddHours(4),
                    tranid    = r["order_number"],
                    reference = r["reference"].ToString(),
                    approved  = r["approved"].ToString().ToBool(),
                    name      = r["name"].ToString(),
                    message   = r["message"].ToString(),
                    amount    = r["total_amount"].ToString(),
                    date      = r["date"].ToDate(),
                    type      = r["transaction_code"].ToInt()
                };
                var settlelist = items.ToDictionary(ii => ii.reference, ii => ii);

                var q = from t in DbUtil.Db.Transactions
                        where settlelist.Keys.Contains(t.TransactionId)
                        where t.Approved == true
                        select t;
                var tlist = q.ToDictionary(ii => ii.TransactionId, ii => ii); // transactions that are found in setteled list;
                var q2    = from st in settlelist
                            where !tlist.Keys.Contains(st.Key)
                            select st.Value;
                var notbefore = DateTime.Parse("6/1/12");
                foreach (var st in q2)
                {
                    var    t = DbUtil.Db.Transactions.SingleOrDefault(j => j.TransactionId == st.reference && st.date >= notbefore);
                    string first, last;
                    Util.NameSplit(st.name, out first, out last);
                    var tt = new Transaction
                    {
                        Name               = st.name,
                        First              = first,
                        Last               = last,
                        TransactionId      = st.reference,
                        Amt                = st.amount.ToDecimal(),
                        Approved           = st.approved,
                        Message            = st.message,
                        TransactionDate    = st.date,
                        TransactionGateway = "sage",
                        Settled            = st.settled,
                        Batch              = batch.date,
                        Batchref           = batch.reference,
                        Batchtyp           = batch.type,
                        OriginalId         = t != null ? (t.OriginalId ?? t.Id) : (int?)null,
                        Fromsage           = true,
                        Description        = t != null ? t.Description : "no description from sage, id=" + st.tranid,
                    };
                    if (st.type == 6) // credit transaction
                    {
                        tt.Amt = -tt.Amt;
                    }
                    DbUtil.Db.Transactions.InsertOnSubmit(tt);
                }

                foreach (var t in q)
                {
                    if (!settlelist.ContainsKey(t.TransactionId))
                    {
                        continue;
                    }
                    t.Batch    = batch.date;
                    t.Batchref = batch.reference;
                    t.Batchtyp = batch.type;
                    t.Settled  = settlelist[t.TransactionId].settled;
                }
                var cb = DbUtil.Db.CheckedBatches.SingleOrDefault(bb => bb.BatchRef == batch.reference);
                if (cb == null)
                {
                    DbUtil.Db.CheckedBatches.InsertOnSubmit(
                        new CheckedBatch()
                    {
                        BatchRef = batch.reference,
                        CheckedX = DateTime.Now
                    });
                }
                else
                {
                    cb.CheckedX = DateTime.Now;
                }
                DbUtil.Db.SubmitChanges();
            }
        }
Exemplo 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();
        }
Exemplo n.º 8
0
        public static PaymentForm CreatePaymentFormForBalanceDue(Transaction ti, decimal amtdue)
        {
            PaymentInfo pi = null;

            if (ti.Person != null && OnlineRegModel.GetTransactionGateway().Equal("sage"))
            {
                pi = ti.Person.PaymentInfos.FirstOrDefault();
            }
            if (pi == null)
            {
                pi = new PaymentInfo();
            }

            var pf = new PaymentForm
            {
                URL         = ti.Url,
                PayBalance  = true,
                AmtToPay    = amtdue,
                Amtdue      = 0,
                AllowCoupon = true,
                AskDonation = false,
                Description = ti.Description,
                OrgId       = ti.OrgId,
                OriginalId  = ti.OriginalId,
                Email       = Util.FirstAddress(ti.Emails).Address,
                FormId      = Guid.NewGuid(),

                First         = ti.First,
                MiddleInitial = ti.MiddleInitial.Truncate(1) ?? "",
                Last          = ti.Last,
                Suffix        = ti.Suffix,

                Phone   = ti.Phone,
                Address = ti.Address,
                City    = ti.City,
                State   = ti.State,
                Zip     = ti.Zip,
                testing = ti.Testing ?? false,
                TranId  = ti.Id,
#if DEBUG2
                CreditCard = "4111111111111111",
                CCV        = "123",
                Expires    = "1015",
                Routing    = "056008849",
                Account    = "12345678901234"
#else
                CreditCard  = pi.MaskedCard,
                MaskedCCV   = Util.Mask(new StringBuilder(pi.Ccv), 0),
                CCV         = pi.Ccv,
                Expires     = pi.Expires,
                Account     = pi.MaskedAccount,
                Routing     = pi.Routing,
                SavePayInfo =
                    (pi.MaskedAccount != null && pi.MaskedAccount.StartsWith("X")) ||
                    (pi.MaskedCard != null && pi.MaskedCard.StartsWith("X")),
#endif
            };

            pf.Type = pf.NoEChecksAllowed ? "C" : "";
            var org     = DbUtil.Db.LoadOrganizationById(ti.OrgId);
            var setting = new CmsData.Registration.Settings(org.RegSetting, DbUtil.Db, org.OrganizationId);

            pf.UseBootstrap = setting.UseBootstrap;
            return(pf);
        }