diff --git a/src/Core/Services/Implementations/UserService.cs b/src/Core/Services/Implementations/UserService.cs index a939e74be..dccaa0f07 100644 --- a/src/Core/Services/Implementations/UserService.cs +++ b/src/Core/Services/Implementations/UserService.cs @@ -164,6 +164,16 @@ namespace Bit.Core.Services }); } + if(!string.IsNullOrWhiteSpace(user.StripeSubscriptionId)) + { + var subscriptionService = new StripeSubscriptionService(); + var canceledSub = await subscriptionService.CancelAsync(user.StripeSubscriptionId, false); + if(!canceledSub.CanceledAt.HasValue) + { + throw new BadRequestException("Unable to cancel subscription."); + } + } + await _userRepository.DeleteAsync(user); return IdentityResult.Success; }