feat(SW-817): hide apple pay if not supported
This commit is contained in:
@@ -81,6 +81,8 @@ export default function Payment({
|
|||||||
const { toDate, fromDate, rooms: rooms, hotel } = roomData
|
const { toDate, fromDate, rooms: rooms, hotel } = roomData
|
||||||
|
|
||||||
const [confirmationNumber, setConfirmationNumber] = useState<string>("")
|
const [confirmationNumber, setConfirmationNumber] = useState<string>("")
|
||||||
|
const [availablePaymentOptions, setAvailablePaymentOptions] =
|
||||||
|
useState(otherPaymentOptions)
|
||||||
|
|
||||||
const methods = useForm<PaymentFormData>({
|
const methods = useForm<PaymentFormData>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -118,6 +120,18 @@ export default function Payment({
|
|||||||
retryInterval
|
retryInterval
|
||||||
)
|
)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (window.ApplePaySession) {
|
||||||
|
setAvailablePaymentOptions(otherPaymentOptions)
|
||||||
|
} else {
|
||||||
|
setAvailablePaymentOptions(
|
||||||
|
otherPaymentOptions.filter(
|
||||||
|
(option) => option !== PaymentMethodEnum.applePay
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, [otherPaymentOptions, setAvailablePaymentOptions])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (bookingStatus?.data?.paymentUrl) {
|
if (bookingStatus?.data?.paymentUrl) {
|
||||||
router.push(bookingStatus.data.paymentUrl)
|
router.push(bookingStatus.data.paymentUrl)
|
||||||
@@ -260,7 +274,7 @@ export default function Payment({
|
|||||||
value={PaymentMethodEnum.card}
|
value={PaymentMethodEnum.card}
|
||||||
label={intl.formatMessage({ id: "Credit card" })}
|
label={intl.formatMessage({ id: "Credit card" })}
|
||||||
/>
|
/>
|
||||||
{otherPaymentOptions.map((paymentMethod) => (
|
{availablePaymentOptions.map((paymentMethod) => (
|
||||||
<PaymentOption
|
<PaymentOption
|
||||||
key={paymentMethod}
|
key={paymentMethod}
|
||||||
name="paymentMethod"
|
name="paymentMethod"
|
||||||
|
|||||||
1
types/window.d.ts
vendored
1
types/window.d.ts
vendored
@@ -13,4 +13,5 @@ interface Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cookiebot: { changed: boolean; consented: boolean }
|
Cookiebot: { changed: boolean; consented: boolean }
|
||||||
|
ApplePaySession: (() => void) | undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user