1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-29 00:32:18 -05:00
This commit is contained in:
Jonas Hendrickx 2025-01-28 12:30:30 +01:00
parent 51ffe3cef8
commit cb0b705ae7
2 changed files with 26 additions and 27 deletions

View File

@ -730,8 +730,7 @@ public class AccountsController : Controller
BillingAddressCity = model.City, BillingAddressCity = model.City,
BillingAddressState = model.State, BillingAddressState = model.State,
BillingAddressCountry = model.Country, BillingAddressCountry = model.Country,
BillingAddressPostalCode = model.PostalCode, BillingAddressPostalCode = model.PostalCode
TaxIdNumber = model.TaxId
}); });
} }

View File

@ -1394,15 +1394,9 @@ public class StripePaymentService : IPaymentService
try try
{ {
if (!string.IsNullOrWhiteSpace(taxInfo.TaxIdNumber))
{
taxInfo.TaxIdType = taxInfo.TaxIdType ??
_taxService.GetStripeTaxCode(taxInfo.BillingAddressCountry, taxInfo.TaxIdNumber);
}
if (customer == null) if (customer == null)
{ {
customer = await _stripeAdapter.CustomerCreateAsync(new CustomerCreateOptions var customerCreateOptions = new CustomerCreateOptions
{ {
Description = subscriber.BillingName(), Description = subscriber.BillingName(),
Email = subscriber.BillingEmailAddress(), Email = subscriber.BillingEmailAddress(),
@ -1422,7 +1416,9 @@ public class StripePaymentService : IPaymentService
] ]
}, },
Address = taxInfo == null ? null : new AddressOptions Address = taxInfo == null
? null
: new AddressOptions
{ {
Country = taxInfo.BillingAddressCountry, Country = taxInfo.BillingAddressCountry,
PostalCode = taxInfo.BillingAddressPostalCode, PostalCode = taxInfo.BillingAddressPostalCode,
@ -1431,17 +1427,21 @@ public class StripePaymentService : IPaymentService
City = taxInfo.BillingAddressCity, City = taxInfo.BillingAddressCity,
State = taxInfo.BillingAddressState State = taxInfo.BillingAddressState
}, },
TaxIdData = string.IsNullOrWhiteSpace(taxInfo.TaxIdNumber)
? []
: [
new CustomerTaxIdDataOptions
{
Type = taxInfo.TaxIdType,
Value = taxInfo.TaxIdNumber
}
],
Expand = ["sources", "tax", "subscriptions"], Expand = ["sources", "tax", "subscriptions"],
}); };
if (!string.IsNullOrWhiteSpace(taxInfo.TaxIdNumber))
{
taxInfo.TaxIdType = taxInfo.TaxIdType ??
_taxService.GetStripeTaxCode(taxInfo.BillingAddressCountry, taxInfo.TaxIdNumber);
customerCreateOptions.TaxIdData =
[
new CustomerTaxIdDataOptions { Type = taxInfo.TaxIdType, Value = taxInfo.TaxIdNumber }
];
}
customer = await _stripeAdapter.CustomerCreateAsync(customerCreateOptions);
subscriber.Gateway = GatewayType.Stripe; subscriber.Gateway = GatewayType.Stripe;
subscriber.GatewayCustomerId = customer.Id; subscriber.GatewayCustomerId = customer.Id;