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:
parent
413c1cc4ce
commit
e17f5004cc
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue