diff --git a/core/server/api/canary/members.js b/core/server/api/canary/members.js index 48491cb95a..7cf0deea58 100644 --- a/core/server/api/canary/members.js +++ b/core/server/api/canary/members.js @@ -429,42 +429,6 @@ module.exports = { } }, - validateImport: { - permissions: { - method: 'add' - }, - headers: {}, - async query(frame) { - const importedMembers = frame.data.members; - - await Promise.map(importedMembers, (async (entry) => { - if (entry.stripe_customer_id) { - if (!membersService.config.isStripeConnected()) { - throw new errors.ValidationError({ - message: i18n.t('errors.api.members.stripeNotConnected.message', { - id: entry.stripe_customer_id - }), - context: i18n.t('errors.api.members.stripeNotConnected.context'), - help: i18n.t('errors.api.members.stripeNotConnected.help') - }); - } - - try { - await membersService.api.members.getStripeCustomer(entry.stripe_customer_id); - } catch (error) { - throw new errors.ValidationError({ - message: `Member not imported. ${error.message}`, - context: i18n.t('errors.api.members.stripeCustomerNotFound.context'), - help: i18n.t('errors.api.members.stripeCustomerNotFound.help') - }); - } - } - })); - - return null; - } - }, - importCSV: { statusCode: 201, permissions: { diff --git a/core/server/web/api/canary/admin/routes.js b/core/server/web/api/canary/admin/routes.js index 13e6a56a6a..4e60fed8fb 100644 --- a/core/server/web/api/canary/admin/routes.js +++ b/core/server/web/api/canary/admin/routes.js @@ -93,7 +93,6 @@ module.exports = function apiRoutes() { router.get('/members/stats', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.stats)); - router.post('/members/upload/validate', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.validateImport)); router.get('/members/upload', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.exportCSV)); router.post('/members/upload', shared.middlewares.labs.members, diff --git a/test/api-acceptance/admin/members_spec.js b/test/api-acceptance/admin/members_spec.js index acb85f7e28..0e7dc18ce0 100644 --- a/test/api-acceptance/admin/members_spec.js +++ b/test/api-acceptance/admin/members_spec.js @@ -261,49 +261,6 @@ describe('Members API', function () { .expect(404); }); - it('Can validate import data', async function () { - const member = { - name: 'test', - email: 'memberTestAdd@test.com' - }; - - const res = await request - .post(localUtils.API.getApiQuery(`members/upload/validate`)) - .send({members: [member]}) - .set('Origin', config.get('url')) - .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules.private) - .expect(200); - - should.not.exist(res.headers['x-cache-invalidate']); - const jsonResponse = res.body; - should.exist(jsonResponse); - should.not.exist(jsonResponse.members); - }); - - it('Fails to validate import data when stripe_customer_id is present but Stripe is not connected', async function () { - const member = { - name: 'test', - email: 'memberTestAdd@test.com', - stripe_customer_id: 'cus_XXXXX' - }; - - const res = await request - .post(localUtils.API.getApiQuery(`members/upload/validate`)) - .send({members: [member]}) - .set('Origin', config.get('url')) - .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules.private) - .expect(422); - - should.not.exist(res.headers['x-cache-invalidate']); - const jsonResponse = res.body; - should.exist(jsonResponse); - should.exist(jsonResponse.errors); - jsonResponse.errors[0].message.should.match(/Missing Stripe connection/i); - jsonResponse.errors[0].context.should.match(/no Stripe account connected/i); - }); - it('Can export CSV', async function () { const res = await request .get(localUtils.API.getApiQuery(`members/upload/`))