The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix stripeCustomerId nullish case
Steven Tey3ac84a23da65
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 145204fbc7..ac9574cacd 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@@ -136,12 +136,9 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {}linkId = clickEvent.link_id;-- // if it's not either a regular stripe checkout setup or a stripe checkout link,- // we skip the event- } else {+ } else if (stripeCustomerId) {/*- for regular stripe checkout setup:+ for regular stripe checkout setup (provided stripeCustomerId is present):- if dubCustomerId is provided:- we update the customer with the stripe customerId (for future events)- else:@@ -203,6 +200,8 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {);linkId = leadEvent.link_id;+ } else {+ return "No dubCustomerId or stripeCustomerId found in Stripe checkout session metadata, skipping...";}if (charge.amount_total === 0) {diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/utils.tsindex 38ea7438b2..0fa7c17d45 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/utils.ts@@ -158,10 +158,16 @@ export async function updateCustomerWithStripeCustomerId({dubCustomerId,stripeCustomerId,}: {- stripeAccountId: string;+ stripeAccountId?: string | null;dubCustomerId: string;- stripeCustomerId: string;+ stripeCustomerId?: string | null;}) {+ // if stripeCustomerId or stripeAccountId is not provided, return null+ // (same logic as in getConnectedCustomer)+ if (!stripeCustomerId || !stripeAccountId) {+ return null;+ }+try {// Update customer with stripeCustomerId if exists – for future eventsreturn await prisma.customer.update({