diff --git a/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx b/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx index c48e30177..37c110329 100644 --- a/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx +++ b/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx @@ -68,7 +68,11 @@ export default function ConfirmationPage() { import("@/lib/generate-voucher"); }, []); - const { data: _booking, refetch: refetchBooking } = useQuery({ + const { + data: _booking, + refetch: refetchBooking, + isLoading: isBookingLoading, + } = useQuery({ queryKey: ["booking", bookingId], queryFn: async (): Promise => { try { @@ -271,6 +275,26 @@ export default function ConfirmationPage() { if (!bookingId || !pnr) return null; + // Wait for the actual booking status before deciding pending vs. confirmed — + // without this, _booking is briefly undefined on first load, isConfirmed reads + // as false, and the page flashes "payment pending" before flipping to + // "confirmed" once the fetch resolves (common, since the payment webhook has + // often already completed by the time the user lands here). + if (isBookingLoading) { + return ( +
+
+
+
+

+ Please wait, we are processing your booking… +

+
+
+
+ ); + } + return (