mirror of
https://github.com/bitwarden/server
synced 2026-01-03 09:03:44 +00:00
[PM-8830] Billing Enums Rename (#4180)
* Renamed ProductType to ProductTierType * Renamed Product properties to ProductTier * Moved ProductTierType to Bit.Core.Billing.Enums namespace from Bit.Core.Enums * Moved PlanType enum to Bit.Core.Billing.Enums * Moved StaticStore to Bit.Core.Billing.Models.StaticStore namespace * Added ProductType enum * dotnet format
This commit is contained in:
@@ -53,9 +53,9 @@ public class CloudSyncSponsorshipsCommand : ICloudSyncSponsorshipsCommand
|
||||
|
||||
foreach (var selfHostedSponsorship in sponsorshipsData)
|
||||
{
|
||||
var requiredSponsoringProductType = StaticStore.GetSponsoredPlan(selfHostedSponsorship.PlanSponsorshipType)?.SponsoringProductType;
|
||||
var requiredSponsoringProductType = StaticStore.GetSponsoredPlan(selfHostedSponsorship.PlanSponsorshipType)?.SponsoringProductTierType;
|
||||
if (requiredSponsoringProductType == null
|
||||
|| StaticStore.GetPlan(sponsoringOrg.PlanType).Product != requiredSponsoringProductType.Value)
|
||||
|| StaticStore.GetPlan(sponsoringOrg.PlanType).ProductTier != requiredSponsoringProductType.Value)
|
||||
{
|
||||
continue; // prevent unsupported sponsorships
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ public class SetUpSponsorshipCommand : ISetUpSponsorshipCommand
|
||||
}
|
||||
|
||||
// Check org to sponsor's product type
|
||||
var requiredSponsoredProductType = StaticStore.GetSponsoredPlan(sponsorship.PlanSponsorshipType.Value)?.SponsoredProductType;
|
||||
var requiredSponsoredProductType = StaticStore.GetSponsoredPlan(sponsorship.PlanSponsorshipType.Value)?.SponsoredProductTierType;
|
||||
if (requiredSponsoredProductType == null ||
|
||||
sponsoredOrganization == null ||
|
||||
StaticStore.GetPlan(sponsoredOrganization.PlanType).Product != requiredSponsoredProductType.Value)
|
||||
StaticStore.GetPlan(sponsoredOrganization.PlanType).ProductTier != requiredSponsoredProductType.Value)
|
||||
{
|
||||
throw new BadRequestException("Can only redeem sponsorship offer on families organizations.");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ValidateSponsorshipCommand : CancelSponsorshipCommand, IValidateSpo
|
||||
|
||||
var sponsoringOrgPlan = Utilities.StaticStore.GetPlan(sponsoringOrganization.PlanType);
|
||||
if (OrgDisabledForMoreThanGracePeriod(sponsoringOrganization) ||
|
||||
sponsoredPlan.SponsoringProductType != sponsoringOrgPlan.Product ||
|
||||
sponsoredPlan.SponsoringProductTierType != sponsoringOrgPlan.ProductTier ||
|
||||
existingSponsorship.ToDelete ||
|
||||
SponsorshipIsSelfHostedOutOfSync(existingSponsorship))
|
||||
{
|
||||
|
||||
@@ -30,10 +30,10 @@ public class CreateSponsorshipCommand : ICreateSponsorshipCommand
|
||||
throw new BadRequestException("Cannot offer a Families Organization Sponsorship to yourself. Choose a different email.");
|
||||
}
|
||||
|
||||
var requiredSponsoringProductType = StaticStore.GetSponsoredPlan(sponsorshipType)?.SponsoringProductType;
|
||||
var requiredSponsoringProductType = StaticStore.GetSponsoredPlan(sponsorshipType)?.SponsoringProductTierType;
|
||||
if (requiredSponsoringProductType == null ||
|
||||
sponsoringOrg == null ||
|
||||
StaticStore.GetPlan(sponsoringOrg.PlanType).Product != requiredSponsoringProductType.Value)
|
||||
StaticStore.GetPlan(sponsoringOrg.PlanType).ProductTier != requiredSponsoringProductType.Value)
|
||||
{
|
||||
throw new BadRequestException("Specified Organization cannot sponsor other organizations.");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
using Bit.Core.AdminConsole.Enums.Provider;
|
||||
using Bit.Core.AdminConsole.Repositories;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Business;
|
||||
using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface;
|
||||
@@ -34,7 +34,7 @@ public class AddSecretsManagerSubscriptionCommand : IAddSecretsManagerSubscripti
|
||||
var signup = SetOrganizationUpgrade(organization, additionalSmSeats, additionalServiceAccounts);
|
||||
_organizationService.ValidateSecretsManagerPlan(plan, signup);
|
||||
|
||||
if (plan.Product != ProductType.Free)
|
||||
if (plan.ProductTier != ProductTierType.Free)
|
||||
{
|
||||
await _paymentService.AddSecretsManagerToSubscription(organization, plan, additionalSmSeats, additionalServiceAccounts);
|
||||
}
|
||||
@@ -74,12 +74,12 @@ public class AddSecretsManagerSubscriptionCommand : IAddSecretsManagerSubscripti
|
||||
}
|
||||
|
||||
var plan = StaticStore.Plans.FirstOrDefault(p => p.Type == organization.PlanType && p.SupportsSecretsManager);
|
||||
if (string.IsNullOrWhiteSpace(organization.GatewayCustomerId) && plan.Product != ProductType.Free)
|
||||
if (string.IsNullOrWhiteSpace(organization.GatewayCustomerId) && plan.ProductTier != ProductTierType.Free)
|
||||
{
|
||||
throw new BadRequestException("No payment method found.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(organization.GatewaySubscriptionId) && plan.Product != ProductType.Free)
|
||||
if (string.IsNullOrWhiteSpace(organization.GatewaySubscriptionId) && plan.ProductTier != ProductTierType.Free)
|
||||
{
|
||||
throw new BadRequestException("No subscription found.");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Business;
|
||||
@@ -165,7 +166,7 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs
|
||||
throw new BadRequestException("Organization has no access to Secrets Manager.");
|
||||
}
|
||||
|
||||
if (update.Plan.Product == ProductType.Free)
|
||||
if (update.Plan.ProductTier == ProductTierType.Free)
|
||||
{
|
||||
// No need to check the organization is set up with Stripe
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs;
|
||||
using Bit.Core.AdminConsole.Repositories;
|
||||
using Bit.Core.Auth.Enums;
|
||||
using Bit.Core.Auth.Repositories;
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
@@ -279,7 +280,7 @@ public class UpgradeOrganizationPlanCommand : IUpgradeOrganizationPlanCommand
|
||||
|
||||
if (success)
|
||||
{
|
||||
var upgradePath = GetUpgradePath(existingPlan.Product, newPlan.Product);
|
||||
var upgradePath = GetUpgradePath(existingPlan.ProductTier, newPlan.ProductTier);
|
||||
await _referenceEventService.RaiseEventAsync(
|
||||
new ReferenceEvent(ReferenceEventType.UpgradePlan, organization, _currentContext)
|
||||
{
|
||||
@@ -342,25 +343,25 @@ public class UpgradeOrganizationPlanCommand : IUpgradeOrganizationPlanCommand
|
||||
return await _organizationRepository.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
private static string GetUpgradePath(ProductType oldProductType, ProductType newProductType)
|
||||
private static string GetUpgradePath(ProductTierType oldProductTierType, ProductTierType newProductTierType)
|
||||
{
|
||||
var oldDescription = _upgradePath.TryGetValue(oldProductType, out var description)
|
||||
var oldDescription = _upgradePath.TryGetValue(oldProductTierType, out var description)
|
||||
? description
|
||||
: $"{oldProductType:G}";
|
||||
: $"{oldProductTierType:G}";
|
||||
|
||||
var newDescription = _upgradePath.TryGetValue(newProductType, out description)
|
||||
var newDescription = _upgradePath.TryGetValue(newProductTierType, out description)
|
||||
? description
|
||||
: $"{newProductType:G}";
|
||||
: $"{newProductTierType:G}";
|
||||
|
||||
return $"{oldDescription} → {newDescription}";
|
||||
}
|
||||
|
||||
private static readonly Dictionary<ProductType, string> _upgradePath = new()
|
||||
private static readonly Dictionary<ProductTierType, string> _upgradePath = new()
|
||||
{
|
||||
[ProductType.Free] = "2-person org",
|
||||
[ProductType.Families] = "Families",
|
||||
[ProductType.TeamsStarter] = "Teams Starter",
|
||||
[ProductType.Teams] = "Teams",
|
||||
[ProductType.Enterprise] = "Enterprise"
|
||||
[ProductTierType.Free] = "2-person org",
|
||||
[ProductTierType.Families] = "Families",
|
||||
[ProductTierType.TeamsStarter] = "Teams Starter",
|
||||
[ProductTierType.Teams] = "Teams",
|
||||
[ProductTierType.Enterprise] = "Enterprise"
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user