public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var userIP = GeoLocation.GetUserIP(Request).Split(':').First(); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RegistrationDate = DateTime.UtcNow, LastLoginTime = DateTime.UtcNow, IPAddress = userIP, IPAddressCountry = GeoLocationHelper.GetCountryFromIP(userIP), BillingAddress = new BillingAddress() }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Create Stripe user var taxPercent = user.IPAddressCountry != null && EuropeanVat.Countries.ContainsKey(user.IPAddressCountry) ? EuropeanVat.Countries[user.IPAddressCountry] : 0; // if no plan set, default to professional var planId = string.IsNullOrEmpty(model.SubscriptionPlan) ? "professional_monthly" : model.SubscriptionPlan; await SubscriptionsFacade.SubscribeUserAsync(user, planId, taxPercent : taxPercent); await UserManager.UpdateAsync(user); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); await UserManager.EmailService.SendWelcomeEmail(user.UserName, user.Email); TempData["flash"] = new FlashSuccessViewModel("Congratulations! Your account has been created."); return(RedirectToAction("Index", "Notes")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }