mirror of
https://github.com/bitwarden/server.git
synced 2024-11-29 13:25:17 +01:00
cancel sub completely if past exp date
This commit is contained in:
parent
5fa5634a50
commit
6d173385b0
@ -547,7 +547,7 @@ namespace Bit.Api.Controllers
|
|||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userService.CancelPremiumAsync(user, true);
|
await _userService.CancelPremiumAsync(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("reinstate-premium")]
|
[HttpPost("reinstate-premium")]
|
||||||
|
@ -284,7 +284,7 @@ namespace Bit.Api.Controllers
|
|||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
await _organizationService.CancelSubscriptionAsync(orgIdGuid, true);
|
await _organizationService.CancelSubscriptionAsync(orgIdGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/reinstate")]
|
[HttpPost("{id}/reinstate")]
|
||||||
|
@ -11,7 +11,7 @@ namespace Bit.Core.Services
|
|||||||
public interface IOrganizationService
|
public interface IOrganizationService
|
||||||
{
|
{
|
||||||
Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken);
|
Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken);
|
||||||
Task CancelSubscriptionAsync(Guid organizationId, bool endOfPeriod = false);
|
Task CancelSubscriptionAsync(Guid organizationId, bool? endOfPeriod = null);
|
||||||
Task ReinstateSubscriptionAsync(Guid organizationId);
|
Task ReinstateSubscriptionAsync(Guid organizationId);
|
||||||
Task UpgradePlanAsync(Guid organizationId, PlanType plan, int additionalSeats);
|
Task UpgradePlanAsync(Guid organizationId, PlanType plan, int additionalSeats);
|
||||||
Task AdjustStorageAsync(Guid organizationId, short storageAdjustmentGb);
|
Task AdjustStorageAsync(Guid organizationId, short storageAdjustmentGb);
|
||||||
|
@ -47,7 +47,7 @@ namespace Bit.Core.Services
|
|||||||
Task UpdateLicenseAsync(User user, UserLicense license);
|
Task UpdateLicenseAsync(User user, UserLicense license);
|
||||||
Task AdjustStorageAsync(User user, short storageAdjustmentGb);
|
Task AdjustStorageAsync(User user, short storageAdjustmentGb);
|
||||||
Task ReplacePaymentMethodAsync(User user, string paymentToken);
|
Task ReplacePaymentMethodAsync(User user, string paymentToken);
|
||||||
Task CancelPremiumAsync(User user, bool endOfPeriod = false);
|
Task CancelPremiumAsync(User user, bool? endOfPeriod = null);
|
||||||
Task ReinstatePremiumAsync(User user);
|
Task ReinstatePremiumAsync(User user);
|
||||||
Task DisablePremiumAsync(Guid userId, DateTime? expirationDate);
|
Task DisablePremiumAsync(Guid userId, DateTime? expirationDate);
|
||||||
Task DisablePremiumAsync(User user, DateTime? expirationDate);
|
Task DisablePremiumAsync(User user, DateTime? expirationDate);
|
||||||
|
@ -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);
|
var organization = await GetOrgById(organizationId);
|
||||||
if(organization == null)
|
if(organization == null)
|
||||||
@ -93,7 +93,14 @@ namespace Bit.Core.Services
|
|||||||
throw new NotFoundException();
|
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)
|
public async Task ReinstateSubscriptionAsync(Guid organizationId)
|
||||||
|
@ -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);
|
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)
|
public async Task ReinstatePremiumAsync(User user)
|
||||||
|
Loading…
Reference in New Issue
Block a user