diff --git a/server/routes/webhooks.js b/server/routes/webhooks.js index 20168f1..1c60a13 100644 --- a/server/routes/webhooks.js +++ b/server/routes/webhooks.js @@ -29,6 +29,12 @@ router.post('/stripe', express.raw({ type: 'application/json' }), async (req, re 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 switch (event.type) { case 'checkout.session.completed': @@ -92,8 +98,15 @@ async function handleCheckoutSessionCompleted(session) { } 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)}`); + 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 await fulfillOrder(order, session);