private int GetCostInPence(IMember member, PaymentStates paymentState) { int costInPence = 0; var membershipType = member.GetValue <MembershipTypeEnum>(MemberProperty.membershipType); switch (paymentState) { case PaymentStates.MemberRenewal: case PaymentStates.MemberUpgrade: costInPence = _membershipCostCalculator.Calculate(_sessionProvider.RenewalOptions, DateTime.Now); break; case PaymentStates.TrainingCredits: costInPence = _sessionProvider.TrainingCreditsInPence; break; case PaymentStates.OwsSignup: costInPence = _membershipCostCalculator.OwsSignupCostPence; break; default: costInPence = _membershipCostCalculator.PaymentStateCost(paymentState, membershipType); break; } return(costInPence); }
private void MapPaymentStateToModel(PaymentModel model, IMember member, PaymentStates paymentState) { model.HasPaymentDetails = true; model.PaymentDescription = paymentState.GetAttributeOfType <DescriptionAttribute>().Description; int costInPence = GetCostInPence(member, paymentState); model.Cost = (costInPence / 100m); }
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)); }
public int PaymentStateCost(PaymentStates state, MembershipTypeEnum type) { switch (state) { case PaymentStates.SS05991: case PaymentStates.SS05992: { return(SwimsSubsCostInPence(type)); } } throw new Exception("Unknown cost"); }
private void ProcessPaymentState(PaymentModel model, IMember member, PaymentStates paymentState) { switch (paymentState) { case PaymentStates.SS05991: { member.SetValue(MemberProperty.swimSubs1, string.Format("Swim Subs Apr - Sept {0}", DateTime.Now.Year)); model.ShowSwimSubsConfirmation = true; break; } case PaymentStates.SS05992: { var janToMarch = new List <int>() { 1, 2, 3 }; int year1 = janToMarch.Any(m => m == DateTime.Now.Month) ? DateTime.Now.Year - 1 : DateTime.Now.Year; member.SetValue(MemberProperty.swimSubs2, string.Format("Swim Subs Oct {0} - Mar {1}", year1, year1 + 1)); model.ShowSwimSubsConfirmation = true; break; } case PaymentStates.MemberRenewal: case PaymentStates.MemberUpgrade: { _memberProvider.UpdateMemberOptions(member, _sessionProvider.RenewalOptions, isUpgrade: paymentState == PaymentStates.MemberUpgrade); model.ShowRenewed = true; break; } case PaymentStates.TrainingCredits: { var credits = member.GetValue <int>(MemberProperty.TrainingCredits); credits = credits + (_sessionProvider.TrainingCreditsInPence / 100); member.SetValue(MemberProperty.TrainingCredits, credits); model.ShowCreditsConfirmation = true; break; } case PaymentStates.OwsSignup: { _memberProvider.AcceptOpenWaterWaiver(member); model.ShowOwsSignupConfirmation = true; break; } } _memberService.Save(member); }
public ActionResult PaymentRedirect(PaymentStates state) { var member = _memberProvider.GetLoggedInMember(); if (member == null) { return(CurrentUmbracoPage()); } _sessionProvider.CanProcessPaymentCompletion = true; var redirectUrl = $"/Payment?state={state}"; return(Redirect(redirectUrl)); }
public ActionResult Renew(MemberOptions model) { var member = _memberProvider.GetLoggedInMember(); if (!ModelState.IsValid || member == null) { return(CurrentUmbracoPage()); } _sessionProvider.RenewalOptions = model; var membershipType = member.GetValue <MembershipTypeEnum>(MemberProperty.membershipType); bool isRenewing = membershipType != MembershipTypeEnum.Guest; Logger.Info(typeof(RenewController), $"Member {(isRenewing ? "renewal" : "upgrade")} request: {member.Email}, {JsonConvert.SerializeObject(model)}"); PaymentStates state = isRenewing ? PaymentStates.MemberRenewal : PaymentStates.MemberUpgrade; _sessionProvider.CanProcessPaymentCompletion = true; var redirectUrl = $"/Payment?state={state}"; return(Redirect(redirectUrl)); }
private void CreatePaymentStates() { PaymentStates.Add(PaymentState.Create(id: 0, caption: "Unpaid", color: "Tomato")); PaymentStates.Add(PaymentState.Create(id: 1, caption: "Paid", color: "LightGreen")); }
public int SwimCreditsCost(PaymentStates credits) { return((int)credits * 100); }
private ActionResult RedirectToMandatePage(PaymentStates paymentState) { var mandatePageUrl = $"/mandate?state={paymentState}"; return(Redirect(mandatePageUrl)); }