mirror of
https://github.com/bitwarden/server.git
synced 2025-03-12 13:29:14 +01:00
Derive item add on status from price metadata (#5389)
This commit is contained in:
parent
c82908f40b
commit
cb1c12794f
@ -73,8 +73,11 @@ public class SubscriptionInfo
|
|||||||
Name = item.Plan.Nickname;
|
Name = item.Plan.Nickname;
|
||||||
Amount = item.Plan.Amount.GetValueOrDefault() / 100M;
|
Amount = item.Plan.Amount.GetValueOrDefault() / 100M;
|
||||||
Interval = item.Plan.Interval;
|
Interval = item.Plan.Interval;
|
||||||
AddonSubscriptionItem =
|
|
||||||
Utilities.StaticStore.IsAddonSubscriptionItem(item.Plan.Id);
|
if (item.Metadata != null)
|
||||||
|
{
|
||||||
|
AddonSubscriptionItem = item.Metadata.TryGetValue("isAddOn", out var value) && bool.Parse(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Quantity = (int)item.Quantity;
|
Quantity = (int)item.Quantity;
|
||||||
|
@ -158,21 +158,4 @@ public static class StaticStore
|
|||||||
|
|
||||||
public static SponsoredPlan GetSponsoredPlan(PlanSponsorshipType planSponsorshipType) =>
|
public static SponsoredPlan GetSponsoredPlan(PlanSponsorshipType planSponsorshipType) =>
|
||||||
SponsoredPlans.FirstOrDefault(p => p.PlanSponsorshipType == planSponsorshipType);
|
SponsoredPlans.FirstOrDefault(p => p.PlanSponsorshipType == planSponsorshipType);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines if the stripe plan id is an addon item by checking if the provided stripe plan id
|
|
||||||
/// matches either the <see cref="Plan.PasswordManagerPlanFeatures.StripeStoragePlanId"/> or <see cref="Plan.SecretsManagerPlanFeatures.StripeServiceAccountPlanId"/>
|
|
||||||
/// in any <see cref="Plans"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="stripePlanId"></param>
|
|
||||||
/// <returns>
|
|
||||||
/// True if the stripePlanId is a addon product, false otherwise
|
|
||||||
/// </returns>
|
|
||||||
public static bool IsAddonSubscriptionItem(string stripePlanId)
|
|
||||||
{
|
|
||||||
// TODO: PRICING -> https://bitwarden.atlassian.net/browse/PM-16844
|
|
||||||
return Plans.Any(p =>
|
|
||||||
p.PasswordManager.StripeStoragePlanId == stripePlanId ||
|
|
||||||
(p.SecretsManager?.StripeServiceAccountPlanId == stripePlanId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user