1
0
mirror of https://github.com/bitwarden/server synced 2025-12-20 18:23:44 +00:00

[PM-18028] Attempting to enable automatic tax on customer with invalid location (#5374)

This commit is contained in:
Jonas Hendrickx
2025-02-06 16:34:22 +01:00
committed by GitHub
parent bc27ec2b9b
commit 678d5d5d63
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);
}