The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update get-customer-stripe-invoices.ts
Kiran Kabbb2134ac61
diff --git a/apps/web/lib/api/customers/get-customer-stripe-invoices.ts b/apps/web/lib/api/customers/get-customer-stripe-invoices.tsindex 86ab2764b7..a325fd36e1 100644--- a/apps/web/lib/api/customers/get-customer-stripe-invoices.ts+++ b/apps/web/lib/api/customers/get-customer-stripe-invoices.ts@@ -1,6 +1,7 @@import { prisma } from "@/lib/prisma";import { stripeAppClient } from "@/lib/stripe";import { StripeCustomerInvoiceSchema } from "@/lib/zod/schemas/customers";+import { STRIPE_INTEGRATION_ID } from "@dub/utils";import { Project } from "@prisma/client";import Stripe from "stripe";import { DubApiError } from "../errors";@@ -26,7 +27,7 @@ export async function getCustomerStripeInvoices({stripeCustomerId: string;workspace: Pick<Project,- "stripeConnectId" | "stripeConnectMode" | "defaultProgramId"+ "id" | "stripeConnectId" | "stripeConnectMode" | "defaultProgramId">;}) {if (!workspace.stripeConnectId) {@@ -37,6 +38,24 @@ export async function getCustomerStripeInvoices({});}+ const installedIntegration = await prisma.installedIntegration.findFirst({+ where: {+ projectId: workspace.id,+ integrationId: STRIPE_INTEGRATION_ID,+ },+ select: {+ id: true,+ },+ });++ if (!installedIntegration) {+ throw new DubApiError({+ code: "bad_request",+ message:+ "The Stripe integration is not installed on your workspace. Please install the Stripe integration under /settings/integrations/stripe to proceed.",+ });+ }+if (!stripeCustomerId.startsWith("cus_")) {throw new DubApiError({code: "bad_request",