示例#1
0
        public AcceptivaGateway(CMSDataContext db, bool testing, PaymentProcessTypes ProcessType)
        {
            this.db          = db;
            this.ProcessType = ProcessType;

            if (testing || MultipleGatewayUtils.GatewayTesting(db, ProcessType))
            {
                _apiKey       = "CZDWp7dXCo4W3xTA7LtWAijidvPdj2wa";
                _merch_ach_id = "dKdDFtqC";
                _merch_cc_id  = "R6MLUevR";
                _isTesting    = true;
                //If this setting exists we settle transactions manually, so we can refund.
                //For live environment settlements are automatic 1 day later
                _automaticSettle = db.Setting("AutomaticSettle");
            }
            else
            {
                _apiKey       = MultipleGatewayUtils.Setting(db, "AcceptivaApiKey", "", (int)ProcessType);
                _merch_ach_id = MultipleGatewayUtils.Setting(db, "AcceptivaAchId", "", (int)ProcessType);
                _merch_cc_id  = MultipleGatewayUtils.Setting(db, "AcceptivaCCId", "", (int)ProcessType);

                if (string.IsNullOrWhiteSpace(_apiKey))
                {
                    throw new Exception("AcceptivaApiKey setting not found, which is required for Acceptiva.");
                }
                if (string.IsNullOrWhiteSpace(_merch_ach_id))
                {
                    throw new Exception("AcceptivaAcctId setting not found, which is required for Acceptiva.");
                }
                if (string.IsNullOrWhiteSpace(_merch_cc_id))
                {
                    throw new Exception("AcceptivaCCId setting not found, which is required for Acceptiva.");
                }
            }
        }
        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);
            }
        }
示例#3
0
        public SageGateway(CMSDataContext db, bool testing, PaymentProcessTypes ProcessType)
        {
            this.db = db;
            var gatewayTesting = MultipleGatewayUtils.GatewayTesting(db, ProcessType);

            if (testing || gatewayTesting)
            {
                _id           = "856423594649";
                _key          = "M5Q4C9P2T4N5";
                _originatorId = "1111111111";
            }
            else
            {
                _id  = MultipleGatewayUtils.Setting(db, "M_ID", "", (int)ProcessType);
                _key = MultipleGatewayUtils.Setting(db, "M_KEY", "", (int)ProcessType);

                if (string.IsNullOrWhiteSpace(_id))
                {
                    throw new Exception("M_ID setting not found, which is required for Sage.");
                }
                if (string.IsNullOrWhiteSpace(_key))
                {
                    throw new Exception("M_KEY setting not found, which is required for Sage.");
                }

                _originatorId = MultipleGatewayUtils.Setting(db, "SageOriginatorId", "", (int)ProcessType);
            }
        }
        public AuthorizeNetGateway(CMSDataContext db, bool testing, PaymentProcessTypes ProcessType)
        {
            this.db = db;
            IsLive  = !(testing || MultipleGatewayUtils.GatewayTesting(db, ProcessType));
            if (!IsLive)
            {
                _login = "******";
                _key   = "9wE4j7M372ehz6Fy";
            }
            else
            {
                _login = MultipleGatewayUtils.Setting(db, "x_login", "", (int)ProcessType);
                _key   = MultipleGatewayUtils.Setting(db, "x_tran_key", "", (int)ProcessType);

                if (string.IsNullOrWhiteSpace(_login))
                {
                    throw new Exception("x_login setting not found, which is required for Authorize.net.");
                }

                if (string.IsNullOrWhiteSpace(_key))
                {
                    throw new Exception("x_tran_key setting not found, which is required for Authorize.net.");
                }
            }
        }
