The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Use workspace Stripe Connect ID in integration webhook handlers.
Kiran Ka0b38266e661
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/account-application-deauthorized.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/account-application-deauthorized.tsindex 899b3b2cc5..e503be5de8 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/account-application-deauthorized.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/account-application-deauthorized.ts@@ -5,12 +5,10 @@ import { WebhookHandlerInput, WebhookHandlerResponse } from "./types";// Handle event "account.application.deauthorized"export async function accountApplicationDeauthorized({+ event,mode,workspace,-}: Omit<- WebhookHandlerInput<Stripe.AccountApplicationDeauthorizedEvent>,- "event"->): Promise<WebhookHandlerResponse> {+}: WebhookHandlerInput<Stripe.AccountApplicationDeauthorizedEvent>): Promise<WebhookHandlerResponse> {const stripeAccountId = workspace.stripeConnectId!;if (mode === "test") {diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.tsindex d768055e1b..8929ee6dbb 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/charge-refunded.ts@@ -12,7 +12,7 @@ export async function chargeRefunded({workspace,}: WebhookHandlerInput<Stripe.ChargeRefundedEvent>): Promise<WebhookHandlerResponse> {const charge = event.data.object;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;const stripe = stripeAppClient({mode,diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.tsindex 989d126b09..dab1acc976 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts@@ -38,7 +38,7 @@ export async function checkoutSessionCompleted({let dubCustomerExternalId =charge.metadata?.dubCustomerExternalId || charge.metadata?.dubCustomerId;const clientReferenceId = charge.client_reference_id;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;const stripeCustomerId = charge.customer as string;const stripeCustomerName = charge.customer_details?.name;const stripeCustomerEmail = charge.customer_details?.email;diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.tsindex cedb449c39..18eab7445d 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts@@ -18,7 +18,7 @@ export async function couponDeleted({"mode">): Promise<WebhookHandlerResponse> {const coupon = event.data.object;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;if (!workspace.defaultProgramId) {return {diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.tsindex ece13feddc..fc5e4fa4e1 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-subscription-created.ts@@ -23,6 +23,7 @@ export async function customerSubscriptionCreated({};}+ const stripeAccountId = workspace.stripeConnectId!;const stripeCustomerId = createdSubscription.customer as string;const installedIntegration = await prisma.installedIntegration.findFirst({@@ -63,7 +64,7 @@ export async function customerSubscriptionCreated({if (!customer) {const stripeCustomer = await getConnectedCustomer({stripeCustomerId,- stripeAccountId: workspace.stripeConnectId,+ stripeAccountId,mode,});diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.tsindex 18b14c1be4..1c385bbe48 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts@@ -27,7 +27,7 @@ export async function invoicePaid({}: WebhookHandlerInput<Stripe.InvoicePaidEvent>): Promise<WebhookHandlerResponse> {const invoice = event.data.object;const stripeCustomerId = invoice.customer as string | null;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;const invoiceId = invoice.id;if (!invoiceId) {@@ -53,7 +53,7 @@ export async function invoicePaid({if (!customer) {const connectedCustomer = await getConnectedCustomer({stripeCustomerId,- stripeAccountId: workspace.stripeConnectId,+ stripeAccountId,mode,});@@ -67,7 +67,7 @@ export async function invoicePaid({customer = await prisma.customer.update({where: {projectConnectId_externalId: {- projectConnectId: workspace.stripeConnectId!,+ projectConnectId: stripeAccountId,externalId: dubCustomerExternalId,},},@@ -143,7 +143,7 @@ export async function invoicePaid({timestamp: new Date().toISOString(),dubCustomerExternalId: customer.externalId,stripeCustomerId,- stripeAccountId: workspace.stripeConnectId,+ stripeAccountId,invoiceId,customerId: customer.id,workspaceId: customer.projectId,diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/promotion-code-updated.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/promotion-code-updated.tsindex e47c1352d9..d61cbd9a8c 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/promotion-code-updated.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/promotion-code-updated.ts@@ -11,7 +11,7 @@ export async function promotionCodeUpdated({"mode">): Promise<WebhookHandlerResponse> {const promotionCode = event.data.object;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;if (!workspace.defaultProgramId) {return {diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/route.tsindex 3af1905584..26cf74ccf6 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/route.ts@@ -126,6 +126,7 @@ export const POST = withAxiom(async (req: Request) => {switch (event.type) {case "account.application.deauthorized":result = await accountApplicationDeauthorized({+ event,mode,workspace,});diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/utils/sync-customer.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/utils/sync-customer.tsindex dbf7e9f78c..3b20ff3734 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/utils/sync-customer.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/utils/sync-customer.ts@@ -27,7 +27,7 @@ export async function syncCustomer({"mode">): Promise<WebhookHandlerResponse> {const stripeCustomer = event.data.object;- const stripeAccountId = event.account as string;+ const stripeAccountId = workspace.stripeConnectId!;const dubCustomerExternalId =stripeCustomer.metadata?.dubCustomerExternalId ||stripeCustomer.metadata?.dubCustomerId;