diff --git a/services/web/app/src/Features/Subscription/PaymentProviderEntities.js b/services/web/app/src/Features/Subscription/PaymentProviderEntities.js index 298480a972..f6a8af4aa5 100644 --- a/services/web/app/src/Features/Subscription/PaymentProviderEntities.js +++ b/services/web/app/src/Features/Subscription/PaymentProviderEntities.js @@ -87,6 +87,15 @@ class PaymentProviderSubscription { return isStandaloneAiAddOnPlanCode(this.planCode) } + /** + * Returns whether this subscription is a group subscription + * + * @return {boolean} + */ + isGroupSubscription() { + return isGroupPlanCode(this.planCode) + } + /** * Returns whether this subcription will have the given add-on next billing * period. @@ -543,6 +552,15 @@ function isStandaloneAiAddOnPlanCode(planCode) { return STANDALONE_AI_ADD_ON_CODES.includes(planCode) } +/** + * Returns whether the given plan code is a group plan + * + * @param {string} planCode + */ +function isGroupPlanCode(planCode) { + return planCode.includes('group') +} + /** * Returns whether subscription change will have have the ai bundle once the change is processed * @@ -575,6 +593,7 @@ module.exports = { PaymentProviderPlan, PaymentProviderCoupon, PaymentProviderAccount, + isGroupPlanCode, isStandaloneAiAddOnPlanCode, subscriptionChangeIsAiAssistUpgrade, PaymentProviderImmediateCharge, diff --git a/services/web/app/src/Features/Subscription/PlansLocator.js b/services/web/app/src/Features/Subscription/PlansLocator.js index 937d2d3ccb..a418e23b78 100644 --- a/services/web/app/src/Features/Subscription/PlansLocator.js +++ b/services/web/app/src/Features/Subscription/PlansLocator.js @@ -34,6 +34,10 @@ const recurlyPlanCodeToStripeLookupKey = { 'student-annual': 'student_annual', student: 'student_monthly', student_free_trial_7_days: 'student_monthly', + group_professional: 'group_professional_enterprise', + group_professional_educational: 'group_professional_educational', + group_collaborator: 'group_standard_enterprise', + group_collaborator_educational: 'group_standard_educational', } /** @@ -46,24 +50,28 @@ function mapRecurlyPlanCodeToStripeLookupKey(recurlyPlanCode) { } const recurlyPlanCodeToPlanTypeAndPeriod = { - collaborator: { planType: 'standard', period: 'monthly' }, - collaborator_free_trial_7_days: { planType: 'standard', period: 'monthly' }, - 'collaborator-annual': { planType: 'standard', period: 'annual' }, - professional: { planType: 'professional', period: 'monthly' }, + collaborator: { planType: 'individual', period: 'monthly' }, + collaborator_free_trial_7_days: { planType: 'individual', period: 'monthly' }, + 'collaborator-annual': { planType: 'individual', period: 'annual' }, + professional: { planType: 'individual', period: 'monthly' }, professional_free_trial_7_days: { - planType: 'professional', + planType: 'individual', period: 'monthly', }, - 'professional-annual': { planType: 'professional', period: 'annual' }, + 'professional-annual': { planType: 'individual', period: 'annual' }, student: { planType: 'student', period: 'monthly' }, student_free_trial_7_days: { planType: 'student', period: 'monthly' }, 'student-annual': { planType: 'student', period: 'annual' }, + group_professional: { planType: 'group', period: 'annual' }, + group_professional_educational: { planType: 'group', period: 'annual' }, + group_collaborator: { planType: 'group', period: 'annual' }, + group_collaborator_educational: { planType: 'group', period: 'annual' }, } /** * * @param {RecurlyPlanCode} recurlyPlanCode - * @returns {{ planType: 'standard' | 'professional' | 'student', period: 'annual' | 'monthly'}} + * @returns {{ planType: 'individual' | 'group' | 'student', period: 'annual' | 'monthly'}} */ function getPlanTypeAndPeriodFromRecurlyPlanCode(recurlyPlanCode) { return recurlyPlanCodeToPlanTypeAndPeriod[recurlyPlanCode] diff --git a/services/web/test/unit/src/Subscription/PlansLocatorTests.js b/services/web/test/unit/src/Subscription/PlansLocatorTests.js index 9373c02b89..f705baa01c 100644 --- a/services/web/test/unit/src/Subscription/PlansLocatorTests.js +++ b/services/web/test/unit/src/Subscription/PlansLocatorTests.js @@ -120,7 +120,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'collaborator' ) - expect(planType).to.equal('standard') + expect(planType).to.equal('individual') expect(period).to.equal('monthly') }) @@ -129,7 +129,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'collaborator_free_trial_7_days' ) - expect(planType).to.equal('standard') + expect(planType).to.equal('individual') expect(period).to.equal('monthly') }) @@ -138,7 +138,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'collaborator-annual' ) - expect(planType).to.equal('standard') + expect(planType).to.equal('individual') expect(period).to.equal('annual') }) @@ -147,7 +147,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'professional' ) - expect(planType).to.equal('professional') + expect(planType).to.equal('individual') expect(period).to.equal('monthly') }) @@ -156,7 +156,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'professional_free_trial_7_days' ) - expect(planType).to.equal('professional') + expect(planType).to.equal('individual') expect(period).to.equal('monthly') }) @@ -165,7 +165,7 @@ describe('PlansLocator', function () { this.PlansLocator.getPlanTypeAndPeriodFromRecurlyPlanCode( 'professional-annual' ) - expect(planType).to.equal('professional') + expect(planType).to.equal('individual') expect(period).to.equal('annual') }) diff --git a/services/web/types/subscription/plan.ts b/services/web/types/subscription/plan.ts index a1b0f7b5d6..c5e8f7e820 100644 --- a/services/web/types/subscription/plan.ts +++ b/services/web/types/subscription/plan.ts @@ -81,11 +81,19 @@ export type RecurlyPlanCode = | 'student' | 'student-annual' | 'student_free_trial_7_days' + | 'group_professional' + | 'group_professional_educational' + | 'group_collaborator' + | 'group_collaborator_educational' export type StripeLookupKey = - | 'collaborator_monthly' - | 'collaborator_annual' + | 'standard_monthly' + | 'standard_annual' | 'professional_monthly' | 'professional_annual' | 'student_monthly' | 'student_annual' + | 'group_standard_enterprise' + | 'group_professional_enterprise' + | 'group_standard_educational' + | 'group_professional_educational'