1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

combined tax updates with other operations

This commit is contained in:
Chad Scharf
2020-06-17 19:49:27 -04:00
parent f7e5f1f15e
commit b7a500eb63
10 changed files with 66 additions and 14 deletions

View File

@ -467,6 +467,10 @@ namespace Bit.Api.Controllers
{
license = await ApiHelpers.ReadJsonFileFromBody<UserLicense>(HttpContext, model.License);
}
else if (!valid && !_globalSettings.SelfHosted)
{
throw new BadRequestException("Country is required.");
}
if (!valid || (_globalSettings.SelfHosted && license == null))
{
@ -474,7 +478,8 @@ namespace Bit.Api.Controllers
}
var result = await _userService.SignUpPremiumAsync(user, model.PaymentToken,
model.PaymentMethodType.Value, model.AdditionalStorageGb.GetValueOrDefault(0), license);
model.PaymentMethodType.Value, model.AdditionalStorageGb.GetValueOrDefault(0), license,
model.Country, model.PostalCode);
var profile = new ProfileResponseModel(user, null, await _userService.TwoFactorIsEnabledAsync(user));
return new PaymentResponseModel
{
@ -534,6 +539,11 @@ namespace Bit.Api.Controllers
throw new UnauthorizedAccessException();
}
await _paymentService.SaveTaxInfoAsync(user, new TaxInfo
{
BillingAddressCountry = model.Country,
BillingAddressPostalCode = model.PostalCode,
});
await _userService.ReplacePaymentMethodAsync(user, model.PaymentToken, model.PaymentMethodType.Value);
}

View File

@ -208,9 +208,18 @@ namespace Bit.Api.Controllers
{
throw new NotFoundException();
}
await _organizationService.ReplacePaymentMethodAsync(orgIdGuid, model.PaymentToken,
model.PaymentMethodType.Value);
model.PaymentMethodType.Value, new TaxInfo
{
BillingAddressLine1 = model.Line1,
BillingAddressLine2 = model.Line2,
BillingAddressState = model.State,
BillingAddressCity = model.City,
BillingAddressPostalCode = model.PostalCode,
BillingAddressCountry = model.Country,
TaxIdNumber = model.TaxId,
});
}
[HttpPost("{id}/upgrade")]