🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
refactor(billing): relocate Stripe (#15458)
Steffen Schmitzae84d6a394ef
diff --git a/web/src/__tests__/server/createDefaultSpendAlerts.servertest.ts b/web/src/__tests__/server/createDefaultSpendAlerts.servertest.tsindex 18b069ab98..3267a10336 100644--- a/web/src/__tests__/server/createDefaultSpendAlerts.servertest.ts+++ b/web/src/__tests__/server/createDefaultSpendAlerts.servertest.ts@@ -1,6 +1,6 @@import { prisma } from "@langfuse/shared/src/db";import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";-import { createDefaultSpendAlerts } from "@/src/ee/features/billing/server/stripeWebhookHandler";+import { createDefaultSpendAlerts } from "@/src/ee/features/billing/server/stripe/stripeWebhookHandler";import { stripeProducts } from "@/src/ee/features/billing/utils/stripeCatalogue";describe("createDefaultSpendAlerts", () => {diff --git a/web/src/__tests__/server/stripe-webhook-handler.servertest.ts b/web/src/__tests__/server/stripe-webhook-handler.servertest.tsindex 41f566ae85..f51fe7e8de 100644--- a/web/src/__tests__/server/stripe-webhook-handler.servertest.ts+++ b/web/src/__tests__/server/stripe-webhook-handler.servertest.ts@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest";import { v4 } from "uuid";import type Stripe from "stripe";import { prisma } from "@langfuse/shared/src/db";-import { handleSubscriptionChanged } from "@/src/ee/features/billing/server/stripeWebhookHandler";+import { handleSubscriptionChanged } from "@/src/ee/features/billing/server/stripe/stripeWebhookHandler";import { env } from "@/src/env.mjs";const buildSubscription = (args: {diff --git a/web/src/app/api/billing/stripe-webhook/route.ts b/web/src/app/api/billing/stripe-webhook/route.tsindex 1b59965eba..cd2304c5e3 100644--- a/web/src/app/api/billing/stripe-webhook/route.ts+++ b/web/src/app/api/billing/stripe-webhook/route.ts@@ -1,4 +1,4 @@-import { stripeWebhookHandler } from "@/src/ee/features/billing/server/stripeWebhookHandler";+import { stripeWebhookHandler } from "@/src/ee/features/billing/server/stripe/stripeWebhookHandler";export const dynamic = "force-dynamic";diff --git a/web/src/ee/features/billing/README.md b/web/src/ee/features/billing/README.mdindex 3c1bfeabe0..35ee0850ec 100644--- a/web/src/ee/features/billing/README.md+++ b/web/src/ee/features/billing/README.md@@ -26,7 +26,7 @@ See `web/src/ee/features/billing/server/cloudBillingRouter.ts`.### Checkout and Subscription Management-Implemented in `web/src/ee/features/billing/server/stripeBillingService.ts`.+Implemented in `web/src/ee/features/billing/server/stripe/stripeBillingService.ts`.1. **Checkout**- Initiated from billing settings; only products from the catalogue are allowed.@@ -60,7 +60,7 @@ Implemented in `web/src/ee/features/billing/server/stripeBillingService.ts`.### Webhooks-See `web/src/ee/features/billing/server/stripeWebhookHandler.ts`.+See `web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts`.- Validates signature; ensures events are handled only in the correct `cloudRegion`.- Ensures subscription metadata (`orgId`, `cloudRegion`) is set (falls back to checkout session lookup if needed).diff --git a/web/src/ee/features/billing/server/cloudBillingRouter.ts b/web/src/ee/features/billing/server/cloudBillingRouter.tsindex 7e7ede51f4..8fed1f5f6c 100644--- a/web/src/ee/features/billing/server/cloudBillingRouter.ts+++ b/web/src/ee/features/billing/server/cloudBillingRouter.ts@@ -10,7 +10,7 @@ import { TRPCError } from "@trpc/server";import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { auditLog } from "@/src/features/audit-logs/auditLog";import { logger } from "@langfuse/shared/src/server";-import { createBillingServiceFromContext } from "./stripeBillingService";+import { createBillingServiceFromContext } from "./stripe/stripeBillingService";import { isCloudBillingEnabled } from "../utils/isCloudBilling";export const cloudBillingRouter = createTRPCRouter({diff --git a/web/src/ee/features/billing/server/stripeBillingService.ts b/web/src/ee/features/billing/server/stripe/stripeBillingService.tssimilarity index 100%rename from web/src/ee/features/billing/server/stripeBillingService.tsrename to web/src/ee/features/billing/server/stripe/stripeBillingService.tsdiff --git a/web/src/ee/features/billing/server/stripeWebhookHandler.ts b/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.tssimilarity index 100%rename from web/src/ee/features/billing/server/stripeWebhookHandler.tsrename to web/src/ee/features/billing/server/stripe/stripeWebhookHandler.tsdiff --git a/web/src/features/organizations/server/organizationRouter.ts b/web/src/features/organizations/server/organizationRouter.tsindex e39a93a8d6..fc77a204e6 100644--- a/web/src/features/organizations/server/organizationRouter.ts+++ b/web/src/features/organizations/server/organizationRouter.ts@@ -16,7 +16,7 @@ import {getLastTraceTimestampsByProjects,redis,} from "@langfuse/shared/src/server";-import { createBillingServiceFromContext } from "@/src/ee/features/billing/server/stripeBillingService";+import { createBillingServiceFromContext } from "@/src/ee/features/billing/server/stripe/stripeBillingService";import { isCloudBillingEnabled } from "@/src/ee/features/billing/utils/isCloudBilling";import { shouldAutoEnableV4 } from "@/src/features/events/lib/v4Rollout";import { buildAdminOrgContext } from "@/src/features/organizations/server/adminOrgContext";