public void Should_Return_ProcessType(string description, int processType, int result)
        {
            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var org = new Organization
                {
                    OrganizationName     = DatabaseTestBase.RandomString(),
                    RegistrationTypeId   = processType,
                    Description          = description,
                    CreatedDate          = DateTime.Now,
                    OrganizationStatusId = 30,
                };

                try
                {
                    db.Organizations.InsertOnSubmit(org);
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    var i = e;
                }

                var paymentProcessType = MultipleGatewayUtils.ProcessByTransactionDescription(db, org.Description);
                var pp = (int)paymentProcessType;
                pp.ShouldBe(result);
            }
        }
 public void Should_Return_RegistrationProcessType()
 {
     using (var db = CMSDataContext.Create(DatabaseFixture.Host))
     {
         var randomDescription  = DatabaseTestBase.RandomString();
         var paymentProcessType = MultipleGatewayUtils.ProcessByTransactionDescription(db, randomDescription);
         var pp = (int)paymentProcessType;
         pp.ShouldBe(3);
     }
 }
示例#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 processType          = MultipleGatewayUtils.ProcessByTransactionDescription(CurrentDatabase, t0.Description);
            var gw                   = CurrentDatabase.Gateway(t.Testing.GetValueOrDefault(false), null, processType: processType);
            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));
        }