示例#1
0
        private PaymentResponseDto CreatePayment(IMember member, PaymentStates paymentState)
        {
            string mandateId = member.GetValue <string>(MemberProperty.directDebitMandateId);
            string email     = member.Email;

            int    costInPence = GetCostInPence(member, paymentState);
            string description = paymentState.GetAttributeOfType <DescriptionAttribute>().Description;

            return(_goCardlessProvider.CreatePayment(_logger, mandateId, email, costInPence, description));
        }
示例#2
0
        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());
        }