From 51ffe3cef81e993289c42ed37f4a43ba46a38e45 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Fri, 10 Jan 2025 13:44:10 +0100 Subject: [PATCH] [PM-26932] Improve validation tax information when subscribing to premium --- src/Api/Auth/Controllers/AccountsController.cs | 6 +++++- .../Request/Accounts/PremiumRequestModel.cs | 17 +++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Api/Auth/Controllers/AccountsController.cs b/src/Api/Auth/Controllers/AccountsController.cs index 7990a5a18a..b36e045217 100644 --- a/src/Api/Auth/Controllers/AccountsController.cs +++ b/src/Api/Auth/Controllers/AccountsController.cs @@ -666,7 +666,11 @@ public class AccountsController : Controller new TaxInfo { BillingAddressCountry = model.Country, - BillingAddressPostalCode = model.PostalCode + BillingAddressPostalCode = model.PostalCode, + BillingAddressCity = model.City, + BillingAddressLine1 = model.Line1, + BillingAddressLine2 = model.Line2, + BillingAddressState = model.State, }); var userTwoFactorEnabled = await _userService.TwoFactorIsEnabledAsync(user); diff --git a/src/Api/Models/Request/Accounts/PremiumRequestModel.cs b/src/Api/Models/Request/Accounts/PremiumRequestModel.cs index 26d199381f..410bb35cc7 100644 --- a/src/Api/Models/Request/Accounts/PremiumRequestModel.cs +++ b/src/Api/Models/Request/Accounts/PremiumRequestModel.cs @@ -12,9 +12,19 @@ public class PremiumRequestModel : IValidatableObject [Range(0, 99)] public short? AdditionalStorageGb { get; set; } public IFormFile License { get; set; } - public string Country { get; set; } + + public string Line1 { get; set; } + public string Line2 { get; set; } + + [Required] public string PostalCode { get; set; } + public string City { get; set; } + public string State { get; set; } + + [Required] + public string Country { get; set; } + public bool Validate(GlobalSettings globalSettings) { if (!(License == null && !globalSettings.SelfHosted) || @@ -32,10 +42,5 @@ public class PremiumRequestModel : IValidatableObject { yield return new ValidationResult("Payment token or license is required."); } - if (Country == "US" && string.IsNullOrWhiteSpace(PostalCode)) - { - yield return new ValidationResult("Zip / postal code is required.", - new string[] { nameof(PostalCode) }); - } } }