1
0
mirror of https://github.com/bitwarden/server synced 2025-12-14 15:23:42 +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

@@ -820,10 +820,16 @@ namespace Bit.Core.Services
}
}
public async Task CancelPremiumAsync(User user, bool endOfPeriod = false)
public async Task CancelPremiumAsync(User user, bool? endOfPeriod = null)
{
var paymentService = user.GetPaymentService(_globalSettings);
await paymentService.CancelSubscriptionAsync(user, endOfPeriod);
var eop = endOfPeriod.GetValueOrDefault(true);
if(!endOfPeriod.HasValue && user.PremiumExpirationDate.HasValue &&
user.PremiumExpirationDate.Value < DateTime.UtcNow)
{
eop = false;
}
await paymentService.CancelSubscriptionAsync(user, eop);
}
public async Task ReinstatePremiumAsync(User user)