示例#5
0
 public SettingsFeesModel(CMSDataContext db, int id)
 {
     CurrentDatabase = db;
     Id = id;
     this.CopyPropertiesFrom(Org, typeof(OrgAttribute));
     this.CopyPropertiesFrom(RegSettings, typeof(RegAttribute));
     IsPushpay = (int)GatewayTypes.Pushpay == MultipleGatewayUtils.GatewayId(CurrentDatabase, PaymentProcessTypes.OnlineRegistration);
 }
 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);
     }
 }
示例#7
0
        public ActionResult CompleteRegistration()
        {
            Response.NoCache();
            var s = (string)TempData["onlineregmodel"];

            if (s == null)
            {
                DbUtil.LogActivity("OnlineReg Error PageRefreshNotAllowed");
                return(Message("Registration cannot be completed after a page refresh."));
            }
            var m   = Util.DeSerialize <OnlineRegModel>(s);
            var msg = m.CheckExpiredOrCompleted();

            if (msg.HasValue())
            {
                return(Message(msg));
            }

            var ret = m.CompleteRegistration(this);

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

            if (ret.Route == RouteType.Payment && (int)GatewayTypes.Pushpay == GatewayId)
            {
                m.UpdateDatum();
                Session["PaymentProcessType"] = PaymentProcessTypes.OnlineRegistration;
                return(Redirect($"/Pushpay/Registration/{m.DatumId}"));
            }

            switch (ret.Route)
            {
            case RouteType.Error:
                m.Log(ret.Message);
                return(Message(ret.Message));

            case RouteType.Action:
                return(View(ret.View));

            case RouteType.Redirect:
                return(RedirectToAction(ret.View, ret.RouteData));

            case RouteType.Terms:
                return(View(ret.View, m));

            case RouteType.Payment:
                return(View(ret.View, ret.PaymentForm));
            }
            m.Log("BadRouteOnCompleteRegistration");
            return(Message("unexpected value on CompleteRegistration"));
        }
        public ActionResult CompleteRegistration()
        {
            Response.NoCache();
            var m = ReadOnlineRegModelFromSession();

            if (m == null)
            {
                return(Message("Registration cannot be completed after a page refresh."));
            }
            m.CurrentDatabase = CurrentDatabase;
            var msg = m.CheckExpiredOrCompleted();

            if (msg.HasValue())
            {
                return(Message(msg));
            }

            var ret = m.CompleteRegistration(this);

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

            if (ret.Route == RouteType.Payment && (int)GatewayTypes.Pushpay == GatewayId)
            {
                ret.PaymentForm.isExternalPayment = true;
                m.UpdateDatum();
                RequestManager.SessionProvider.Add("PaymentProcessType", PaymentProcessTypes.OnlineRegistration.ToInt().ToString());
            }

            switch (ret.Route)
            {
            case RouteType.Error:
                m.Log(ret.Message);
                return(Message(ret.Message));

            case RouteType.Action:
                return(View(ret.View));

            case RouteType.Redirect:
                return(RedirectToAction(ret.View, ret.RouteData));

            case RouteType.Terms:
                return(View(ret.View, m));

            case RouteType.Payment:
                return(View(ret.View, ret.PaymentForm));
            }
            m.Log("BadRouteOnCompleteRegistration");
            return(Message("unexpected value on CompleteRegistration"));
        }
示例#9
0
        private void InitializePaymentInfo(int peopleId)
        {
            var person    = CurrentDatabase.LoadPersonById(peopleId);
            var accountId = MultipleGatewayUtils.GetAccount(CurrentDatabase, ProcessType)?.GatewayAccountId;
            var pi        = person.PaymentInfo(accountId ?? 0);

            if (pi == null)
            {
                pi = new PaymentInfo()
                {
                    GatewayAccountId = accountId ?? 0
                };
                person.PaymentInfos.Add(pi);
            }
            pi.SetBillingAddress(First, MiddleInitial, Last, Suffix, Address, Address2, City,
                                 State, Country, Zip, Phone);
        }
