2
0

🐛 (billing) Only fetch active subscriptions

This commit is contained in:
Baptiste Arnaud
2023-05-05 11:02:59 -04:00
parent 8b3a690809
commit 98a21f3a9e
3 changed files with 5 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ export const getSubscription = authenticatedProcedure
const subscriptions = await stripe.subscriptions.list({
customer: workspace.stripeId,
limit: 1,
status: 'active',
})
const subscription = subscriptions?.data.shift()

View File

@@ -72,6 +72,8 @@ export const updateSubscription = authenticatedProcedure
})
const { data } = await stripe.subscriptions.list({
customer: workspace.stripeId,
limit: 1,
status: 'active',
})
const subscription = data[0] as Stripe.Subscription | undefined
const currentPlanItemId = subscription?.items.data.find((item) =>

View File

@@ -59,6 +59,8 @@ export const cancelSubscription = async (stripeId: string) => {
const currentSubscriptionId = (
await stripe.subscriptions.list({
customer: stripeId,
limit: 1,
status: 'active',
})
).data.shift()?.id
if (currentSubscriptionId)