public Transaction ProcessPaymentTransaction(OnlineRegModel m) { var ti = (m?.Transaction != null) ? CreateTransaction(CurrentDatabase, m.Transaction, AmtToPay) : CreateTransaction(CurrentDatabase); int?pid = null; if (m != null) { m.ParseSettings(); pid = m.UserPeopleId; if (m.TranId == null) { m.TranId = ti.Id; } } if (!pid.HasValue) { var pds = CurrentDatabase.FindPerson(First, Last, null, Email, Phone); if (pds.Count() == 1) { pid = pds.Single().PeopleId.Value; } } TransactionResponse tinfo; var processType = m?.ProcessType ?? PaymentProcessTypes.OnlineRegistration; var gw = CurrentDatabase.Gateway(testing, null, processType); if (SavePayInfo) { tinfo = gw.PayWithVault(pid ?? 0, AmtToPay ?? 0, Description, ti.Id, Type); } else { tinfo = Type == PaymentType.Ach ? PayWithCheck(gw, pid, ti) : PayWithCreditCard(gw, pid, ti); } ti.TransactionId = tinfo.TransactionId; ti.Testing = CheckIfIsGatewayTesting(ti.Testing.GetValueOrDefault(), processType); if (ti.Testing.GetValueOrDefault() && !ti.TransactionId.Contains("(testing)")) { ti.TransactionId += "(testing)"; } ti.Approved = tinfo.Approved; transactionApproved = tinfo.Approved; if (!ti.Approved.GetValueOrDefault()) { ti.Amtdue += ti.Amt; if (m != null && m.OnlineGiving()) { ti.Amtdue = 0; } } ti.Message = tinfo.Message; ti.AuthCode = tinfo.AuthCode; ti.TransactionDate = Util.Now; CurrentDatabase.SubmitChanges(); return(ti); }
public static PaymentForm CreatePaymentForm(OnlineRegModel m) { var r = m.GetTransactionInfo(); if (r == null) { return(null); } var pf = new PaymentForm { FormId = Guid.NewGuid(), AmtToPay = m.PayAmount() + (m.donation ?? 0), AskDonation = m.AskDonation(), AllowCoupon = !m.OnlineGiving(), PayBalance = false, Amtdue = m.TotalAmount() + (m.donation ?? 0), Donate = m.donation, Description = m.DescriptionForPayment, Email = r.Email, First = r.First, MiddleInitial = r.Middle, Last = r.Last, Suffix = r.Suffix, IsLoggedIn = m.UserPeopleId.HasValue, OrgId = m.List[0].orgid, URL = m.URL, testing = m.testing ?? false, Terms = m.Terms, Address = r.Address, Address2 = r.Address2, City = r.City, State = r.State, Country = r.Country, Zip = r.Zip, Phone = r.Phone, SupportMissionTrip = m.SupportMissionTrip, extTransactionId = m.transactionId, ProcessType = m.ProcessType, #if DEBUG2 CreditCard = "4111111111111111", CVV = "123", Expires = "1017", Routing = "056008849", Account = "12345678901234", #endif }; if (r.payinfo.PeopleId == m.UserPeopleId) // Is this the logged in user? { pf.CreditCard = r.payinfo.MaskedCard; pf.Account = r.payinfo.MaskedAccount; pf.Routing = r.payinfo.Routing; pf.Expires = r.payinfo.Expires; pf.SavePayInfo = (r.payinfo.MaskedAccount != null && r.payinfo.MaskedAccount.StartsWith("X")) || (r.payinfo.MaskedCard != null && r.payinfo.MaskedCard.StartsWith("X")); pf.Type = r.payinfo.PreferredPaymentType; // if no preferred payment type pick credit card or ach if we have anything. if (string.IsNullOrWhiteSpace(pf.Type)) { pf.Type = !string.IsNullOrWhiteSpace(pf.CreditCard) ? PaymentType.CreditCard : null; } if (string.IsNullOrWhiteSpace(pf.Type)) { pf.Type = !string.IsNullOrWhiteSpace(pf.Account) ? PaymentType.Ach : null; } } ClearMaskedNumbers(pf, r.payinfo); pf.AllowSaveProgress = m.AllowSaveProgress(); pf.NoCreditCardsAllowed = m.NoCreditCardsAllowed(); if (m.OnlineGiving()) { #if DEBUG pf.NoCreditCardsAllowed = false; #else pf.NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool(); #endif pf.IsGiving = true; pf.FinanceOnly = true; pf.Type = r.payinfo.PreferredGivingType; } else if (m.ManageGiving() || m.OnlinePledge()) { pf.FinanceOnly = true; } if (pf.NoCreditCardsAllowed) { pf.Type = PaymentType.Ach; // bank account only } else if (pf.NoEChecksAllowed) { pf.Type = PaymentType.CreditCard; // credit card only } pf.Type = pf.NoEChecksAllowed ? PaymentType.CreditCard : pf.Type; pf.DatumId = m.DatumId ?? 0; return(pf); }
public Transaction ProcessPaymentTransaction(OnlineRegModel m) { var ti = (m?.Transaction != null) ? CreateTransaction(DbUtil.Db, m.Transaction, AmtToPay) : CreateTransaction(DbUtil.Db); int? pid = null; if (m != null) { m.ParseSettings(); pid = m.UserPeopleId; if (m.TranId == null) m.TranId = ti.Id; } if (!pid.HasValue) { var pds = DbUtil.Db.FindPerson(First, Last, null, Email, Phone); if (pds.Count() == 1) pid = pds.Single().PeopleId.Value; } TransactionResponse tinfo; var gw = DbUtil.Db.Gateway(testing); if (SavePayInfo) tinfo = gw.PayWithVault(pid ?? 0, AmtToPay ?? 0, Description, ti.Id, Type); else { tinfo = Type == PaymentType.Ach ? PayWithCheck(gw, pid, ti) : PayWithCreditCard(gw, pid, ti); } ti.TransactionId = tinfo.TransactionId; if (ti.Testing.GetValueOrDefault() && !ti.TransactionId.Contains("(testing)")) ti.TransactionId += "(testing)"; ti.Approved = tinfo.Approved; if (!ti.Approved.GetValueOrDefault()) { 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; }
private ActionResult RouteSpecialLogin(OnlineRegModel m) { if (Util.UserPeopleId == null) throw new Exception("Util.UserPeopleId is null on login"); var link = RouteExistingRegistration(m); if(link.HasValue()) return Redirect(link); m.CreateAnonymousList(); m.UserPeopleId = Util.UserPeopleId; if (m.OnlineGiving()) { m.Log("Login OnlineGiving"); return RegisterFamilyMember(Util.UserPeopleId.Value, m); } link = RouteManageGivingSubscriptionsPledgeVolunteer(m); if (link.HasValue()) return Content(link); // this will be used for a redirect in javascript return null; }
public static PaymentForm CreatePaymentForm(OnlineRegModel m) { var r = m.GetTransactionInfo(); if (r == null) return null; var pf = new PaymentForm { FormId = Guid.NewGuid(), AmtToPay = m.PayAmount() + (m.donation ?? 0), AskDonation = m.AskDonation(), AllowCoupon = !m.OnlineGiving(), PayBalance = false, Amtdue = m.TotalAmount() + (m.donation ?? 0), Donate = m.donation, Description = m.DescriptionForPayment, Email = r.Email, First = r.First, MiddleInitial = r.Middle, Last = r.Last, Suffix = r.Suffix, IsLoggedIn = m.UserPeopleId.HasValue, OrgId = m.List[0].orgid, URL = m.URL, testing = m.testing ?? false, Terms = m.Terms, Address = r.Address, Address2 = r.Address2, City = r.City, State = r.State, Country = r.Country, Zip = r.Zip, Phone = r.Phone #if DEBUG2 CreditCard = "4111111111111111", CVV = "123", Expires = "1017", Routing = "056008849", Account = "12345678901234" #endif }; if (r.payinfo.PeopleId == m.UserPeopleId) // Is this the logged in user? { pf.CreditCard = r.payinfo.MaskedCard; pf.Account = r.payinfo.MaskedAccount; pf.Routing = r.payinfo.Routing; pf.Expires = r.payinfo.Expires; pf.SavePayInfo = (r.payinfo.MaskedAccount != null && r.payinfo.MaskedAccount.StartsWith("X")) || (r.payinfo.MaskedCard != null && r.payinfo.MaskedCard.StartsWith("X")); pf.Type = r.payinfo.PreferredPaymentType; } ClearMaskedNumbers(pf, r.payinfo); pf.AllowSaveProgress = m.AllowSaveProgress(); pf.NoCreditCardsAllowed = m.NoCreditCardsAllowed(); if (m.OnlineGiving()) { #if DEBUG pf.NoCreditCardsAllowed = false; #else pf.NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool(); #endif pf.IsGiving = true; pf.FinanceOnly = true; pf.Type = r.payinfo.PreferredGivingType; } else if (m.ManageGiving() || m.OnlinePledge()) { pf.FinanceOnly = true; } if (pf.NoCreditCardsAllowed) pf.Type = PaymentType.Ach; // bank account only else if (pf.NoEChecksAllowed) pf.Type = PaymentType.CreditCard; // credit card only pf.Type = pf.NoEChecksAllowed ? PaymentType.CreditCard : pf.Type; pf.DatumId = m.DatumId ?? 0; return pf; }