示例#10
0
        private string AchType(int?pid)
        {
            var type = "checking";

            if (pid.HasValue)
            {
                var usesaving = MultipleGatewayUtils.Setting(db, "UseSavingAccounts", (int)ProcessType);
                if (usesaving)
                {
                    if (Person.GetExtraValue(db, pid.Value, "AchSaving")?.BitValue == true)
                    {
                        type = "savings";
                    }
                }
            }
            return(type);
        }
示例#11
0
        private TransactionInfo InitializeTransactionInfo()
        {
            var r         = new TransactionInfo();
            var accountId = MultipleGatewayUtils.GetAccount(CurrentDatabase, ProcessType)?.GatewayAccountId ?? 0;

            if (user != null && FirstPerson != null)
            {
                r.payinfo = FirstPerson.PaymentInfo(accountId);
            }
            if (r.payinfo == null)
            {
                r.payinfo = new PaymentInfo {
                    MaskedAccount = "", MaskedCard = "", GatewayAccountId = accountId
                };
            }
            return(r);
        }
示例#12
0
        public ActionResult CompleteRegistration()
        {
            Response.NoCache();
            var m = ReadOnlineRegModelFromSession();

            m.CurrentDatabase = CurrentDatabase;
            var msg = m.CheckExpiredOrCompleted();

            if (msg.HasValue())
            {
                return(Message(msg));
            }

            var ret = m.CompleteRegistration(this);

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

            if (ret.Route == RouteType.Payment && (int)GatewayTypes.Pushpay == GatewayId)
            {
                m.UpdateDatum();
                Session["PaymentProcessType"] = PaymentProcessTypes.OnlineRegistration;
                return(Redirect($"/Pushpay/Registration/{m.DatumId}"));
            }

            switch (ret.Route)
            {
            case RouteType.Error:
                m.Log(ret.Message);
                return(Message(ret.Message));

            case RouteType.Action:
                return(View(ret.View));

            case RouteType.Redirect:
                return(RedirectToAction(ret.View, ret.RouteData));

            case RouteType.Terms:
                return(View(ret.View, m));

            case RouteType.Payment:
                return(View(ret.View, ret.PaymentForm));
            }
            m.Log("BadRouteOnCompleteRegistration");
            return(Message("unexpected value on CompleteRegistration"));
        }
示例#13
0
        public BluePayGateway(CMSDataContext db, bool testing, PaymentProcessTypes ProcessType)
        {
            this.db = db;
            IsLive  = !(testing || MultipleGatewayUtils.GatewayTesting(db, ProcessType));

            _login = MultipleGatewayUtils.Setting(db, "bluepay_accountId", "", (int)ProcessType);
            _key   = MultipleGatewayUtils.Setting(db, "bluepay_secretKey", "", (int)ProcessType);

            if (string.IsNullOrWhiteSpace(_login))
            {
                throw new Exception("bluepay_accountId setting not found, which is required for BluePay.");
            }

            if (string.IsNullOrWhiteSpace(_key))
            {
                throw new Exception("bluepay_secretKey setting not found, which is required for BluePay.");
            }
        }
示例#14
0
        private static void ClearMaskedNumbers(PaymentForm pf, PaymentInfo pi)
        {
            int?GatewayId = MultipleGatewayUtils.GatewayId(DbUtil.Db, pf.ProcessType);

            var clearBankDetails       = false;
            var clearCreditCardDetails = false;

            switch (GatewayId)
            {
            case (int)GatewayTypes.Sage:
                clearBankDetails       = !pi.SageBankGuid.HasValue;
                clearCreditCardDetails = !pi.SageCardGuid.HasValue;
                break;

            case (int)GatewayTypes.Transnational:
                clearBankDetails       = !pi.TbnBankVaultId.HasValue;
                clearCreditCardDetails = !pi.TbnCardVaultId.HasValue;
                break;

            // case (int)GatewayTypes.Acceptiva:
            // return new AcceptivaGateway(this, testing, ProcessType);
            case (int)GatewayTypes.AuthorizeNet:
                clearBankDetails       = !pi.AuNetCustPayBankId.HasValue;
                clearCreditCardDetails = !pi.AuNetCustPayId.HasValue;
                break;

            default:
                break;
            }

            if (clearBankDetails)
            {
                pf.Account = string.Empty;
                pf.Routing = string.Empty;
            }

            if (clearCreditCardDetails)
            {
                pf.CreditCard = string.Empty;
                pf.CVV        = string.Empty;
                pf.Expires    = string.Empty;
            }
        }
