diff --git a/src/Core/Models/StaticStore/Plan.cs b/src/Core/Models/StaticStore/Plan.cs index d8f9a991a8..41fe436728 100644 --- a/src/Core/Models/StaticStore/Plan.cs +++ b/src/Core/Models/StaticStore/Plan.cs @@ -11,6 +11,7 @@ namespace Bit.Core.Models.StaticStore public short BaseSeats { get; set; } public bool CanBuyAdditionalSeats { get; set; } public short? MaxAdditionalSeats { get; set; } + public bool UseGroups { get; set; } public decimal BasePrice { get; set; } public decimal SeatPrice { get; set; } public short? MaxCollections { get; set; } diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 27e11df90e..a759ec49cb 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -281,6 +281,8 @@ namespace Bit.Core.Services } } + // TODO: Groups? + var subscriptionService = new StripeSubscriptionService(); if(string.IsNullOrWhiteSpace(organization.StripeSubscriptionId)) { @@ -288,20 +290,22 @@ namespace Bit.Core.Services var subCreateOptions = new StripeSubscriptionCreateOptions { TrialPeriodDays = newPlan.TrialPeriodDays, - Items = new List - { - new StripeSubscriptionItemOption - { - PlanId = newPlan.StripePlanId, - Quantity = 1 - } - }, + Items = new List(), Metadata = new Dictionary { { "organizationId", organization.Id.ToString() } } }; - if(additionalSeats > 0) + if(newPlan.StripePlanId != null) + { + subCreateOptions.Items.Add(new StripeSubscriptionItemOption + { + PlanId = newPlan.StripePlanId, + Quantity = 1 + }); + } + + if(additionalSeats > 0 && newPlan.StripeSeatPlanId != null) { subCreateOptions.Items.Add(new StripeSubscriptionItemOption { @@ -317,17 +321,19 @@ namespace Bit.Core.Services // Update existing sub. var subUpdateOptions = new StripeSubscriptionUpdateOptions { - Items = new List - { - new StripeSubscriptionItemUpdateOption - { - PlanId = newPlan.StripePlanId, - Quantity = 1 - } - } + Items = new List() }; - if(additionalSeats > 0) + if(newPlan.StripePlanId != null) + { + subUpdateOptions.Items.Add(new StripeSubscriptionItemUpdateOption + { + PlanId = newPlan.StripePlanId, + Quantity = 1 + }); + } + + if(additionalSeats > 0 && newPlan.StripeSeatPlanId != null) { subUpdateOptions.Items.Add(new StripeSubscriptionItemUpdateOption { @@ -338,6 +344,8 @@ namespace Bit.Core.Services await subscriptionService.UpdateAsync(organization.StripeSubscriptionId, subUpdateOptions); } + + // TODO: Update organization } public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment) @@ -506,20 +514,22 @@ namespace Bit.Core.Services var subCreateOptions = new StripeSubscriptionCreateOptions { TrialPeriodDays = plan.TrialPeriodDays, - Items = new List - { - new StripeSubscriptionItemOption - { - PlanId = plan.StripePlanId, - Quantity = 1 - } - }, + Items = new List(), Metadata = new Dictionary { { "organizationId", newOrgId.ToString() } } }; - if(signup.AdditionalSeats > 0) + if(plan.StripePlanId != null) + { + subCreateOptions.Items.Add(new StripeSubscriptionItemOption + { + PlanId = plan.StripePlanId, + Quantity = 1 + }); + } + + if(signup.AdditionalSeats > 0 && plan.StripeSeatPlanId != null) { subCreateOptions.Items.Add(new StripeSubscriptionItemOption { @@ -552,6 +562,7 @@ namespace Bit.Core.Services PlanType = plan.Type, Seats = (short)(plan.BaseSeats + signup.AdditionalSeats), MaxCollections = plan.MaxCollections, + UseGroups = plan.UseGroups, Plan = plan.Name, StripeCustomerId = customer?.Id, StripeSubscriptionId = subscription?.Id, diff --git a/src/Core/Utilities/StaticStore.cs b/src/Core/Utilities/StaticStore.cs index 91100e1fa2..38a5850bc1 100644 --- a/src/Core/Utilities/StaticStore.cs +++ b/src/Core/Utilities/StaticStore.cs @@ -139,6 +139,34 @@ namespace Bit.Core.Utilities StripeSeatPlanId = "teams-org-seat-annually", UpgradeSortOrder = 2, TrialPeriodDays = 7 + }, + new Plan + { + Type = PlanType.EnterpriseMonthly, + BaseSeats = 0, + BasePrice = 0, + SeatPrice = 4M, + CanBuyAdditionalSeats = true, + Name = "Enterprise (Monthly)", + StripePlanId = null, + StripeSeatPlanId = "enterprise-org-seat-monthly", + UpgradeSortOrder = 3, + TrialPeriodDays = 7, + UseGroups = true + }, + new Plan + { + Type = PlanType.EnterpriseAnnually, + BaseSeats = 0, + BasePrice = 0, + SeatPrice = 36, + CanBuyAdditionalSeats = true, + Name = "Enterprise (Annually)", + StripePlanId = null, + StripeSeatPlanId = "enterprise-org-seat-annually", + UpgradeSortOrder = 3, + TrialPeriodDays = 7, + UseGroups = true } };