1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-09 20:03:47 -05:00

[PM-18028] Enabling automatic tax for customers without country or with manual tax rates set (#5376)

This commit is contained in:
Jonas Hendrickx
2025-02-20 16:01:48 +01:00
committed by GitHub
parent 9f4aa1ab2b
commit 4bef2357d5
8 changed files with 155 additions and 35 deletions

View File

@ -1,6 +1,7 @@
using Bit.Billing.Constants;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Billing.Extensions;
using Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.Interfaces;
using Bit.Core.Repositories;
using Bit.Core.Services;
@ -160,16 +161,16 @@ public class UpcomingInvoiceHandler : IUpcomingInvoiceHandler
private async Task<Subscription> TryEnableAutomaticTaxAsync(Subscription subscription)
{
if (subscription.AutomaticTax.Enabled)
var customerGetOptions = new CustomerGetOptions { Expand = ["tax"] };
var customer = await _stripeFacade.GetCustomer(subscription.CustomerId, customerGetOptions);
var subscriptionUpdateOptions = new SubscriptionUpdateOptions();
if (!subscriptionUpdateOptions.EnableAutomaticTax(customer, subscription))
{
return subscription;
}
var subscriptionUpdateOptions = new SubscriptionUpdateOptions
{
AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true }
};
return await _stripeFacade.UpdateSubscription(subscription.Id, subscriptionUpdateOptions);
}