mirror of
https://github.com/bitwarden/server.git
synced 2024-11-24 12:35:25 +01:00
[SG 475] Fix error thrown when changing payment method (#2137)
* Add null check for sources * Add expand to get customer sources
This commit is contained in:
parent
f736008cb3
commit
378b54524f
@ -1187,7 +1187,9 @@ namespace Bit.Core.Services
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
|
||||
{
|
||||
customer = await _stripeAdapter.CustomerGetAsync(subscriber.GatewayCustomerId);
|
||||
var options = new Stripe.CustomerGetOptions();
|
||||
options.AddExpand("sources");
|
||||
customer = await _stripeAdapter.CustomerGetAsync(subscriber.GatewayCustomerId, options);
|
||||
if (customer.Metadata?.Any() ?? false)
|
||||
{
|
||||
stripeCustomerMetadata = customer.Metadata;
|
||||
@ -1372,6 +1374,8 @@ namespace Bit.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
if (customer.Sources != null)
|
||||
{
|
||||
foreach (var source in customer.Sources.Where(s => s.Id != defaultSourceId))
|
||||
{
|
||||
if (source is Stripe.BankAccount)
|
||||
@ -1383,6 +1387,7 @@ namespace Bit.Core.Services
|
||||
await _stripeAdapter.CardDeleteAsync(customer.Id, source.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cardPaymentMethods = _stripeAdapter.PaymentMethodListAutoPaging(new Stripe.PaymentMethodListOptions
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user