@fragno-dev/stripe 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/database/schema.ts","../../../src/models/subscriptions.ts","../../../src/types.ts","../../../src/definition.ts","../../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;cAKa,cAAY,wBAAA,CAAA,OAAA,uBAAA,wBAAA,CAAA,MAAA,eA+BvB,wBAAA,CA/BuB,SAAA,IAAA,aAAA,wBAAA,CAAA,iCAAA,wBAAA,CAAA,QAAA,SAAA,wBAAA,CAAA,QAAA,KAAA,sBAAA,wBAAA,CAAA,kDAAA,wBAAA,wBAAA,CAAA,oCAAA,2BAAA,wBAAA,CAAA,oCAAA,+BAAA,wBAAA,CAAA,oCAAA,iBAAA,wBAAA,CAAA,2CAAA,sBAAA,wBAAA,CAAA,oBAAA,aAAA,gBAAA,oBAAA,wBAAA,CAAA,oBAAA,aAAA,gBAAA,qBAAA,wBAAA,CAAA,oBAAA,aAAA,gBAAA,mBAAA,wBAAA,CAAA,oBAAA,aAAA,gBAAA,4BAAA,wBAAA,CAAA,2CAAA,mBAAA,wBAAA,CAAA,oBAAA,aAAA,gBAAA,gBAAA,wBAAA,CAAA,mDAAA,oBAAA,wBAAA,CAAA,oBAAA,aAAA,SAAA,oBAAA,wBAAA,CAAA,oBAAA,aAAA,QAAA,eAAA,wBAAA,CAAA,WAAA,GAAA,eAAA,wBAAA,CAAA,MAAA,wBAAA,CAAA,SAAA,0BAAA,iCAAA,wBAAA,CAAA,gBAAA,wBAAA,CAAA,oCAAA,wBAAA,CAAA,SAAA,sCAAA,qCAAA,wBAAA,CAAA,gBAAA,wBAAA,CAAA,oCAAA,wBAAA,CAAA,SAAA,0CAAA,2BAAA,wBAAA,CAAA,gBAAA,wBAAA,CAAA,kDAAA,wBAAA,CAAA,SA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BAAA,CAAA;MAIkB,WAAA,kBAAA,gBAAA;MAAR,KAAA,kBAAA,gBAAA;MAC2B,eAAA,kBAAA,gBAAA;MAAR,sBAAA,kBAAA,eAAA,gCAAA,CAAA;MAEc,cAAA,kBAAA,iBAAA,gBAAA,CAAA;MAAO,QAAA,iBAAA;;;;MCoC9D,KAAA,kBAeH,iBAAA,gBAAA,CAAA;MAAA,iBAAA,kBAAA,iBAAA,cAAA,gBAAA,CAAA,CAAA;IAf2B,CAAA,sBAAA,CAAA;IAAA,OAAA,iBAAA;EAAA,CAAA,sBAAA,EAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAA;IAAA,QAAA,iBAAA;;;;ICrJrB,QAAA,gBAAoB;IAAA,UAAA,aAAA;IAC1B,SAAA,aAAA;IACM,SAAA,kBAAA,gBAAA;IAA8B,aAAA,kBAAA,gBAAA;IAAA,cAAA,kBAAA,gBAAA;;uBAAA;IAAA,QAAA,iBAAA;+BAAA,gBAAA;EAAA,CAAA,sBAAA,GAAA,SAAA,EAAA,uBAAA,GAAA,wBAAA,GAAA,gCAAA,GAAA,uBAAA,GAAA,iCAAA,GAAA,4CAAA,GAAA,wCAAA,GAAA,+BAAA,GAAA,yBAAA,EAAA,MAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/database/schema.ts","../../../src/models/subscriptions.ts","../../../src/types.ts","../../../src/definition.ts","../../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;cAKa,cAAY,wBAAA,CAAA,OAAA,uBAAA,wBAAA,CAAA,MAAA,eA+BvB,wBAAA,CA/BuB,SAAA,IAAA,aAAA,wBAAA,CAAA,iCAAA,wBAAA,CAAA,QAAA,SAAA,wBAAA,CAAA,QAAA,KAAA,sBAAA,wBAAA,CA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A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAA;EAAA,CAAA,sBAAA,GAAA,SAAA,EAAA,+BAAA,EAAA,MAAA,CAAA;;;;ICrJrB,UAAA,aAAoB;IAAA,SAAA,aAAA;IAC1B,SAAA,kBAAA,gBAAA;IACM,aAAA,kBAAA,gBAAA;IAA8B,cAAA,kBAAA,gBAAA;EAAA,CAAA,sBAAA,GAAA,SAAA,gBAAA,CAAA;;YAAA,iBAAA;IAAA,SAAA,kBAAA,gBAAA;;sEAAA,yCAAA,sBAAA,gBAAA,CAAA;IAAA,SAAA,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["s: number | undefined | null","x: string | { id: string }","stripeSubscription: Stripe.Subscription","defaultLogger: Logger","subscription: T","deps: StripeFragmentDeps","db: AbstractQuery<typeof stripeSchema>","services: StripeFragmentServices","data: Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"createdAt\" | \"updatedAt\"\n >","id: string","data: Partial<Omit<TableToInsertValues<typeof stripeSchema.tables.subscription>, \"id\">>","stripeSubscriptionId: string","stripeCustomerId: string","referenceId: string","args: StripeEventHandler","eventToHandler: Record<\n SupportedStripeEvent,\n (args: StripeEventHandler) => Promise<void>\n>","event: Stripe.Event","error: unknown","err: unknown","customerId: string | undefined","existingSubscription: SubscriptionResponse | null","error","promotionCodeId: string | undefined","error: unknown","err: unknown","config: StripeFragmentConfig","fragnoConfig: FragnoPublicConfigWithDatabase","fragnoConfig: FragnoPublicClientConfig"],"sources":["../../src/database/schema.ts","../../src/utils.ts","../../src/definition.ts","../../src/webhook/handlers.ts","../../src/routes/webhooks.ts","../../src/models/customers.ts","../../src/routes/errors.ts","../../src/routes/customers.ts","../../src/models/subscriptions.ts","../../src/routes/subscriptions.ts","../../src/models/products.ts","../../src/routes/products.ts","../../src/models/prices.ts","../../src/routes/prices.ts","../../src/index.ts"],"sourcesContent":["import { schema, idColumn, column } from \"@fragno-dev/db/schema\";\n\n/**\n * Database schema for subscriptions that are linked to external stripe subscriptions.\n */\nexport const stripeSchema = schema((s) => {\n return s.addTable(\"subscription\", (t) => {\n return (\n t\n .addColumn(\"id\", idColumn())\n // referenceId: entity to which this subscription applies (i.e. userId), nullable because unset on subscription updates\n .addColumn(\"referenceId\", column(\"string\").nullable())\n .addColumn(\"stripePriceId\", column(\"string\"))\n .addColumn(\"stripeCustomerId\", column(\"string\"))\n .addColumn(\"stripeSubscriptionId\", column(\"string\"))\n .addColumn(\"status\", column(\"string\").defaultTo(\"incomplete\")) // Stripe.Subscription.Status\n .addColumn(\"periodStart\", column(\"timestamp\").nullable())\n .addColumn(\"periodEnd\", column(\"timestamp\").nullable())\n .addColumn(\"trialStart\", column(\"timestamp\").nullable())\n .addColumn(\"trialEnd\", column(\"timestamp\").nullable())\n .addColumn(\"cancelAtPeriodEnd\", column(\"bool\").defaultTo(false))\n .addColumn(\"cancelAt\", column(\"timestamp\").nullable())\n .addColumn(\"seats\", column(\"integer\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .addColumn(\n \"updatedAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_stripe_customer_id\", [\"stripeCustomerId\"])\n .createIndex(\"idx_stripe_subscription_id\", [\"stripeSubscriptionId\"])\n .createIndex(\"idx_reference_id\", [\"referenceId\"])\n );\n });\n});\n","import type Stripe from \"stripe\";\nimport type { TableToInsertValues } from \"@fragno-dev/db/query\";\nimport type { stripeSchema } from \"./database/schema\";\n\nexport function toDate(s: number): Date;\nexport function toDate(s: undefined): undefined;\nexport function toDate(s: null): null;\nexport function toDate(s: number | null): Date | null;\nexport function toDate(s: number | undefined | null): Date | undefined | null {\n return s !== undefined && s !== null ? new Date(s * 1000) : s;\n}\n\nexport function getId(x: string | { id: string }): string {\n return typeof x === \"string\" ? x : x.id;\n}\n\n/**\n * Maps a Stripe.Subscription to the internal subscription schema.\n */\nexport function stripeSubscriptionToInternalSubscription(\n stripeSubscription: Stripe.Subscription,\n): Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"updatedAt\" | \"referenceId\"\n> {\n const firstItem = stripeSubscription.items.data[0];\n\n if (!firstItem) {\n // It should be impossible for a subscription to have no items (CITATION NEEDED)\n throw new Error(\"Subscription contains no items\");\n }\n\n const priceId = getId(firstItem.price);\n const customerId = getId(stripeSubscription.customer);\n\n return {\n stripePriceId: priceId,\n stripeCustomerId: customerId,\n stripeSubscriptionId: stripeSubscription.id,\n status: stripeSubscription.status,\n periodStart: toDate(firstItem.current_period_start),\n periodEnd: toDate(firstItem.current_period_end),\n trialStart: toDate(stripeSubscription.trial_start),\n trialEnd: toDate(stripeSubscription.trial_end),\n cancelAtPeriodEnd: stripeSubscription.cancel_at_period_end ?? false,\n cancelAt: toDate(stripeSubscription.cancel_at),\n createdAt: toDate(stripeSubscription.created),\n seats: firstItem.quantity ?? null,\n };\n}\n","import Stripe from \"stripe\";\nimport type { AbstractQuery, TableToInsertValues } from \"@fragno-dev/db/query\";\nimport type {\n Logger,\n StripeFragmentConfig,\n StripeFragmentDeps,\n StripeFragmentServices,\n} from \"./types\";\nimport { stripeSchema } from \"./database/schema\";\nimport { defineFragment } from \"@fragno-dev/core\";\nimport { withDatabase } from \"@fragno-dev/db\";\nimport { stripeSubscriptionToInternalSubscription } from \"./utils\";\n\nconst LOG_PREFIX = \"[Stripe Fragment]\";\nconst defaultLogger: Logger = {\n info: (...data) => console.info(LOG_PREFIX, ...data),\n error: (...data) => console.error(LOG_PREFIX, ...data),\n warn: (...data) => console.warn(LOG_PREFIX, ...data),\n debug: (...data) => console.debug(LOG_PREFIX, ...data),\n log: (...data) => console.log(LOG_PREFIX, ...data),\n};\n\nconst asExternalSubscription = <T extends { id: { externalId: string }; status: string }>(\n subscription: T,\n) => ({\n ...subscription,\n id: subscription.id.externalId,\n status: subscription.status as Stripe.Subscription.Status,\n});\n\nfunction createStripeServices(\n deps: StripeFragmentDeps,\n db: AbstractQuery<typeof stripeSchema>,\n): StripeFragmentServices {\n const services: StripeFragmentServices = {\n getStripeClient(): Stripe {\n return deps.stripe;\n },\n createSubscription: async (\n data: Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"createdAt\" | \"updatedAt\"\n >,\n ) => {\n return (await db.create(\"subscription\", data)).externalId;\n },\n updateSubscription: async (\n id: string,\n data: Partial<Omit<TableToInsertValues<typeof stripeSchema.tables.subscription>, \"id\">>,\n ) => {\n await db.update(\"subscription\", id, (b) => b.set({ ...data, updatedAt: new Date() }));\n },\n\n getSubscriptionByStripeId: async (stripeSubscriptionId: string) => {\n const result = await db.findFirst(\"subscription\", (b) =>\n b.whereIndex(\"idx_stripe_subscription_id\", (eb) =>\n eb(\"stripeSubscriptionId\", \"=\", stripeSubscriptionId),\n ),\n );\n if (!result) {\n return null;\n }\n\n return asExternalSubscription(result);\n },\n getSubscriptionsByStripeCustomerId: async (stripeCustomerId: string) => {\n return (\n await db.find(\"subscription\", (b) =>\n b.whereIndex(\"idx_stripe_customer_id\", (eb) =>\n eb(\"stripeCustomerId\", \"=\", stripeCustomerId),\n ),\n )\n ).map(asExternalSubscription);\n },\n getSubscriptionById: async (id: string) => {\n const result = await db.findFirst(\"subscription\", (b) =>\n b.whereIndex(\"primary\", (eb) => eb(\"id\", \"=\", id)),\n );\n if (!result) {\n return null;\n }\n return asExternalSubscription(result);\n },\n getSubscriptionsByReferenceId: async (referenceId: string) => {\n const result = await db.find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n if (result.length == 0) {\n return [];\n }\n return result.map(asExternalSubscription);\n },\n\n deleteSubscription: async (id: string) => {\n await db.delete(\"subscription\", id);\n },\n\n deleteSubscriptionsByReferenceId: async (referenceId: string) => {\n const uow = db\n .createUnitOfWork()\n .find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n\n const [subscriptions] = await uow.executeRetrieve();\n subscriptions.forEach((sub) => sub && uow.delete(\"subscription\", sub.id));\n\n return await uow.executeMutations();\n },\n\n getAllSubscriptions: async () => {\n return (await db.find(\"subscription\", (b) => b.whereIndex(\"primary\"))).map(\n asExternalSubscription,\n );\n },\n\n /* Retrieve Stripe Subscription and create/update/delete internal entity */\n syncStripeSubscriptions: async (referenceId: string, stripeCustomerId: string) => {\n const stripeSubscriptions = await deps.stripe.subscriptions.list({\n customer: stripeCustomerId,\n status: \"all\",\n });\n\n if (stripeSubscriptions.data.length === 0) {\n await services.deleteSubscriptionsByReferenceId(referenceId);\n return { success: true };\n }\n\n const uow = db\n .createUnitOfWork()\n .find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n\n const [existingSubscriptions] = await uow.executeRetrieve();\n\n // Mutation phase: process all Stripe subscriptions (including canceled)\n for (const stripeSubscription of stripeSubscriptions.data) {\n const existingSubscription = existingSubscriptions.find(\n (sub) => sub.stripeSubscriptionId === stripeSubscription.id,\n );\n\n if (existingSubscription) {\n // Update existing subscription with optimistic concurrency control\n uow.update(\"subscription\", existingSubscription.id, (b) =>\n b\n .set({\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n updatedAt: new Date(),\n })\n .check(),\n );\n } else {\n // Create new subscription\n uow.create(\"subscription\", {\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: referenceId ?? null,\n updatedAt: new Date(),\n });\n }\n }\n\n // Execute all mutations and return result\n return uow.executeMutations();\n },\n };\n return services;\n}\n\nexport const stripeFragmentDefinition = defineFragment<StripeFragmentConfig>(\"stripe\")\n .extend(withDatabase(stripeSchema))\n .withDependencies(({ config }) => {\n const stripeClient = new Stripe(config.stripeSecretKey, config.stripeClientOptions ?? {});\n\n return {\n stripe: stripeClient,\n log: config.logger ? config.logger : defaultLogger,\n };\n })\n .providesBaseService(({ deps }) => {\n return {\n ...createStripeServices(deps, deps.db),\n };\n })\n .build();\n","import type { Stripe } from \"stripe\";\nimport type { StripeFragmentConfig, StripeFragmentDeps, StripeFragmentServices } from \"../types\";\nimport { FragnoApiError } from \"@fragno-dev/core/api\";\nimport { getId, stripeSubscriptionToInternalSubscription } from \"../utils\";\n\nexport interface StripeEventHandler {\n event: Stripe.Event;\n services: StripeFragmentServices;\n deps: StripeFragmentDeps;\n config: StripeFragmentConfig;\n}\n\n// https://docs.stripe.com/api/events/types\nexport type SupportedStripeEvent =\n | \"checkout.session.completed\"\n | \"customer.subscription.deleted\"\n | \"customer.subscription.updated\"\n | \"customer.subscription.paused\"\n | \"customer.subscription.created\"\n | \"customer.subscription.pending_update_applied\"\n | \"customer.subscription.pending_update_expired\"\n | \"customer.subscription.resumed\"\n | \"customer.subscription.trial_will_end\";\n// TODO: for customer tracking\n// | \"customer.updated\"\n// TODO: for stripe product payment tracking\n// | \"invoice.marked_uncollectible\"\n// | \"invoice.paid\"\n// | \"invoice.payment_action_required\"\n// | \"invoice.payment_failed\"\n// | \"invoice.payment_succeeded\"\n// | \"invoice.upcoming\"\n// | \"payment_intent.canceled\"\n// | \"payment_intent.payment_failed\"\n// | \"payment_intent.succeeded\";\n\n/**\n * Event Handler for checkout.session.completed\n *\n * This handler is ONLY for subscription checkout sessions.\n * Occurs when a Checkout Session has been successfully completed.\n */\nexport async function checkoutSessionCompletedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n const checkoutSession = event.data.object as Stripe.Checkout.Session;\n\n // Skip if this is not a subscription session\n if (checkoutSession.mode !== \"subscription\") {\n deps.log.info(`Not handling checkout session with mode ${checkoutSession.mode}: ${event.id}`);\n return;\n }\n\n const subscriptionId = checkoutSession.subscription;\n if (typeof subscriptionId !== \"string\") {\n deps.log.error(\"No subscription ID in checkout session\");\n return;\n }\n\n // Retrieve the full subscription details from Stripe\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(subscriptionId);\n\n // Extract customer ID\n const customerId = getId(stripeSubscription.customer);\n\n // Extract subscription details from first item\n const firstItem = stripeSubscription.items.data[0];\n if (!firstItem) {\n deps.log.error(\"No subscription items found\");\n return;\n }\n\n // Get referenceId from checkout session (client_reference_id or metadata)\n const referenceId =\n checkoutSession.metadata?.[\"referenceId\"] || checkoutSession.client_reference_id;\n\n // Get existing subscription ID from metadata (if updating an existing one)\n const existingSubscriptionId = checkoutSession.metadata?.[\"subscriptionId\"];\n\n const subscriptionData = {\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: referenceId ?? null,\n };\n\n // If we have an existing subscription ID, try to update it\n if (existingSubscriptionId) {\n await services.updateSubscription(existingSubscriptionId, subscriptionData);\n deps.log.info(`Updated subscription ${existingSubscriptionId} for customer ${customerId}`);\n return;\n }\n\n // Otherwise, check if subscription already exists by Stripe subscription ID\n const existing = await services.getSubscriptionByStripeId(stripeSubscription.id);\n if (existing) {\n // TODO: update that subscription's data?\n deps.log.info(`Subscription already exists for Stripe ID ${stripeSubscription.id}`);\n return;\n }\n\n // Create new subscription record\n const createdSubscriptionId = await services.createSubscription(subscriptionData);\n deps.log.info(\n `Created subscription ${createdSubscriptionId} for customer ${customerId} (Stripe ID: ${stripeSubscription.id})`,\n );\n}\n\n/**\n * Event Handler for customer.subscription.paused\n *\n * Occurs whenever a customer’s subscription is paused. Only applies when\n * subscriptions enter status=paused, not when payment collection is paused.\n *\n * PAUSED status: The subscription has ended its trial period without a default\n * payment method and the trial_settings.end_behavior.missing_payment_method is set\n * to pause. Invoices are no longer created for the subscription. After attaching a\n * default payment method to the customer, you can resume the subscription.\n */\nexport async function customerSubscriptionPausedHandler(args: StripeEventHandler) {\n // As far as I can tell, this only sets the status of a subscription to paused and nothing else.\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.pending_update_applied\n *\n * Occurs whenever a customer’s subscription’s pending update is applied,\n * and the subscription is updated.\n */\nexport async function customerSubscriptionPendingUpdateAppliedHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.pending_update_expired\n *\n * Occurs whenever a customer’s subscription’s pending update expires\n * before the related invoice is paid.\n */\nexport async function customerSubscriptionPendingUpdateExpiredHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.resumed\n *\n * Occurs whenever a customer’s subscription is no longer paused.\n * Only applies when a status=paused subscription is resumed, not when payment\n * collection is resumed.\n */\nexport async function customerSubscriptionResumedHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.trial_will_end\n *\n * Occurs three days before a subscription's trial period is scheduled to end,\n * or when a trial is ended immediately (using trial_end=now). This event allows\n * you to send reminders or take action before the trial expires.\n */\nexport async function customerSubscriptionTrialWillEndHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.updated\n *\n * Occurs whenever a subscription changes (e.g., switching from one plan to another,\n * or changing the status from trial to active).\n */\nexport async function customerSubscriptionUpdatedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n deps.log.info(`Processing ${event.type}: ${event.id}`);\n\n const stripeSubscription = event.data.object as Stripe.Subscription;\n\n const firstItem = stripeSubscription.items?.data?.[0];\n if (!firstItem) {\n throw new FragnoApiError(\n { message: \"Subscription contains no items\", code: \"EMPTY_SUBSCRIPTION\" },\n 400,\n );\n }\n\n const customerId = getId(stripeSubscription.customer);\n\n // Try to find existing subscription\n let subscription = await services.getSubscriptionByStripeId(stripeSubscription.id);\n\n // If not found by Stripe ID, try to find by customer ID\n if (!subscription) {\n const customerSubs = await services.getSubscriptionsByStripeCustomerId(customerId);\n\n if (customerSubs.length > 1) {\n subscription =\n customerSubs.find((sub) => sub.status === \"active\" || sub.status === \"trialing\") ?? null;\n\n if (!subscription) {\n deps.log.warn(\n `Multiple subscriptions found for customer ${customerId} but none active or trialing`,\n );\n return;\n }\n } else {\n subscription = customerSubs[0] ?? null;\n }\n }\n\n if (!subscription) {\n deps.log.warn(\n `No subscription found for Stripe ID ${stripeSubscription.id}, creating new record`,\n );\n\n const createdSubscriptionId = await services.createSubscription({\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: stripeSubscription.metadata?.[\"referenceId\"] ?? null,\n });\n\n deps.log.info(\n `Created subscription ${createdSubscriptionId} for customer ${customerId} (Stripe ID: ${stripeSubscription.id})`,\n );\n return;\n }\n\n await services.updateSubscription(\n subscription.id,\n stripeSubscriptionToInternalSubscription(stripeSubscription),\n );\n\n deps.log.info(`Updated subscription ${subscription.id} (Stripe ID: ${stripeSubscription.id})`);\n}\n\n/**\n * Event Handler for customer.subscription.deleted\n *\n * Occurs whenever a customer's subscription ends.\n */\nexport async function customerSubscriptionDeletedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n deps.log.info(`Processing customer.subscription.deleted: ${event.id}`);\n\n const stripeSubscription = event.data.object as Stripe.Subscription;\n\n // Find existing subscription\n const subscription = await services.getSubscriptionByStripeId(stripeSubscription.id);\n\n if (!subscription) {\n deps.log.warn(`No subscription found for Stripe ID ${stripeSubscription.id}`);\n return;\n }\n\n // Update status to canceled\n await services.updateSubscription(subscription.id, {\n status: \"canceled\",\n });\n\n deps.log.info(\n `Marked subscription ${subscription.id} as canceled (Stripe ID: ${stripeSubscription.id})`,\n );\n}\n\nexport const eventToHandler: Record<\n SupportedStripeEvent,\n (args: StripeEventHandler) => Promise<void>\n> = {\n \"checkout.session.completed\": checkoutSessionCompletedHandler,\n \"customer.subscription.deleted\": customerSubscriptionDeletedHandler,\n \"customer.subscription.created\": customerSubscriptionUpdatedHandler,\n \"customer.subscription.updated\": customerSubscriptionUpdatedHandler,\n \"customer.subscription.paused\": customerSubscriptionPausedHandler,\n \"customer.subscription.pending_update_applied\": customerSubscriptionPendingUpdateAppliedHandler,\n \"customer.subscription.pending_update_expired\": customerSubscriptionPendingUpdateExpiredHandler,\n \"customer.subscription.resumed\": customerSubscriptionResumedHandler,\n \"customer.subscription.trial_will_end\": customerSubscriptionTrialWillEndHandler,\n};\n","import { z } from \"zod\";\nimport Stripe from \"stripe\";\nimport { eventToHandler, type SupportedStripeEvent } from \"../webhook/handlers\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const webhookRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ config, deps, services, defineRoute }) => {\n return [\n defineRoute({\n method: \"POST\",\n path: \"/webhook\",\n outputSchema: z.object({\n success: z.boolean(),\n }),\n errorCodes: [\"MISSING_SIGNATURE\", \"WEBHOOK_SIGNATURE_INVALID\", \"WEBHOOK_ERROR\"] as const,\n handler: async ({ headers, rawBody }, { json, error }) => {\n // Get the signature\n const signature = headers.get(\"stripe-signature\");\n\n if (!signature) {\n return error(\n { message: \"Missing stripe-signature header\", code: \"MISSING_SIGNATURE\" },\n 400,\n );\n }\n\n if (!rawBody) {\n return error(\n { message: \"Missing request body for webhook verification\", code: \"WEBHOOK_ERROR\" },\n 400,\n );\n }\n\n // Verify the webhook signature\n let event: Stripe.Event;\n try {\n // Support both Stripe v18 (constructEvent) and v19+ (constructEventAsync)\n if (typeof deps.stripe.webhooks.constructEventAsync === \"function\") {\n // Stripe v19+ - use async method\n event = await deps.stripe.webhooks.constructEventAsync(\n rawBody,\n signature,\n config.webhookSecret,\n );\n } else {\n // Stripe v18 - use sync method\n event = deps.stripe.webhooks.constructEvent(rawBody, signature, config.webhookSecret);\n }\n } catch (err) {\n if (err instanceof Stripe.errors.StripeSignatureVerificationError) {\n return error(\n {\n message: `Webhook signature verification failed`,\n code: \"WEBHOOK_SIGNATURE_INVALID\",\n },\n 400,\n );\n }\n throw err;\n }\n\n if (!event) {\n return error({ message: \"Failed to construct event\", code: \"WEBHOOK_ERROR\" }, 400);\n }\n\n if (config.onEvent) {\n deps.log.info(\"Running user callback event\");\n await config.onEvent({ event, stripeClient: deps.stripe });\n }\n\n const eventHandler = eventToHandler[event.type as SupportedStripeEvent];\n if (!eventHandler) {\n deps.log.info(`Webhook event ${event.type}: ${event.id} ignored`);\n return json({ success: true });\n }\n\n deps.log.info(`Executing event handler for ${event.type}: ${event.id}`);\n await eventHandler({ event, services, deps, config });\n\n return json({ success: true });\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const CustomerResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"customer\"),\n balance: z.number(),\n business_name: z.string().optional(),\n created: z.number(),\n currency: z.string().nullable().optional(),\n deleted: z.void().optional(),\n delinquent: z.boolean().nullable().optional(),\n description: z.string().nullable(),\n email: z.string().nullable(),\n individual_name: z.string().optional(),\n invoice_credit_balance: z.record(z.string(), z.number()).optional(),\n invoice_prefix: z.string().nullable().optional(),\n livemode: z.boolean(),\n metadata: z.record(z.string(), z.string()),\n name: z.string().nullable().optional(),\n next_invoice_sequence: z.number().optional(),\n phone: z.string().nullable().optional(),\n preferred_locales: z.array(z.string()).nullable().optional(),\n});\n\nexport type CustomerResponseSchema = z.infer<typeof CustomerResponseSchema>;\n","import { FragnoApiError } from \"@fragno-dev/core/api\";\n\nfunction isStripeError(error: unknown): error is { type: string; message: string; code: string } {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"type\" in error &&\n typeof error.type === \"string\" &&\n \"message\" in error &&\n typeof error.message === \"string\"\n );\n}\n\nexport function stripeToApiError(error: unknown): FragnoApiError | unknown {\n // Attempt to generate more ergnomic error messages\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"there are no changes to confirm\")\n ) {\n return new FragnoApiError(\n { message: \"Trying to upgrade to same subscription plan\", code: \"UPGRADE_HAS_NO_EFFECT\" },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"is already set to be canceled at period end\")\n ) {\n return new FragnoApiError(\n {\n message: \"Subscription is already set to be canceled at period end\",\n code: \"SUBSCRIPTION_ALREADY_CANCELED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\n \"the subscription update feature in the portal configuration is disabled\",\n )\n ) {\n return new FragnoApiError(\n {\n message: \"Subscription cannot be updated to this plan\",\n code: \"SUBSCRIPTION_UPDATE_NOT_ALLOWED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"does not include `promotion_code`\")\n ) {\n return new FragnoApiError(\n {\n message: \"Cannot apply promotion code when updating subscription\",\n code: \"SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.code == \"promotion_code_customer_not_first_time\"\n ) {\n return new FragnoApiError(\n {\n message: \"This promotion code cannot be redeemed because you have already used it before.\",\n code: \"PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME\",\n },\n 500,\n );\n }\n\n return error;\n}\n","import { z } from \"zod\";\nimport { CustomerResponseSchema } from \"../models/customers\";\nimport { stripeToApiError } from \"./errors\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const customersRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/customers\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of customers to return (max 100)\"),\n startingAfter: z\n .string()\n .optional()\n .describe(\"Customer ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n customers: z.array(CustomerResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more customers to fetch\"),\n }),\n handler: async ({ query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const customers = await deps.stripe.customers.list({\n limit,\n starting_after: startingAfter,\n });\n return json({\n customers: customers.data,\n hasMore: customers.has_more,\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/portal\",\n inputSchema: z.object({\n returnUrl: z.url().describe(\"URL to redirect to after completing billing portal\"),\n }),\n outputSchema: z.object({\n url: z.url().describe(\"URL to redirect to after cancellation\"),\n redirect: z.boolean().describe(\"Whether to redirect to the URL\"),\n }),\n errorCodes: [\"NO_STRIPE_CUSTOMER_FOR_ENTITY\"] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const { stripeCustomerId } = await config.resolveEntityFromRequest(context);\n\n if (!stripeCustomerId) {\n return error(\n {\n message: \"No stripe customer to create billing portal for\",\n code: \"NO_STRIPE_CUSTOMER_FOR_ENTITY\",\n },\n 400,\n );\n }\n\n try {\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: stripeCustomerId,\n return_url: body.returnUrl,\n });\n\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (err: unknown) {\n throw stripeToApiError(err);\n }\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const SubscriptionReponseSchema = z.object({\n id: z.string(),\n stripeSubscriptionId: z.string(),\n stripeCustomerId: z.string(),\n stripePriceId: z.string(),\n referenceId: z.string().nullable(),\n status: z.enum([\n \"active\",\n \"canceled\",\n \"incomplete\",\n \"incomplete_expired\",\n \"past_due\",\n \"paused\",\n \"trialing\",\n \"unpaid\",\n ]),\n periodStart: z.date().nullable(),\n periodEnd: z.date().nullable(),\n trialStart: z.date().nullable(),\n trialEnd: z.date().nullable(),\n cancelAtPeriodEnd: z.boolean().nullable(),\n cancelAt: z.date().nullable(),\n seats: z.number().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const SubscriptionUpgradeRequestSchema = z.object({\n priceId: z.string().describe(\"Stripe price ID to subscribe/upgrade to\"),\n quantity: z.number().positive().describe(\"Number of seats\"),\n successUrl: z.url().describe(\"Redirect URL after successful checkout\"),\n cancelUrl: z.url().describe(\"Redirect URL if checkout is cancelled\"),\n returnUrl: z.string().optional().describe(\"Return URL for billing portal\"),\n promotionCode: z.string().optional().describe(\"Promotion code to apply\"),\n subscriptionId: z\n .string()\n .optional()\n .describe(\n \"Subscription ID to upgrade, if none provided assume the active subscription of the user.\",\n ),\n});\n\nexport type SubscriptionResponse = z.infer<typeof SubscriptionReponseSchema>;\n","import { z } from \"zod\";\nimport {\n SubscriptionReponseSchema,\n SubscriptionUpgradeRequestSchema,\n type SubscriptionResponse,\n} from \"../models/subscriptions\";\nimport { stripeToApiError } from \"./errors\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const subscriptionsRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, services, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/subscriptions\",\n outputSchema: z.object({\n subscriptions: z.array(SubscriptionReponseSchema),\n }),\n handler: async (_, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n // TODO: Implement pagination\n return json({\n subscriptions: await services.getAllSubscriptions(),\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/subscription/upgrade\",\n inputSchema: SubscriptionUpgradeRequestSchema,\n outputSchema: z.object({\n url: z.string(),\n redirect: z.boolean(),\n sessionId: z.string().optional(),\n }),\n errorCodes: [\n \"MISSING_CUSTOMER_INFO\",\n \"SUBSCRIPTION_NOT_FOUND\",\n \"CUSTOMER_SUBSCRIPTION_MISMATCH\",\n \"UPGRADE_HAS_NO_EFFECT\",\n \"SUBSCRIPTION_UPDATE_NOT_ALLOWED\",\n \"SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED\",\n \"PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME\",\n \"MULTIPLE_ACTIVE_SUBSCRIPTIONS\",\n \"NO_ACTIVE_SUBSCRIPTIONS\",\n ] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const entity = await config.resolveEntityFromRequest(context);\n\n let customerId: string | undefined = entity.stripeCustomerId;\n let existingSubscription: SubscriptionResponse | null = null;\n\n // Step 1: Get active subscriptions\n if (entity.stripeCustomerId) {\n const existingSubscriptions = await services.getSubscriptionsByStripeCustomerId(\n entity.stripeCustomerId,\n );\n\n // Cannot upgrade cancelled subscriptions\n let activeSubscriptions = existingSubscriptions.filter((s) => s.status !== \"canceled\");\n\n // A specific subscription has been specified\n if (body.subscriptionId) {\n activeSubscriptions = activeSubscriptions.filter((s) => s.id === body.subscriptionId);\n }\n\n if (activeSubscriptions.length > 1) {\n return error(\n {\n message:\n \"Multiple active subscriptions found for customer, please specify which subscription to upgrade\",\n code: \"MULTIPLE_ACTIVE_SUBSCRIPTIONS\",\n },\n 400,\n );\n }\n if (activeSubscriptions.length === 0) {\n return error(\n {\n message: \"No active subscriptions found for customer\",\n code: \"NO_ACTIVE_SUBSCRIPTIONS\",\n },\n 400,\n );\n }\n existingSubscription = activeSubscriptions[0];\n\n if (\n customerId &&\n existingSubscription.stripeCustomerId &&\n existingSubscription.stripeCustomerId !== customerId\n ) {\n return error(\n {\n message:\n \"Subsciption being updated does not belong to Stripe Customer that was provided\",\n code: \"CUSTOMER_SUBSCRIPTION_MISMATCH\",\n },\n 422,\n );\n }\n\n customerId = existingSubscription.stripeCustomerId;\n }\n\n // Step 2: Get or Create customer if not found\n if (!customerId) {\n const existingLinkedCustomer = await deps.stripe.customers.search({\n query: `metadata['referenceId']:'${entity.referenceId}'`,\n limit: 1,\n });\n\n if (existingLinkedCustomer.data.length === 1) {\n // Use existing customer\n customerId = existingLinkedCustomer.data[0].id;\n } else {\n // Create new Stripe Customer\n\n // Check if sufficient data is provided for this scenario\n if (!entity.customerEmail || !entity.referenceId) {\n return error({\n message:\n \"New Stripe Customer must be created, but customerEmail or referenceID has not been provided\",\n code: \"MISSING_CUSTOMER_INFO\",\n });\n }\n\n const newCustomer = await deps.stripe.customers.create({\n email: entity.customerEmail,\n metadata: {\n referenceId: entity.referenceId,\n ...entity.stripeMetadata,\n },\n });\n customerId = newCustomer.id;\n }\n\n // Communicate back to the user that a customer has been created/linked\n try {\n await config.onStripeCustomerCreated(customerId, entity.referenceId);\n } catch (error) {\n deps.log.error(\"onStripeCustomerCreated failed!\", error);\n }\n }\n\n // Step 3: Resolve promotion code to ID if provided\n let promotionCodeId: string | undefined = undefined;\n if (body.promotionCode) {\n const promotionCodes = await deps.stripe.promotionCodes.list({\n code: body.promotionCode,\n active: true,\n limit: 1,\n });\n if (promotionCodes.data.length > 0) {\n promotionCodeId = promotionCodes.data[0].id;\n }\n }\n\n // Step 4: If existing subscription is active, modify using billing portal\n if (\n existingSubscription?.status === \"active\" ||\n existingSubscription?.status === \"trialing\"\n ) {\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(\n existingSubscription.stripeSubscriptionId,\n );\n\n try {\n // when /upgrade is called on a subscription scheduled to cancel at the end of the billing period,\n // it is still \"active\" but it's not possible to renew it using a billing portal.\n if (existingSubscription.cancelAt != null) {\n deps.log.info(\"un-cancelling subscription\", stripeSubscription.id);\n\n await deps.stripe.subscriptions.update(stripeSubscription.id, {\n cancel_at_period_end: false,\n });\n\n return json({\n url: body.returnUrl || body.successUrl,\n redirect: true,\n });\n }\n // Portal session to confirm subscription changes\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: customerId,\n return_url: body.returnUrl || body.successUrl,\n flow_data: {\n type: \"subscription_update_confirm\",\n after_completion: {\n type: \"redirect\",\n redirect: {\n return_url: body.returnUrl || body.successUrl,\n },\n },\n subscription_update_confirm: {\n subscription: existingSubscription.stripeSubscriptionId,\n items: [\n {\n // We always create subscriptions with a single item\n id: stripeSubscription.items.data[0]?.id as string,\n quantity: body.quantity,\n price: body.priceId,\n },\n ],\n ...(promotionCodeId && {\n discounts: [{ promotion_code: promotionCodeId }],\n }),\n },\n },\n });\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (error: unknown) {\n throw stripeToApiError(error);\n }\n }\n\n // Step 5: Create a Subscription\n const checkoutSession = await deps.stripe.checkout.sessions.create({\n customer: customerId,\n success_url: body.successUrl,\n cancel_url: body.cancelUrl,\n line_items: [\n {\n price: body.priceId,\n quantity: body.quantity,\n },\n ],\n mode: \"subscription\",\n metadata: {\n referenceId: entity.referenceId,\n },\n ...(promotionCodeId && {\n discounts: [{ promotion_code: promotionCodeId }],\n }),\n });\n\n return json({\n url: checkoutSession.url!,\n redirect: true,\n sessionId: checkoutSession.id,\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/subscription/cancel\",\n inputSchema: z.object({\n returnUrl: z.url().describe(\"URL to redirect to after cancellation is complete\"),\n subscriptionId: z\n .string()\n .optional()\n .describe(\"Which subscription to cancel, if there are multiple active subscriptions\"),\n }),\n outputSchema: z.object({\n url: z.url().describe(\"URL to redirect to after cancellation\"),\n redirect: z.boolean().describe(\"Whether to redirect to the URL\"),\n }),\n errorCodes: [\n \"SUBSCRIPTION_NOT_FOUND\",\n \"NO_SUBSCRIPTION_TO_CANCEL\",\n \"SUBSCRIPTION_ALREADY_CANCELED\",\n \"NO_STRIPE_CUSTOMER_LINKED\",\n \"MULTIPLE_SUBSCRIPTIONS_FOUND\",\n ] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const { stripeCustomerId } = await config.resolveEntityFromRequest(context);\n\n if (!stripeCustomerId) {\n return error(\n { message: \"No stripe customer linked to entity\", code: \"NO_STRIPE_CUSTOMER_LINKED\" },\n 400,\n );\n }\n\n let activeSubscriptions = (\n await services.getSubscriptionsByStripeCustomerId(stripeCustomerId)\n ).filter((s) => s.status === \"active\");\n\n // A specific active subscription was requested\n if (body.subscriptionId) {\n activeSubscriptions = activeSubscriptions.filter((s) => s.id === body.subscriptionId);\n }\n\n if (activeSubscriptions.length === 0) {\n return error(\n { message: \"No active subscription to cancel\", code: \"NO_SUBSCRIPTION_TO_CANCEL\" },\n 404,\n );\n }\n\n if (activeSubscriptions.length > 1) {\n return error(\n {\n message: \"Multiple active subscriptions found\",\n code: \"MULTIPLE_SUBSCRIPTIONS_FOUND\",\n },\n 400,\n );\n }\n\n const activeSubscription = activeSubscriptions[0];\n\n try {\n // Get active subscriptions from Stripe for this customer\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(\n activeSubscription.stripeSubscriptionId,\n );\n\n if (!stripeSubscription) {\n return error(\n {\n message: \"Active subscription not found in Stripe\",\n code: \"SUBSCRIPTION_NOT_FOUND\",\n },\n 404,\n );\n }\n\n // Check if subscription is already set to cancel at period end\n if (stripeSubscription.cancel_at_period_end) {\n // Already scheduled for cancellation, just return success\n return json({\n url: \"\", // No redirect needed\n redirect: false,\n });\n }\n\n // Create billing portal session for cancellation\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: activeSubscription.stripeCustomerId!,\n return_url: body.returnUrl,\n flow_data: {\n type: \"subscription_cancel\",\n subscription_cancel: {\n subscription: stripeSubscription.id,\n },\n after_completion: {\n type: \"redirect\",\n redirect: {\n return_url: body.returnUrl,\n },\n },\n },\n });\n\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (err: unknown) {\n throw stripeToApiError(err);\n }\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const ProductResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"product\"),\n active: z.boolean(),\n created: z.number(),\n default_price: z.union([z.string(), z.any()]).nullable().optional(),\n deleted: z.void().optional(),\n description: z.string().nullable(),\n images: z.array(z.string()),\n livemode: z.boolean(),\n marketing_features: z.array(z.any()),\n metadata: z.any(),\n name: z.string(),\n package_dimensions: z.any().nullable(),\n shippable: z.boolean().nullable(),\n statement_descriptor: z.string().nullable().optional(),\n tax_code: z.union([z.string(), z.any()]).nullable(),\n type: z.string(),\n unit_label: z.string().nullable().optional(),\n updated: z.number(),\n url: z.string().nullable(),\n});\n\nexport type ProductResponseSchema = z.infer<typeof ProductResponseSchema>;\n","import { z } from \"zod\";\nimport { ProductResponseSchema } from \"../models/products\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const productsRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/products\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of products to return (max 100)\"),\n startingAfter: z.string().optional().describe(\"Product ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n products: z.array(ProductResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more items to fetch\"),\n }),\n handler: async ({ query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const products = await deps.stripe.products.list({\n limit,\n starting_after: startingAfter,\n });\n\n return json({\n products: products.data,\n hasMore: products.has_more,\n });\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const PriceResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"price\"),\n active: z.boolean(),\n billing_scheme: z.string(),\n created: z.number(),\n currency: z.string(),\n custom_unit_amount: z.any().nullable().optional(),\n deleted: z.void().optional(),\n livemode: z.boolean(),\n lookup_key: z.string().nullable().optional(),\n metadata: z.any(),\n nickname: z.string().nullable().optional(),\n product: z.union([z.string(), z.any()]),\n recurring: z\n .object({\n aggregate_usage: z.string().nullable().optional(),\n interval: z.enum([\"day\", \"week\", \"month\", \"year\"]),\n interval_count: z.number(),\n meter: z.string().nullable().optional(),\n trial_period_days: z.number().nullable().optional(),\n usage_type: z.string(),\n })\n .nullable()\n .optional(),\n tax_behavior: z.string().nullable().optional(),\n tiers_mode: z.string().nullable().optional(),\n transform_quantity: z.any().nullable().optional(),\n type: z.enum([\"one_time\", \"recurring\"]),\n unit_amount: z.number().nullable().optional(),\n unit_amount_decimal: z.string().nullable().optional(),\n});\n\nexport type PriceResponseSchema = z.infer<typeof PriceResponseSchema>;\n","import { z } from \"zod\";\nimport { PriceResponseSchema } from \"../models/prices\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const pricesRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/products/:productId/prices\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of prices to return (max 100)\"),\n startingAfter: z.string().optional().describe(\"Price ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n prices: z.array(PriceResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more items to fetch\"),\n }),\n handler: async ({ pathParams, query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const { productId } = pathParams;\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const prices = await deps.stripe.prices.list({\n product: productId,\n limit,\n starting_after: startingAfter,\n });\n\n return json({\n prices: prices.data,\n hasMore: prices.has_more,\n });\n },\n }),\n ];\n },\n);\n","import { createClientBuilder } from \"@fragno-dev/core/client\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\nimport type { FragnoPublicConfigWithDatabase } from \"@fragno-dev/db\";\nimport type { StripeFragmentConfig } from \"./types\";\nimport { stripeFragmentDefinition } from \"./definition\";\nimport { webhookRoutesFactory } from \"./routes/webhooks\";\nimport { customersRoutesFactory } from \"./routes/customers\";\nimport { subscriptionsRoutesFactory } from \"./routes/subscriptions\";\nimport { productsRoutesFactory } from \"./routes/products\";\nimport { pricesRoutesFactory } from \"./routes/prices\";\nimport { instantiate } from \"@fragno-dev/core\";\n\nconst routes = [\n webhookRoutesFactory,\n customersRoutesFactory,\n subscriptionsRoutesFactory,\n productsRoutesFactory,\n pricesRoutesFactory,\n] as const;\n\nexport function createStripeFragment(\n config: StripeFragmentConfig,\n fragnoConfig: FragnoPublicConfigWithDatabase,\n) {\n return instantiate(stripeFragmentDefinition)\n .withConfig(config)\n .withRoutes(routes)\n .withOptions(fragnoConfig)\n .build();\n}\n\nexport function createStripeFragmentClients(fragnoConfig: FragnoPublicClientConfig = {}) {\n const builder = createClientBuilder(stripeFragmentDefinition, fragnoConfig, routes);\n\n return {\n // These hooks are for building internal administrative interfaces\n useCustomers: builder.createHook(\"/admin/customers\"),\n useProducts: builder.createHook(\"/admin/products\"),\n usePrices: builder.createHook(\"/admin/products/:productId/prices\"),\n useSubscription: builder.createHook(\"/admin/subscriptions\"),\n // Billing Portal for stripe customer\n useBillingPortal: builder.createMutator(\"POST\", \"/portal\"),\n // These clients are for end-users to create/update/cancel their subscriptions\n upgradeSubscription: builder.createMutator(\"POST\", \"/subscription/upgrade\"),\n cancelSubscription: builder.createMutator(\"POST\", \"/subscription/cancel\"),\n };\n}\n\nexport { stripeFragmentDefinition } from \"./definition\";\nexport type {\n StripeFragmentConfig,\n StripeFragmentDeps,\n StripeFragmentServices,\n Logger,\n} from \"./types\";\nexport type { FragnoRouteConfig } from \"@fragno-dev/core\";\n"],"mappings":";;;;;;;;;;;;AAKA,MAAa,eAAe,OAAO,CAAC,MAAM;AACxC,QAAO,EAAE,SAAS,gBAAgB,CAAC,MAAM;AACvC,SACE,EACG,UAAU,MAAM,UAAU,CAAC,CAE3B,UAAU,eAAe,OAAO,SAAS,CAAC,UAAU,CAAC,CACrD,UA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EAAC;AAEF,UAAO,KAAK;IACV,QAAQ,OAAO;IACf,SAAS,OAAO;GACjB,EAAC;EACH;CACF,EAAC,AACH;AACF,EACF;;;;ACrCD,MAAM,SAAS;CACb;CACA;CACA;CACA;CACA;AACD;AAED,SAAgB,qBACdC,QACAC,cACA;AACA,QAAO,YAAY,yBAAyB,CACzC,WAAW,OAAO,CAClB,WAAW,OAAO,CAClB,YAAY,aAAa,CACzB,OAAO;AACX;AAED,SAAgB,4BAA4BC,eAAyC,CAAE,GAAE;CACvF,MAAM,UAAU,oBAAoB,0BAA0B,cAAc,OAAO;AAEnF,QAAO;EAEL,cAAc,QAAQ,WAAW,mBAAmB;EACpD,aAAa,QAAQ,WAAW,kBAAkB;EAClD,WAAW,QAAQ,WAAW,oCAAoC;EAClE,iBAAiB,QAAQ,WAAW,uBAAuB;EAE3D,kBAAkB,QAAQ,cAAc,QAAQ,UAAU;EAE1D,qBAAqB,QAAQ,cAAc,QAAQ,wBAAwB;EAC3E,oBAAoB,QAAQ,cAAc,QAAQ,uBAAuB;CAC1E;AACF"}
1
+ {"version":3,"file":"index.js","names":["s: number | undefined | null","x: string | { id: string }","stripeSubscription: Stripe.Subscription","defaultLogger: Logger","subscription: T","deps: StripeFragmentDeps","db: SimpleQueryInterface<typeof stripeSchema>","services: StripeFragmentServices","data: Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"createdAt\" | \"updatedAt\"\n >","id: string","data: Partial<Omit<TableToInsertValues<typeof stripeSchema.tables.subscription>, \"id\">>","stripeSubscriptionId: string","stripeCustomerId: string","referenceId: string","args: StripeEventHandler","eventToHandler: Record<\n SupportedStripeEvent,\n (args: StripeEventHandler) => Promise<void>\n>","event: Stripe.Event","error: unknown","err: unknown","customerId: string | undefined","existingSubscription: SubscriptionResponse | null","error","promotionCodeId: string | undefined","error: unknown","err: unknown","config: StripeFragmentConfig","fragnoConfig: FragnoPublicConfigWithDatabase","fragnoConfig: FragnoPublicClientConfig"],"sources":["../../src/database/schema.ts","../../src/utils.ts","../../src/definition.ts","../../src/webhook/handlers.ts","../../src/routes/webhooks.ts","../../src/models/customers.ts","../../src/routes/errors.ts","../../src/routes/customers.ts","../../src/models/subscriptions.ts","../../src/routes/subscriptions.ts","../../src/models/products.ts","../../src/routes/products.ts","../../src/models/prices.ts","../../src/routes/prices.ts","../../src/index.ts"],"sourcesContent":["import { schema, idColumn, column } from \"@fragno-dev/db/schema\";\n\n/**\n * Database schema for subscriptions that are linked to external stripe subscriptions.\n */\nexport const stripeSchema = schema((s) => {\n return s.addTable(\"subscription\", (t) => {\n return (\n t\n .addColumn(\"id\", idColumn())\n // referenceId: entity to which this subscription applies (i.e. userId), nullable because unset on subscription updates\n .addColumn(\"referenceId\", column(\"string\").nullable())\n .addColumn(\"stripePriceId\", column(\"string\"))\n .addColumn(\"stripeCustomerId\", column(\"string\"))\n .addColumn(\"stripeSubscriptionId\", column(\"string\"))\n .addColumn(\"status\", column(\"string\").defaultTo(\"incomplete\")) // Stripe.Subscription.Status\n .addColumn(\"periodStart\", column(\"timestamp\").nullable())\n .addColumn(\"periodEnd\", column(\"timestamp\").nullable())\n .addColumn(\"trialStart\", column(\"timestamp\").nullable())\n .addColumn(\"trialEnd\", column(\"timestamp\").nullable())\n .addColumn(\"cancelAtPeriodEnd\", column(\"bool\").defaultTo(false))\n .addColumn(\"cancelAt\", column(\"timestamp\").nullable())\n .addColumn(\"seats\", column(\"integer\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .addColumn(\n \"updatedAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_stripe_customer_id\", [\"stripeCustomerId\"])\n .createIndex(\"idx_stripe_subscription_id\", [\"stripeSubscriptionId\"])\n .createIndex(\"idx_reference_id\", [\"referenceId\"])\n );\n });\n});\n","import type Stripe from \"stripe\";\nimport type { TableToInsertValues } from \"@fragno-dev/db/query\";\nimport type { stripeSchema } from \"./database/schema\";\n\nexport function toDate(s: number): Date;\nexport function toDate(s: undefined): undefined;\nexport function toDate(s: null): null;\nexport function toDate(s: number | null): Date | null;\nexport function toDate(s: number | undefined | null): Date | undefined | null {\n return s !== undefined && s !== null ? new Date(s * 1000) : s;\n}\n\nexport function getId(x: string | { id: string }): string {\n return typeof x === \"string\" ? x : x.id;\n}\n\n/**\n * Maps a Stripe.Subscription to the internal subscription schema.\n */\nexport function stripeSubscriptionToInternalSubscription(\n stripeSubscription: Stripe.Subscription,\n): Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"updatedAt\" | \"referenceId\"\n> {\n const firstItem = stripeSubscription.items.data[0];\n\n if (!firstItem) {\n // It should be impossible for a subscription to have no items (CITATION NEEDED)\n throw new Error(\"Subscription contains no items\");\n }\n\n const priceId = getId(firstItem.price);\n const customerId = getId(stripeSubscription.customer);\n\n return {\n stripePriceId: priceId,\n stripeCustomerId: customerId,\n stripeSubscriptionId: stripeSubscription.id,\n status: stripeSubscription.status,\n periodStart: toDate(firstItem.current_period_start),\n periodEnd: toDate(firstItem.current_period_end),\n trialStart: toDate(stripeSubscription.trial_start),\n trialEnd: toDate(stripeSubscription.trial_end),\n cancelAtPeriodEnd: stripeSubscription.cancel_at_period_end ?? false,\n cancelAt: toDate(stripeSubscription.cancel_at),\n createdAt: toDate(stripeSubscription.created),\n seats: firstItem.quantity ?? null,\n };\n}\n","import Stripe from \"stripe\";\nimport type { SimpleQueryInterface, TableToInsertValues } from \"@fragno-dev/db/query\";\nimport type {\n Logger,\n StripeFragmentConfig,\n StripeFragmentDeps,\n StripeFragmentServices,\n} from \"./types\";\nimport { stripeSchema } from \"./database/schema\";\nimport { defineFragment } from \"@fragno-dev/core\";\nimport { withDatabase } from \"@fragno-dev/db\";\nimport { stripeSubscriptionToInternalSubscription } from \"./utils\";\n\nconst LOG_PREFIX = \"[Stripe Fragment]\";\nconst defaultLogger: Logger = {\n info: (...data) => console.info(LOG_PREFIX, ...data),\n error: (...data) => console.error(LOG_PREFIX, ...data),\n warn: (...data) => console.warn(LOG_PREFIX, ...data),\n debug: (...data) => console.debug(LOG_PREFIX, ...data),\n log: (...data) => console.log(LOG_PREFIX, ...data),\n};\n\nconst asExternalSubscription = <T extends { id: { externalId: string }; status: string }>(\n subscription: T,\n) => ({\n ...subscription,\n id: subscription.id.externalId,\n status: subscription.status as Stripe.Subscription.Status,\n});\n\nfunction createStripeServices(\n deps: StripeFragmentDeps,\n db: SimpleQueryInterface<typeof stripeSchema>,\n): StripeFragmentServices {\n const services: StripeFragmentServices = {\n getStripeClient(): Stripe {\n return deps.stripe;\n },\n createSubscription: async (\n data: Omit<\n TableToInsertValues<typeof stripeSchema.tables.subscription>,\n \"id\" | \"createdAt\" | \"updatedAt\"\n >,\n ) => {\n return (await db.create(\"subscription\", data)).externalId;\n },\n updateSubscription: async (\n id: string,\n data: Partial<Omit<TableToInsertValues<typeof stripeSchema.tables.subscription>, \"id\">>,\n ) => {\n await db.update(\"subscription\", id, (b) => b.set({ ...data, updatedAt: new Date() }));\n },\n\n getSubscriptionByStripeId: async (stripeSubscriptionId: string) => {\n const result = await db.findFirst(\"subscription\", (b) =>\n b.whereIndex(\"idx_stripe_subscription_id\", (eb) =>\n eb(\"stripeSubscriptionId\", \"=\", stripeSubscriptionId),\n ),\n );\n if (!result) {\n return null;\n }\n\n return asExternalSubscription(result);\n },\n getSubscriptionsByStripeCustomerId: async (stripeCustomerId: string) => {\n return (\n await db.find(\"subscription\", (b) =>\n b.whereIndex(\"idx_stripe_customer_id\", (eb) =>\n eb(\"stripeCustomerId\", \"=\", stripeCustomerId),\n ),\n )\n ).map(asExternalSubscription);\n },\n getSubscriptionById: async (id: string) => {\n const result = await db.findFirst(\"subscription\", (b) =>\n b.whereIndex(\"primary\", (eb) => eb(\"id\", \"=\", id)),\n );\n if (!result) {\n return null;\n }\n return asExternalSubscription(result);\n },\n getSubscriptionsByReferenceId: async (referenceId: string) => {\n const result = await db.find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n if (result.length == 0) {\n return [];\n }\n return result.map(asExternalSubscription);\n },\n\n deleteSubscription: async (id: string) => {\n await db.delete(\"subscription\", id);\n },\n\n deleteSubscriptionsByReferenceId: async (referenceId: string) => {\n const uow = db\n .createUnitOfWork()\n .find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n\n const [subscriptions] = await uow.executeRetrieve();\n subscriptions.forEach((sub) => sub && uow.delete(\"subscription\", sub.id));\n\n return await uow.executeMutations();\n },\n\n getAllSubscriptions: async () => {\n return (await db.find(\"subscription\", (b) => b.whereIndex(\"primary\"))).map(\n asExternalSubscription,\n );\n },\n\n /* Retrieve Stripe Subscription and create/update/delete internal entity */\n syncStripeSubscriptions: async (referenceId: string, stripeCustomerId: string) => {\n const stripeSubscriptions = await deps.stripe.subscriptions.list({\n customer: stripeCustomerId,\n status: \"all\",\n });\n\n if (stripeSubscriptions.data.length === 0) {\n await services.deleteSubscriptionsByReferenceId(referenceId);\n return { success: true };\n }\n\n const uow = db\n .createUnitOfWork()\n .find(\"subscription\", (b) =>\n b.whereIndex(\"idx_reference_id\", (eb) => eb(\"referenceId\", \"=\", referenceId)),\n );\n\n const [existingSubscriptions] = await uow.executeRetrieve();\n\n // Mutation phase: process all Stripe subscriptions (including canceled)\n for (const stripeSubscription of stripeSubscriptions.data) {\n const existingSubscription = existingSubscriptions.find(\n (sub) => sub.stripeSubscriptionId === stripeSubscription.id,\n );\n\n if (existingSubscription) {\n // Update existing subscription with optimistic concurrency control\n uow.update(\"subscription\", existingSubscription.id, (b) =>\n b\n .set({\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n updatedAt: new Date(),\n })\n .check(),\n );\n } else {\n // Create new subscription\n uow.create(\"subscription\", {\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: referenceId ?? null,\n updatedAt: new Date(),\n });\n }\n }\n\n // Execute all mutations and return result\n return uow.executeMutations();\n },\n };\n return services;\n}\n\nexport const stripeFragmentDefinition = defineFragment<StripeFragmentConfig>(\"stripe\")\n .extend(withDatabase(stripeSchema))\n .withDependencies(({ config }) => {\n const stripeClient = new Stripe(config.stripeSecretKey, config.stripeClientOptions ?? {});\n\n return {\n stripe: stripeClient,\n log: config.logger ? config.logger : defaultLogger,\n };\n })\n .providesBaseService(({ deps }) => {\n return {\n ...createStripeServices(deps, deps.db),\n };\n })\n .build();\n","import type { Stripe } from \"stripe\";\nimport type { StripeFragmentConfig, StripeFragmentDeps, StripeFragmentServices } from \"../types\";\nimport { FragnoApiError } from \"@fragno-dev/core/api\";\nimport { getId, stripeSubscriptionToInternalSubscription } from \"../utils\";\n\nexport interface StripeEventHandler {\n event: Stripe.Event;\n services: StripeFragmentServices;\n deps: StripeFragmentDeps;\n config: StripeFragmentConfig;\n}\n\n// https://docs.stripe.com/api/events/types\nexport type SupportedStripeEvent =\n | \"checkout.session.completed\"\n | \"customer.subscription.deleted\"\n | \"customer.subscription.updated\"\n | \"customer.subscription.paused\"\n | \"customer.subscription.created\"\n | \"customer.subscription.pending_update_applied\"\n | \"customer.subscription.pending_update_expired\"\n | \"customer.subscription.resumed\"\n | \"customer.subscription.trial_will_end\";\n// TODO: for customer tracking\n// | \"customer.updated\"\n// TODO: for stripe product payment tracking\n// | \"invoice.marked_uncollectible\"\n// | \"invoice.paid\"\n// | \"invoice.payment_action_required\"\n// | \"invoice.payment_failed\"\n// | \"invoice.payment_succeeded\"\n// | \"invoice.upcoming\"\n// | \"payment_intent.canceled\"\n// | \"payment_intent.payment_failed\"\n// | \"payment_intent.succeeded\";\n\n/**\n * Event Handler for checkout.session.completed\n *\n * This handler is ONLY for subscription checkout sessions.\n * Occurs when a Checkout Session has been successfully completed.\n */\nexport async function checkoutSessionCompletedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n const checkoutSession = event.data.object as Stripe.Checkout.Session;\n\n // Skip if this is not a subscription session\n if (checkoutSession.mode !== \"subscription\") {\n deps.log.info(`Not handling checkout session with mode ${checkoutSession.mode}: ${event.id}`);\n return;\n }\n\n const subscriptionId = checkoutSession.subscription;\n if (typeof subscriptionId !== \"string\") {\n deps.log.error(\"No subscription ID in checkout session\");\n return;\n }\n\n // Retrieve the full subscription details from Stripe\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(subscriptionId);\n\n // Extract customer ID\n const customerId = getId(stripeSubscription.customer);\n\n // Extract subscription details from first item\n const firstItem = stripeSubscription.items.data[0];\n if (!firstItem) {\n deps.log.error(\"No subscription items found\");\n return;\n }\n\n // Get referenceId from checkout session (client_reference_id or metadata)\n const referenceId =\n checkoutSession.metadata?.[\"referenceId\"] || checkoutSession.client_reference_id;\n\n // Get existing subscription ID from metadata (if updating an existing one)\n const existingSubscriptionId = checkoutSession.metadata?.[\"subscriptionId\"];\n\n const subscriptionData = {\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: referenceId ?? null,\n };\n\n // If we have an existing subscription ID, try to update it\n if (existingSubscriptionId) {\n await services.updateSubscription(existingSubscriptionId, subscriptionData);\n deps.log.info(`Updated subscription ${existingSubscriptionId} for customer ${customerId}`);\n return;\n }\n\n // Otherwise, check if subscription already exists by Stripe subscription ID\n const existing = await services.getSubscriptionByStripeId(stripeSubscription.id);\n if (existing) {\n // TODO: update that subscription's data?\n deps.log.info(`Subscription already exists for Stripe ID ${stripeSubscription.id}`);\n return;\n }\n\n // Create new subscription record\n const createdSubscriptionId = await services.createSubscription(subscriptionData);\n deps.log.info(\n `Created subscription ${createdSubscriptionId} for customer ${customerId} (Stripe ID: ${stripeSubscription.id})`,\n );\n}\n\n/**\n * Event Handler for customer.subscription.paused\n *\n * Occurs whenever a customer’s subscription is paused. Only applies when\n * subscriptions enter status=paused, not when payment collection is paused.\n *\n * PAUSED status: The subscription has ended its trial period without a default\n * payment method and the trial_settings.end_behavior.missing_payment_method is set\n * to pause. Invoices are no longer created for the subscription. After attaching a\n * default payment method to the customer, you can resume the subscription.\n */\nexport async function customerSubscriptionPausedHandler(args: StripeEventHandler) {\n // As far as I can tell, this only sets the status of a subscription to paused and nothing else.\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.pending_update_applied\n *\n * Occurs whenever a customer’s subscription’s pending update is applied,\n * and the subscription is updated.\n */\nexport async function customerSubscriptionPendingUpdateAppliedHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.pending_update_expired\n *\n * Occurs whenever a customer’s subscription’s pending update expires\n * before the related invoice is paid.\n */\nexport async function customerSubscriptionPendingUpdateExpiredHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.resumed\n *\n * Occurs whenever a customer’s subscription is no longer paused.\n * Only applies when a status=paused subscription is resumed, not when payment\n * collection is resumed.\n */\nexport async function customerSubscriptionResumedHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.trial_will_end\n *\n * Occurs three days before a subscription's trial period is scheduled to end,\n * or when a trial is ended immediately (using trial_end=now). This event allows\n * you to send reminders or take action before the trial expires.\n */\nexport async function customerSubscriptionTrialWillEndHandler(args: StripeEventHandler) {\n return customerSubscriptionUpdatedHandler(args);\n}\n\n/**\n * Event Handler for customer.subscription.updated\n *\n * Occurs whenever a subscription changes (e.g., switching from one plan to another,\n * or changing the status from trial to active).\n */\nexport async function customerSubscriptionUpdatedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n deps.log.info(`Processing ${event.type}: ${event.id}`);\n\n const stripeSubscription = event.data.object as Stripe.Subscription;\n\n const firstItem = stripeSubscription.items?.data?.[0];\n if (!firstItem) {\n throw new FragnoApiError(\n { message: \"Subscription contains no items\", code: \"EMPTY_SUBSCRIPTION\" },\n 400,\n );\n }\n\n const customerId = getId(stripeSubscription.customer);\n\n // Try to find existing subscription\n let subscription = await services.getSubscriptionByStripeId(stripeSubscription.id);\n\n // If not found by Stripe ID, try to find by customer ID\n if (!subscription) {\n const customerSubs = await services.getSubscriptionsByStripeCustomerId(customerId);\n\n if (customerSubs.length > 1) {\n subscription =\n customerSubs.find((sub) => sub.status === \"active\" || sub.status === \"trialing\") ?? null;\n\n if (!subscription) {\n deps.log.warn(\n `Multiple subscriptions found for customer ${customerId} but none active or trialing`,\n );\n return;\n }\n } else {\n subscription = customerSubs[0] ?? null;\n }\n }\n\n if (!subscription) {\n deps.log.warn(\n `No subscription found for Stripe ID ${stripeSubscription.id}, creating new record`,\n );\n\n const createdSubscriptionId = await services.createSubscription({\n ...stripeSubscriptionToInternalSubscription(stripeSubscription),\n referenceId: stripeSubscription.metadata?.[\"referenceId\"] ?? null,\n });\n\n deps.log.info(\n `Created subscription ${createdSubscriptionId} for customer ${customerId} (Stripe ID: ${stripeSubscription.id})`,\n );\n return;\n }\n\n await services.updateSubscription(\n subscription.id,\n stripeSubscriptionToInternalSubscription(stripeSubscription),\n );\n\n deps.log.info(`Updated subscription ${subscription.id} (Stripe ID: ${stripeSubscription.id})`);\n}\n\n/**\n * Event Handler for customer.subscription.deleted\n *\n * Occurs whenever a customer's subscription ends.\n */\nexport async function customerSubscriptionDeletedHandler({\n event,\n services,\n deps,\n}: StripeEventHandler) {\n deps.log.info(`Processing customer.subscription.deleted: ${event.id}`);\n\n const stripeSubscription = event.data.object as Stripe.Subscription;\n\n // Find existing subscription\n const subscription = await services.getSubscriptionByStripeId(stripeSubscription.id);\n\n if (!subscription) {\n deps.log.warn(`No subscription found for Stripe ID ${stripeSubscription.id}`);\n return;\n }\n\n // Update status to canceled\n await services.updateSubscription(subscription.id, {\n status: \"canceled\",\n });\n\n deps.log.info(\n `Marked subscription ${subscription.id} as canceled (Stripe ID: ${stripeSubscription.id})`,\n );\n}\n\nexport const eventToHandler: Record<\n SupportedStripeEvent,\n (args: StripeEventHandler) => Promise<void>\n> = {\n \"checkout.session.completed\": checkoutSessionCompletedHandler,\n \"customer.subscription.deleted\": customerSubscriptionDeletedHandler,\n \"customer.subscription.created\": customerSubscriptionUpdatedHandler,\n \"customer.subscription.updated\": customerSubscriptionUpdatedHandler,\n \"customer.subscription.paused\": customerSubscriptionPausedHandler,\n \"customer.subscription.pending_update_applied\": customerSubscriptionPendingUpdateAppliedHandler,\n \"customer.subscription.pending_update_expired\": customerSubscriptionPendingUpdateExpiredHandler,\n \"customer.subscription.resumed\": customerSubscriptionResumedHandler,\n \"customer.subscription.trial_will_end\": customerSubscriptionTrialWillEndHandler,\n};\n","import { z } from \"zod\";\nimport Stripe from \"stripe\";\nimport { eventToHandler, type SupportedStripeEvent } from \"../webhook/handlers\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const webhookRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ config, deps, services, defineRoute }) => {\n return [\n defineRoute({\n method: \"POST\",\n path: \"/webhook\",\n outputSchema: z.object({\n success: z.boolean(),\n }),\n errorCodes: [\"MISSING_SIGNATURE\", \"WEBHOOK_SIGNATURE_INVALID\", \"WEBHOOK_ERROR\"] as const,\n handler: async ({ headers, rawBody }, { json, error }) => {\n // Get the signature\n const signature = headers.get(\"stripe-signature\");\n\n if (!signature) {\n return error(\n { message: \"Missing stripe-signature header\", code: \"MISSING_SIGNATURE\" },\n 400,\n );\n }\n\n if (!rawBody) {\n return error(\n { message: \"Missing request body for webhook verification\", code: \"WEBHOOK_ERROR\" },\n 400,\n );\n }\n\n // Verify the webhook signature\n let event: Stripe.Event;\n try {\n // Support both Stripe v18 (constructEvent) and v19+ (constructEventAsync)\n if (typeof deps.stripe.webhooks.constructEventAsync === \"function\") {\n // Stripe v19+ - use async method\n event = await deps.stripe.webhooks.constructEventAsync(\n rawBody,\n signature,\n config.webhookSecret,\n );\n } else {\n // Stripe v18 - use sync method\n event = deps.stripe.webhooks.constructEvent(rawBody, signature, config.webhookSecret);\n }\n } catch (err) {\n if (err instanceof Stripe.errors.StripeSignatureVerificationError) {\n return error(\n {\n message: `Webhook signature verification failed`,\n code: \"WEBHOOK_SIGNATURE_INVALID\",\n },\n 400,\n );\n }\n throw err;\n }\n\n if (!event) {\n return error({ message: \"Failed to construct event\", code: \"WEBHOOK_ERROR\" }, 400);\n }\n\n if (config.onEvent) {\n deps.log.info(\"Running user callback event\");\n await config.onEvent({ event, stripeClient: deps.stripe });\n }\n\n const eventHandler = eventToHandler[event.type as SupportedStripeEvent];\n if (!eventHandler) {\n deps.log.info(`Webhook event ${event.type}: ${event.id} ignored`);\n return json({ success: true });\n }\n\n deps.log.info(`Executing event handler for ${event.type}: ${event.id}`);\n await eventHandler({ event, services, deps, config });\n\n return json({ success: true });\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const CustomerResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"customer\"),\n balance: z.number(),\n business_name: z.string().optional(),\n created: z.number(),\n currency: z.string().nullable().optional(),\n deleted: z.void().optional(),\n delinquent: z.boolean().nullable().optional(),\n description: z.string().nullable(),\n email: z.string().nullable(),\n individual_name: z.string().optional(),\n invoice_credit_balance: z.record(z.string(), z.number()).optional(),\n invoice_prefix: z.string().nullable().optional(),\n livemode: z.boolean(),\n metadata: z.record(z.string(), z.string()),\n name: z.string().nullable().optional(),\n next_invoice_sequence: z.number().optional(),\n phone: z.string().nullable().optional(),\n preferred_locales: z.array(z.string()).nullable().optional(),\n});\n\nexport type CustomerResponseSchema = z.infer<typeof CustomerResponseSchema>;\n","import { FragnoApiError } from \"@fragno-dev/core/api\";\n\nfunction isStripeError(error: unknown): error is { type: string; message: string; code: string } {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"type\" in error &&\n typeof error.type === \"string\" &&\n \"message\" in error &&\n typeof error.message === \"string\"\n );\n}\n\nexport function stripeToApiError(error: unknown): FragnoApiError | unknown {\n // Attempt to generate more ergnomic error messages\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"there are no changes to confirm\")\n ) {\n return new FragnoApiError(\n { message: \"Trying to upgrade to same subscription plan\", code: \"UPGRADE_HAS_NO_EFFECT\" },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"is already set to be canceled at period end\")\n ) {\n return new FragnoApiError(\n {\n message: \"Subscription is already set to be canceled at period end\",\n code: \"SUBSCRIPTION_ALREADY_CANCELED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\n \"the subscription update feature in the portal configuration is disabled\",\n )\n ) {\n return new FragnoApiError(\n {\n message: \"Subscription cannot be updated to this plan\",\n code: \"SUBSCRIPTION_UPDATE_NOT_ALLOWED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.message.includes(\"does not include `promotion_code`\")\n ) {\n return new FragnoApiError(\n {\n message: \"Cannot apply promotion code when updating subscription\",\n code: \"SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED\",\n },\n 500,\n );\n }\n\n if (\n isStripeError(error) &&\n error.type === \"StripeInvalidRequestError\" &&\n error.code == \"promotion_code_customer_not_first_time\"\n ) {\n return new FragnoApiError(\n {\n message: \"This promotion code cannot be redeemed because you have already used it before.\",\n code: \"PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME\",\n },\n 500,\n );\n }\n\n return error;\n}\n","import { z } from \"zod\";\nimport { CustomerResponseSchema } from \"../models/customers\";\nimport { stripeToApiError } from \"./errors\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const customersRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/customers\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of customers to return (max 100)\"),\n startingAfter: z\n .string()\n .optional()\n .describe(\"Customer ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n customers: z.array(CustomerResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more customers to fetch\"),\n }),\n handler: async ({ query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const customers = await deps.stripe.customers.list({\n limit,\n starting_after: startingAfter,\n });\n return json({\n customers: customers.data,\n hasMore: customers.has_more,\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/portal\",\n inputSchema: z.object({\n returnUrl: z.url().describe(\"URL to redirect to after completing billing portal\"),\n }),\n outputSchema: z.object({\n url: z.url().describe(\"URL to redirect to after cancellation\"),\n redirect: z.boolean().describe(\"Whether to redirect to the URL\"),\n }),\n errorCodes: [\"NO_STRIPE_CUSTOMER_FOR_ENTITY\"] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const { stripeCustomerId } = await config.resolveEntityFromRequest(context);\n\n if (!stripeCustomerId) {\n return error(\n {\n message: \"No stripe customer to create billing portal for\",\n code: \"NO_STRIPE_CUSTOMER_FOR_ENTITY\",\n },\n 400,\n );\n }\n\n try {\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: stripeCustomerId,\n return_url: body.returnUrl,\n });\n\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (err: unknown) {\n throw stripeToApiError(err);\n }\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const SubscriptionReponseSchema = z.object({\n id: z.string(),\n stripeSubscriptionId: z.string(),\n stripeCustomerId: z.string(),\n stripePriceId: z.string(),\n referenceId: z.string().nullable(),\n status: z.enum([\n \"active\",\n \"canceled\",\n \"incomplete\",\n \"incomplete_expired\",\n \"past_due\",\n \"paused\",\n \"trialing\",\n \"unpaid\",\n ]),\n periodStart: z.date().nullable(),\n periodEnd: z.date().nullable(),\n trialStart: z.date().nullable(),\n trialEnd: z.date().nullable(),\n cancelAtPeriodEnd: z.boolean().nullable(),\n cancelAt: z.date().nullable(),\n seats: z.number().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nexport const SubscriptionUpgradeRequestSchema = z.object({\n priceId: z.string().describe(\"Stripe price ID to subscribe/upgrade to\"),\n quantity: z.number().positive().describe(\"Number of seats\"),\n successUrl: z.url().describe(\"Redirect URL after successful checkout\"),\n cancelUrl: z.url().describe(\"Redirect URL if checkout is cancelled\"),\n returnUrl: z.string().optional().describe(\"Return URL for billing portal\"),\n promotionCode: z.string().optional().describe(\"Promotion code to apply\"),\n subscriptionId: z\n .string()\n .optional()\n .describe(\n \"Subscription ID to upgrade, if none provided assume the active subscription of the user.\",\n ),\n});\n\nexport type SubscriptionResponse = z.infer<typeof SubscriptionReponseSchema>;\n","import { z } from \"zod\";\nimport {\n SubscriptionReponseSchema,\n SubscriptionUpgradeRequestSchema,\n type SubscriptionResponse,\n} from \"../models/subscriptions\";\nimport { stripeToApiError } from \"./errors\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const subscriptionsRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, services, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/subscriptions\",\n outputSchema: z.object({\n subscriptions: z.array(SubscriptionReponseSchema),\n }),\n handler: async (_, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n // TODO: Implement pagination\n return json({\n subscriptions: await services.getAllSubscriptions(),\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/subscription/upgrade\",\n inputSchema: SubscriptionUpgradeRequestSchema,\n outputSchema: z.object({\n url: z.string(),\n redirect: z.boolean(),\n sessionId: z.string().optional(),\n }),\n errorCodes: [\n \"MISSING_CUSTOMER_INFO\",\n \"SUBSCRIPTION_NOT_FOUND\",\n \"CUSTOMER_SUBSCRIPTION_MISMATCH\",\n \"UPGRADE_HAS_NO_EFFECT\",\n \"SUBSCRIPTION_UPDATE_NOT_ALLOWED\",\n \"SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED\",\n \"PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME\",\n \"MULTIPLE_ACTIVE_SUBSCRIPTIONS\",\n \"NO_ACTIVE_SUBSCRIPTIONS\",\n ] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const entity = await config.resolveEntityFromRequest(context);\n\n let customerId: string | undefined = entity.stripeCustomerId;\n let existingSubscription: SubscriptionResponse | null = null;\n\n // Step 1: Get active subscriptions\n if (entity.stripeCustomerId) {\n const existingSubscriptions = await services.getSubscriptionsByStripeCustomerId(\n entity.stripeCustomerId,\n );\n\n // Cannot upgrade cancelled subscriptions\n let activeSubscriptions = existingSubscriptions.filter((s) => s.status !== \"canceled\");\n\n // A specific subscription has been specified\n if (body.subscriptionId) {\n activeSubscriptions = activeSubscriptions.filter((s) => s.id === body.subscriptionId);\n }\n\n if (activeSubscriptions.length > 1) {\n return error(\n {\n message:\n \"Multiple active subscriptions found for customer, please specify which subscription to upgrade\",\n code: \"MULTIPLE_ACTIVE_SUBSCRIPTIONS\",\n },\n 400,\n );\n }\n if (activeSubscriptions.length === 0) {\n return error(\n {\n message: \"No active subscriptions found for customer\",\n code: \"NO_ACTIVE_SUBSCRIPTIONS\",\n },\n 400,\n );\n }\n existingSubscription = activeSubscriptions[0];\n\n if (\n customerId &&\n existingSubscription.stripeCustomerId &&\n existingSubscription.stripeCustomerId !== customerId\n ) {\n return error(\n {\n message:\n \"Subsciption being updated does not belong to Stripe Customer that was provided\",\n code: \"CUSTOMER_SUBSCRIPTION_MISMATCH\",\n },\n 422,\n );\n }\n\n customerId = existingSubscription.stripeCustomerId;\n }\n\n // Step 2: Get or Create customer if not found\n if (!customerId) {\n const existingLinkedCustomer = await deps.stripe.customers.search({\n query: `metadata['referenceId']:'${entity.referenceId}'`,\n limit: 1,\n });\n\n if (existingLinkedCustomer.data.length === 1) {\n // Use existing customer\n customerId = existingLinkedCustomer.data[0].id;\n } else {\n // Create new Stripe Customer\n\n // Check if sufficient data is provided for this scenario\n if (!entity.customerEmail || !entity.referenceId) {\n return error({\n message:\n \"New Stripe Customer must be created, but customerEmail or referenceID has not been provided\",\n code: \"MISSING_CUSTOMER_INFO\",\n });\n }\n\n const newCustomer = await deps.stripe.customers.create({\n email: entity.customerEmail,\n metadata: {\n referenceId: entity.referenceId,\n ...entity.stripeMetadata,\n },\n });\n customerId = newCustomer.id;\n }\n\n // Communicate back to the user that a customer has been created/linked\n try {\n await config.onStripeCustomerCreated(customerId, entity.referenceId);\n } catch (error) {\n deps.log.error(\"onStripeCustomerCreated failed!\", error);\n }\n }\n\n // Step 3: Resolve promotion code to ID if provided\n let promotionCodeId: string | undefined = undefined;\n if (body.promotionCode) {\n const promotionCodes = await deps.stripe.promotionCodes.list({\n code: body.promotionCode,\n active: true,\n limit: 1,\n });\n if (promotionCodes.data.length > 0) {\n promotionCodeId = promotionCodes.data[0].id;\n }\n }\n\n // Step 4: If existing subscription is active, modify using billing portal\n if (\n existingSubscription?.status === \"active\" ||\n existingSubscription?.status === \"trialing\"\n ) {\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(\n existingSubscription.stripeSubscriptionId,\n );\n\n try {\n // when /upgrade is called on a subscription scheduled to cancel at the end of the billing period,\n // it is still \"active\" but it's not possible to renew it using a billing portal.\n if (existingSubscription.cancelAt != null) {\n deps.log.info(\"un-cancelling subscription\", stripeSubscription.id);\n\n await deps.stripe.subscriptions.update(stripeSubscription.id, {\n cancel_at_period_end: false,\n });\n\n return json({\n url: body.returnUrl || body.successUrl,\n redirect: true,\n });\n }\n // Portal session to confirm subscription changes\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: customerId,\n return_url: body.returnUrl || body.successUrl,\n flow_data: {\n type: \"subscription_update_confirm\",\n after_completion: {\n type: \"redirect\",\n redirect: {\n return_url: body.returnUrl || body.successUrl,\n },\n },\n subscription_update_confirm: {\n subscription: existingSubscription.stripeSubscriptionId,\n items: [\n {\n // We always create subscriptions with a single item\n id: stripeSubscription.items.data[0]?.id as string,\n quantity: body.quantity,\n price: body.priceId,\n },\n ],\n ...(promotionCodeId && {\n discounts: [{ promotion_code: promotionCodeId }],\n }),\n },\n },\n });\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (error: unknown) {\n throw stripeToApiError(error);\n }\n }\n\n // Step 5: Create a Subscription\n const checkoutSession = await deps.stripe.checkout.sessions.create({\n customer: customerId,\n success_url: body.successUrl,\n cancel_url: body.cancelUrl,\n line_items: [\n {\n price: body.priceId,\n quantity: body.quantity,\n },\n ],\n mode: \"subscription\",\n metadata: {\n referenceId: entity.referenceId,\n },\n ...(promotionCodeId && {\n discounts: [{ promotion_code: promotionCodeId }],\n }),\n });\n\n return json({\n url: checkoutSession.url!,\n redirect: true,\n sessionId: checkoutSession.id,\n });\n },\n }),\n defineRoute({\n method: \"POST\",\n path: \"/subscription/cancel\",\n inputSchema: z.object({\n returnUrl: z.url().describe(\"URL to redirect to after cancellation is complete\"),\n subscriptionId: z\n .string()\n .optional()\n .describe(\"Which subscription to cancel, if there are multiple active subscriptions\"),\n }),\n outputSchema: z.object({\n url: z.url().describe(\"URL to redirect to after cancellation\"),\n redirect: z.boolean().describe(\"Whether to redirect to the URL\"),\n }),\n errorCodes: [\n \"SUBSCRIPTION_NOT_FOUND\",\n \"NO_SUBSCRIPTION_TO_CANCEL\",\n \"SUBSCRIPTION_ALREADY_CANCELED\",\n \"NO_STRIPE_CUSTOMER_LINKED\",\n \"MULTIPLE_SUBSCRIPTIONS_FOUND\",\n ] as const,\n handler: async (context, { json, error }) => {\n const body = await context.input.valid();\n const { stripeCustomerId } = await config.resolveEntityFromRequest(context);\n\n if (!stripeCustomerId) {\n return error(\n { message: \"No stripe customer linked to entity\", code: \"NO_STRIPE_CUSTOMER_LINKED\" },\n 400,\n );\n }\n\n let activeSubscriptions = (\n await services.getSubscriptionsByStripeCustomerId(stripeCustomerId)\n ).filter((s) => s.status === \"active\");\n\n // A specific active subscription was requested\n if (body.subscriptionId) {\n activeSubscriptions = activeSubscriptions.filter((s) => s.id === body.subscriptionId);\n }\n\n if (activeSubscriptions.length === 0) {\n return error(\n { message: \"No active subscription to cancel\", code: \"NO_SUBSCRIPTION_TO_CANCEL\" },\n 404,\n );\n }\n\n if (activeSubscriptions.length > 1) {\n return error(\n {\n message: \"Multiple active subscriptions found\",\n code: \"MULTIPLE_SUBSCRIPTIONS_FOUND\",\n },\n 400,\n );\n }\n\n const activeSubscription = activeSubscriptions[0];\n\n try {\n // Get active subscriptions from Stripe for this customer\n const stripeSubscription = await deps.stripe.subscriptions.retrieve(\n activeSubscription.stripeSubscriptionId,\n );\n\n if (!stripeSubscription) {\n return error(\n {\n message: \"Active subscription not found in Stripe\",\n code: \"SUBSCRIPTION_NOT_FOUND\",\n },\n 404,\n );\n }\n\n // Check if subscription is already set to cancel at period end\n if (stripeSubscription.cancel_at_period_end) {\n // Already scheduled for cancellation, just return success\n return json({\n url: \"\", // No redirect needed\n redirect: false,\n });\n }\n\n // Create billing portal session for cancellation\n const portalSession = await deps.stripe.billingPortal.sessions.create({\n customer: activeSubscription.stripeCustomerId!,\n return_url: body.returnUrl,\n flow_data: {\n type: \"subscription_cancel\",\n subscription_cancel: {\n subscription: stripeSubscription.id,\n },\n after_completion: {\n type: \"redirect\",\n redirect: {\n return_url: body.returnUrl,\n },\n },\n },\n });\n\n return json({\n url: portalSession.url,\n redirect: true,\n });\n } catch (err: unknown) {\n throw stripeToApiError(err);\n }\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const ProductResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"product\"),\n active: z.boolean(),\n created: z.number(),\n default_price: z.union([z.string(), z.any()]).nullable().optional(),\n deleted: z.void().optional(),\n description: z.string().nullable(),\n images: z.array(z.string()),\n livemode: z.boolean(),\n marketing_features: z.array(z.any()),\n metadata: z.any(),\n name: z.string(),\n package_dimensions: z.any().nullable(),\n shippable: z.boolean().nullable(),\n statement_descriptor: z.string().nullable().optional(),\n tax_code: z.union([z.string(), z.any()]).nullable(),\n type: z.string(),\n unit_label: z.string().nullable().optional(),\n updated: z.number(),\n url: z.string().nullable(),\n});\n\nexport type ProductResponseSchema = z.infer<typeof ProductResponseSchema>;\n","import { z } from \"zod\";\nimport { ProductResponseSchema } from \"../models/products\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const productsRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/products\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of products to return (max 100)\"),\n startingAfter: z.string().optional().describe(\"Product ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n products: z.array(ProductResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more items to fetch\"),\n }),\n handler: async ({ query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const products = await deps.stripe.products.list({\n limit,\n starting_after: startingAfter,\n });\n\n return json({\n products: products.data,\n hasMore: products.has_more,\n });\n },\n }),\n ];\n },\n);\n","import { z } from \"zod\";\n\nexport const PriceResponseSchema = z.object({\n id: z.string(),\n object: z.literal(\"price\"),\n active: z.boolean(),\n billing_scheme: z.string(),\n created: z.number(),\n currency: z.string(),\n custom_unit_amount: z.any().nullable().optional(),\n deleted: z.void().optional(),\n livemode: z.boolean(),\n lookup_key: z.string().nullable().optional(),\n metadata: z.any(),\n nickname: z.string().nullable().optional(),\n product: z.union([z.string(), z.any()]),\n recurring: z\n .object({\n aggregate_usage: z.string().nullable().optional(),\n interval: z.enum([\"day\", \"week\", \"month\", \"year\"]),\n interval_count: z.number(),\n meter: z.string().nullable().optional(),\n trial_period_days: z.number().nullable().optional(),\n usage_type: z.string(),\n })\n .nullable()\n .optional(),\n tax_behavior: z.string().nullable().optional(),\n tiers_mode: z.string().nullable().optional(),\n transform_quantity: z.any().nullable().optional(),\n type: z.enum([\"one_time\", \"recurring\"]),\n unit_amount: z.number().nullable().optional(),\n unit_amount_decimal: z.string().nullable().optional(),\n});\n\nexport type PriceResponseSchema = z.infer<typeof PriceResponseSchema>;\n","import { z } from \"zod\";\nimport { PriceResponseSchema } from \"../models/prices\";\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { stripeFragmentDefinition } from \"../definition\";\n\nexport const pricesRoutesFactory = defineRoutes(stripeFragmentDefinition).create(\n ({ deps, config, defineRoute }) => {\n return [\n defineRoute({\n method: \"GET\",\n path: \"/admin/products/:productId/prices\",\n inputSchema: z.object({\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .default(50)\n .describe(\"Number of prices to return (max 100)\"),\n startingAfter: z.string().optional().describe(\"Price ID to start after for pagination\"),\n }),\n outputSchema: z.object({\n prices: z.array(PriceResponseSchema),\n hasMore: z.boolean().describe(\"Whether there are more items to fetch\"),\n }),\n handler: async ({ pathParams, query }, { json, error }) => {\n if (!config.enableAdminRoutes) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const { productId } = pathParams;\n const limit = Number(query.get(\"limit\")) || undefined;\n const startingAfter = query.get(\"startingAfter\") || undefined;\n\n const prices = await deps.stripe.prices.list({\n product: productId,\n limit,\n starting_after: startingAfter,\n });\n\n return json({\n prices: prices.data,\n hasMore: prices.has_more,\n });\n },\n }),\n ];\n },\n);\n","import { createClientBuilder } from \"@fragno-dev/core/client\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\nimport type { FragnoPublicConfigWithDatabase } from \"@fragno-dev/db\";\nimport type { StripeFragmentConfig } from \"./types\";\nimport { stripeFragmentDefinition } from \"./definition\";\nimport { webhookRoutesFactory } from \"./routes/webhooks\";\nimport { customersRoutesFactory } from \"./routes/customers\";\nimport { subscriptionsRoutesFactory } from \"./routes/subscriptions\";\nimport { productsRoutesFactory } from \"./routes/products\";\nimport { pricesRoutesFactory } from \"./routes/prices\";\nimport { instantiate } from \"@fragno-dev/core\";\n\nconst routes = [\n webhookRoutesFactory,\n customersRoutesFactory,\n subscriptionsRoutesFactory,\n productsRoutesFactory,\n pricesRoutesFactory,\n] as const;\n\nexport function createStripeFragment(\n config: StripeFragmentConfig,\n fragnoConfig: FragnoPublicConfigWithDatabase,\n) {\n return instantiate(stripeFragmentDefinition)\n .withConfig(config)\n .withRoutes(routes)\n .withOptions(fragnoConfig)\n .build();\n}\n\nexport function createStripeFragmentClients(fragnoConfig: FragnoPublicClientConfig = {}) {\n const builder = createClientBuilder(stripeFragmentDefinition, fragnoConfig, routes);\n\n return {\n // These hooks are for building internal administrative interfaces\n useCustomers: builder.createHook(\"/admin/customers\"),\n useProducts: builder.createHook(\"/admin/products\"),\n usePrices: builder.createHook(\"/admin/products/:productId/prices\"),\n useSubscription: builder.createHook(\"/admin/subscriptions\"),\n // Billing Portal for stripe customer\n useBillingPortal: builder.createMutator(\"POST\", \"/portal\"),\n // These clients are for end-users to create/update/cancel their subscriptions\n upgradeSubscription: builder.createMutator(\"POST\", \"/subscription/upgrade\"),\n cancelSubscription: builder.createMutator(\"POST\", \"/subscription/cancel\"),\n };\n}\n\nexport { stripeFragmentDefinition } from \"./definition\";\nexport type {\n StripeFragmentConfig,\n StripeFragmentDeps,\n StripeFragmentServices,\n Logger,\n} from \"./types\";\nexport type { FragnoRouteConfig } from \"@fragno-dev/core\";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,MAAM,EAAE,WAAW,GAAG;GACtB,MAAM,QAAQ,OAAO,MAAM,IAAI,QAAQ,CAAC;GACxC,MAAM,gBAAgB,MAAM,IAAI,gBAAgB;GAEhD,MAAM,SAAS,MAAM,KAAK,OAAO,OAAO,KAAK;IAC3C,SAAS;IACT;IACA,gBAAgB;GACjB,EAAC;AAEF,UAAO,KAAK;IACV,QAAQ,OAAO;IACf,SAAS,OAAO;GACjB,EAAC;EACH;CACF,EAAC,AACH;AACF,EACF;;;;ACrCD,MAAM,SAAS;CACb;CACA;CACA;CACA;CACA;AACD;AAED,SAAgB,qBACdC,QACAC,cACA;AACA,QAAO,YAAY,yBAAyB,CACzC,WAAW,OAAO,CAClB,WAAW,OAAO,CAClB,YAAY,aAAa,CACzB,OAAO;AACX;AAED,SAAgB,4BAA4BC,eAAyC,CAAE,GAAE;CACvF,MAAM,UAAU,oBAAoB,0BAA0B,cAAc,OAAO;AAEnF,QAAO;EAEL,cAAc,QAAQ,WAAW,mBAAmB;EACpD,aAAa,QAAQ,WAAW,kBAAkB;EAClD,WAAW,QAAQ,WAAW,oCAAoC;EAClE,iBAAiB,QAAQ,WAAW,uBAAuB;EAE3D,kBAAkB,QAAQ,cAAc,QAAQ,UAAU;EAE1D,qBAAqB,QAAQ,cAAc,QAAQ,wBAAwB;EAC3E,oBAAoB,QAAQ,cAAc,QAAQ,uBAAuB;CAC1E;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragno-dev/stripe",
3
3
  "description": "Stripe integration using Fragno",
4
- "version": "0.1.2",
4
+ "version": "1.0.0",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -66,17 +66,17 @@
66
66
  "dependencies": {
67
67
  "stripe": "^19.1.0",
68
68
  "zod": "^4.0.5",
69
- "@fragno-dev/core": "0.1.10"
69
+ "@fragno-dev/core": "0.1.11"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^20",
73
73
  "@vitest/coverage-istanbul": "^3.2.4",
74
74
  "tsdown": "^0.11.9",
75
75
  "vitest": "^3.2.4",
76
+ "@fragno-dev/test": "1.0.0",
76
77
  "@fragno-dev/unplugin-fragno": "0.0.7",
77
- "@fragno-dev/test": "0.1.14",
78
78
  "@fragno-private/vitest-config": "0.0.0",
79
- "@fragno-dev/db": "0.1.15"
79
+ "@fragno-dev/db": "0.2.0"
80
80
  },
81
81
  "private": false,
82
82
  "peerDependencies": {
@@ -85,7 +85,7 @@
85
85
  "svelte": ">=4.0.0",
86
86
  "typescript": "^5",
87
87
  "vue": ">=3.0.0",
88
- "@fragno-dev/db": "^0.1.15"
88
+ "@fragno-dev/db": "^0.2.0"
89
89
  },
90
90
  "repository": {
91
91
  "type": "git",