The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add try catch to checkout-session-completed
Steven Tey59dca969264a
diff --git a/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.tsindex 83db796fe6..8a4b6621b3 100644--- a/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts+++ b/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts@@ -16,18 +16,25 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {return;}- // Update customer with stripe customerId- const customer = await prisma.customer.update({- where: {- projectConnectId_externalId: {- projectConnectId: stripeAccountId,- externalId: dubCustomerId,+ let customer;+ try {+ // Update customer with stripe customerId if exists+ customer = await prisma.customer.update({+ where: {+ projectConnectId_externalId: {+ projectConnectId: stripeAccountId,+ externalId: dubCustomerId,+ },+ },+ data: {+ stripeCustomerId,},- },- data: {- stripeCustomerId,- },- });+ });+ } catch (error) {+ // Skip if customer not found+ console.error(error);+ return;+ }if (invoiceId) {// Skip if invoice id is already processed