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:
@@ -38,6 +38,9 @@ export default async function PaymentCallbackPage(
|
|||||||
const confirmationNumber = searchParams.confirmationNumber
|
const confirmationNumber = searchParams.confirmationNumber
|
||||||
|
|
||||||
if (!status || !confirmationNumber) {
|
if (!status || !confirmationNumber) {
|
||||||
|
console.error(
|
||||||
|
`[payment-callback] missing status or confirmationNumber in search params`
|
||||||
|
)
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,17 +72,21 @@ export default async function PaymentCallbackPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
console.error(
|
||||||
|
`[payment-callback] no token found for user, cannot fetch booking`
|
||||||
|
)
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const booking = await getBooking(confirmationNumber, params.lang, token)
|
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 expire = Math.floor(Date.now() / 1000) + 60
|
||||||
const sig = encrypt(expire.toString())
|
const sig = encrypt(expire.toString())
|
||||||
const confirmationUrl = `${bookingConfirmation(lang)}?RefId=${encodeURIComponent(refId)}`
|
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 (
|
return (
|
||||||
<HandleErrorCallback
|
<HandleErrorCallback
|
||||||
returnUrl={returnUrl.toString()}
|
returnUrl={returnUrl.toString()}
|
||||||
|
|||||||
Reference in New Issue
Block a user