1
0
mirror of https://github.com/bitwarden/server synced 2025-12-15 07:43:54 +00:00

cancel sub completely if past exp date

This commit is contained in:
Kyle Spearrin
2018-12-31 13:34:02 -05:00
parent 5fa5634a50
commit 6d173385b0
6 changed files with 21 additions and 8 deletions

View File

@@ -85,7 +85,7 @@ namespace Bit.Core.Services
}
}
public async Task CancelSubscriptionAsync(Guid organizationId, bool endOfPeriod = false)
public async Task CancelSubscriptionAsync(Guid organizationId, bool? endOfPeriod = null)
{
var organization = await GetOrgById(organizationId);
if(organization == null)
@@ -93,7 +93,14 @@ namespace Bit.Core.Services
throw new NotFoundException();
}
await _stripePaymentService.CancelSubscriptionAsync(organization, endOfPeriod);
var eop = endOfPeriod.GetValueOrDefault(true);
if(!endOfPeriod.HasValue && organization.ExpirationDate.HasValue &&
organization.ExpirationDate.Value < DateTime.UtcNow)
{
eop = false;
}
await _stripePaymentService.CancelSubscriptionAsync(organization, eop);
}
public async Task ReinstateSubscriptionAsync(Guid organizationId)