1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-25 14:52:21 -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,26 +1416,32 @@ public class StripePaymentService : IPaymentService
] ]
}, },
Address = taxInfo == null ? null : new AddressOptions Address = taxInfo == null
{ ? null
Country = taxInfo.BillingAddressCountry, : new AddressOptions
PostalCode = taxInfo.BillingAddressPostalCode,
Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
Line2 = taxInfo.BillingAddressLine2,
City = taxInfo.BillingAddressCity,
State = taxInfo.BillingAddressState
},
TaxIdData = string.IsNullOrWhiteSpace(taxInfo.TaxIdNumber)
? []
: [
new CustomerTaxIdDataOptions
{ {
Type = taxInfo.TaxIdType, Country = taxInfo.BillingAddressCountry,
Value = taxInfo.TaxIdNumber PostalCode = taxInfo.BillingAddressPostalCode,
} Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
], Line2 = taxInfo.BillingAddressLine2,
City = taxInfo.BillingAddressCity,
State = taxInfo.BillingAddressState
},
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;