public ActionResult ConfirmPayment(RegistrationCompleteModel model) { model.PromptForConfirmation = false; RegistrationDetails registrationDetails = _sessionProvider.RegistrationDetails; if (registrationDetails == null || string.IsNullOrWhiteSpace(_sessionProvider.GoCardlessRedirectFlowId)) { TempData["Model"] = model; return(CurrentUmbracoPage()); } string mandateId = _goCardlessProvider.CompleteRedirectRequest(_sessionProvider.GoCardlessRedirectFlowId, _sessionProvider.SessionId); registrationDetails.PersonalDetails.DirectDebitMandateId = mandateId; var regDetails = registrationDetails.PersonalDetails; int costInPence = _membershipCostCalculator.Calculate(registrationDetails.MemberOptions, DateTime.Now); model.Cost = (costInPence / 100m).ToString("N2"); var paymentDescription = MemberProvider.GetPaymentDescription(registrationDetails.MemberOptions); var paymentResponse = _goCardlessProvider.CreatePayment(Logger, regDetails.DirectDebitMandateId, regDetails.Email, costInPence, paymentDescription); model.IsRegistered = paymentResponse == PaymentResponseDto.Success; if (model.IsRegistered) { var member = _memberProvider.CreateMember(regDetails, new string[] { MSTCRoles.Member }); _memberProvider.UpdateMemberDetails(member, registrationDetails.PersonalDetails, registrationDetails.MemberOptions); //Login the member FormsAuthentication.SetAuthCookie(member.Username, true); string content = GetRegEmailContent(registrationDetails, true); _emailProvider.SendEmail(EmailProvider.MembersEmail, EmailProvider.SupportEmail, "New MSTC member registration", content); _sessionProvider.RegistrationDetails = null; _sessionProvider.GoCardlessRedirectFlowId = null; TempData["Model"] = model; return(CurrentUmbracoPage()); } else { string content = GetRegEmailContent(registrationDetails, false); _emailProvider.SendEmail(EmailProvider.SupportEmail, EmailProvider.SupportEmail, "MSTC member registration problem", content); } TempData["Model"] = model; return(CurrentUmbracoPage()); }
public ActionResult RenderRegistrationComplete() { var registrationDetails = _sessionProvider.RegistrationDetails; if (registrationDetails == null) { return(PartialView("Registration/RegistrationComplete", new RegistrationCompleteModel())); } int costInPence = _membershipCostCalculator.Calculate(registrationDetails.MemberOptions, DateTime.Now); var model = new RegistrationCompleteModel() { PromptForConfirmation = registrationDetails != null, PaymentDescription = MemberProvider.GetPaymentDescription(registrationDetails.MemberOptions), Cost = (costInPence / 100m).ToString("N2") }; return(PartialView("Registration/RegistrationComplete", model)); }