From 05c68263f8986f72287e86727ca14ac1a7fb09c2 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 20:24:35 +0100 Subject: [PATCH] Fix: Update order status to PAID on checkout success page When user reaches the success page after payment, update the order status from PENDING to PAID. This ensures the admin panel shows the correct status immediately after payment confirmation. --- .claude/settings.local.json | 3 ++- src/app/checkout/success/page.tsx | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index e0c7add..88de9f0 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -73,7 +73,8 @@ "Bash(xargs grep -l \"design-spec\")", "Bash(git commit -m 'Improve: Design specification sheet now shows previews and info *)", "Bash(git commit -m 'Fix: Handle undefined designElements in design spec SVG rendering *)", - "Bash(git commit -m 'Fix: Ensure cart is completely cleared after payment success *)" + "Bash(git commit -m 'Fix: Ensure cart is completely cleared after payment success *)", + "Bash(git commit -m 'Fix: Update order status to PAID on checkout success page *)" ] } } diff --git a/src/app/checkout/success/page.tsx b/src/app/checkout/success/page.tsx index 6799e2f..a783991 100644 --- a/src/app/checkout/success/page.tsx +++ b/src/app/checkout/success/page.tsx @@ -16,8 +16,18 @@ export default async function CheckoutSuccessPage({ where: { stripeSessionId: sessionId }, include: { items: true }, }); + + // Update order status to PAID if it's still PENDING + if (order && order.status === 'PENDING') { + order = await prisma.order.update({ + where: { id: order.id }, + data: { status: 'PAID' }, + include: { items: true }, + }); + console.log('✓ Order status updated to PAID:', order.id); + } } catch (err) { - console.error('Error fetching order for success page:', err); + console.error('Error handling order for success page:', err); } }