예제 #1
0
        public void CheckStoreInVault(ModelStateDictionary modelState, int peopleid)
        {
            if (!IsLoggedIn.GetValueOrDefault() || !SavePayInfo)
            {
                return;
            }

            var gateway = CurrentDatabase.Gateway(testing, null, ProcessType);

            if (!modelState.IsValid)
            {
                return;
            }

            // we need to perform a $1 auth if this is a brand new credit card that we are going to store it in the vault.
            // otherwise we skip doing an auth just call store in vault just like normal.
            VerifyCardWithAuth(modelState, gateway, peopleid);
            if (!modelState.IsValid)
            {
                return;
            }

            InitializePaymentInfo(peopleid);

            gateway.StoreInVault(peopleid, Type, CreditCard,
                                 DbUtil.NormalizeExpires(Expires).ToString2("MMyy"), CVV, Routing, Account,
                                 IsGiving.GetValueOrDefault());
        }
예제 #2
0
        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);
        }
예제 #3
0
        public ActionResult CreditVoid(int id, string type, decimal?amt, TransactionsModel m)
        {
            var t = CurrentDatabase.Transactions.SingleOrDefault(tt => tt.Id == id);

            if (t == null)
            {
                return(Content("notran"));
            }

            var qq = from tt in CurrentDatabase.Transactions
                     where tt.OriginalId == id || tt.Id == id
                     orderby tt.Id descending
                     select tt;
            var t0 = qq.First();
            var gw = CurrentDatabase.Gateway(t.Testing ?? false);
            TransactionResponse resp = null;
            var re = t.TransactionId;

            if (re.Contains("(testing"))
            {
                re = re.Substring(0, re.IndexOf("(testing)"));
            }

            if (type == "Void")
            {
                resp = gw.VoidCreditCardTransaction(re);
                if (!resp.Approved)
                {
                    resp = gw.VoidCheckTransaction(re);
                }

                t.Voided = resp.Approved;
                amt      = t.Amt;
            }
            else
            {
                if (t.PaymentType == PaymentType.Ach)
                {
                    resp = gw.RefundCheck(re, amt ?? 0);
                }
                else if (t.PaymentType == PaymentType.CreditCard)
                {
                    resp = gw.RefundCreditCard(re, amt ?? 0, t.LastFourCC);
                }

                t.Credited = resp.Approved;
            }

            if (!resp.Approved)
            {
                DbUtil.LogActivity("error: " + resp.Message);
                return(Content("error: " + resp.Message));
            }

            var transaction = new Transaction
            {
                TransactionId      = resp.TransactionId + (t.Testing == true ? "(testing)" : ""),
                First              = t.First,
                MiddleInitial      = t.MiddleInitial,
                Last               = t.Last,
                Suffix             = t.Suffix,
                Amt                = -amt,
                Amtdue             = t0.Amtdue + amt,
                Approved           = true,
                AuthCode           = t.AuthCode,
                Message            = t.Message,
                Donate             = -t.Donate,
                Regfees            = -t.Regfees,
                TransactionDate    = DateTime.Now,
                TransactionGateway = t.TransactionGateway,
                Testing            = t.Testing,
                Description        = t.Description,
                OrgId              = t.OrgId,
                OriginalId         = t.OriginalId,
                Participants       = t.Participants,
                Financeonly        = t.Financeonly,
                PaymentType        = t.PaymentType,
                LastFourCC         = t.LastFourCC,
                LastFourACH        = t.LastFourACH
            };

            CurrentDatabase.Transactions.InsertOnSubmit(transaction);
            CurrentDatabase.SubmitChanges();
            DbUtil.LogActivity("CreditVoid for " + t.TransactionId);

            CurrentDatabase.SendEmail(Util.TryGetMailAddress(CurrentDatabase.StaffEmailForOrg(transaction.OrgId ?? 0)),
                                      "Void/Credit Transaction Type: " + type,
                                      $@"<table>
<tr><td>Name</td><td>{Transaction.FullName(t)}</td></tr>
<tr><td>Email</td><td>{t.Emails}</td></tr>
<tr><td>Address</td><td>{t.Address}</td></tr>
<tr><td>Phone</td><td>{t.Phone}</td></tr>
<tr><th colspan=""2"">Transaction Info</th></tr>
<tr><td>Description</td><td>{t.Description}</td></tr>
<tr><td>Amount</td><td>{-amt:N2}</td></tr>
<tr><td>Date</td><td>{t.TransactionDate.FormatDateTm()}</td></tr>
<tr><td>TranIds</td><td>Org: {t.Id} {t.TransactionId}, Curr: {transaction.Id} {transaction.TransactionId}</td></tr>
<tr><td>User</td><td>{Util.UserFullName}</td></tr>
</table>", Util.EmailAddressListFromString(CurrentDatabase.StaffEmailForOrg(transaction.OrgId ?? 0)));

            return(View("List", m));
        }