Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Block live Stripe mode in staging and sandbox workspaces

Kiran Kb5272478bbd4
diff --git a/apps/web/app/(ee)/api/stripe/integration/route.ts b/apps/web/app/(ee)/api/stripe/integration/route.ts
index 46a7a5cc2a..0c2687bc86 100644
--- a/apps/web/app/(ee)/api/stripe/integration/route.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/route.ts
@@ -3,6 +3,7 @@ import { parseRequestBody } from "@/lib/api/utils";
import { withWorkspace } from "@/lib/auth";
import { stripeIntegrationSettingsSchema } from "@/lib/integrations/stripe/schema";
import { prisma } from "@dub/prisma";
+import { WorkspaceEnvironment } from "@dub/prisma/client";
import { STRIPE_INTEGRATION_ID } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
@@ -32,6 +33,18 @@ export const PATCH = withWorkspace(
});
}
+ if (
+ stripeMode === "live" &&
+ (workspace.environment === WorkspaceEnvironment.staging ||
+ workspace.environment === WorkspaceEnvironment.sandbox)
+ ) {
+ throw new DubApiError({
+ code: "bad_request",
+ message:
+ "Live Stripe mode cannot be used in staging or sandbox workspaces.",
+ });
+ }
+
const installation = await prisma.installedIntegration.findUnique({
where: {
id: token.installationId,