1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-06 18:42:49 -05:00

[PM-13999] show estimated tax for taxable countries (#5110)

This commit is contained in:
Jonas Hendrickx
2025-01-02 20:27:53 +01:00
committed by GitHub
parent 1062c6d522
commit 97e11774e3
32 changed files with 1806 additions and 548 deletions

View File

@ -28,7 +28,8 @@ public class OrganizationBillingService(
IOrganizationRepository organizationRepository,
ISetupIntentCache setupIntentCache,
IStripeAdapter stripeAdapter,
ISubscriberService subscriberService) : IOrganizationBillingService
ISubscriberService subscriberService,
ITaxService taxService) : IOrganizationBillingService
{
public async Task Finalize(OrganizationSale sale)
{
@ -173,14 +174,38 @@ public class OrganizationBillingService(
throw new BillingException();
}
var (address, taxIdData) = customerSetup.TaxInformation.GetStripeOptions();
customerCreateOptions.Address = address;
customerCreateOptions.Address = new AddressOptions
{
Line1 = customerSetup.TaxInformation.Line1,
Line2 = customerSetup.TaxInformation.Line2,
City = customerSetup.TaxInformation.City,
PostalCode = customerSetup.TaxInformation.PostalCode,
State = customerSetup.TaxInformation.State,
Country = customerSetup.TaxInformation.Country,
};
customerCreateOptions.Tax = new CustomerTaxOptions
{
ValidateLocation = StripeConstants.ValidateTaxLocationTiming.Immediately
};
customerCreateOptions.TaxIdData = taxIdData;
if (!string.IsNullOrEmpty(customerSetup.TaxInformation.TaxId))
{
var taxIdType = taxService.GetStripeTaxCode(customerSetup.TaxInformation.Country,
customerSetup.TaxInformation.TaxId);
if (taxIdType == null)
{
logger.LogWarning("Could not determine tax ID type for organization '{OrganizationID}' in country '{Country}' with tax ID '{TaxID}'.",
organization.Id,
customerSetup.TaxInformation.Country,
customerSetup.TaxInformation.TaxId);
}
customerCreateOptions.TaxIdData =
[
new() { Type = taxIdType, Value = customerSetup.TaxInformation.TaxId }
];
}
var (paymentMethodType, paymentMethodToken) = customerSetup.TokenizedPaymentSource;