From 82cf09560052fe0be7e26f07b96a2025e45e3e9e Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 10 Jun 2020 21:14:45 +0530 Subject: [PATCH] Added stripe config check to members site data refs https://github.com/TryGhost/members.js/issues/43 - Adds new `isStripeConfigured` flag to public members site data which denotes if stripe setup is completed - Helps clients like members.js/themes to configure payment behavior based on this flag --- core/server/services/members/middleware.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/server/services/members/middleware.js b/core/server/services/members/middleware.js index 1f40022070..04dd945db5 100644 --- a/core/server/services/members/middleware.js +++ b/core/server/services/members/middleware.js @@ -84,6 +84,12 @@ const updateMemberData = async function (req, res) { }; const getMemberSiteData = async function (req, res) { + const stripePaymentProcessor = settingsCache.get('members_subscription_settings').paymentProcessors.find( + paymentProcessor => paymentProcessor.adapter === 'stripe' + ); + const stripeSecretToken = stripePaymentProcessor && stripePaymentProcessor.config.secret_token; + const stripePublicToken = stripePaymentProcessor && stripePaymentProcessor.config.public_token; + const isStripeConfigured = (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== ''); const response = { title: settingsCache.get('title'), description: settingsCache.get('description'), @@ -92,7 +98,8 @@ const getMemberSiteData = async function (req, res) { url: urlUtils.urlFor('home', true), version: ghostVersion.safe, plans: membersService.config.getPublicPlans(), - allowSelfSignup: membersService.config.getAllowSelfSignup() + allowSelfSignup: membersService.config.getAllowSelfSignup(), + isStripeConfigured }; // Brand is currently an experimental feature