Example #1
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));
        }
Example #2
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());
            }
        }
Example #3
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());
            }
        }