Add comprehensive webhook payload logging for customer data extraction
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m20s

- Log full Stripe webhook JSON payload for debugging
- Extract and log customer name, address, and metadata
- Makes it easy to see business names and custom fields in logs
- Helps identify available data for future enhancements

server/routes/webhooks.js:32-36, 101-109
This commit is contained in:
Matt 2025-11-03 14:08:19 +01:00
parent 039ddc0fa8
commit e9b79531e1

View File

@ -29,6 +29,12 @@ router.post('/stripe', express.raw({ type: 'application/json' }), async (req, re
console.log(`📬 Received webhook: ${event.type}`); console.log(`📬 Received webhook: ${event.type}`);
// Log full webhook payload for debugging and data extraction
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log('📦 Full Stripe Webhook Payload:');
console.log(JSON.stringify(event, null, 2));
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
// Handle different event types // Handle different event types
switch (event.type) { switch (event.type) {
case 'checkout.session.completed': case 'checkout.session.completed':
@ -92,8 +98,15 @@ async function handleCheckoutSessionCompleted(session) {
} }
console.log(`💳 Payment confirmed for order: ${order.id}`); console.log(`💳 Payment confirmed for order: ${order.id}`);
console.log(` Customer: ${session.customer_details?.email}`); console.log(` Customer Email: ${session.customer_details?.email}`);
console.log(` Customer Name: ${session.customer_details?.name || 'Not provided'}`);
console.log(` Amount: $${(order.total_amount / 100).toFixed(2)}`); console.log(` Amount: $${(order.total_amount / 100).toFixed(2)}`);
if (session.customer_details?.address) {
console.log(` Address: ${JSON.stringify(session.customer_details.address)}`);
}
if (session.metadata && Object.keys(session.metadata).length > 0) {
console.log(` Metadata: ${JSON.stringify(session.metadata)}`);
}
// Fulfill order via Wren API // Fulfill order via Wren API
await fulfillOrder(order, session); await fulfillOrder(order, session);