From b2cb9a2f6901b2078cd25e9a8e55205ac81c5b7f Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Mon, 15 Jun 2020 09:12:03 -0400 Subject: [PATCH] Billing addr line1 fix, pr feedback --- src/Api/Controllers/AccountsController.cs | 1 - src/Api/Controllers/OrganizationsController.cs | 1 - src/Core/Models/Api/Response/TaxInfoResponseModel.cs | 3 ++- src/Core/Models/Business/TaxInfo.cs | 6 ++++++ src/Core/Services/Implementations/StripePaymentService.cs | 6 +++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Api/Controllers/AccountsController.cs b/src/Api/Controllers/AccountsController.cs index a69cffb7f2..f3457cc176 100644 --- a/src/Api/Controllers/AccountsController.cs +++ b/src/Api/Controllers/AccountsController.cs @@ -634,7 +634,6 @@ namespace Bit.Api.Controllers } [HttpPut("tax")] - [HttpPost("tax")] [SelfHosted(NotSelfHostedOnly = true)] public async Task PutTaxInfo([FromBody]TaxInfoUpdateRequestModel model) { diff --git a/src/Api/Controllers/OrganizationsController.cs b/src/Api/Controllers/OrganizationsController.cs index ccb881dc53..a4dcd4c916 100644 --- a/src/Api/Controllers/OrganizationsController.cs +++ b/src/Api/Controllers/OrganizationsController.cs @@ -484,7 +484,6 @@ namespace Bit.Api.Controllers } [HttpPut("{id}/tax")] - [HttpPost("{id}/tax")] [SelfHosted(NotSelfHostedOnly = true)] public async Task PutTaxInfo(string id, [FromBody]OrganizationTaxInfoUpdateRequestModel model) { diff --git a/src/Core/Models/Api/Response/TaxInfoResponseModel.cs b/src/Core/Models/Api/Response/TaxInfoResponseModel.cs index a39c88364f..55301c32a3 100644 --- a/src/Core/Models/Api/Response/TaxInfoResponseModel.cs +++ b/src/Core/Models/Api/Response/TaxInfoResponseModel.cs @@ -4,7 +4,8 @@ namespace Bit.Core.Models.Api { public class TaxInfoResponseModel { - public TaxInfoResponseModel () { } + public TaxInfoResponseModel() { } + public TaxInfoResponseModel(TaxInfo taxInfo) { if (taxInfo == null) diff --git a/src/Core/Models/Business/TaxInfo.cs b/src/Core/Models/Business/TaxInfo.cs index d236146216..5f493be178 100644 --- a/src/Core/Models/Business/TaxInfo.cs +++ b/src/Core/Models/Business/TaxInfo.cs @@ -26,9 +26,13 @@ { if (string.IsNullOrWhiteSpace(BillingAddressCountry) || string.IsNullOrWhiteSpace(TaxIdNumber)) + { return null; + } if (!string.IsNullOrWhiteSpace(_taxIdType)) + { return _taxIdType; + } switch (BillingAddressCountry) { @@ -44,7 +48,9 @@ case "CA": // May break for those in Québec given the assumption of QST if (BillingAddressState?.Contains("bec") ?? false) + { _taxIdType = "ca_qst"; + } _taxIdType = "ca_bn"; break; case "CL": diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs index ecccf661a5..4e954b50e5 100644 --- a/src/Core/Services/Implementations/StripePaymentService.cs +++ b/src/Core/Services/Implementations/StripePaymentService.cs @@ -165,7 +165,7 @@ namespace Bit.Core.Services Country = taxInfo.BillingAddressCountry, PostalCode = taxInfo.BillingAddressPostalCode, // 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, City = taxInfo.BillingAddressCity, State = taxInfo.BillingAddressState, @@ -1536,7 +1536,7 @@ namespace Bit.Core.Services // Line1 is required, so if missing we're using the subscriber name // 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; } @@ -1565,7 +1565,7 @@ namespace Bit.Core.Services { Address = new AddressOptions { - Line1 = taxInfo.BillingAddressLine1 ?? subscriber.BillingName(), + Line1 = taxInfo.BillingAddressLine1 ?? string.Empty, Line2 = taxInfo.BillingAddressLine2, City = taxInfo.BillingAddressCity, State = taxInfo.BillingAddressState,