diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx index 411340050..4327d8410 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx @@ -38,6 +38,9 @@ export default async function PaymentCallbackPage( const confirmationNumber = searchParams.confirmationNumber if (!status || !confirmationNumber) { + console.error( + `[payment-callback] missing status or confirmationNumber in search params` + ) notFound() } @@ -69,17 +72,21 @@ export default async function PaymentCallbackPage( } if (!token) { + console.error( + `[payment-callback] no token found for user, cannot fetch booking` + ) notFound() } const booking = await getBooking(confirmationNumber, params.lang, token) - if (!booking) { - notFound() - } - const { refId } = booking + const refId = booking?.refId - if (status === PaymentCallbackStatusEnum.Success && confirmationNumber) { + if ( + status === PaymentCallbackStatusEnum.Success && + confirmationNumber && + refId + ) { const expire = Math.floor(Date.now() / 1000) + 60 const sig = encrypt(expire.toString()) const confirmationUrl = `${bookingConfirmation(lang)}?RefId=${encodeURIComponent(refId)}` @@ -127,6 +134,14 @@ export default async function PaymentCallbackPage( } } + if (status === PaymentCallbackStatusEnum.Error) { + console.error( + `[payment-callback] error status received for ${confirmationNumber}, status: ${status}` + ) + searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed) + errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}` + } + return (