mirror of
https://github.com/bitwarden/server.git
synced 2025-05-23 04:21:05 -05:00
enterprise plans
This commit is contained in:
parent
81d4be6f56
commit
e996a410dc
@ -11,6 +11,7 @@ namespace Bit.Core.Models.StaticStore
|
|||||||
public short BaseSeats { get; set; }
|
public short BaseSeats { get; set; }
|
||||||
public bool CanBuyAdditionalSeats { get; set; }
|
public bool CanBuyAdditionalSeats { get; set; }
|
||||||
public short? MaxAdditionalSeats { get; set; }
|
public short? MaxAdditionalSeats { get; set; }
|
||||||
|
public bool UseGroups { get; set; }
|
||||||
public decimal BasePrice { get; set; }
|
public decimal BasePrice { get; set; }
|
||||||
public decimal SeatPrice { get; set; }
|
public decimal SeatPrice { get; set; }
|
||||||
public short? MaxCollections { get; set; }
|
public short? MaxCollections { get; set; }
|
||||||
|
@ -281,6 +281,8 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Groups?
|
||||||
|
|
||||||
var subscriptionService = new StripeSubscriptionService();
|
var subscriptionService = new StripeSubscriptionService();
|
||||||
if(string.IsNullOrWhiteSpace(organization.StripeSubscriptionId))
|
if(string.IsNullOrWhiteSpace(organization.StripeSubscriptionId))
|
||||||
{
|
{
|
||||||
@ -288,20 +290,22 @@ namespace Bit.Core.Services
|
|||||||
var subCreateOptions = new StripeSubscriptionCreateOptions
|
var subCreateOptions = new StripeSubscriptionCreateOptions
|
||||||
{
|
{
|
||||||
TrialPeriodDays = newPlan.TrialPeriodDays,
|
TrialPeriodDays = newPlan.TrialPeriodDays,
|
||||||
Items = new List<StripeSubscriptionItemOption>
|
Items = new List<StripeSubscriptionItemOption>(),
|
||||||
{
|
|
||||||
new StripeSubscriptionItemOption
|
|
||||||
{
|
|
||||||
PlanId = newPlan.StripePlanId,
|
|
||||||
Quantity = 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Metadata = new Dictionary<string, string> {
|
Metadata = new Dictionary<string, string> {
|
||||||
{ "organizationId", organization.Id.ToString() }
|
{ "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
|
subCreateOptions.Items.Add(new StripeSubscriptionItemOption
|
||||||
{
|
{
|
||||||
@ -317,17 +321,19 @@ namespace Bit.Core.Services
|
|||||||
// Update existing sub.
|
// Update existing sub.
|
||||||
var subUpdateOptions = new StripeSubscriptionUpdateOptions
|
var subUpdateOptions = new StripeSubscriptionUpdateOptions
|
||||||
{
|
{
|
||||||
Items = new List<StripeSubscriptionItemUpdateOption>
|
Items = new List<StripeSubscriptionItemUpdateOption>()
|
||||||
|
};
|
||||||
|
|
||||||
|
if(newPlan.StripePlanId != null)
|
||||||
{
|
{
|
||||||
new StripeSubscriptionItemUpdateOption
|
subUpdateOptions.Items.Add(new StripeSubscriptionItemUpdateOption
|
||||||
{
|
{
|
||||||
PlanId = newPlan.StripePlanId,
|
PlanId = newPlan.StripePlanId,
|
||||||
Quantity = 1
|
Quantity = 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if(additionalSeats > 0)
|
if(additionalSeats > 0 && newPlan.StripeSeatPlanId != null)
|
||||||
{
|
{
|
||||||
subUpdateOptions.Items.Add(new StripeSubscriptionItemUpdateOption
|
subUpdateOptions.Items.Add(new StripeSubscriptionItemUpdateOption
|
||||||
{
|
{
|
||||||
@ -338,6 +344,8 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
await subscriptionService.UpdateAsync(organization.StripeSubscriptionId, subUpdateOptions);
|
await subscriptionService.UpdateAsync(organization.StripeSubscriptionId, subUpdateOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Update organization
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment)
|
public async Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment)
|
||||||
@ -506,20 +514,22 @@ namespace Bit.Core.Services
|
|||||||
var subCreateOptions = new StripeSubscriptionCreateOptions
|
var subCreateOptions = new StripeSubscriptionCreateOptions
|
||||||
{
|
{
|
||||||
TrialPeriodDays = plan.TrialPeriodDays,
|
TrialPeriodDays = plan.TrialPeriodDays,
|
||||||
Items = new List<StripeSubscriptionItemOption>
|
Items = new List<StripeSubscriptionItemOption>(),
|
||||||
{
|
|
||||||
new StripeSubscriptionItemOption
|
|
||||||
{
|
|
||||||
PlanId = plan.StripePlanId,
|
|
||||||
Quantity = 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Metadata = new Dictionary<string, string> {
|
Metadata = new Dictionary<string, string> {
|
||||||
{ "organizationId", newOrgId.ToString() }
|
{ "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
|
subCreateOptions.Items.Add(new StripeSubscriptionItemOption
|
||||||
{
|
{
|
||||||
@ -552,6 +562,7 @@ namespace Bit.Core.Services
|
|||||||
PlanType = plan.Type,
|
PlanType = plan.Type,
|
||||||
Seats = (short)(plan.BaseSeats + signup.AdditionalSeats),
|
Seats = (short)(plan.BaseSeats + signup.AdditionalSeats),
|
||||||
MaxCollections = plan.MaxCollections,
|
MaxCollections = plan.MaxCollections,
|
||||||
|
UseGroups = plan.UseGroups,
|
||||||
Plan = plan.Name,
|
Plan = plan.Name,
|
||||||
StripeCustomerId = customer?.Id,
|
StripeCustomerId = customer?.Id,
|
||||||
StripeSubscriptionId = subscription?.Id,
|
StripeSubscriptionId = subscription?.Id,
|
||||||
|
@ -139,6 +139,34 @@ namespace Bit.Core.Utilities
|
|||||||
StripeSeatPlanId = "teams-org-seat-annually",
|
StripeSeatPlanId = "teams-org-seat-annually",
|
||||||
UpgradeSortOrder = 2,
|
UpgradeSortOrder = 2,
|
||||||
TrialPeriodDays = 7
|
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
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user