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.
This commit is contained in:
Andymick
2026-07-18 20:24:35 +01:00
parent 43da81bd66
commit 05c68263f8
2 changed files with 13 additions and 2 deletions
+11 -1
View File
@@ -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);
}
}