1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-28 06:44:50 -05:00

[PM-26932] Improve validation tax information when subscribing to premium

This commit is contained in:
Jonas Hendrickx 2025-01-10 13:44:10 +01:00
parent ce2ecf9da0
commit 51ffe3cef8
2 changed files with 16 additions and 7 deletions

View File

@ -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);

View File

@ -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) });
}
}
}