(stripeCustomerId: string)
| 14 | * which may not be populated yet when early invoice events arrive). |
| 15 | */ |
| 16 | export async function isOrgCustomer(stripeCustomerId: string): Promise<boolean> { |
| 17 | try { |
| 18 | const orgs = await db |
| 19 | .select({ id: schema.org.id }) |
| 20 | .from(schema.org) |
| 21 | .where(eq(schema.org.stripe_customer_id, stripeCustomerId)) |
| 22 | .limit(1) |
| 23 | return orgs.length > 0 |
| 24 | } catch (error) { |
| 25 | logger.error( |
| 26 | { stripeCustomerId, error }, |
| 27 | 'Failed to check if customer is an org - defaulting to false', |
| 28 | ) |
| 29 | return false |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * BILLING_DISABLED: Checks if a Stripe event is related to organization billing. |
no test coverage detected