Skip to content

Commit

Permalink
[PM-13451] Update subscription setup process to support MOE providers (
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashendrickx authored Oct 25, 2024
1 parent 6272e84 commit 53ad9df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,42 +379,23 @@ public async Task<Subscription> SetupSubscription(

var subscriptionItemOptionsList = new List<SubscriptionItemOptions>();

var teamsProviderPlan =
providerPlans.SingleOrDefault(providerPlan => providerPlan.PlanType == PlanType.TeamsMonthly);

if (teamsProviderPlan == null || !teamsProviderPlan.IsConfigured())
foreach (var providerPlan in providerPlans)
{
logger.LogError("Cannot start subscription for provider ({ProviderID}) that has no configured Teams plan", provider.Id);

throw new BillingException();
}

var teamsPlan = StaticStore.GetPlan(PlanType.TeamsMonthly);

subscriptionItemOptionsList.Add(new SubscriptionItemOptions
{
Price = teamsPlan.PasswordManager.StripeProviderPortalSeatPlanId,
Quantity = teamsProviderPlan.SeatMinimum
});

var enterpriseProviderPlan =
providerPlans.SingleOrDefault(providerPlan => providerPlan.PlanType == PlanType.EnterpriseMonthly);
var plan = StaticStore.GetPlan(providerPlan.PlanType);

if (enterpriseProviderPlan == null || !enterpriseProviderPlan.IsConfigured())
{
logger.LogError("Cannot start subscription for provider ({ProviderID}) that has no configured Enterprise plan", provider.Id);
if (!providerPlan.IsConfigured())
{
logger.LogError("Cannot start subscription for provider ({ProviderID}) that has no configured {ProviderName} plan", provider.Id, plan.Name);
throw new BillingException();
}

throw new BillingException();
subscriptionItemOptionsList.Add(new SubscriptionItemOptions
{
Price = plan.PasswordManager.StripeProviderPortalSeatPlanId,
Quantity = providerPlan.SeatMinimum
});
}

var enterprisePlan = StaticStore.GetPlan(PlanType.EnterpriseMonthly);

subscriptionItemOptionsList.Add(new SubscriptionItemOptions
{
Price = enterprisePlan.PasswordManager.StripeProviderPortalSeatPlanId,
Quantity = enterpriseProviderPlan.SeatMinimum
});

var subscriptionCreateOptions = new SubscriptionCreateOptions
{
AutomaticTax = new SubscriptionAutomaticTaxOptions
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Billing/Models/StaticStore/Plans/EnterprisePlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public EnterprisePasswordManagerFeatures(bool isAnnual)
AdditionalStoragePricePerGb = 4;
StripeStoragePlanId = "storage-gb-annually";
StripeSeatPlanId = "2023-enterprise-org-seat-annually";
StripeProviderPortalSeatPlanId = "password-manager-provider-portal-enterprise-annually-2024";
SeatPrice = 72;
ProviderPortalSeatPrice = 72;
}
else
{
Expand Down

0 comments on commit 53ad9df

Please sign in to comment.