feat: WEB-210 Fallback booking URL if encryption fails
This commit is contained in:
@@ -116,12 +116,19 @@ const updateStaysBookingUrl = async (
|
|||||||
stay.attributes.confirmationNumber.toString() +
|
stay.attributes.confirmationNumber.toString() +
|
||||||
"," +
|
"," +
|
||||||
apiJson.data.attributes.lastName
|
apiJson.data.attributes.lastName
|
||||||
let encryptedBookingValue = encryptValue(originalString)
|
const encryptedBookingValue = encryptValue(originalString)
|
||||||
|
const bookingUrl = !!encryptedBookingValue
|
||||||
|
? fullBookingUrl + "?RefId=" + encryptedBookingValue
|
||||||
|
: fullBookingUrl +
|
||||||
|
"?lastName=" +
|
||||||
|
apiJson.data.attributes.lastName +
|
||||||
|
"&bookingId=" +
|
||||||
|
stay.attributes.confirmationNumber
|
||||||
return {
|
return {
|
||||||
...stay,
|
...stay,
|
||||||
attributes: {
|
attributes: {
|
||||||
...stay.attributes,
|
...stay.attributes,
|
||||||
bookingUrl: fullBookingUrl + "?RefId=" + encryptedBookingValue,
|
bookingUrl: bookingUrl,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import crypto from "crypto"
|
|||||||
import { env } from "@/env/server"
|
import { env } from "@/env/server"
|
||||||
|
|
||||||
export default function encryptValue(originalString: string) {
|
export default function encryptValue(originalString: string) {
|
||||||
let result = ""
|
let result: String = ""
|
||||||
try {
|
try {
|
||||||
const encryptionKey = env.BOOKING_ENCRYPTION_KEY
|
const encryptionKey = env.BOOKING_ENCRYPTION_KEY
|
||||||
const bufferKey = Buffer.from(encryptionKey, "utf8")
|
const bufferKey = Buffer.from(encryptionKey, "utf8")
|
||||||
@@ -20,5 +20,5 @@ export default function encryptValue(originalString: string) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
return result.toString()
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user