Пример #1
0
        public ActionResult Register(MemberOptions memberOptions, PersonalDetails personalDetails)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            var member = Services.MemberService.GetByEmail(personalDetails.Email);

            if (member != null)
            {
                ModelState.AddModelError("Email", "There is already a member registered with the supplied email address.");
                return(CurrentUmbracoPage());
            }

            var model = new RegistrationDetails()
            {
                PersonalDetails = personalDetails, MemberOptions = memberOptions
            };

            _sessionProvider.RegistrationDetails = model;

            Logger.Info(typeof(RegistrationController), $"New member registration request: {JsonConvert.SerializeObject(model)}");

            var customerDto = new CustomerDto()
            {
                GivenName    = model.PersonalDetails.FirstName,
                FamilyName   = model.PersonalDetails.LastName,
                AddressLine1 = model.PersonalDetails.Address1,
                City         = model.PersonalDetails.City,
                PostalCode   = model.PersonalDetails.Postcode,
                Email        = model.PersonalDetails.Email
            };

            string scheme     = _goCardlessProvider.Environment == GoCardlessClient.Environment.LIVE ? "Https" : Request.Url.Scheme;
            string rootUrl    = string.Format("{0}://{1}{2}", scheme, Request.Url.Host, Request.Url.Port == 80 ? string.Empty : ":" + Request.Url.Port);
            string successUrl = string.Format("{0}/the-club/confirm-registration", rootUrl);

            var redirectResponse = _goCardlessProvider.CreateRedirectRequest(Logger, customerDto, "MSTC Member Registration", _sessionProvider.SessionId,
                                                                             successUrl);

            if (redirectResponse.HasError)
            {
                ModelState.AddModelError("", redirectResponse.Error);
                return(CurrentUmbracoPage());
            }

            _sessionProvider.GoCardlessRedirectFlowId = redirectResponse.Id;
            return(Redirect(redirectResponse.RedirectUrl));
        }
Пример #2
0
        public ActionResult Index()
        {
            var    member = _memberProvider.GetLoggedInMember();
            string state  = Request.QueryString["state"];
            bool   canProcessPaymentCompletion = _sessionProvider.CanProcessPaymentCompletion;

            if (member == null || !canProcessPaymentCompletion || string.IsNullOrEmpty(state))
            {
                return(View(false));
            }

            var    fullName   = member.Name;
            string familyName = fullName;
            string givenName  = string.Empty;

            if (fullName.Contains(" "))
            {
                var names = fullName.Split(' ');
                familyName = names.Last();
                givenName  = string.Join(" ", names.Take(names.Length - 1));
            }

            var customerDto = new CustomerDto()
            {
                GivenName    = givenName,
                FamilyName   = familyName,
                AddressLine1 = member.GetValue <string>(MemberProperty.Address1),
                City         = member.GetValue <string>(MemberProperty.City),
                PostalCode   = member.GetValue <string>(MemberProperty.Postcode),
                Email        = member.Email
            };

            string rootUrl           = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port == 80 ? string.Empty : ":" + Request.Url.Port);
            string mandateSuccessUrl = string.Format("{0}/payment?state={1}", rootUrl, state);

            var redirectResponse = _goCardlessProvider.CreateRedirectRequest(_logger, customerDto, "Mid Sussex Tri Club DD Mandate Setup", _sessionProvider.SessionId,
                                                                             mandateSuccessUrl);

            if (redirectResponse.HasError)
            {
                ModelState.AddModelError("", redirectResponse.Error);
                return(View(true));
            }

            _sessionProvider.GoCardlessRedirectFlowId = redirectResponse.Id;
            return(Redirect(redirectResponse.RedirectUrl));
        }