#MrLowLevel

1 messages · Page 1 of 1 (latest)

fierce anchor
#

if you don't pass the filter, it defaults to only returning active subscriptions

civic osprey
#

Which are active statuses?

#

incomplete, trialing, active, past_due, unpaid?

fierce anchor
#

active and trialing I think

civic osprey
#

Or is unpaid terminal too?

#

Ok, basically I want to prevent creating a new sub if the user already has one

#

So I want to know which statuses are "recoverable", and see if there exists a subscription with such a status for that user

#

Currently the code goes something like

const subscriptions = await stripe.subscriptions.list({ customer: user.customerId, limit: 1 })
if (subscriptions.data.length > 0) {
  throw new InvalidOperationError('User already has a subscription')
}
fierce anchor
#

best way is to check your database where you have saved the ID of their existing subscription