Merged in fix/payment-error (pull request #2342)

Fix/payment error

* fix: dont show not found page when payment fails

* Show error message when payment fails


Approved-by: Anton Gunnarsson
This commit is contained in:
Linus Flood
2025-06-11 17:49:27 +00:00
parent 2b4c05a313
commit 6bf7462ac7

View File

@@ -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 (
<HandleErrorCallback
returnUrl={returnUrl.toString()}