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 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; }