mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 09:02:48 -05:00
Replace StripePaymentService with PremiumUserBillingService in ReplacePaymentMethodAsync call (#5350)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Bit.Core.Billing.Caches;
|
||||
using Bit.Core.Billing.Constants;
|
||||
using Bit.Core.Billing.Models;
|
||||
using Bit.Core.Billing.Models.Sales;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
@ -58,6 +59,28 @@ public class PremiumUserBillingService(
|
||||
await userRepository.ReplaceAsync(user);
|
||||
}
|
||||
|
||||
public async Task UpdatePaymentMethod(
|
||||
User user,
|
||||
TokenizedPaymentSource tokenizedPaymentSource,
|
||||
TaxInformation taxInformation)
|
||||
{
|
||||
if (string.IsNullOrEmpty(user.GatewayCustomerId))
|
||||
{
|
||||
var customer = await CreateCustomerAsync(user,
|
||||
new CustomerSetup { TokenizedPaymentSource = tokenizedPaymentSource, TaxInformation = taxInformation });
|
||||
|
||||
user.Gateway = GatewayType.Stripe;
|
||||
user.GatewayCustomerId = customer.Id;
|
||||
|
||||
await userRepository.ReplaceAsync(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
await subscriberService.UpdatePaymentSource(user, tokenizedPaymentSource);
|
||||
await subscriberService.UpdateTaxInformation(user, taxInformation);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Customer> CreateCustomerAsync(
|
||||
User user,
|
||||
CustomerSetup customerSetup)
|
||||
|
Reference in New Issue
Block a user