示例#15
0
        public PushpayController(IRequestManager requestManager) : base(requestManager)
        {
            PaymentProcessTypes processType = PaymentProcessTypes.OneTimeGiving;

            try
            {
                processType = (PaymentProcessTypes)int.Parse(requestManager.SessionProvider.Get <string>("PaymentProcessType"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            _pushpay = new PushpayConnection(
                CurrentDatabase.GetSetting("PushPayAccessToken", ""),
                CurrentDatabase.GetSetting("PushPayRefreshToken", ""),
                CurrentDatabase,
                Configuration.Current.PushpayAPIBaseUrl,
                Configuration.Current.PushpayClientID,
                Configuration.Current.PushpayClientSecret,
                Configuration.Current.OAuth2TokenEndpoint,
                Configuration.Current.TouchpointAuthServer,
                Configuration.Current.OAuth2AuthorizeEndpoint);

            _pushpayPayment        = new PushpayPayment(_pushpay, CurrentDatabase, processType);
            _resolver              = new PushpayResolver(_pushpay, CurrentDatabase);
            _defaultMerchantHandle = _pushpayPayment._defaultMerchantHandle;
            _givingLink            = Configuration.Current.PushpayGivingLinkBase;
            _state = CurrentDatabase.Host;

            isTesting = MultipleGatewayUtils.Setting(CurrentDatabase, "GatewayTesting", (int)processType);
            if (isTesting)
            {
                _ru = "touchpointest";
            }
            else
            {
                _ru = Configuration.Current.PushpayRU;
            }
        }
示例#16
0
        public TransNationalGateway(CMSDataContext db, bool testing, PaymentProcessTypes ProcessType)
        {
            this.db = db;

            if (testing || MultipleGatewayUtils.GatewayTesting(db, ProcessType))
            {
                _userName = "******";
                _password = "******";
            }
            else
            {
                _userName = MultipleGatewayUtils.Setting(db, "TNBUsername", "", (int)ProcessType);
                _password = MultipleGatewayUtils.Setting(db, "TNBPassword", "", (int)ProcessType);

                if (string.IsNullOrWhiteSpace(_userName))
                {
                    throw new Exception("TNBUsername setting not found, which is required for TransNational.");
                }
                if (string.IsNullOrWhiteSpace(_password))
                {
                    throw new Exception("TNBPassword setting not found, which is required for TransNational.");
                }
            }
        }
示例#17
0
        public static PaymentForm CreatePaymentFormForBalanceDue(CMSDataContext db, Transaction ti, decimal amtdue, string email)
        {
            PaymentInfo pi        = null;
            var         accountId = MultipleGatewayUtils.GetAccount(db, PaymentProcessTypes.OnlineRegistration)?.GatewayAccountId;

            if (ti.Person != null)
            {
                pi = ti.Person.PaymentInfo(accountId ?? 0);
            }

            if (pi == null)
            {
                pi = new PaymentInfo()
                {
                    GatewayAccountId = accountId ?? 0
                };
            }

            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 ?? email).Address,
                FormId        = Guid.NewGuid(),
                First         = ti.First,
                MiddleInitial = ti.MiddleInitial.Truncate(1) ?? "",
                Last          = ti.Last,
                Suffix        = ti.Suffix,
                Phone         = ti.Phone,
                Address       = ti.Address,
                Address2      = ti.Address2,
                City          = ti.City,
                State         = ti.State,
                Country       = ti.Country,
                Zip           = ti.Zip,
                testing       = ti.Testing ?? false,
                TranId        = ti.Id,
                ProcessType   = PaymentProcessTypes.OnlineRegistration
            };

            if (pi.PeopleId == Util.UserPeopleId) // Is this the logged in user?
            {
                pf.CreditCard  = pi.MaskedCard;
                pf.Expires     = pi.Expires;
                pf.Account     = pi.MaskedAccount;
                pf.Routing     = pi.Routing;
                pf.SavePayInfo =
                    (pi.MaskedAccount != null && pi.MaskedAccount.StartsWith("X")) ||
                    (pi.MaskedCard != null && pi.MaskedCard.StartsWith("X"));
            }

            ClearMaskedNumbers(pf, pi);

            var org = db.LoadOrganizationById(ti.OrgId);

            pf.NoCreditCardsAllowed = org?.NoCreditCards == true;
            pf.Type = pf.NoEChecksAllowed ? PaymentType.CreditCard : pf.NoCreditCardsAllowed ? PaymentType.Ach : "";
            return(pf);
        }
示例#18
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));
        }
