From e9208888326007a37f91c931a83e16fa09fd4a96 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Wed, 14 Aug 2024 14:32:18 +0700 Subject: [PATCH] Wired up stripeEnabled to Koenig config (#20750) ref PLG-109 - Added a boolean config property `stripeEnabled` to the configuration. - This property is now passed down to the Koenig Editor to manage features based on Stripe connectivity. --- ghost/admin/app/components/koenig-lexical-editor.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/components/koenig-lexical-editor.js b/ghost/admin/app/components/koenig-lexical-editor.js index b63e16157f..704aac7e6d 100644 --- a/ghost/admin/app/components/koenig-lexical-editor.js +++ b/ghost/admin/app/components/koenig-lexical-editor.js @@ -441,6 +441,16 @@ export default class KoenigLexicalEditor extends Component { } }; + const checkStripeEnabled = () => { + const hasDirectKeys = !!(this.settings.stripeSecretKey && this.settings.stripePublishableKey); + const hasConnectKeys = !!(this.settings.stripeConnectSecretKey && this.settings.stripeConnectPublishableKey); + + if (this.config.stripeDirect) { + return hasDirectKeys; + } + return hasDirectKeys || hasConnectKeys; + }; + const defaultCardConfig = { unsplash: this.settings.unsplash ? unsplashConfig.defaultHeaders : null, tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null, @@ -461,7 +471,8 @@ export default class KoenigLexicalEditor extends Component { searchLinks, siteTitle: this.settings.title, siteDescription: this.settings.description, - siteUrl: this.config.getSiteUrl('/') + siteUrl: this.config.getSiteUrl('/'), + stripeEnabled: checkStripeEnabled() // returns a boolean }; const cardConfig = Object.assign({}, defaultCardConfig, props.cardConfig, {pinturaConfig: this.pinturaConfig});