0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

🐛 Fixed unable to create new prices on switching Stripe account (#13013)

closes https://github.com/TryGhost/Team/issues/724
closes https://github.com/TryGhost/Team/issues/739

Currently, site owners are allowed to disconnect Stripe if they don't have any active subscriptions for a member. On disconnect, all stripe related data for the old account in DB should be cleared as using Stripe id for old account can cause weird failures due to incorrect Stripe key being used. This was also causing site owners to not be able to create new prices after connecting to new account as it ended up using old stripe product id which failed on Stripe request.
This commit is contained in:
Rishabh Garg 2021-06-08 21:28:16 +05:30 committed by GitHub
parent 413c1cc4ce
commit e17f5004cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ const {BadRequestError, NoPermissionError, NotFoundError} = require('@tryghost/e
const settingsService = require('../../services/settings');
const settingsCache = require('../../services/settings/cache');
const membersService = require('../../services/members');
const ghostBookshelf = require('../../models/base');
module.exports = {
docName: 'settings',
@ -191,6 +192,17 @@ module.exports = {
});
}
/** Delete all Stripe data from DB */
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
`);
return models.Settings.edit([{
key: 'stripe_connect_publishable_key',
value: null