Handle payment fail and cancel events
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import PaymentCallback from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback"
|
||||
import { trackPaymentEvent } from "@/utils/tracking"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
@@ -47,15 +48,31 @@ export default async function PaymentCallbackPage({
|
||||
? bookingStatus.metadata.errorCode.toString()
|
||||
: PaymentErrorCodeEnum.Failed.toString()
|
||||
)
|
||||
trackPaymentEvent({
|
||||
event: "paymentFail",
|
||||
hotelId: searchObject.get("hotel"),
|
||||
errorMessage:
|
||||
bookingStatus?.metadata?.errorMessage ??
|
||||
`No error message found for booking ${confirmationNumber}, status: ${status}`,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`[payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
)
|
||||
if (status === "cancel") {
|
||||
searchObject.set("errorCode", PaymentErrorCodeEnum.Cancelled.toString())
|
||||
trackPaymentEvent({
|
||||
event: "paymentCancel",
|
||||
hotelId: searchObject.get("hotel"),
|
||||
})
|
||||
}
|
||||
if (status === "error") {
|
||||
searchObject.set("errorCode", PaymentErrorCodeEnum.Failed.toString())
|
||||
trackPaymentEvent({
|
||||
event: "paymentFail",
|
||||
hotelId: searchObject.get("hotel"),
|
||||
errorMessage: `Failed to get booking status for ${confirmationNumber}, status: ${status}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user