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
Justin Baur 231eb84e69
Turn On ImplicitUsings (#2079)
* Turn on ImplicitUsings

* Fix formatting

* Run linter
2022-06-29 19:46:41 -04:00

33 lines
955 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 });
}
}
}