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 32f596254..411340050 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 @@ -41,6 +41,22 @@ export default async function PaymentCallbackPage( notFound() } + const returnUrl = details(lang) + const searchObject = new URLSearchParams() + let errorMessage = undefined + + if (status === PaymentCallbackStatusEnum.Cancel) { + searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled) + return ( + + ) + } + let token = "" const session = await auth() if (isValidSession(session)) { @@ -57,7 +73,6 @@ export default async function PaymentCallbackPage( } const booking = await getBooking(confirmationNumber, params.lang, token) - if (!booking) { notFound() } @@ -81,11 +96,6 @@ export default async function PaymentCallbackPage( ) } - const returnUrl = details(lang) - const searchObject = new URLSearchParams() - - let errorMessage = undefined - if (refId) { try { const caller = await serverClient() @@ -112,13 +122,8 @@ export default async function PaymentCallbackPage( console.error( `[payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}` ) - if (status === PaymentCallbackStatusEnum.Cancel) { - searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled) - } - if (status === PaymentCallbackStatusEnum.Error) { - searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed) - errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}` - } + searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed) + errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}` } } diff --git a/apps/scandic-web/server/routers/booking/utils.ts b/apps/scandic-web/server/routers/booking/utils.ts index 414fe84ed..98a2dbac1 100644 --- a/apps/scandic-web/server/routers/booking/utils.ts +++ b/apps/scandic-web/server/routers/booking/utils.ts @@ -32,7 +32,7 @@ export async function getBooking( // If the booking is not found, return null. // This scenario is expected to happen when a logged in user trying to access a booking that doesn't belong to them. - if (apiResponse.status === 400) { + if (apiResponse.status === 404) { return null }