🐛 (billing) Only fetch active subscriptions
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user