Merged in fix/SW-3020-paymentInfo-tracking (pull request #2403)

fix(SW-3020): add correct paymentInfo in booking flow and ancillary flow

* fix(SW-3020): add correct paymentInfo in booking flow and ancillary flow

* fix(SW-3020): fix pr comments


Approved-by: Tobias Johansson
This commit is contained in:
Bianca Widstam
2025-06-24 13:38:30 +00:00
parent eb77241a4e
commit 5c3b30ea93
10 changed files with 136 additions and 23 deletions

View File

@@ -45,3 +45,46 @@ export function calculateTotalRoomPrice(
comparisonPrice,
}
}
export const paymentInfoStorageName = "payment-info-storage"
type PaymentInfoSessionData = {
paymentMethod: string
isSavedCreditCard: boolean
}
export function readPaymentInfoFromSessionStorage():
| PaymentInfoSessionData
| undefined {
try {
const paymentInfoSessionData = sessionStorage.getItem(
paymentInfoStorageName
)
if (!paymentInfoSessionData) return undefined
return JSON.parse(paymentInfoSessionData)
} catch (error) {
console.error("Error reading from session storage:", error)
return undefined
}
}
export function writePaymentInfoToSessionStorage(
paymentMethod: string,
isSavedCreditCard: boolean
) {
try {
sessionStorage.setItem(
paymentInfoStorageName,
JSON.stringify({
paymentMethod,
isSavedCreditCard,
})
)
} catch (error) {
console.error("Error writing to session storage:", error)
}
}
export function clearPaymentInfoSessionStorage() {
sessionStorage.removeItem(paymentInfoStorageName)
}