diff --git a/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx index 5bbf565f0..1a24d6c11 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(payment-callback)/payment-callback/page.tsx @@ -2,6 +2,7 @@ import { redirect } from "next/navigation" import { BOOKING_CONFIRMATION_NUMBER, + MEMBERSHIP_FAILED_ERROR, PaymentErrorCodeEnum, } from "@/constants/booking" import { @@ -31,7 +32,17 @@ export default async function PaymentCallbackPage({ const confirmationNumber = searchParams.confirmationNumber if (status === "success" && confirmationNumber) { - const confirmationUrl = `${bookingConfirmation(lang)}?${BOOKING_CONFIRMATION_NUMBER}=${confirmationNumber}` + const bookingStatus = await serverClient().booking.status({ + confirmationNumber, + }) + const membershipFailedError = bookingStatus.errors.find( + (e) => e.errorCode === MEMBERSHIP_FAILED_ERROR + ) + + const errorParam = membershipFailedError + ? `&errorCode=${membershipFailedError.errorCode}` + : "" + const confirmationUrl = `${bookingConfirmation(lang)}?${BOOKING_CONFIRMATION_NUMBER}=${confirmationNumber}${errorParam}` console.log(`[payment-callback] redirecting to: ${confirmationUrl}`) redirect(confirmationUrl) diff --git a/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx b/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx index dffeb5b81..b5884b689 100644 --- a/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx +++ b/components/HotelReservation/BookingConfirmation/Confirmation/index.tsx @@ -1,7 +1,10 @@ "use client" +import { useSearchParams } from "next/navigation" import { useRef } from "react" import { useIntl } from "react-intl" +import { MEMBERSHIP_FAILED_ERROR } from "@/constants/booking" + import Header from "@/components/HotelReservation/BookingConfirmation/Header" import HotelDetails from "@/components/HotelReservation/BookingConfirmation/HotelDetails" import PaymentDetails from "@/components/HotelReservation/BookingConfirmation/PaymentDetails" @@ -22,9 +25,11 @@ export default function Confirmation({ hotel, room, }: ConfirmationProps) { + const searchParams = useSearchParams() const intl = useIntl() const mainRef = useRef(null) - + const membershipFailedError = + searchParams.get("errorCode") === MEMBERSHIP_FAILED_ERROR const failedToVerifyMembership = booking.rateDefinition.isMemberRate && !booking.guest.membershipNumber @@ -32,7 +37,20 @@ export default function Confirmation({
- {failedToVerifyMembership && ( + {/* Customer has manually entered a membership number for which verification failed */} + {membershipFailedError && ( + + )} + {/* For some other reason membership could not be verified */} + {!membershipFailedError && failedToVerifyMembership && (