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

Updated MembersAPI to take StripeAPIService as dep (#338)

refs https://github.com/TryGhost/Team/issues/1083

The Offers service is going to need access to the StripeAPIService too,
so we must pull its initialisation out of this module up to the Ghost
application layer, which will allow us to pass a reference of the
StripeAPIService to wherever needs it.
This commit is contained in:
Fabien 'egg' O'Carroll 2021-10-04 13:34:17 +02:00 committed by GitHub
parent 9341c318d3
commit c5784da2b6

View file

@ -3,7 +3,6 @@ const body = require('body-parser');
const MagicLink = require('@tryghost/magic-link');
const common = require('./common');
const StripeAPIService = require('@tryghost/members-stripe-service');
const MemberAnalyticsService = require('@tryghost/member-analytics-service');
const MembersAnalyticsIngress = require('@tryghost/members-analytics-ingress');
@ -55,6 +54,7 @@ module.exports = function MembersAPI({
Product,
Settings
},
stripeAPIService,
logger,
labsService
}) {
@ -70,16 +70,6 @@ module.exports = function MembersAPI({
const stripeConfig = paymentConfig && paymentConfig.stripe || {};
const stripeAPIService = new StripeAPIService({
config: {
secretKey: stripeConfig.secretKey,
publicKey: stripeConfig.publicKey,
appInfo: stripeConfig.appInfo,
enablePromoCodes: stripeConfig.enablePromoCodes
},
logger
});
const memberAnalyticsService = MemberAnalyticsService.create(MemberAnalyticEvent);
memberAnalyticsService.eventHandler.setupSubscribers();
@ -198,7 +188,7 @@ module.exports = function MembersAPI({
await StripeCustomer.forge().query().del();
}
const ready = paymentConfig.stripe ? Promise.all([
const ready = stripeAPIService.configured ? Promise.all([
stripeMigrations.populateProductsAndPrices().then(() => {
return stripeMigrations.populateStripePricesFromStripePlansSetting(stripeConfig.plans);
}).then(() => {