public ActionResult OnePageGiving(PaymentForm pf) { if (!Util.ValidEmail(pf.Email)) ModelState.AddModelError("Email", "Need a valid email address"); if (pf.AmtToPay == 0) ModelState.AddModelError("AmtToPay", "Invalid Amount"); if (pf.IsUs && !pf.Zip.HasValue()) ModelState.AddModelError("Zip", "Zip is Required for US"); if(pf.ShowCampusOnePageGiving) if((pf.CampusId ?? 0) == 0) ModelState.AddModelError("CampusId", "Campus is Required"); var m = new OnlineRegModel(Request, pf.OrgId, pf.testing, null, null, pf.source) { URL = "/OnePageGiving/" + pf.OrgId}; SetHeaders(m); SetInstructions(m); var p = m.List[0]; if(pf.ShowCampusOnePageGiving) pf.Campuses = p.Campuses().ToList(); if (!ModelState.IsValid) return View("OnePageGiving/Index", pf); if (CheckAddress(pf) == false) return View("OnePageGiving/Index", pf); pf.ValidatePaymentForm(ModelState, shouldValidateBilling: false); if (!ModelState.IsValid) return View("OnePageGiving/Index", pf); p.orgid = m.Orgid; p.FirstName = pf.First; p.LastName = pf.Last; p.EmailAddress = pf.Email; p.Phone = pf.Phone; p.AddressLineOne = pf.Address; p.City = pf.City; p.State = pf.State; p.ZipCode = pf.Zip; p.Country = pf.Country; if(pf.ShowCampusOnePageGiving) p.Campus = pf.CampusId.ToString(); pf.State = pf.State; p.IsNew = p.person == null; if (pf.testing) pf.CheckTesting(); var id = pf.OrgId; if(id == null) return Message("Missing OrgId"); if (pf.Country.HasValue() && !pf.Zip.HasValue()) pf.Zip = "NA"; var ti = pf.ProcessPaymentTransaction(m); if ((ti.Approved ?? false) == false) { ModelState.AddModelError("TranId", ti.Message); return View("OnePageGiving/Index", pf); } if (pf.Zip == "NA") pf.Zip = null; var fundid = m.settings[id.Value].DonationFundId ?? 0; p.FundItem.Add(fundid, pf.AmtToPay); var ret = m.ConfirmTransaction(ti); switch (ret.Route) { case RouteType.ModelAction: if (ti.Approved == true) { TempData["onlineregmodel"] = Util.Serialize(m); return Redirect("/OnePageGiving/ThankYou"); } ErrorSignal.FromCurrentContext().Raise(new Exception(ti.Message)); ModelState.AddModelError("TranId", ti.Message); return View("OnePageGiving/Index", pf); case RouteType.Error: DbUtil.Db.LogActivity("OnePageGiving Error " + ret.Message, pf.OrgId); return Message(ret.Message); default: // unexptected Route ErrorSignal.FromCurrentContext().Raise(new Exception("OnePageGiving Unexpected route")); DbUtil.Db.LogActivity("OnlineReg Unexpected Route " + ret.Message, pf.OrgId); ModelState.AddModelError("TranId", "unexpected error in payment processing"); return View(ret.View ?? "OnePageGiving/Index", pf); } }