Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
ο»Ώusing Bit.Core;
using Bit.Core.AdminConsole.Entities.Provider;
ο»Ώusing Bit.Core.AdminConsole.Entities.Provider;
using Bit.Core.Billing.Constants;
using Bit.Core.Billing.Providers.Models;
using Bit.Core.Billing.Providers.Queries;
using Bit.Core.Billing.Services;
using Bit.Core.Billing.Tax.Utilities;
using Bit.Core.Context;
using Bit.Core.Services;
using Stripe;
using Stripe.Tax;

Expand All @@ -19,7 +16,6 @@ namespace Bit.Commercial.Core.Billing.Providers.Queries;

public class GetProviderWarningsQuery(
ICurrentContext currentContext,
IFeatureService featureService,
IStripeAdapter stripeAdapter,
ISubscriberService subscriberService) : IGetProviderWarningsQuery
{
Expand Down Expand Up @@ -65,24 +61,14 @@ await subscriberService.GetSubscription(provider,
Provider provider,
Customer customer)
{
if (featureService.IsEnabled(FeatureFlagKeys.PM37597_AlwaysEnableStripeAutomaticTax))
if (customer.TaxExempt != TaxExempt.None)
{
if (customer.TaxExempt != TaxExempt.None)
{
return null;
}

if (customer.Address?.Country == CountryAbbreviations.UnitedStates)
{
return null;
}
return null;
}
else

if (customer.Address?.Country == CountryAbbreviations.UnitedStates)
{
if (TaxHelpers.IsDirectTaxCountry(customer.Address?.Country))
{
return null;
}
return null;
}

if (!currentContext.ProviderProviderAdmin(provider.Id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Globalization;
using Bit.Commercial.Core.Billing.Providers.Models;
using Bit.Core;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Entities.Provider;
using Bit.Core.AdminConsole.Enums.Provider;
Expand All @@ -19,7 +18,6 @@
using Bit.Core.Billing.Providers.Repositories;
using Bit.Core.Billing.Providers.Services;
using Bit.Core.Billing.Services;
using Bit.Core.Billing.Tax.Utilities;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
Expand All @@ -40,7 +38,6 @@ namespace Bit.Commercial.Core.Billing.Providers.Services;
public class ProviderBillingService(
IBraintreeGateway braintreeGateway,
IEventService eventService,
IFeatureService featureService,
IGlobalSettings globalSettings,
ILogger<ProviderBillingService> logger,
IOrganizationRepository organizationRepository,
Expand Down Expand Up @@ -275,17 +272,6 @@ await subscriberService.GetCustomerOrThrow(provider,
]
};

if (!featureService.IsEnabled(FeatureFlagKeys.PM37597_AlwaysEnableStripeAutomaticTax))
{
var determinedTaxExemptStatus = TaxHelpers.DetermineTaxExemptStatus(providerCustomer.Address?.Country, providerCustomer.TaxExempt);
customerCreateOptions.TaxExempt = providerCustomer switch
{
{ Address.Country: not null and not "", TaxExempt: var customerTaxExemptStatus } when
determinedTaxExemptStatus != customerTaxExemptStatus => determinedTaxExemptStatus,
_ => providerCustomer.TaxExempt
};
}

var customer = await stripeAdapter.CreateCustomerAsync(customerCreateOptions);

organization.GatewayCustomerId = customer.Id;
Expand Down Expand Up @@ -511,11 +497,6 @@ public async Task<Customer> SetupCustomer(
Metadata = new Dictionary<string, string> { { "region", globalSettings.BaseServiceUri.CloudRegion } }
};

if (!featureService.IsEnabled(FeatureFlagKeys.PM37597_AlwaysEnableStripeAutomaticTax))
{
options.TaxExempt = TaxHelpers.DetermineTaxExemptStatus(billingAddress.Country);
}

if (billingAddress.TaxId != null)
{
options.TaxIdData =
Expand Down
Loading
Loading