Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/fxa-auth-client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 0 additions & 7 deletions packages/fxa-auth-server/docs/swagger/subscriptions-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 = [
Expand All @@ -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
*/
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -1241,7 +1175,7 @@ describe('DirectStripeRoutes', () => {
);
jest
.spyOn(directStripeRoutesInstance, 'customerChanged')
.mockResolvedValue();
.mockResolvedValue(undefined);
paymentMethod = deepCopy(paymentMethodFixture);
directStripeRoutesInstance.stripeHelper.getPaymentMethod.mockResolvedValue(
paymentMethod
Expand Down Expand Up @@ -1854,7 +1788,7 @@ describe('DirectStripeRoutes', () => {
);
jest
.spyOn(directStripeRoutesInstance, 'customerChanged')
.mockResolvedValue();
.mockResolvedValue(undefined);
VALID_REQUEST.payload = {
invoiceId: 'in_testinvoice',
paymentMethodId: 'pm_asdf',
Expand Down Expand Up @@ -2307,7 +2241,7 @@ describe('DirectStripeRoutes', () => {

jest
.spyOn(directStripeRoutesInstance, 'customerChanged')
.mockResolvedValue();
.mockResolvedValue(undefined);

const actual =
await directStripeRoutesInstance.updateSubscription(VALID_REQUEST);
Expand Down Expand Up @@ -2338,7 +2272,7 @@ describe('DirectStripeRoutes', () => {

jest
.spyOn(directStripeRoutesInstance, 'customerChanged')
.mockResolvedValue();
.mockResolvedValue(undefined);

await directStripeRoutesInstance.updateSubscription(VALID_REQUEST);

Expand Down Expand Up @@ -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', () => {
Expand Down
24 changes: 0 additions & 24 deletions packages/fxa-auth-server/lib/routes/subscriptions/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;
Expand Down Expand Up @@ -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',
Expand Down
8 changes: 0 additions & 8 deletions packages/fxa-auth-server/test/client/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 0 additions & 3 deletions packages/fxa-auth-server/test/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion packages/fxa-auth-server/test/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ const PUSHBOX_METHOD_NAMES = [
];

const SUBHUB_METHOD_NAMES = [
'listPlans',
'updateCustomer',
'deleteCustomer',
'listSubscriptions',
Expand Down
9 changes: 0 additions & 9 deletions packages/fxa-content-server/app/scripts/lib/fxa-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
9 changes: 0 additions & 9 deletions packages/fxa-content-server/app/scripts/models/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 0 additions & 11 deletions packages/fxa-content-server/app/tests/spec/models/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading