mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[AC-2744] Add provider portal pricing for consolidated billing (#4210)
* Expanded Teams and Enterprise plan with provider seat data * Updated provider setup process with new plan information * Updated provider subscription retrieval and update with new plan information * Updated client invoice report with new plan information * Fixed tests * Fix broken test
This commit is contained in:
@ -26,7 +26,7 @@ public record ConsolidatedBillingSubscriptionResponse(
|
||||
.Select(providerPlan =>
|
||||
{
|
||||
var plan = StaticStore.GetPlan(providerPlan.PlanType);
|
||||
var cost = (providerPlan.SeatMinimum + providerPlan.PurchasedSeats) * plan.PasswordManager.SeatPrice;
|
||||
var cost = (providerPlan.SeatMinimum + providerPlan.PurchasedSeats) * plan.PasswordManager.ProviderPortalSeatPrice;
|
||||
var cadence = plan.IsAnnual ? _annualCadence : _monthlyCadence;
|
||||
return new ProviderPlanResponse(
|
||||
plan.Name,
|
||||
@ -36,7 +36,9 @@ public record ConsolidatedBillingSubscriptionResponse(
|
||||
cost,
|
||||
cadence);
|
||||
});
|
||||
|
||||
var gracePeriod = subscription.CollectionMethod == "charge_automatically" ? 14 : 30;
|
||||
|
||||
return new ConsolidatedBillingSubscriptionResponse(
|
||||
subscription.Status,
|
||||
subscription.CurrentPeriodEnd,
|
||||
|
@ -121,8 +121,10 @@ public class PlanResponseModel : ResponseModel
|
||||
{
|
||||
StripePlanId = plan.StripePlanId;
|
||||
StripeSeatPlanId = plan.StripeSeatPlanId;
|
||||
StripeProviderPortalSeatPlanId = plan.StripeProviderPortalSeatPlanId;
|
||||
BasePrice = plan.BasePrice;
|
||||
SeatPrice = plan.SeatPrice;
|
||||
ProviderPortalSeatPrice = plan.ProviderPortalSeatPrice;
|
||||
AllowSeatAutoscale = plan.AllowSeatAutoscale;
|
||||
HasAdditionalSeatsOption = plan.HasAdditionalSeatsOption;
|
||||
MaxAdditionalSeats = plan.MaxAdditionalSeats;
|
||||
@ -141,8 +143,10 @@ public class PlanResponseModel : ResponseModel
|
||||
// Seats
|
||||
public string StripePlanId { get; init; }
|
||||
public string StripeSeatPlanId { get; init; }
|
||||
public string StripeProviderPortalSeatPlanId { get; init; }
|
||||
public decimal BasePrice { get; init; }
|
||||
public decimal SeatPrice { get; init; }
|
||||
public decimal ProviderPortalSeatPrice { get; init; }
|
||||
public bool AllowSeatAutoscale { get; init; }
|
||||
public bool HasAdditionalSeatsOption { get; init; }
|
||||
public int? MaxAdditionalSeats { get; init; }
|
||||
|
@ -67,9 +67,9 @@ public class ProviderEventService(
|
||||
|
||||
var discountedPercentage = (100 - (invoice.Discount?.Coupon?.PercentOff ?? 0)) / 100;
|
||||
|
||||
var discountedEnterpriseSeatPrice = enterprisePlan.PasswordManager.SeatPrice * discountedPercentage;
|
||||
var discountedEnterpriseSeatPrice = enterprisePlan.PasswordManager.ProviderPortalSeatPrice * discountedPercentage;
|
||||
|
||||
var discountedTeamsSeatPrice = teamsPlan.PasswordManager.SeatPrice * discountedPercentage;
|
||||
var discountedTeamsSeatPrice = teamsPlan.PasswordManager.ProviderPortalSeatPrice * discountedPercentage;
|
||||
|
||||
var invoiceItems = clients.Select(client => new ProviderInvoiceItem
|
||||
{
|
||||
|
@ -63,8 +63,10 @@ public abstract record Plan
|
||||
// Seats
|
||||
public string StripePlanId { get; init; }
|
||||
public string StripeSeatPlanId { get; init; }
|
||||
public string StripeProviderPortalSeatPlanId { get; init; }
|
||||
public decimal BasePrice { get; init; }
|
||||
public decimal SeatPrice { get; init; }
|
||||
public decimal ProviderPortalSeatPrice { get; init; }
|
||||
public bool AllowSeatAutoscale { get; init; }
|
||||
public bool HasAdditionalSeatsOption { get; init; }
|
||||
public int? MaxAdditionalSeats { get; init; }
|
||||
|
@ -92,8 +92,10 @@ public record EnterprisePlan : Plan
|
||||
else
|
||||
{
|
||||
StripeSeatPlanId = "2023-enterprise-seat-monthly";
|
||||
StripeProviderPortalSeatPlanId = "password-manager-provider-portal-enterprise-monthly-2024";
|
||||
StripeStoragePlanId = "storage-gb-monthly";
|
||||
SeatPrice = 7;
|
||||
ProviderPortalSeatPrice = 6;
|
||||
AdditionalStoragePricePerGb = 0.5M;
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +86,10 @@ public record TeamsPlan : Plan
|
||||
else
|
||||
{
|
||||
StripeSeatPlanId = "2023-teams-org-seat-monthly";
|
||||
StripeProviderPortalSeatPlanId = "password-manager-provider-portal-teams-monthly-2024";
|
||||
StripeStoragePlanId = "storage-gb-monthly";
|
||||
SeatPrice = 5;
|
||||
ProviderPortalSeatPrice = 4;
|
||||
AdditionalStoragePricePerGb = 0.5M;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ public class ProviderSubscriptionUpdate : SubscriptionUpdate
|
||||
throw ContactSupport($"Cannot create a {nameof(ProviderSubscriptionUpdate)} for {nameof(PlanType)} that doesn't support consolidated billing");
|
||||
}
|
||||
|
||||
_planId = GetPasswordManagerPlanId(Utilities.StaticStore.GetPlan(planType));
|
||||
var plan = Utilities.StaticStore.GetPlan(planType);
|
||||
|
||||
_planId = plan.PasswordManager.StripeProviderPortalSeatPlanId;
|
||||
_previouslyPurchasedSeats = previouslyPurchasedSeats;
|
||||
_newlyPurchasedSeats = newlyPurchasedSeats;
|
||||
}
|
||||
|
Reference in New Issue
Block a user