Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(billing): relocate Stripe (#15458)

Steffen Schmitzae84d6a394ef
diff --git a/web/src/__tests__/server/createDefaultSpendAlerts.servertest.ts b/web/src/__tests__/server/createDefaultSpendAlerts.servertest.ts
index 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.ts
index 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.ts
index 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.md
index 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.ts
index 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.ts
similarity index 100%
rename from web/src/ee/features/billing/server/stripeBillingService.ts
rename to web/src/ee/features/billing/server/stripe/stripeBillingService.ts
diff --git a/web/src/ee/features/billing/server/stripeWebhookHandler.ts b/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts
similarity index 100%
rename from web/src/ee/features/billing/server/stripeWebhookHandler.ts
rename to web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts
diff --git a/web/src/features/organizations/server/organizationRouter.ts b/web/src/features/organizations/server/organizationRouter.ts
index 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";