Reputation: 43491
I'm using:
const stripeCustomerSubscriptions = await stripe.subscriptions.list({
customer: req.body.stripeCustomerId,
status: 'active'
});
and that gets me all active
subscriptions. But I want all active
and trialing
. Any way to specify both?
Upvotes: 2
Views: 1555
Reputation: 963
you can use search like so
const subscriptions = await stripe.subscriptions.search({
query: 'status:\'active\' OR status:\'trialing\'',
})
Upvotes: 0
Reputation: 53525
Per Stripe API docs if we want to retrieve more than one status we should specify "all" in the status field and filter the results that we get back by ourselves.
The code should look something like:
const stripeCustomerSubscriptions = await stripe.subscriptions.list({
customer: req.body.stripeCustomerId,
status: 'all'
});
const filteredSubs = stripeCustomerSubscriptions.data.filter(sub => sub.status === 'active' || sub.status === 'trialing');
Upvotes: 3