示例#19
0
 public static GatewayAccount GetTransactionGateway(CMSDataContext db, PaymentProcessTypes processType = PaymentProcessTypes.OnlineRegistration)
 {
     return(MultipleGatewayUtils.GetAccount(db, processType));
 }
示例#20
0
        public JsonResult GetGatewayConfig(int ProcessType, string Key)
        {
            string PushpayMerchant = MultipleGatewayUtils.Setting(CurrentDatabase, Key, "", ProcessType);

            return(Json(PushpayMerchant, JsonRequestBehavior.AllowGet));
        }
示例#21
0
        public ActionResult Index(int?id, bool?testing, string email, bool?login, string registertag, bool?showfamily, int?goerid, int?gsid, string source, int?pledgeFund)
        {
            Response.NoCache();

            var m             = new OnlineRegModel(Request, CurrentDatabase, id, testing, email, login, source);
            var isMissionTrip = (m.org?.IsMissionTrip).GetValueOrDefault();

            if (isMissionTrip)
            {
                m.ProcessType = PaymentProcessTypes.OnlineRegistration;
            }
            else
            {
                AssignPaymentProcessType(ref m);
            }

            if (pledgeFund != null)
            {
                m.pledgeFundId = pledgeFund.Value;
            }

            SetHeaders(m);

            int?GatewayId       = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);
            var gatewayRequired = (m.PayAmount() > 0 || m.ProcessType == PaymentProcessTypes.OneTimeGiving || m.ProcessType == PaymentProcessTypes.RecurringGiving);

            if (GatewayId.IsNull() && gatewayRequired)
            {
                return(View("OnePageGiving/NotConfigured"));
            }

            if ((int)GatewayTypes.Pushpay == GatewayId && string.IsNullOrEmpty(MultipleGatewayUtils.Setting(CurrentDatabase, "PushpayMerchant", "", (int)m.ProcessType)))
            {
                ViewBag.Header       = m.Header;
                ViewBag.Instructions = m.Instructions;
                return(View("OnePageGiving/NotConfigured"));
            }

            if (m.ManageGiving())
            {
                Session[$"Campus-{m.Orgid}"] =
                    m.Campus            = Request.QueryString["campus"];
                Session["DefaultFunds"] = Request.QueryString["funds"];
                m.DefaultFunds          = Session["DefaultFunds"]?.ToString();
            }

            if (isMissionTrip)
            {
                if (gsid != null || goerid != null)
                {
                    m.PrepareMissionTrip(gsid, goerid);
                }
            }

            var pid = m.CheckRegisterLink(registertag);

            if (m.NotActive())
            {
                return(View("OnePageGiving/NotActive", m));
            }
            if (m.MissionTripSelfSupportPaylink.HasValue() && m.GoerId > 0)
            {
                return(Redirect(m.MissionTripSelfSupportPaylink));
            }

            return(RouteRegistration(m, pid, showfamily));
        }
