Skip to content

Commit f7d7359

Browse files
GeneAIclaude
authored andcommitted
fix: Handle null customer_email in Stripe webhook
Use session.customer_details?.email as fallback when session.customer_email is null, fixing the NOT NULL constraint violation on customer creation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cc7a4cb commit f7d7359

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

website/app/api/stripe/webhook/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,16 @@ export async function POST(req: NextRequest) {
111111
// Initialize database if needed
112112
await ensureDbInitialized();
113113

114+
// Get customer email - check both locations
115+
const customerEmail = session.customer_email || session.customer_details?.email;
116+
if (!customerEmail) {
117+
console.error('No customer email found in session');
118+
break;
119+
}
120+
114121
// Create or find customer
115122
const customer = await findOrCreateCustomer(
116-
session.customer_email!,
123+
customerEmail,
117124
session.customer as string,
118125
session.customer_details?.name || undefined
119126
);

0 commit comments

Comments
 (0)