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

Billing addr line1 fix, pr feedback

This commit is contained in:
Chad Scharf
2020-06-15 09:12:03 -04:00
parent 1552ff7b29
commit b2cb9a2f69
5 changed files with 11 additions and 6 deletions

View File

@ -634,7 +634,6 @@ namespace Bit.Api.Controllers
} }
[HttpPut("tax")] [HttpPut("tax")]
[HttpPost("tax")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutTaxInfo([FromBody]TaxInfoUpdateRequestModel model) public async Task PutTaxInfo([FromBody]TaxInfoUpdateRequestModel model)
{ {

View File

@ -484,7 +484,6 @@ namespace Bit.Api.Controllers
} }
[HttpPut("{id}/tax")] [HttpPut("{id}/tax")]
[HttpPost("{id}/tax")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutTaxInfo(string id, [FromBody]OrganizationTaxInfoUpdateRequestModel model) public async Task PutTaxInfo(string id, [FromBody]OrganizationTaxInfoUpdateRequestModel model)
{ {

View File

@ -5,6 +5,7 @@ namespace Bit.Core.Models.Api
public class TaxInfoResponseModel public class TaxInfoResponseModel
{ {
public TaxInfoResponseModel() { } public TaxInfoResponseModel() { }
public TaxInfoResponseModel(TaxInfo taxInfo) public TaxInfoResponseModel(TaxInfo taxInfo)
{ {
if (taxInfo == null) if (taxInfo == null)

View File

@ -26,9 +26,13 @@
{ {
if (string.IsNullOrWhiteSpace(BillingAddressCountry) || if (string.IsNullOrWhiteSpace(BillingAddressCountry) ||
string.IsNullOrWhiteSpace(TaxIdNumber)) string.IsNullOrWhiteSpace(TaxIdNumber))
{
return null; return null;
}
if (!string.IsNullOrWhiteSpace(_taxIdType)) if (!string.IsNullOrWhiteSpace(_taxIdType))
{
return _taxIdType; return _taxIdType;
}
switch (BillingAddressCountry) switch (BillingAddressCountry)
{ {
@ -44,7 +48,9 @@
case "CA": case "CA":
// May break for those in Québec given the assumption of QST // May break for those in Québec given the assumption of QST
if (BillingAddressState?.Contains("bec") ?? false) if (BillingAddressState?.Contains("bec") ?? false)
{
_taxIdType = "ca_qst"; _taxIdType = "ca_qst";
}
_taxIdType = "ca_bn"; _taxIdType = "ca_bn";
break; break;
case "CL": case "CL":

View File

@ -165,7 +165,7 @@ namespace Bit.Core.Services
Country = taxInfo.BillingAddressCountry, Country = taxInfo.BillingAddressCountry,
PostalCode = taxInfo.BillingAddressPostalCode, PostalCode = taxInfo.BillingAddressPostalCode,
// Line1 is required in Stripe's API, suggestion in Docs is to use Business Name intead. // Line1 is required in Stripe's API, suggestion in Docs is to use Business Name intead.
Line1 = taxInfo.BillingAddressLine1 ?? org.BusinessName, Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
Line2 = taxInfo.BillingAddressLine2, Line2 = taxInfo.BillingAddressLine2,
City = taxInfo.BillingAddressCity, City = taxInfo.BillingAddressCity,
State = taxInfo.BillingAddressState, State = taxInfo.BillingAddressState,
@ -1536,7 +1536,7 @@ namespace Bit.Core.Services
// Line1 is required, so if missing we're using the subscriber name // Line1 is required, so if missing we're using the subscriber name
// see: https://stripe.com/docs/api/customers/create#create_customer-address-line1 // see: https://stripe.com/docs/api/customers/create#create_customer-address-line1
if (address != null && address.Line1 == subscriber.BillingName()) if (address != null && string.IsNullOrWhiteSpace(address.Line1))
{ {
address.Line1 = null; address.Line1 = null;
} }
@ -1565,7 +1565,7 @@ namespace Bit.Core.Services
{ {
Address = new AddressOptions Address = new AddressOptions
{ {
Line1 = taxInfo.BillingAddressLine1 ?? subscriber.BillingName(), Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
Line2 = taxInfo.BillingAddressLine2, Line2 = taxInfo.BillingAddressLine2,
City = taxInfo.BillingAddressCity, City = taxInfo.BillingAddressCity,
State = taxInfo.BillingAddressState, State = taxInfo.BillingAddressState,