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

Refactored ghost_head to use isStripeConnected

no-issue

This is to make sure that whether stripeDirect is enabled or not, that
the stripe script is correctly added to ghost_head.
This commit is contained in:
Fabien O'Carroll 2020-06-09 13:14:46 +02:00 committed by Fabien 'egg' O'Carroll
parent 299c9aaddb
commit 0d11c66c26
2 changed files with 5 additions and 8 deletions

View file

@ -2,7 +2,7 @@
// Usage: `{{ghost_head}}`
//
// Outputs scripts and other assets at the top of a Ghost theme
const {metaData, escapeExpression, SafeString, logging, settingsCache, config, blogIcon, labs} = require('../services/proxy');
const {metaData, escapeExpression, SafeString, logging, settingsCache, members, config, blogIcon, labs} = require('../services/proxy');
const _ = require('lodash');
const debug = require('ghost-ignition').debug('ghost_head');
@ -37,17 +37,11 @@ function finaliseStructuredData(metaData) {
}
function getMembersHelper() {
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;
let membersHelper = `<script defer src="${getAssetUrl('public/members.js', true)}"></script>`;
if (config.get('enableDeveloperExperiments')) {
membersHelper = `<script defer src="https://unpkg.com/@tryghost/members-js@latest/umd/members.min.js"></script>`;
}
if (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== '') {
if (members.config.isStripeConnected()) {
membersHelper += '<script src="https://js.stripe.com/v3/"></script>';
}
return membersHelper;

View file

@ -27,6 +27,9 @@ module.exports = {
// TODO: Only expose "get"
settingsCache: settingsCache,
// TODO: Rethink how we get config in
members: require('../../server/services/members'),
// These 3 are kind of core and required all the time
errors,
i18n,