mirror of
https://github.com/bitwarden/server
synced 2025-12-22 03:03:33 +00:00
[SG-72] Sync changed email address with stripe (#2042)
* sync changed email address with strip * sync changed email address with strip * fixed formatting * throw exception if not successful * Added revert if stripe sync fails * Added revert if stripe sync fails * Added revert if stripe sync fails * created stripe sync service * fixed lint issue * reverted to use stripe exception message * added null checks to customer id and email address * added braces * removed empty email
This commit is contained in:
33
src/Core/Services/Implementations/StripeSyncService.cs
Normal file
33
src/Core/Services/Implementations/StripeSyncService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Threading.Tasks;
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user