From 0030acf5a6fedb759bd4f9033b13ba40b9010d8c Mon Sep 17 00:00:00 2001 From: Sven Ewers Date: Fri, 17 Jan 2020 05:57:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Optimized=20loading=20stripe=20s?= =?UTF-8?q?cripts=20only=20when=20it=20is=20needed=20(#11499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #11463 - Ghost used to always load stripe.js into the frontend of all pages when memberships are enabled, even when Stripe isn't configured / memberships to a page are free. This changes Ghost's behaviour to only load stripe.js when both stripe API tokens are present & not empty (the quickest way to verify that Stripe is fully configured & operational on a blog). - Needs a follow-up cleanup removing confusing/not functional `isPaymentConfigured` method from members service --- core/frontend/helpers/ghost_head.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/frontend/helpers/ghost_head.js b/core/frontend/helpers/ghost_head.js index c0f932fc94..d27aa3dc7c 100644 --- a/core/frontend/helpers/ghost_head.js +++ b/core/frontend/helpers/ghost_head.js @@ -44,10 +44,17 @@ function finaliseStructuredData(metaData) { } function getMembersHelper() { - return ` - - - `; + const stripePaymentProcessor = settingsCache.get('members_subscription_settings').paymentProcessors.find( + paymentProcessor => paymentProcessor.adapter === 'stripe' + ); + const stripeSecretToken = stripePaymentProcessor.config.secret_token; + const stripePublicToken = stripePaymentProcessor.config.public_token; + + var membersHelper = ``; + if (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== '') { + membersHelper += ''; + } + return membersHelper; } /**