示例#22
0
        public ActionResult OnePageGiving(int id, bool?testing, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, CurrentDatabase, id, testing, null, null, source);

                var pid = Util.UserPeopleId;
                if (pid.HasValue)
                {
                    PrePopulate(m, pid.Value);
                }

                SetHeaders(m);
                m.CheckRegisterLink(null);

                if (m.NotActive())
                {
                    return(View("OnePageGiving/NotActive", m));
                }

                if ((m.org.IsMissionTrip.IsNotNull() && m.org.IsMissionTrip == true) ? true : false)
                {
                    m.ProcessType = PaymentProcessTypes.OneTimeGiving;
                }
                else
                {
                    m.ProcessType = (m.org.RegistrationTypeId.IsNull() || m.org.RegistrationTypeId == RegistrationTypeCode.OnlineGiving)
                        ? PaymentProcessTypes.OneTimeGiving
                        : PaymentProcessTypes.OnlineRegistration;
                }

                int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

                if (GatewayId == (int)GatewayTypes.Pushpay && m.OnlineGiving())
                {
                    ViewBag.Header = "One Page Giving";
                    if (string.IsNullOrEmpty(MultipleGatewayUtils.Setting(CurrentDatabase, "PushpayMerchant", "", (int)m.ProcessType)))
                    {
                        return(View("OnePageGiving/NotConfigured"));
                    }

                    return(Redirect($"/Pushpay/OnePage"));
                }

                var pf = PaymentForm.CreatePaymentForm(m);
                pf.AmtToPay = null;

                if (string.IsNullOrWhiteSpace(pf.Type))
                {
                    pf.Type = pf.NoCreditCardsAllowed ? "B" : "C";
                }

#if DEBUG
                if (!pid.HasValue)
                {
                    pf.First      = "Otis";
                    pf.Last       = "Sukamotis";
                    pf.Email      = "*****@*****.**";
                    pf.Address    = "135 Riveredge Cv";
                    pf.Zip        = "";
                    pf.CreditCard = "3111111111111111";
                    pf.Expires    = "1018";
                    pf.CVV        = "123";
                    pf.AmtToPay   = 23M;
                }
#endif

                var p = m.List[0];
                if (pf.ShowCampusOnePageGiving)
                {
                    pf.Campuses = p.Campuses().ToList();
                }

                var designatedFund = p.DesignatedDonationFund().FirstOrDefault();
                pf.Description = designatedFund != null ? designatedFund.Text : m.DescriptionForPayment;

                SetInstructions(m);

                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                {
                    return(Message(ex.Message));
                }
                throw;
            }
        }
