MCPcopy Index your code
hub / github.com/simstudioai/sim / hasPaidSubscription

Function hasPaidSubscription

apps/sim/lib/billing/core/subscription.ts:151–179  ·  view source on GitHub ↗
(
  referenceId: string,
  options: HasPaidSubscriptionOptions = {}
)

Source from the content-addressed store, hash-verified

149 * Fails closed by default: returns true on error to prevent duplicate creation.
150 */
151export async function hasPaidSubscription(
152 referenceId: string,
153 options: HasPaidSubscriptionOptions = {}
154): Promise<boolean> {
155 const { onError = 'assume-active' } = options
156
157 try {
158 const [activeSub] = await db
159 .select({ id: subscription.id })
160 .from(subscription)
161 .where(
162 and(
163 eq(subscription.referenceId, referenceId),
164 inArray(subscription.status, ENTITLED_SUBSCRIPTION_STATUSES)
165 )
166 )
167 .limit(1)
168
169 return !!activeSub
170 } catch (error) {
171 logger.error('Error checking active subscription', { error, referenceId })
172
173 if (onError === 'throw') {
174 throw error
175 }
176
177 return true
178 }
179}
180
181export async function getOrganizationIdForSubscriptionReference(
182 referenceId: string

Callers 2

Calls 2

errorMethod · 0.80
eqFunction · 0.50

Tested by

no test coverage detected