public static void SendFeePaidEmail(Member member, int feeAmount, string feeOption) { string Subject = "We've received a fee payment of $" + feeAmount + " CAD " + "from " + member.FirstName + " " + member.LastName; string HTMLBody = "<p>A fee payment of $" + feeAmount + " CAD " + "(for a " + feeOption + ")" + " from " + member.FirstName + " " + member.LastName + " was made by credit card to us for his/her " + ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? "new member registration" : "new patron registration" ) : ( member.FeeOption != FeeOption.OneYearPatronage ? "membership renewal" : "patronage renewal" ) ) + ". The fee payment should be arriving in our bank account in a few days. </p>"; SendEmail(System.Configuration.ConfigurationManager.AppSettings["OrganisationEmailAddress"], Subject, HTMLBody); }
public ActionResult Payment(Member member, string stripeToken) { string token = stripeToken; int feeAmount; string feeOption; string paymentMethod; switch(member.FeeOption) { case FeeOption.OneYearMembership: feeAmount = 10; feeOption = "one year membership with us"; break; case FeeOption.FiveYearMembership: feeAmount = 40; feeOption = "five year membership with us"; break; case FeeOption.LifetimeMembership: feeAmount = 200; feeOption = "lifetime membership with us"; break; default: feeAmount = 500; feeOption = "one year patronage fee"; break; } switch (member.PaymentMethod) { case PaymentMethod.Cash: paymentMethod = "cash"; break; case PaymentMethod.Cheque: paymentMethod = "cheque"; break; default: paymentMethod = "credit card"; break; } var myCharge = new StripeChargeCreateOptions(); myCharge.Amount = feeAmount * 100; myCharge.Currency = "cad"; myCharge.Description = "Membership/Patronage Fee Payment"; myCharge.Source = new StripeSourceOptions() { TokenId = token }; var chargeService = new StripeChargeService(); try { StripeCharge stripeCharge = chargeService.Create(myCharge); } catch (StripeException e) { if (e.StripeError.ErrorType == "card_error" || e.StripeError.ErrorType == "invalid_request_error") { ViewBag.Error = e.StripeError.Message; } else { ViewBag.Error = "Something went wrong on our side and we couldn't process your donation. We hope you don't mind trying to submit your donation again!"; } ViewBag.FeeAmount = feeAmount; ViewBag.FeeOption = feeOption; return View(member); } try { AWICEmailHelper.SendFeePaidEmail(member, feeAmount, feeOption); AWICEmailHelper.SendMemberRegistrationReceivedEmail(member, feeAmount, feeOption, paymentMethod); } catch(Exception e) { // Ignore, since email not sent to member or AWIC is not an issue } ViewBag.FeeAmount = feeAmount; ViewBag.FeeOption = feeOption; ViewBag.PaymentMethod = paymentMethod; return View("SignUpComplete", member); }
public ActionResult SignUp(Member member) { if (ModelState.IsValid) { member.Date = DateTime.Now.AddHours(3.0); int feeAmount; string feeOption; string paymentMethod; switch (member.FeeOption) { case FeeOption.OneYearMembership: feeAmount = 10; feeOption = "one year membership with us"; break; case FeeOption.FiveYearMembership: feeAmount = 40; feeOption = "five year membership with us"; break; case FeeOption.LifetimeMembership: feeAmount = 200; feeOption = "lifetime membership with us"; break; default: feeAmount = 500; feeOption = "one year patronage fee"; break; } switch (member.PaymentMethod) { case PaymentMethod.Cash: paymentMethod = "cash"; break; case PaymentMethod.Cheque: paymentMethod = "cheque"; break; default: paymentMethod = "credit card"; break; } bool noExceptionThrown = false; try { AWICEmailHelper.SendMemberRegistrationEmail(member, UppercaseFirst(feeOption.Replace(" with us", "")), UppercaseFirst(paymentMethod)); if(member.PaymentMethod == PaymentMethod.CreditCard) { ViewBag.FeeAmount = feeAmount; ViewBag.FeeOption = feeOption; return View("Payment", member); } noExceptionThrown = true; } catch(Exception e) { // Error will be handled in code after if statement } if(noExceptionThrown) { try { AWICEmailHelper.SendMemberRegistrationReceivedEmail(member, feeAmount, feeOption, paymentMethod); ViewBag.FeeAmount = feeAmount; ViewBag.FeeOption = feeOption; ViewBag.PaymentMethod = paymentMethod; return View("SignUpComplete", member); } catch(Exception e) { // Ignore, since email not sent to member is not an issue } } } ModelState.AddModelError("", "Something went wrong while trying to submit your membership form. " + "Please fix any errors below, if any. Otherwise, please try again, or email " + "us your intent to sign up as a member of AWIC at " + System.Configuration.ConfigurationManager.AppSettings["OrganisationEmailAddress"] + ". "); return View(member); }
public static void SendMemberRegistrationReceivedEmail(Member member, int amount, string feeOption, string paymentMethod) { UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext); string path = urlHelper.Action("Contact", "Home"); Uri fullURL = new Uri(HttpContext.Current.Request.Url, path); string Subject = "Your " + ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? "membership at " : "patronage at " ) : ( member.FeeOption != FeeOption.OneYearPatronage ? "membership renewal for " : "patronage renewal for " ) ) + "AWIC"; // : string HTMLBody = "<p>Hi " + member.FirstName + ", </p>" + ( member.PaymentMethod == PaymentMethod.CreditCard ? ( ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? ( "<p>Congratulations! You are now a member of AWIC! </p>" + "<p>You can start enjoying the benefits of becoming a member right away. Some of them are: </p>" ) : ( "<p>Thank you for becoming a patron of AWIC! </p>" + "<p>You can start enjoying some of the membership benefits right away, like: </p>" ) ) : ( member.FeeOption != FeeOption.OneYearPatronage ? ( "<p>Congratulations! Your membership with AWIC has been renewed! </p>" + "<p>You can continue to receive the benefits of being a member of AWIC. </p>" ) : ( "<p>Thank you! Your patronage with AWIC has been renewed! </p>" + "<p>You can continue to receive membership benefits, as before. </p>" ) ) ) ) : ( ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? ( "<p>You're just one step short of becoming a member of AWIC! </p>" + "<p>We've yet to receive your fee payment of $" + amount + " CAD for your " + feeOption + " by " + paymentMethod + ". " + "Once we've received it, you can start enjoying the following benefits " + "of becoming a member: </p>" ) : ( "<p>You're just one step short of becoming a patron of AWIC! </p>" + "<p>We've yet to receive your fee payment of $" + amount + " CAD for your " + feeOption + " by " + paymentMethod + ". " + "Once we've received it, you can start enjoying some of the membership benefits, " + "such as: </p>" ) ) : ( member.FeeOption != FeeOption.OneYearPatronage ? ( "<p>You're just one step short of renewing your membership with AWIC! </p>" + "<p>We've yet to receive your fee payment of $" + amount + " CAD for your " + feeOption + " by " + paymentMethod + ". " + "Once we've received it, you can continue to receive the benefits of being " + "a member of AWIC. </p>" ) : ( "<p>You're just one step short of renewing your patronage with AWIC! </p>" + "<p>We've yet to receive your fee payment of $" + amount + " CAD for your " + feeOption + " by " + paymentMethod + ". " + "Once we've received it, you can continue to receive membership benefits, " + "as before. </p>" ) ) ) ) ) + ( member.MembershipType == MembershipType.New ? ( "<ul>" + "<li>Stand for nomination for the Board of Directors</li>" + "<li>Voting privileges at the Annual General Meeting</li>" + "<li>Discount on some of AWIC's events</li>" + "<li>Low cost advertising in AWIC's newsletter</li>" + "<li>Receive AWIC's newsletter</li>" + "<li>Become connected to your community</li>" + "</ul>" ) : ( "" ) ) + "<p>We might contact you if we need to clarify something on the form you submitted" + (member.PaymentMethod != PaymentMethod.CreditCard ? " as well" : "") + ". </p>" + "<p>If you have any questions or concerns about anything, feel free to reply back with your " + "message and we'll be glad to address it. You can also call Nilani Nanthan (our office " + "assistant) at (416) 499-4144 with your message, who will be more than glad to help you. </p>" + "<br />" + "<p>Sincerely, </p>" + "<p>The AWIC Team</p>" + "<br />" + "<p>PS You can find our general contact information <a href=\"" + fullURL + "\">here</a>. </p>"; SendEmail(member.EmailAddress, Subject, HTMLBody); }
public static void SendMemberRegistrationEmail(Member member, string feeOption, string paymentMethod) { string Subject = ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? "New Member Registration - " : "New Patron Registration - " ) : ( member.FeeOption != FeeOption.OneYearPatronage ? "Membership Renewal - " : "Patronage Renewal - " ) ) + member.FirstName + " " + member.LastName; string HTMLBody = "<p>A " + ( member.MembershipType == MembershipType.New ? ( member.FeeOption != FeeOption.OneYearPatronage ? "membership" : "patron-ship" ) : ( member.FeeOption != FeeOption.OneYearPatronage ? "membership renewal" : "patron-ship renewal" ) ) + " form was submitted by " + member.FirstName + " " + member.LastName + "</p>" + "<br />" + "<p>Here is the form: </p>" + "<p>Date: " + member.Date.ToLongDateString() + "</p>" + "<p>Membership Type: " + member.MembershipType.ToString() + "</p>" + "<p>First Name: " + member.FirstName + "</p>" + "<p>Last Name: " + member.LastName + "</p>" + "<p>Address: " + member.Address + "</p>" + "<p>City: " + member.City + "</p>" + "<p>Province or State: " + member.ProvinceOrState + "</p>" + "<p>Country: " + member.Country + "</p>" + "<p>Postal Code: " + member.PostalCode + "</p>" + "<p>Phone Number: " + member.Phone + "</p>" + "<p>E-mail Address: " + member.EmailAddress + "</p>" + (!String.IsNullOrEmpty(member.ReferredBy) ? "<p>Referred By: " + member.ReferredBy + "</p>" : "") + "<p>Fee Option: " + feeOption + "</p>" + "<p>Payment Method: " + paymentMethod + "</p>"; SendEmail(System.Configuration.ConfigurationManager.AppSettings["OrganisationEmailAddress"], Subject, HTMLBody); }