1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

handle sub incomplete status

This commit is contained in:
Kyle Spearrin 2019-08-12 10:42:14 -04:00
parent 41f9f6a7f0
commit 5c3bf78226
2 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,7 @@ namespace Bit.Core.Models.Business
PeriodEndDate = sub.CurrentPeriodEnd;
CancelledDate = sub.CanceledAt;
CancelAtEndDate = sub.CancelAtPeriodEnd;
Cancelled = sub.Status == "canceled" || sub.Status == "unpaid";
Cancelled = sub.Status == "canceled" || sub.Status == "unpaid" || sub.Status == "incomplete_expired";
if(sub.Items?.Data != null)
{
Items = sub.Items.Data.Select(i => new BillingSubscriptionItem(i));

View File

@ -976,7 +976,8 @@ namespace Bit.Core.Services
throw new GatewayException("Subscription was not found.");
}
if(sub.CanceledAt.HasValue || sub.Status == "canceled" || sub.Status == "unpaid")
if(sub.CanceledAt.HasValue || sub.Status == "canceled" || sub.Status == "unpaid" ||
sub.Status == "incomplete_expired")
{
// Already canceled
return;
@ -1021,7 +1022,8 @@ namespace Bit.Core.Services
throw new GatewayException("Subscription was not found.");
}
if((sub.Status != "active" && sub.Status != "trialing") || !sub.CanceledAt.HasValue)
if((sub.Status != "active" && sub.Status != "trialing" && !sub.Status.StartsWith("incomplete")) ||
!sub.CanceledAt.HasValue)
{
throw new GatewayException("Subscription is not marked for cancellation.");
}