mirror of
https://github.com/bitwarden/server.git
synced 2025-04-22 13:35:10 -05:00
premium access addon for families plans
This commit is contained in:
parent
04ae06420b
commit
0b20f64f2d
@ -26,6 +26,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public short AdditionalSeats { get; set; }
|
public short AdditionalSeats { get; set; }
|
||||||
[Range(0, 99)]
|
[Range(0, 99)]
|
||||||
public short? AdditionalStorageGb { get; set; }
|
public short? AdditionalStorageGb { get; set; }
|
||||||
|
public bool PremiumAccessAddon { get; set; }
|
||||||
[EncryptedString]
|
[EncryptedString]
|
||||||
[EncryptedStringLength(1000)]
|
[EncryptedStringLength(1000)]
|
||||||
public string CollectionName { get; set; }
|
public string CollectionName { get; set; }
|
||||||
@ -42,6 +43,7 @@ namespace Bit.Core.Models.Api
|
|||||||
PaymentToken = PaymentToken,
|
PaymentToken = PaymentToken,
|
||||||
AdditionalSeats = AdditionalSeats,
|
AdditionalSeats = AdditionalSeats,
|
||||||
AdditionalStorageGb = AdditionalStorageGb.GetValueOrDefault(0),
|
AdditionalStorageGb = AdditionalStorageGb.GetValueOrDefault(0),
|
||||||
|
PremiumAccessAddon = PremiumAccessAddon,
|
||||||
BillingEmail = BillingEmail,
|
BillingEmail = BillingEmail,
|
||||||
BusinessName = BusinessName,
|
BusinessName = BusinessName,
|
||||||
BusinessCountry = Country,
|
BusinessCountry = Country,
|
||||||
|
@ -13,6 +13,7 @@ namespace Bit.Core.Models.Business
|
|||||||
public Enums.PlanType Plan { get; set; }
|
public Enums.PlanType Plan { get; set; }
|
||||||
public short AdditionalSeats { get; set; }
|
public short AdditionalSeats { get; set; }
|
||||||
public short AdditionalStorageGb { get; set; }
|
public short AdditionalStorageGb { get; set; }
|
||||||
|
public bool PremiumAccessAddon { get; set; }
|
||||||
public string PaymentToken { get; set; }
|
public string PaymentToken { get; set; }
|
||||||
public string CollectionName { get; set; }
|
public string CollectionName { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,13 @@ namespace Bit.Core.Models.StaticStore
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string StripePlanId { get; set; }
|
public string StripePlanId { get; set; }
|
||||||
public string StripeSeatPlanId { get; set; }
|
public string StripeSeatPlanId { get; set; }
|
||||||
public string StripStoragePlanId { get; set; }
|
public string StripeStoragePlanId { get; set; }
|
||||||
|
public string StripePremiumAccessPlanId { get; set; }
|
||||||
public PlanType Type { get; set; }
|
public PlanType Type { get; set; }
|
||||||
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 CanBuyPremiumAccessAddon { get; set; }
|
||||||
public bool UseGroups { get; set; }
|
public bool UseGroups { get; set; }
|
||||||
public bool UseDirectory { get; set; }
|
public bool UseDirectory { get; set; }
|
||||||
public bool UseEvents { get; set; }
|
public bool UseEvents { get; set; }
|
||||||
|
@ -265,7 +265,7 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
await BillingHelpers.AdjustStorageAsync(_stripePaymentService, organization, storageAdjustmentGb,
|
await BillingHelpers.AdjustStorageAsync(_stripePaymentService, organization, storageAdjustmentGb,
|
||||||
plan.StripStoragePlanId);
|
plan.StripeStoragePlanId);
|
||||||
await ReplaceAndUpdateCache(organization);
|
await ReplaceAndUpdateCache(organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,6 +424,11 @@ namespace Bit.Core.Services
|
|||||||
throw new BadRequestException("Plan does not allow additional storage.");
|
throw new BadRequestException("Plan does not allow additional storage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!plan.CanBuyPremiumAccessAddon && signup.PremiumAccessAddon)
|
||||||
|
{
|
||||||
|
throw new BadRequestException("This plan does not allow you to buy the premium access addon.");
|
||||||
|
}
|
||||||
|
|
||||||
if(plan.BaseSeats + signup.AdditionalSeats <= 0)
|
if(plan.BaseSeats + signup.AdditionalSeats <= 0)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("You do not have any seats!");
|
throw new BadRequestException("You do not have any seats!");
|
||||||
@ -499,11 +504,20 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new StripeSubscriptionItemOption
|
subCreateOptions.Items.Add(new StripeSubscriptionItemOption
|
||||||
{
|
{
|
||||||
PlanId = plan.StripStoragePlanId,
|
PlanId = plan.StripeStoragePlanId,
|
||||||
Quantity = signup.AdditionalStorageGb
|
Quantity = signup.AdditionalStorageGb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(signup.PremiumAccessAddon && plan.StripePremiumAccessPlanId != null)
|
||||||
|
{
|
||||||
|
subCreateOptions.Items.Add(new StripeSubscriptionItemOption
|
||||||
|
{
|
||||||
|
PlanId = plan.StripePremiumAccessPlanId,
|
||||||
|
Quantity = 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
subscription = await subscriptionService.CreateAsync(subCreateOptions);
|
subscription = await subscriptionService.CreateAsync(subCreateOptions);
|
||||||
@ -537,7 +551,7 @@ namespace Bit.Core.Services
|
|||||||
UseTotp = plan.UseTotp,
|
UseTotp = plan.UseTotp,
|
||||||
Use2fa = plan.Use2fa,
|
Use2fa = plan.Use2fa,
|
||||||
SelfHost = plan.SelfHost,
|
SelfHost = plan.SelfHost,
|
||||||
UsersGetPremium = plan.UsersGetPremium,
|
UsersGetPremium = plan.UsersGetPremium || signup.PremiumAccessAddon,
|
||||||
Plan = plan.Name,
|
Plan = plan.Name,
|
||||||
Gateway = plan.Type == PlanType.Free ? null : (GatewayType?)GatewayType.Stripe,
|
Gateway = plan.Type == PlanType.Free ? null : (GatewayType?)GatewayType.Stripe,
|
||||||
GatewayCustomerId = customer?.Id,
|
GatewayCustomerId = customer?.Id,
|
||||||
|
@ -108,9 +108,11 @@ namespace Bit.Core.Utilities
|
|||||||
BaseSeats = 5,
|
BaseSeats = 5,
|
||||||
BasePrice = 12,
|
BasePrice = 12,
|
||||||
CanBuyAdditionalSeats = false,
|
CanBuyAdditionalSeats = false,
|
||||||
|
CanBuyPremiumAccessAddon = true,
|
||||||
Name = "Families",
|
Name = "Families",
|
||||||
StripePlanId = "personal-org-annually",
|
StripePlanId = "personal-org-annually",
|
||||||
StripStoragePlanId = "storage-gb-annually",
|
StripeStoragePlanId = "storage-gb-annually",
|
||||||
|
StripePremiumAccessPlanId = "personal-org-premium-access-annually",
|
||||||
UpgradeSortOrder = 1,
|
UpgradeSortOrder = 1,
|
||||||
TrialPeriodDays = 7,
|
TrialPeriodDays = 7,
|
||||||
UseTotp = true,
|
UseTotp = true,
|
||||||
@ -127,7 +129,7 @@ namespace Bit.Core.Utilities
|
|||||||
Name = "Teams (Monthly)",
|
Name = "Teams (Monthly)",
|
||||||
StripePlanId = "teams-org-monthly",
|
StripePlanId = "teams-org-monthly",
|
||||||
StripeSeatPlanId = "teams-org-seat-monthly",
|
StripeSeatPlanId = "teams-org-seat-monthly",
|
||||||
StripStoragePlanId = "storage-gb-monthly",
|
StripeStoragePlanId = "storage-gb-monthly",
|
||||||
UpgradeSortOrder = 2,
|
UpgradeSortOrder = 2,
|
||||||
TrialPeriodDays = 7,
|
TrialPeriodDays = 7,
|
||||||
UseTotp = true,
|
UseTotp = true,
|
||||||
@ -143,7 +145,7 @@ namespace Bit.Core.Utilities
|
|||||||
Name = "Teams (Annually)",
|
Name = "Teams (Annually)",
|
||||||
StripePlanId = "teams-org-annually",
|
StripePlanId = "teams-org-annually",
|
||||||
StripeSeatPlanId = "teams-org-seat-annually",
|
StripeSeatPlanId = "teams-org-seat-annually",
|
||||||
StripStoragePlanId = "storage-gb-annually",
|
StripeStoragePlanId = "storage-gb-annually",
|
||||||
UpgradeSortOrder = 2,
|
UpgradeSortOrder = 2,
|
||||||
TrialPeriodDays = 7,
|
TrialPeriodDays = 7,
|
||||||
UseTotp = true,
|
UseTotp = true,
|
||||||
@ -159,7 +161,7 @@ namespace Bit.Core.Utilities
|
|||||||
Name = "Enterprise (Monthly)",
|
Name = "Enterprise (Monthly)",
|
||||||
StripePlanId = null,
|
StripePlanId = null,
|
||||||
StripeSeatPlanId = "enterprise-org-seat-monthly",
|
StripeSeatPlanId = "enterprise-org-seat-monthly",
|
||||||
StripStoragePlanId = "storage-gb-monthly",
|
StripeStoragePlanId = "storage-gb-monthly",
|
||||||
UpgradeSortOrder = 3,
|
UpgradeSortOrder = 3,
|
||||||
TrialPeriodDays = 7,
|
TrialPeriodDays = 7,
|
||||||
UseGroups = true,
|
UseGroups = true,
|
||||||
@ -181,7 +183,7 @@ namespace Bit.Core.Utilities
|
|||||||
Name = "Enterprise (Annually)",
|
Name = "Enterprise (Annually)",
|
||||||
StripePlanId = null,
|
StripePlanId = null,
|
||||||
StripeSeatPlanId = "enterprise-org-seat-annually",
|
StripeSeatPlanId = "enterprise-org-seat-annually",
|
||||||
StripStoragePlanId = "storage-gb-annually",
|
StripeStoragePlanId = "storage-gb-annually",
|
||||||
UpgradeSortOrder = 3,
|
UpgradeSortOrder = 3,
|
||||||
TrialPeriodDays = 7,
|
TrialPeriodDays = 7,
|
||||||
UseGroups = true,
|
UseGroups = true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user