1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-26 23:32:19 -05:00
bitwarden/src/Core/Services/Implementations/StripeSyncService.cs
2022-08-29 16:06:55 -04:00

32 lines
865 B
C#

using Bit.Core.Exceptions;
namespace Bit.Core.Services;
public class StripeSyncService : IStripeSyncService
{
private readonly IStripeAdapter _stripeAdapter;
public StripeSyncService(IStripeAdapter stripeAdapter)
{
_stripeAdapter = stripeAdapter;
}
public async Task UpdateCustomerEmailAddress(string gatewayCustomerId, string emailAddress)
{
if (string.IsNullOrWhiteSpace(gatewayCustomerId))
{
throw new InvalidGatewayCustomerIdException();
}
if (string.IsNullOrWhiteSpace(emailAddress))
{
throw new InvalidEmailException();
}
var customer = await _stripeAdapter.CustomerGetAsync(gatewayCustomerId);
await _stripeAdapter.CustomerUpdateAsync(customer.Id,
new Stripe.CustomerUpdateOptions { Email = emailAddress });
}
}