Ejemplo n.º 1
0
        public RouteModel CompleteRegistration(OnlineRegController ctl)
        {
            HistoryAdd("CompleteRegistration");

            var ret = CheckSpecialJavascript();

            if (ret != null)
            {
                return(ret);
            }

            ret = CheckAskDonation(ctl);
            if (ret != null)
            {
                return(ret);
            }

            if (List.Count == 0)
            {
                return(RouteModel.ErrorMessage("Can't find any registrants"));
            }

            RemoveLastRegistrantIfEmpty();

            UpdateDatum();

            ret = CheckNoFeesDue();
            if (ret != null)
            {
                return(ret);
            }

            var terms = Util.PickFirst(Terms, "");

            if (terms.HasValue())
            {
                ctl.ViewBag.Terms = terms;
            }

            ret = CheckTermsNoFee(ctl);
            if (ret != null)
            {
                return(ret);
            }

            ret = CheckAlreadyRegistered();
            if (ret != null)
            {
                return(ret);
            }

            var pf = PaymentForm.CreatePaymentForm(this);

#if DEBUG2
            pf.CheckTesting();
#endif
            Log("PaymentForm");
            ctl.ModelState.Clear();
            return(RouteModel.ViewPayment("Payment/Process", pf));
        }
Ejemplo n.º 2
0
        public RouteModel FinishRegistration(Transaction ti)
        {
            TranId = ti.Id;
            HistoryAdd("ProcessPayment");
            var ed = DbUtil.Db.RegistrationDatas.Single(dd => dd.Id == DatumId);

            ed.Data      = Util.Serialize(this);
            ed.Completed = true;
            DbUtil.Db.SubmitChanges();

            try
            {
                LogOutOfOnlineReg();
                var view = ConfirmTransaction(ti.TransactionId);
                switch (view)
                {
                case ConfirmEnum.Confirm:
                    return(RouteModel.ViewAction("Confirm", this));

                case ConfirmEnum.ConfirmAccount:
                    return(RouteModel.ViewAction("ConfirmAccount", this));
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(RouteModel.ErrorMessage(ex.Message));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public RouteModel ProcessExternalPayment(OnlineRegModel m, out int orgId)
        {
            //This method has to change deppending on different types of gateways
            orgId = 0;
            if (extTransactionId == 0)
            {
                return(new RouteModel()
                {
                    Route = RouteType.Error,
                    Message = "External Payment error",
                });
            }
            Transaction ti = DbUtil.Db.Transactions.Where(p => p.Id == extTransactionId).FirstOrDefault();

            orgId = ti.OrgId.Value;

            HttpContextFactory.Current.Session["FormId"] = FormId;
            if (m != null)
            {
                m.DatumId = DatumId; // todo: not sure this is necessary
                return(m.FinishRegistration(ti));
            }
            OnlineRegModel.ConfirmDuePaidTransaction(ti, ti.TransactionId, true);

            return(RouteModel.AmountDue(AmountDueTrans(DbUtil.Db, ti), ti));
        }
Ejemplo n.º 4
0
 private RouteModel CheckTermsNoFee(OnlineRegController ctl)
 {
     ctl.SetHeaders(this);
     if (PayAmount() == 0 && Terms.HasValue())
     {
         Log("ViewTerms");
         return(RouteModel.ViewTerms("Other/Terms"));
     }
     return(null);
 }
Ejemplo n.º 5
0
 private RouteModel CheckAskDonation(OnlineRegController ctl)
 {
     if (AskDonation() && !donor.HasValue && donation > 0)
     {
         ctl.SetHeaders(this);
         ctl.ModelState.AddModelError("donation",
                                      "Please indicate a donor or clear the donation amount");
         Log("AskDonation");
         return(RouteModel.ViewAction("Other/AskDonation"));
     }
     return(null);
 }
Ejemplo n.º 6
0
        public RouteModel ProcessPayment(ModelStateDictionary modelState, OnlineRegModel m)
        {
            PreventNegatives();
            PreventZero(modelState);
            if (!modelState.IsValid)
            {
                return(RouteModel.ProcessPayment());
            }

            try
            {
                ValidatePaymentForm(modelState);
                if (!modelState.IsValid)
                {
                    return(RouteModel.ProcessPayment());
                }

                if (m?.UserPeopleId != null && m.UserPeopleId > 0)
                {
                    CheckStoreInVault(modelState, m.UserPeopleId.Value);
                }
                if (!modelState.IsValid)
                {
                    return(RouteModel.ProcessPayment());
                }

                var ti = ProcessPaymentTransaction(m);

                if (ti.Approved == false)
                {
                    modelState.AddModelError("form", ti.Message);
                    return(RouteModel.ProcessPayment());
                }

                HttpContext.Current.Session["FormId"] = FormId;
                if (m != null)
                {
                    m.DatumId = DatumId; // todo: not sure this is necessary
                    return(m.FinishRegistration(ti));
                }

                OnlineRegModel.ConfirmDuePaidTransaction(ti, ti.TransactionId, true);

                return(RouteModel.AmountDue(AmountDueTrans(DbUtil.Db, ti), ti));
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
                modelState.AddModelError("form", ex.Message);
                return(RouteModel.ProcessPayment());
            }
        }
Ejemplo n.º 7
0
 private RouteModel CheckNoFeesDue()
 {
     if (PayAmount() == 0 && (donation ?? 0) == 0 && !Terms.HasValue())
     {
         Log("ZeroDue");
         return(RouteModel.Redirect("Confirm",
                                    new
         {
             id = DatumId,
             TransactionID = "zero due",
         }));
     }
     return(null);
 }
Ejemplo n.º 8
0
        private RouteModel CheckAlreadyRegistered()
        {
            var om = DbUtil.Db.OrganizationMembers.SingleOrDefault(
                mm => mm.OrganizationId == Orgid && mm.PeopleId == List[0].PeopleId);

            ParseSettings();

            if (om != null && settings[om.OrganizationId].AllowReRegister == false && !SupportMissionTrip)
            {
                Log("AlreadyRegistered");
                return(RouteModel.ErrorMessage("You are already registered it appears"));
            }
            return(null);
        }
Ejemplo n.º 9
0
 private RouteModel CheckSpecialJavascript()
 {
     if (org != null && org.RegistrationTypeId == RegistrationTypeCode.SpecialJavascript)
     {
         var p = List[0];
         if (p.IsNew)
         {
             p.AddPerson(null, p.org.EntryPointId ?? 0);
         }
         SpecialRegModel.SaveResults(Orgid ?? 0, List[0].PeopleId ?? 0, List[0].SpecialTest);
         Log("SpecialJavascript");
         return(RouteModel.ViewAction("Other/SpecialRegistrationResults"));
     }
     return(null);
 }
Ejemplo n.º 10
0
 public RouteModel ConfirmTransaction(Transaction ti)
 {
     try
     {
         LogOutOfOnlineReg();
         var view = ConfirmTransaction(ti.TransactionId);
         switch (view)
         {
             case ConfirmEnum.Confirm:
                 return RouteModel.ViewAction("Confirm", this);
             case ConfirmEnum.ConfirmAccount:
                 return RouteModel.ViewAction("ConfirmAccount", this);
         }
     }
     catch (Exception ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
         return RouteModel.ErrorMessage(ex.Message);
     }
     return null;
 }
Ejemplo n.º 11
0
        public RouteModel ProcessPayment(ModelStateDictionary modelState, OnlineRegModel m)
        {
            if (m != null && m.email.HasValue() && !Util.ValidEmail(m.email))
            {
                modelState.AddModelError("form", "Invalid email address");
                return(RouteModel.Invalid("Payment/Process", "Invalid email address"));
            }
            PreventNegatives();
            PreventZero(modelState);
            if (!modelState.IsValid)
            {
                return(RouteModel.ProcessPayment());
            }

            try
            {
                if (!modelState.IsValid)
                {
                    return(RouteModel.ProcessPayment());
                }

                ValidatePaymentForm(modelState);
                if (!modelState.IsValid)
                {
                    return(RouteModel.ProcessPayment());
                }

                if (m?.UserPeopleId != null && m.UserPeopleId > 0)
                {
                    CheckStoreInVault(modelState, m.UserPeopleId.Value);
                }

                if (!modelState.IsValid)
                {
                    return(RouteModel.ProcessPayment());
                }

                var ti = ProcessPaymentTransaction(m);

                if (ti.Approved == false)
                {
                    modelState.AddModelError("form", ti.Message);
                    return(RouteModel.ProcessPayment());
                }

                HttpContextFactory.Current.Session["FormId"] = FormId;
                if (m != null)
                {
                    m.DatumId = DatumId; // todo: not sure this is necessary
                    return(m.FinishRegistration(ti));
                }

                OnlineRegModel.ConfirmDuePaidTransaction(ti, ti.TransactionId, true);

                return(RouteModel.AmountDue(AmountDueTrans(CurrentDatabase, ti), ti));
            }
            catch (Exception ex)
            {
                string errorMessage = ValidateTransactionApproved(transactionApproved, ex.Message);

                errorMessage = ValidateVaultId(ex, modelState);

                modelState.AddModelError("form", errorMessage);
                return(RouteModel.ProcessPayment());
            }
        }