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

Updated users module to use getActiveSubscriptions

no-issue

This offloads some stripe specific logic into the stripe module
This commit is contained in:
Fabien O'Carroll 2019-09-25 10:25:20 +07:00
parent 314fd6a540
commit ed4dfd8d54

View file

@ -11,23 +11,24 @@ module.exports = function ({
if (!member) {
return member;
}
if (!stripe) {
return Object.assign(member, {
plans: []
stripe: {
subscriptions: []
}
});
}
try {
const subscription = await stripe.getSubscription(member);
if (subscription.status !== 'active') {
return Object.assign(member, {
plans: []
});
}
const subscriptions = await stripe.getActiveSubscriptions(member);
return Object.assign(member, {
plans: [subscription.plan]
stripe: {
subscriptions
}
});
} catch (err) {
console.log(err);
return null;
}
}