mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Removed automatic tax feature flag (#4487)
This commit is contained in:
@ -103,28 +103,6 @@ public class StripePaymentService : IPaymentService
|
||||
throw new GatewayException("Payment method is not supported at this time.");
|
||||
}
|
||||
|
||||
var pm5766AutomaticTaxIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax);
|
||||
|
||||
if (!pm5766AutomaticTaxIsEnabled &&
|
||||
taxInfo != null &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo.BillingAddressCountry) &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo.BillingAddressPostalCode))
|
||||
{
|
||||
var taxRateSearch = new TaxRate
|
||||
{
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode
|
||||
};
|
||||
var taxRates = await _taxRateRepository.GetByLocationAsync(taxRateSearch);
|
||||
|
||||
// should only be one tax rate per country/zip combo
|
||||
var taxRate = taxRates.FirstOrDefault();
|
||||
if (taxRate != null)
|
||||
{
|
||||
taxInfo.StripeTaxRateId = taxRate.Id;
|
||||
}
|
||||
}
|
||||
|
||||
var subCreateOptions = new OrganizationPurchaseSubscriptionOptions(org, plan, taxInfo, additionalSeats, additionalStorageGb, premiumAccessAddon
|
||||
, additionalSmSeats, additionalServiceAccount);
|
||||
|
||||
@ -180,7 +158,7 @@ public class StripePaymentService : IPaymentService
|
||||
subCreateOptions.AddExpand("latest_invoice.payment_intent");
|
||||
subCreateOptions.Customer = customer.Id;
|
||||
|
||||
if (pm5766AutomaticTaxIsEnabled && CustomerHasTaxLocationVerified(customer))
|
||||
if (CustomerHasTaxLocationVerified(customer))
|
||||
{
|
||||
subCreateOptions.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true };
|
||||
}
|
||||
@ -273,31 +251,7 @@ public class StripePaymentService : IPaymentService
|
||||
throw new GatewayException("Could not find customer payment profile.");
|
||||
}
|
||||
|
||||
var pm5766AutomaticTaxIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax);
|
||||
var taxInfo = upgrade.TaxInfo;
|
||||
|
||||
if (!pm5766AutomaticTaxIsEnabled &&
|
||||
taxInfo != null &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo.BillingAddressCountry) &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo.BillingAddressPostalCode))
|
||||
{
|
||||
var taxRateSearch = new TaxRate
|
||||
{
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode
|
||||
};
|
||||
var taxRates = await _taxRateRepository.GetByLocationAsync(taxRateSearch);
|
||||
|
||||
// should only be one tax rate per country/zip combo
|
||||
var taxRate = taxRates.FirstOrDefault();
|
||||
if (taxRate != null)
|
||||
{
|
||||
taxInfo.StripeTaxRateId = taxRate.Id;
|
||||
}
|
||||
}
|
||||
|
||||
if (pm5766AutomaticTaxIsEnabled &&
|
||||
!string.IsNullOrEmpty(upgrade.TaxInfo?.BillingAddressCountry) &&
|
||||
if (!string.IsNullOrEmpty(upgrade.TaxInfo?.BillingAddressCountry) &&
|
||||
!string.IsNullOrEmpty(upgrade.TaxInfo?.BillingAddressPostalCode))
|
||||
{
|
||||
var addressOptions = new AddressOptions
|
||||
@ -319,7 +273,7 @@ public class StripePaymentService : IPaymentService
|
||||
|
||||
var subCreateOptions = new OrganizationUpgradeSubscriptionOptions(customer.Id, org, plan, upgrade);
|
||||
|
||||
if (pm5766AutomaticTaxIsEnabled && CustomerHasTaxLocationVerified(customer))
|
||||
if (CustomerHasTaxLocationVerified(customer))
|
||||
{
|
||||
subCreateOptions.DefaultTaxRates = [];
|
||||
subCreateOptions.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true };
|
||||
@ -533,26 +487,6 @@ public class StripePaymentService : IPaymentService
|
||||
Quantity = 1
|
||||
});
|
||||
|
||||
var pm5766AutomaticTaxIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax);
|
||||
|
||||
if (!pm5766AutomaticTaxIsEnabled &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo?.BillingAddressCountry) &&
|
||||
!string.IsNullOrWhiteSpace(taxInfo?.BillingAddressPostalCode))
|
||||
{
|
||||
var taxRates = await _taxRateRepository.GetByLocationAsync(
|
||||
new TaxRate
|
||||
{
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode
|
||||
}
|
||||
);
|
||||
var taxRate = taxRates.FirstOrDefault();
|
||||
if (taxRate != null)
|
||||
{
|
||||
subCreateOptions.DefaultTaxRates = [taxRate.Id];
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalStorageGb > 0)
|
||||
{
|
||||
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||
@ -562,7 +496,7 @@ public class StripePaymentService : IPaymentService
|
||||
});
|
||||
}
|
||||
|
||||
if (pm5766AutomaticTaxIsEnabled && CustomerHasTaxLocationVerified(customer))
|
||||
if (CustomerHasTaxLocationVerified(customer))
|
||||
{
|
||||
subCreateOptions.DefaultTaxRates = [];
|
||||
subCreateOptions.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true };
|
||||
@ -605,8 +539,7 @@ public class StripePaymentService : IPaymentService
|
||||
SubscriptionItems = ToInvoiceSubscriptionItemOptions(subCreateOptions.Items)
|
||||
});
|
||||
|
||||
if (_featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax) &&
|
||||
CustomerHasTaxLocationVerified(customer))
|
||||
if (CustomerHasTaxLocationVerified(customer))
|
||||
{
|
||||
previewInvoice.AutomaticTax = new InvoiceAutomaticTax { Enabled = true };
|
||||
}
|
||||
@ -669,8 +602,7 @@ public class StripePaymentService : IPaymentService
|
||||
SubscriptionDefaultTaxRates = subCreateOptions.DefaultTaxRates,
|
||||
};
|
||||
|
||||
var pm5766AutomaticTaxIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax);
|
||||
if (pm5766AutomaticTaxIsEnabled && CustomerHasTaxLocationVerified(customer))
|
||||
if (CustomerHasTaxLocationVerified(customer))
|
||||
{
|
||||
upcomingInvoiceOptions.AutomaticTax = new InvoiceAutomaticTaxOptions { Enabled = true };
|
||||
upcomingInvoiceOptions.SubscriptionDefaultTaxRates = [];
|
||||
@ -800,9 +732,7 @@ public class StripePaymentService : IPaymentService
|
||||
new SubscriptionPendingInvoiceItemIntervalOptions { Interval = "month" };
|
||||
}
|
||||
|
||||
var pm5766AutomaticTaxIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax);
|
||||
if (pm5766AutomaticTaxIsEnabled &&
|
||||
sub.AutomaticTax.Enabled != true &&
|
||||
if (sub.AutomaticTax.Enabled != true &&
|
||||
CustomerHasTaxLocationVerified(sub.Customer))
|
||||
{
|
||||
subUpdateOptions.DefaultTaxRates = [];
|
||||
@ -815,26 +745,6 @@ public class StripePaymentService : IPaymentService
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!pm5766AutomaticTaxIsEnabled)
|
||||
{
|
||||
var customer = await _stripeAdapter.CustomerGetAsync(sub.CustomerId);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(customer?.Address?.Country)
|
||||
&& !string.IsNullOrWhiteSpace(customer?.Address?.PostalCode))
|
||||
{
|
||||
var taxRates = await _taxRateRepository.GetByLocationAsync(new TaxRate
|
||||
{
|
||||
Country = customer.Address.Country,
|
||||
PostalCode = customer.Address.PostalCode
|
||||
});
|
||||
var taxRate = taxRates.FirstOrDefault();
|
||||
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
|
||||
{
|
||||
subUpdateOptions.DefaultTaxRates = [taxRate.Id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string paymentIntentClientSecret = null;
|
||||
try
|
||||
{
|
||||
@ -1502,8 +1412,7 @@ public class StripePaymentService : IPaymentService
|
||||
});
|
||||
}
|
||||
|
||||
if (_featureService.IsEnabled(FeatureFlagKeys.PM5766AutomaticTax) &&
|
||||
!string.IsNullOrEmpty(subscriber.GatewaySubscriptionId) &&
|
||||
if (!string.IsNullOrEmpty(subscriber.GatewaySubscriptionId) &&
|
||||
customer.Subscriptions.Any(sub =>
|
||||
sub.Id == subscriber.GatewaySubscriptionId &&
|
||||
!sub.AutomaticTax.Enabled) &&
|
||||
|
Reference in New Issue
Block a user