mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Added hasActiveStripeSubscriptions method (#169)
no-issue This can be used by Ghost to determine if the Stripe keys can be deleted
This commit is contained in:
parent
aa0b02b75e
commit
ae9870993a
@ -39,6 +39,26 @@ module.exports = function MembersApi({
|
||||
const {encodeIdentityToken, decodeToken} = Tokens({privateKey, publicKey, issuer});
|
||||
const metadata = Metadata({memberStripeCustomerModel, stripeCustomerSubscriptionModel});
|
||||
|
||||
async function hasActiveStripeSubscriptions() {
|
||||
const firstActiveSubscription = await stripeCustomerSubscriptionModel.findOne({
|
||||
status: 'active'
|
||||
});
|
||||
|
||||
if (firstActiveSubscription) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const firstTrialingSubscription = await stripeCustomerSubscriptionModel.findOne({
|
||||
status: 'trialing'
|
||||
});
|
||||
|
||||
if (firstTrialingSubscription) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const stripeStorage = {
|
||||
async get(member) {
|
||||
return metadata.getMetadata('stripe', member);
|
||||
@ -450,6 +470,7 @@ module.exports = function MembersApi({
|
||||
bus,
|
||||
sendEmailWithMagicLink,
|
||||
getMagicLink,
|
||||
hasActiveStripeSubscriptions,
|
||||
members: users
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user