示例#23
0
        public ActionResult ProcessPayment(PaymentForm pf)
        {
            if (pf.ProcessType == PaymentProcessTypes.EmpytProcess)
            {
                pf.ProcessType = PaymentProcessTypes.OnlineRegistration;
            }
            // One time or Reg...
            Response.NoCache();

#if DEBUG
#else
            if (Session["FormId"] != null)
            {
                if ((Guid)Session["FormId"] == pf.FormId)
                {
                    return(Message("Already submitted"));
                }
            }
#endif

            OnlineRegModel m  = null;
            var            ed = CurrentDatabase.RegistrationDatas.SingleOrDefault(e => e.Id == pf.DatumId);
            if (ed != null)
            {
                m = Util.DeSerialize <OnlineRegModel>(ed.Data);
            }

#if DEBUG
#else
            if (m != null && m.History.Any(h => h.Contains("ProcessPayment")))
            {
                return(Content("Already submitted"));
            }
#endif

            int?datumid = null;
            if (m != null)
            {
                m.TermsSignature = pf.TermsSignature;
                datumid          = m.DatumId;
                var msg = m.CheckDuplicateGift(pf.AmtToPay);
                if (Util.HasValue(msg))
                {
                    return(Message(msg));
                }
            }
            if (IsCardTester(pf, "Payment Page"))
            {
                return(Message("Found Card Tester"));
            }

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m?.ProcessType ?? pf.ProcessType);

            if (CurrentDatabase.Setting("UseRecaptcha") && GatewayId != (int)GatewayTypes.Pushpay)
            {
                if (!GoogleRecaptcha.IsValidResponse(HttpContext, CurrentDatabase))
                {
                    CurrentDatabase.LogActivity("OnlineReg Error ReCaptcha validation failed.", pf.OrgId, did: datumid);
                    ModelState.AddModelError("form", "ReCaptcha validation failed.");
                    return(View("Payment/Process", pf));
                }
            }

            RouteModel ret;

            if ((int)GatewayTypes.Pushpay == GatewayId)
            {
                int orgId;
                ret      = pf.ProcessExternalPayment(m, out orgId);
                pf.OrgId = orgId;
            }
            else
            {
                ret = pf.ProcessPayment(ModelState, m);
            }
            SetHeaders(pf.OrgId ?? 0);

            switch (ret.Route)
            {
            case RouteType.ModelAction:
                return(View(ret.View, ret.Model));

            case RouteType.AmtDue:
                ViewBag.amtdue = ret.AmtDue;
                return(View(ret.View, ret.Transaction));

            case RouteType.Error:
                CurrentDatabase.LogActivity("OnlineReg Error " + ret.Message, pf.OrgId, did: datumid);
                return(Message(ret.Message));

            case RouteType.ValidationError:
                return(View(ret.View, pf));

            default:     // unexptected Route
                if (ModelState.IsValid)
                {
                    ErrorSignal.FromCurrentContext().Raise(new Exception("OnlineReg Unexpected route datum= " + datumid));
                    CurrentDatabase.LogActivity("OnlineReg Unexpected Route " + ret.Message, oid: pf.OrgId, did: datumid);
                    ModelState.AddModelError("form", "unexpected error in payment processing");
                }
                return(View(ret.View ?? "Payment/Process", pf));
            }
        }
示例#24
0
        public ActionResult PayAmtDue(string q)
        {
            // reached by the paylink in the confirmation email
            // which is produced in EnrollAndConfirm
            Response.NoCache();

            if (!Util.HasValue(q))
            {
                return(Message("unknown"));
            }

            var id = Util.Decrypt(q).ToInt2();
            var qq = from t in CurrentDatabase.Transactions
                     where t.OriginalId == id || t.Id == id
                     orderby t.Id descending
                     select new { t, email = t.TransactionPeople.FirstOrDefault().Person.EmailAddress };
            var i = qq.FirstOrDefault();

            if (i == null)
            {
                return(Message("no outstanding transaction"));
            }

            var ti     = i.t;
            var email  = i.email;
            var amtdue = PaymentForm.AmountDueTrans(CurrentDatabase, ti);

            if (amtdue == 0)
            {
                return(Message("no outstanding transaction"));
            }

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, PaymentProcessTypes.OnlineRegistration);

            if ((int)GatewayTypes.Pushpay == GatewayId)
            {
                ViewBag.Header = "Payment Process";
                if (string.IsNullOrEmpty(MultipleGatewayUtils.Setting(CurrentDatabase, "PushpayMerchant", "", (int)PaymentProcessTypes.OnlineRegistration)))
                {
                    return(View("OnePageGiving/NotConfigured"));
                }

                Session["PaymentProcessType"] = PaymentProcessTypes.OnlineRegistration;
                return(Redirect($"/Pushpay/PayAmtDue/{ti.Id}/{amtdue}"));
            }
#if DEBUG
            ti.Testing = true;
            if (!Util.HasValue(ti.Address))
            {
                ti.Address = "235 Riveredge";
                ti.City    = "Cordova";
                ti.Zip     = "38018";
                ti.State   = "TN";
            }
#endif
            var pf = PaymentForm.CreatePaymentFormForBalanceDue(CurrentDatabase, ti, amtdue, email);
            pf.ProcessType = PaymentProcessTypes.OnlineRegistration;

            SetHeaders(pf.OrgId ?? 0);

            DbUtil.LogActivity("OnlineReg PayDueStart", ti.OrgId, ti.LoginPeopleId ?? ti.FirstTransactionPeopleId());
            return(View("Payment/Process", pf));
        }
示例#25
0
 public PushpayPayment(PushpayConnection Pushpay, CMSDataContext db, PaymentProcessTypes processType)
 {
     _pushpay        = Pushpay;
     _db             = db;
     _merchantHandle = MultipleGatewayUtils.Setting(db, "PushpayMerchant", "", (int)processType);
 }
示例#26
0
 public static GatewayAccount GetTransactionGateway(PaymentProcessTypes processType = PaymentProcessTypes.OnlineRegistration)
 {
     return(MultipleGatewayUtils.GetAccount(DbUtil.Db, processType));
 }
示例#27
0
 private bool CheckIfIsGatewayTesting(bool testing, PaymentProcessTypes processType)
 {
     return(testing || MultipleGatewayUtils.GatewayTesting(CurrentDatabase, ProcessType));
 }
示例#28
0
        private ActionResult RouteRegistration(OnlineRegModel m, int pid, bool?showfamily)
        {
            if (pid == 0)
            {
                return(View(m));
            }
#if DEBUG
            m.DebugCleanUp();
#endif
            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

            if ((int)GatewayTypes.Pushpay == GatewayId && m.ProcessType == PaymentProcessTypes.OneTimeGiving)
            {
                Session["PaymentProcessType"] = PaymentProcessTypes.OneTimeGiving;
                return(Redirect($"/Pushpay/OneTime/{pid}/{m.Orgid}"));
            }

            if ((int)GatewayTypes.Pushpay == GatewayId && m.ProcessType == PaymentProcessTypes.RecurringGiving)
            {
                Session["PaymentProcessType"] = PaymentProcessTypes.RecurringGiving;
                return(Redirect($"/Pushpay/RecurringManagment/{pid}/{m.Orgid}"));
            }

            var link = RouteExistingRegistration(m, pid);
            if (link.HasValue())
            {
                return(Redirect(link));
            }

            OnlineRegPersonModel p;
            PrepareFirstRegistrant(ref m, pid, showfamily, out p);
            if (p != null)
            {
                p.pledgeFundId = m.pledgeFundId;
            }

            if (!ModelState.IsValid)
            {
                m.Log("CannotProceed");
                return(View(m));
            }

            link = RouteManageGivingSubscriptionsPledgeVolunteer(m);
            if (link.HasValue())
            {
                if (m.ManageGiving()) // use Direct ActionResult instead of redirect
                {
                    return(ManageGiving(m.Orgid.ToString(), m.testing));
                }
                else if (m.RegisterLinkMaster())
                {
                    return(Redirect(link));
                }
                else
                {
                    return(Redirect(link));
                }
            }

            // check for forcing show family, master org, or not found
            if (showfamily == true || p.org == null || p.Found != true)
            {
                return(View(m));
            }

            // ready to answer questions, make sure registration is ok to go
            m.Log("Authorized");
            if (!m.SupportMissionTrip)
            {
                p.IsFilled = p.org.RegLimitCount(CurrentDatabase) >= p.org.Limit;
            }
            if (p.IsFilled)
            {
                m.Log("Closed");
                ModelState.AddModelError(m.GetNameFor(mm => mm.List[0].Found), "Sorry, but registration is closed.");
            }

            p.FillPriorInfo();
            p.SetSpecialFee();

            m.HistoryAdd($"index, pid={pid}, !showfamily, p.org, found=true");
            return(View(m));
        }