mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36: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) {
|
if (!member) {
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stripe) {
|
if (!stripe) {
|
||||||
return Object.assign(member, {
|
return Object.assign(member, {
|
||||||
plans: []
|
stripe: {
|
||||||
|
subscriptions: []
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const subscription = await stripe.getSubscription(member);
|
const subscriptions = await stripe.getActiveSubscriptions(member);
|
||||||
if (subscription.status !== 'active') {
|
|
||||||
return Object.assign(member, {
|
|
||||||
plans: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.assign(member, {
|
return Object.assign(member, {
|
||||||
plans: [subscription.plan]
|
stripe: {
|
||||||
|
subscriptions
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue