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.

handle null stripe customer ID

Steven Tey326a0c6be9b1
diff --git a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
index 8413f5f445..742a5da3e2 100644
--- a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
+++ b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
@@ -122,7 +122,8 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
const payload = {
name: stripeCustomerName,
email: stripeCustomerEmail,
- externalId: stripeCustomerId, // using Stripe customer ID as externalId
+ // stripeCustomerId can potentially be null, so we use email as fallback
+ externalId: stripeCustomerId || stripeCustomerEmail,
projectId: workspace.id,
projectConnectId: stripeAccountId,
stripeCustomerId,
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index 1bea3c7e78..068275ada6 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -203,7 +203,7 @@ const getCustomersMap = async (customerIds: string[]) => {
(acc, customer) => {
acc[customer.id] = CustomerSchema.parse({
id: customer.id,
- externalId: customer.externalId,
+ externalId: customer.externalId || "",
name: customer.name || customer.email || generateRandomName(),
email: customer.email || "",
avatar: