From 2d2202a812789dec30632b7ce2fff232909097d3 Mon Sep 17 00:00:00 2001 From: Lisa Chan Date: Fri, 1 May 2026 16:33:49 -0400 Subject: [PATCH] chore(auth-client,auth,content): Remove /subscriptions/plans --- packages/fxa-auth-client/lib/client.ts | 4 - .../docs/swagger/subscriptions-api.ts | 7 -- .../lib/routes/subscriptions/stripe.spec.ts | 89 ++----------------- .../lib/routes/subscriptions/stripe.ts | 24 ----- packages/fxa-auth-server/test/client/api.js | 8 -- packages/fxa-auth-server/test/client/index.js | 3 - packages/fxa-auth-server/test/mocks.js | 1 - .../app/scripts/lib/fxa-client.js | 9 -- .../app/scripts/models/account.js | 9 -- .../finish_account_setup/set_password.js | 14 +-- .../app/tests/spec/models/account.js | 11 --- .../finish_account_setup/set_password.js | 3 - 12 files changed, 8 insertions(+), 174 deletions(-) diff --git a/packages/fxa-auth-client/lib/client.ts b/packages/fxa-auth-client/lib/client.ts index 8efb03b7962..6d34620d849 100644 --- a/packages/fxa-auth-client/lib/client.ts +++ b/packages/fxa-auth-client/lib/client.ts @@ -3069,10 +3069,6 @@ export default class AuthClient { ); } - async getSubscriptionPlans(headers?: Headers) { - return this.request('GET', '/oauth/subscriptions/plans', null, headers); - } - async getActiveSubscriptions(accessToken: string) { return this.request( 'GET', diff --git a/packages/fxa-auth-server/docs/swagger/subscriptions-api.ts b/packages/fxa-auth-server/docs/swagger/subscriptions-api.ts index ac2ca0313b6..7d7e14854aa 100644 --- a/packages/fxa-auth-server/docs/swagger/subscriptions-api.ts +++ b/packages/fxa-auth-server/docs/swagger/subscriptions-api.ts @@ -51,12 +51,6 @@ const OAUTH_SUBSCRIPTIONS_IAP_APP_STORE_NOTIFICATION_POST = { ], }; -const OAUTH_SUBSCRIPTIONS_PLANS_GET = { - ...TAGS_SUBSCRIPTIONS, - description: '/oauth/subscriptions/plans', - notes: ['Returns a list of available subscription plans.'], -}; - const OAUTH_SUBSCRIPTIONS_ACTIVE_GET = { ...TAGS_SUBSCRIPTIONS, description: '/oauth/subscriptions/active', @@ -327,7 +321,6 @@ const API_DOCS = { OAUTH_SUBSCRIPTIONS_INVOICE_RETRY_POST, OAUTH_SUBSCRIPTIONS_PAYMENTMETHOD_DEFAULT_POST, OAUTH_SUBSCRIPTIONS_PAYPAL_CHECKOUT_POST, - OAUTH_SUBSCRIPTIONS_PLANS_GET, OAUTH_SUBSCRIPTIONS_SETUPINTENT_CREATE_POST, OAUTH_MOZILLA_SUBSCRIPTIONS_CUSTOMER_BILLING_AND_SUBSCRIPTIONS_GET, OAUTH_MOZILLA_SUBSCRIPTIONS_CUSTOMER_PLAN_ELIGIBILITY, diff --git a/packages/fxa-auth-server/lib/routes/subscriptions/stripe.spec.ts b/packages/fxa-auth-server/lib/routes/subscriptions/stripe.spec.ts index 18f7a6e9731..6669e1eadbe 100644 --- a/packages/fxa-auth-server/lib/routes/subscriptions/stripe.spec.ts +++ b/packages/fxa-auth-server/lib/routes/subscriptions/stripe.spec.ts @@ -19,7 +19,7 @@ const { } = require('@fxa/payments/customer'); const uuidv4 = require('uuid').v4; -const { sanitizePlans, handleAuth } = require('.'); +const { handleAuth } = require('.'); // Import the real buildTaxAddress for direct tests (not through the mock) const { buildTaxAddress: realBuildTaxAddress } = jest.requireActual('./utils'); @@ -91,7 +91,6 @@ const ACCOUNT_LOCALE = 'en-US'; const TEST_EMAIL = 'test@email.com'; const UID = uuid.v4({}, Buffer.alloc(16)).toString('hex'); const NOW = Date.now(); -const PLAN_ID_1 = 'plan_G93lTs8hfK7NNG'; const PLANS = mocks.mockPlans; const SUBSCRIPTION_ID_1 = 'sub-8675309'; const ACTIVE_SUBSCRIPTIONS = [ @@ -118,48 +117,6 @@ function deepCopy(object: any) { return JSON.parse(JSON.stringify(object)); } -describe('sanitizePlans', () => { - it('removes capabilities from product & plan metadata', () => { - const expected = [ - { - plan_id: 'firefox_pro_basic_823', - product_id: 'firefox_pro_basic', - product_name: 'Firefox Pro Basic', - interval: 'week', - amount: '123', - currency: 'usd', - plan_metadata: {}, - product_metadata: { - emailIconURL: 'http://example.com/image.jpg', - successActionButtonURL: 'http://getfirefox.com', - }, - }, - { - plan_id: 'firefox_pro_basic_999', - product_id: 'firefox_pro_pro', - product_name: 'Firefox Pro Pro', - interval: 'month', - amount: '456', - currency: 'usd', - plan_metadata: {}, - product_metadata: {}, - }, - { - plan_id: PLAN_ID_1, - product_id: 'prod_G93l8Yn7XJHYUs', - product_name: 'FN Tier 1', - interval: 'month', - amount: 499, - current: 'usd', - plan_metadata: {}, - product_metadata: {}, - }, - ]; - - expect(sanitizePlans(PLANS)).toEqual(expected); - }); -}); - /** * Stripe integration tests */ @@ -248,29 +205,6 @@ describe('subscriptions stripeRoutes', () => { }, }; - describe('Plans', () => { - it('should list available subscription plans', async () => { - const stripeHelper = mocks.mockStripeHelper(['allAbbrevPlans']); - - stripeHelper.allAbbrevPlans = jest.fn(async () => { - return PLANS; - }); - - const directStripeRoutes = new DirectStripeRoutes( - log, - db, - config, - customs, - push, - mailer, - profile, - stripeHelper - ); - - const res = await directStripeRoutes.listPlans(VALID_REQUEST); - expect(res).toEqual(sanitizePlans(PLANS)); - }); - }); describe('listActive', () => { it('should list active subscriptions', async () => { @@ -1241,7 +1175,7 @@ describe('DirectStripeRoutes', () => { ); jest .spyOn(directStripeRoutesInstance, 'customerChanged') - .mockResolvedValue(); + .mockResolvedValue(undefined); paymentMethod = deepCopy(paymentMethodFixture); directStripeRoutesInstance.stripeHelper.getPaymentMethod.mockResolvedValue( paymentMethod @@ -1854,7 +1788,7 @@ describe('DirectStripeRoutes', () => { ); jest .spyOn(directStripeRoutesInstance, 'customerChanged') - .mockResolvedValue(); + .mockResolvedValue(undefined); VALID_REQUEST.payload = { invoiceId: 'in_testinvoice', paymentMethodId: 'pm_asdf', @@ -2307,7 +2241,7 @@ describe('DirectStripeRoutes', () => { jest .spyOn(directStripeRoutesInstance, 'customerChanged') - .mockResolvedValue(); + .mockResolvedValue(undefined); const actual = await directStripeRoutesInstance.updateSubscription(VALID_REQUEST); @@ -2338,7 +2272,7 @@ describe('DirectStripeRoutes', () => { jest .spyOn(directStripeRoutesInstance, 'customerChanged') - .mockResolvedValue(); + .mockResolvedValue(undefined); await directStripeRoutesInstance.updateSubscription(VALID_REQUEST); @@ -2453,19 +2387,6 @@ describe('DirectStripeRoutes', () => { }); }); - describe('listPlans', () => { - it('returns the available plans without auth headers present', async () => { - const expected = sanitizePlans(PLANS); - const request = {}; - - directStripeRoutesInstance.stripeHelper.allAbbrevPlans.mockResolvedValue( - PLANS - ); - const actual = await directStripeRoutesInstance.listPlans(request); - - expect(actual).toEqual(expected); - }); - }); describe('listActive', () => { describe('customer is found', () => { diff --git a/packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts b/packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts index 8b402b217f8..a7fed091f32 100644 --- a/packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts +++ b/packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts @@ -342,14 +342,6 @@ export class StripeHandler { return { subscriptionId }; } - async listPlans(request: AuthRequest) { - this.log.begin('subscriptions.listPlans', request); - const plans = await this.stripeHelper.allAbbrevPlans( - request?.headers?.['accept-language'] - ); - return sanitizePlans(plans); - } - async getProductName(request: AuthRequest) { this.log.begin('subscriptions.getProductName', request); const { productId } = request.query as Record; @@ -1046,22 +1038,6 @@ export const stripeRoutes = ( }, handler: (request: AuthRequest) => stripeHandler.getClients(request), }, - { - method: 'GET', - path: '/oauth/subscriptions/plans', - options: { - ...SUBSCRIPTIONS_DOCS.OAUTH_SUBSCRIPTIONS_PLANS_GET, - response: { - schema: isA - .array() - .items( - validators.subscriptionsPlanWithProductConfigValidator, - validators.subscriptionsPlanWithMetaDataValidator - ) as any, - }, - }, - handler: (request: AuthRequest) => stripeHandler.listPlans(request), - }, { method: 'GET', path: '/oauth/subscriptions/active', diff --git a/packages/fxa-auth-server/test/client/api.js b/packages/fxa-auth-server/test/client/api.js index 3508c94ee55..5aa14378486 100644 --- a/packages/fxa-auth-server/test/client/api.js +++ b/packages/fxa-auth-server/test/client/api.js @@ -1479,14 +1479,6 @@ module.exports = (config) => { ); }; - ClientApi.prototype.getSubscriptionPlans = function (refreshToken) { - return this.doRequestWithBearerToken( - 'GET', - `${this.baseURL}/oauth/subscriptions/plans`, - refreshToken - ); - }; - ClientApi.prototype.getActiveSubscriptions = function (refreshToken) { return this.doRequestWithBearerToken( 'GET', diff --git a/packages/fxa-auth-server/test/client/index.js b/packages/fxa-auth-server/test/client/index.js index 8804b74d9c2..7ed3685a9a4 100644 --- a/packages/fxa-auth-server/test/client/index.js +++ b/packages/fxa-auth-server/test/client/index.js @@ -1209,9 +1209,6 @@ module.exports = (config) => { return this.api.getSubscriptionClients(secret); }; - Client.prototype.getSubscriptionPlans = function (refreshToken) { - return this.api.getSubscriptionPlans(refreshToken); - }; Client.prototype.getActiveSubscriptions = function (refreshToken) { return this.api.getActiveSubscriptions(refreshToken); diff --git a/packages/fxa-auth-server/test/mocks.js b/packages/fxa-auth-server/test/mocks.js index bca6e9bf994..8fb5a0a1d31 100644 --- a/packages/fxa-auth-server/test/mocks.js +++ b/packages/fxa-auth-server/test/mocks.js @@ -232,7 +232,6 @@ const PUSHBOX_METHOD_NAMES = [ ]; const SUBHUB_METHOD_NAMES = [ - 'listPlans', 'updateCustomer', 'deleteCustomer', 'listSubscriptions', diff --git a/packages/fxa-content-server/app/scripts/lib/fxa-client.js b/packages/fxa-content-server/app/scripts/lib/fxa-client.js index cfe9aba52b4..e4b2fa2e8b1 100644 --- a/packages/fxa-content-server/app/scripts/lib/fxa-client.js +++ b/packages/fxa-content-server/app/scripts/lib/fxa-client.js @@ -1314,15 +1314,6 @@ FxaClientWrapper.prototype = { */ getOAuthScopedKeyData: createClientDelegate('getOAuthScopedKeyData'), - /** - * Get a list of subscription plans with an OAuth access token. - * - * @param {String} token An access token from the OAuth server. - * @returns {Promise} A promise that will be fulfilled with a list of - * subscription plans from SubHub. - */ - getSubscriptionPlans: createClientDelegate('getSubscriptionPlans'), - /** * Get a list of active subscriptions with an OAuth access token. * diff --git a/packages/fxa-content-server/app/scripts/models/account.js b/packages/fxa-content-server/app/scripts/models/account.js index 507b8d3a682..3fd82e24570 100644 --- a/packages/fxa-content-server/app/scripts/models/account.js +++ b/packages/fxa-content-server/app/scripts/models/account.js @@ -1132,15 +1132,6 @@ const Account = Backbone.Model.extend( return this._fxaClient.attachedClients(this.get('sessionToken')); }, - /** - * Fetch the list of subscription plans on SubHub. - * - * @returns {Promise} - resolves with a list of subscription plans. - */ - fetchSubscriptionPlans() { - return this._fxaClient.getSubscriptionPlans(); - }, - /** * Check to see if the account has any subscriptions. * diff --git a/packages/fxa-content-server/app/scripts/views/post_verify/finish_account_setup/set_password.js b/packages/fxa-content-server/app/scripts/views/post_verify/finish_account_setup/set_password.js index fe7f1dbad38..40dd9470d24 100644 --- a/packages/fxa-content-server/app/scripts/views/post_verify/finish_account_setup/set_password.js +++ b/packages/fxa-content-server/app/scripts/views/post_verify/finish_account_setup/set_password.js @@ -62,17 +62,9 @@ class SetPassword extends FormView { } redirectToProduct(account) { - return account.fetchSubscriptionPlans().then((plans) => { - const productId = this._verificationInfo.get('product_id'); - const plan = plans.find((p) => p.product_id === productId); - const url = new URL( - plan && plan.product_metadata - ? plan.product_metadata.successActionButtonURL - : 'https://mozilla.org' - ); - url.searchParams.set('email', account.get('email')); - return this.navigateAway(url.href); - }); + const url = new URL('https://mozilla.org'); + url.searchParams.set('email', account.get('email')); + return this.navigateAway(url.href); } beforeRender() { diff --git a/packages/fxa-content-server/app/tests/spec/models/account.js b/packages/fxa-content-server/app/tests/spec/models/account.js index 4718afb04f0..817f6e3f751 100644 --- a/packages/fxa-content-server/app/tests/spec/models/account.js +++ b/packages/fxa-content-server/app/tests/spec/models/account.js @@ -2902,17 +2902,6 @@ describe('models/account', function () { }); }); - describe('fetchSubscriptionPlans', () => { - it('delegates to the fxa-client', () => { - const plans = [{ product_id: 'foo', plan: 'bar' }]; - sinon.stub(fxaClient, 'getSubscriptionPlans').resolves(plans); - - return account.fetchSubscriptionPlans().then((resp) => { - assert.deepEqual(resp, plans); - }); - }); - }); - describe('fetchActiveSubscriptions', () => { it('delegates to the fxa-client', () => { const token = 'tickettoride'; diff --git a/packages/fxa-content-server/app/tests/spec/views/post_verify/finish_account_setup/set_password.js b/packages/fxa-content-server/app/tests/spec/views/post_verify/finish_account_setup/set_password.js index 8703e25da8e..335d4181a6f 100644 --- a/packages/fxa-content-server/app/tests/spec/views/post_verify/finish_account_setup/set_password.js +++ b/packages/fxa-content-server/app/tests/spec/views/post_verify/finish_account_setup/set_password.js @@ -133,9 +133,6 @@ describe('views/post_verify/finish_account_setup/set_password', () => { describe('success', () => { beforeEach(() => { sinon.stub(user, 'finishSetup').callsFake(() => Promise.resolve(true)); - sinon - .stub(account, 'fetchSubscriptionPlans') - .callsFake(() => Promise.resolve([{}])); sinon.spy(view, 'navigateAway'); view.$('#password').val('password'); view.$('#vpassword').val('password');