mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
changing payment method for bank account token
This commit is contained in:
parent
e470301327
commit
10ff21983b
@ -264,6 +264,7 @@ namespace Bit.Core.Services
|
||||
var updatedSubscriber = false;
|
||||
|
||||
var cardService = new StripeCardService();
|
||||
var bankSerice = new BankAccountService();
|
||||
var customerService = new StripeCustomerService();
|
||||
StripeCustomer customer = null;
|
||||
|
||||
@ -286,17 +287,35 @@ namespace Bit.Core.Services
|
||||
updatedSubscriber = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(paymentToken.StartsWith("btok_"))
|
||||
{
|
||||
await bankSerice.CreateAsync(customer.Id, new BankAccountCreateOptions
|
||||
{
|
||||
SourceToken = paymentToken
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await cardService.CreateAsync(customer.Id, new StripeCardCreateOptions
|
||||
{
|
||||
SourceToken = paymentToken
|
||||
});
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(customer.DefaultSourceId))
|
||||
{
|
||||
var source = customer.Sources.FirstOrDefault(s => s.Id == customer.DefaultSourceId);
|
||||
if(source.BankAccount != null)
|
||||
{
|
||||
await bankSerice.DeleteAsync(customer.Id, customer.DefaultSourceId);
|
||||
}
|
||||
else if(source.Card != null)
|
||||
{
|
||||
await cardService.DeleteAsync(customer.Id, customer.DefaultSourceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return updatedSubscriber;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user