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:
parent
314fd6a540
commit
ed4dfd8d54
1 changed files with 9 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue