Merged in fix/SW-3018-payment-cancel-error (pull request #2339)
Fix/SW-3018 payment cancel error * fix(SW-3018): cancel payment error when get booking in callback * fix: wrong status code Approved-by: Linus Flood
This commit is contained in:
committed by
Linus Flood
parent
048a477e52
commit
98983cb44a
@@ -41,6 +41,22 @@ export default async function PaymentCallbackPage(
|
|||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const returnUrl = details(lang)
|
||||||
|
const searchObject = new URLSearchParams()
|
||||||
|
let errorMessage = undefined
|
||||||
|
|
||||||
|
if (status === PaymentCallbackStatusEnum.Cancel) {
|
||||||
|
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled)
|
||||||
|
return (
|
||||||
|
<HandleErrorCallback
|
||||||
|
returnUrl={returnUrl.toString()}
|
||||||
|
searchObject={searchObject}
|
||||||
|
status={status}
|
||||||
|
errorMessage={errorMessage}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let token = ""
|
let token = ""
|
||||||
const session = await auth()
|
const session = await auth()
|
||||||
if (isValidSession(session)) {
|
if (isValidSession(session)) {
|
||||||
@@ -57,7 +73,6 @@ export default async function PaymentCallbackPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const booking = await getBooking(confirmationNumber, params.lang, token)
|
const booking = await getBooking(confirmationNumber, params.lang, token)
|
||||||
|
|
||||||
if (!booking) {
|
if (!booking) {
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
@@ -81,11 +96,6 @@ export default async function PaymentCallbackPage(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnUrl = details(lang)
|
|
||||||
const searchObject = new URLSearchParams()
|
|
||||||
|
|
||||||
let errorMessage = undefined
|
|
||||||
|
|
||||||
if (refId) {
|
if (refId) {
|
||||||
try {
|
try {
|
||||||
const caller = await serverClient()
|
const caller = await serverClient()
|
||||||
@@ -112,13 +122,8 @@ export default async function PaymentCallbackPage(
|
|||||||
console.error(
|
console.error(
|
||||||
`[payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
`[payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||||
)
|
)
|
||||||
if (status === PaymentCallbackStatusEnum.Cancel) {
|
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed)
|
||||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionCancelled)
|
errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||||
}
|
|
||||||
if (status === PaymentCallbackStatusEnum.Error) {
|
|
||||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed)
|
|
||||||
errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export async function getBooking(
|
|||||||
|
|
||||||
// If the booking is not found, return null.
|
// 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.
|
// 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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user