using Stripe; namespace Bit.Core.Billing.Extensions; public static class SubscriptionUpdateOptionsExtensions { /// /// Attempts to enable automatic tax for given subscription options. /// /// /// The existing customer to which the subscription belongs. /// The existing subscription. /// Returns true when successful, false when conditions are not met. public static bool EnableAutomaticTax( this SubscriptionUpdateOptions options, Customer customer, Subscription subscription) { if (subscription.AutomaticTax.Enabled) { return false; } // We might only need to check the automatic tax status. if (!customer.HasTaxLocationVerified() && string.IsNullOrWhiteSpace(customer.Address?.Country)) { return false; } options.DefaultTaxRates = []; options.AutomaticTax = new SubscriptionAutomaticTaxOptions { Enabled = true }; return true; } }