From cd89c7e42744d3a82dce3606ce6032c0834c33be Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Tue, 7 Sep 2021 18:25:53 +0200 Subject: [PATCH] Used @tryghost/members-api Stripe disconnect logic (#13290) refs https://github.com/TryGhost/Team/issues/1006 Moving the logic of disconnecting Stripe into the members-api module decouples the Ghost API from the Members API internals. This method can now be updated independently of Ghost, to implement the deletion of webhooks from Stripe. --- core/server/api/canary/settings.js | 15 +-------------- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/core/server/api/canary/settings.js b/core/server/api/canary/settings.js index 035eb674d8..4e46a882a8 100644 --- a/core/server/api/canary/settings.js +++ b/core/server/api/canary/settings.js @@ -9,7 +9,6 @@ const {BadRequestError, NoPermissionError, NotFoundError} = require('@tryghost/e const settingsService = require('../../services/settings'); const settingsCache = require('../../../shared/settings-cache'); const membersService = require('../../services/members'); -const ghostBookshelf = require('../../models/base'); module.exports = { docName: 'settings', @@ -192,19 +191,7 @@ module.exports = { }); } - /** Delete all Stripe data from DB */ - await ghostBookshelf.knex.raw(` - UPDATE products SET monthly_price_id = null, yearly_price_id = null - `); - await ghostBookshelf.knex.raw(` - DELETE FROM stripe_prices - `); - await ghostBookshelf.knex.raw(` - DELETE FROM stripe_products - `); - await ghostBookshelf.knex.raw(` - DELETE FROM members_stripe_customers - `); + await membersService.api.disconnectStripe(); return models.Settings.edit([{ key: 'stripe_connect_publishable_key', diff --git a/package.json b/package.json index 9993865f3d..90040870c6 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "@tryghost/limit-service": "0.6.1", "@tryghost/logging": "0.1.6", "@tryghost/magic-link": "1.0.11", - "@tryghost/members-api": "1.29.3", + "@tryghost/members-api": "1.31.0", "@tryghost/members-csv": "1.1.6", "@tryghost/members-importer": "0.3.1", "@tryghost/members-ssr": "1.0.12", diff --git a/yarn.lock b/yarn.lock index bc62276e44..e4a81009aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -921,10 +921,10 @@ jsonwebtoken "^8.5.1" lodash "^4.17.15" -"@tryghost/members-api@1.29.3": - version "1.29.3" - resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.29.3.tgz#793d447ddb4c60efd4099a876ee9036d97f6efd9" - integrity sha512-NwKuUyuXvF0E4Xo/EYLSLfom8lWv+PydfU62mBBZjiGgAsT94xhs2PqOCL+aHzIxSxrW9phx5KlXK6cvk1wD0A== +"@tryghost/members-api@1.31.0": + version "1.31.0" + resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.31.0.tgz#ea4d2053201b1ebc1d3b88fc9444c784d474ee4a" + integrity sha512-lxHLfGjCDIRJEh9dzpaqynKx+J+NiDobj1MrgaMVR2Bu6fo/c13HQUN2gocXOaCmWzuvg/BBmnyEyRCEmwj4cw== dependencies: "@tryghost/debug" "^0.1.2" "@tryghost/errors" "^0.2.9"