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AAAA,IAA0B7B,IACnCvL,EAAiB4M,EAAAA,GAAcM,QAC/B1C,GAAgBa,EAAAA,EAAAA,IAAmBlM,EAAY,2CACtC0N,EAAAA,EAAAA,IAAgBtB,KAAc0B,EAAAA,EAAAA,IAAc1B,IAAcA,EAAUnB,QAC7EpK,EAAiB4M,EAAAA,GAAcM,OAEnC,GAEC,CAAC3B,GAAW,C,qEC/DjB,MAAMwH,EAAY,CAAC,kBAAmB,aAAc,KAAM,KAAM,SAEnDC,EAAkBhR,IAC7B,MAAMiR,EAAY,IAAIpX,IAAIkX,GAC1B,IAAIG,EAAiBlR,EAKrB,OAJAiR,EAAUnP,SAASqP,IACjBD,EAAiBlR,EAAM4Q,QAAQO,EAAO,GAAG,IAGpCD,CAAc,EAQhB,SAASE,EAASpR,GACvB,GAAqB,iBAAVA,EACT,OAAOgR,EAAehR,GAAO8D,WAAWuN,OAG1C,GAAqB,iBAAVrR,EACT,IAAK,MAAMjF,KAAOiF,EACU,iBAAfA,EAAMjF,KACfiF,EAAMjF,GAAOiW,EAAehR,EAAMjF,IAAM+I,WAAWuN,QAKzD,OAAOrR,CACT,C","sources":["webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/getIsEligibleForApplePay.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/PaywallHostedButtons/constants.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/PaywallHostedButtons/index.tsx","webpack://nocodenodeweb/./src/client/components/ButtonsStack/PaywallHostedButtons/styles.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/PaywallHostedButtons/utils.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ordersHelper.ts","webpack://nocodenodeweb/./src/client/components/OrderStatus/utils.tsx","webpack://nocodenodeweb/./src/client/components/ViewCart/validation/rules.ts","webpack://nocodenodeweb/./src/client/components/ViewCart/validation/index.ts","webpack://nocodenodeweb/./src/client/helpers/fetchWrapper.ts","webpack://nocodenodeweb/./src/client/helpers/getPaymentTotalFields.ts","webpack://nocodenodeweb/./src/client/hooks/useOrderStatus.ts","webpack://nocodenodeweb/./src/common/sanitize.ts"],"sourcesContent":["import { UAParser } from 'ua-parser-js';\nimport { logWarnClient, logErrorClient } from '@client/utils/beaverLogger';\n\nconst chinaCountryCodes = ['CN', 'C2'];\n\nexport const isDeviceEligibleForApplePay = (buyerCountry = ''): boolean => {\n const parser = new UAParser();\n const { model = '' } = parser.getDevice();\n const { version = '' } = parser.getOS();\n\n // Apple Pay China Eligibility\n const isChina = chinaCountryCodes.includes(buyerCountry.toUpperCase());\n\n if (isChina) {\n // Apple Pay only eligible for iPad and iPhone devices in China.\n const eligibleDevices = ['iPad', 'iPhone'];\n if (eligibleDevices.indexOf(model) !== -1) {\n // The device must be running iOS 11.2 or later.\n const [major, minor] = version.split('.');\n const intMajor = parseInt(major, 10);\n const intMinor = parseInt(minor, 10);\n if (intMajor < 12) {\n return intMajor >= 11 && intMinor >= 2;\n }\n return true;\n }\n // Device not eligible\n return false;\n }\n // Buyer not in China\n return true;\n};\n\nconst isIframe = (): boolean => {\n return window.top !== window.self;\n};\n\nconst getIsEligibleForApplePay = ({\n buyerCountryCode,\n merchantCountryCode,\n supportedCountries\n}: {\n buyerCountryCode: string | undefined;\n merchantCountryCode: string | undefined;\n supportedCountries: string[];\n}) => {\n if (!window?.ApplePaySession) {\n return false;\n }\n\n if (!buyerCountryCode) {\n logErrorClient('getIsEligibleForApplePay', 'Missing buyer country code');\n return false;\n }\n\n if (!merchantCountryCode) {\n logErrorClient('getIsEligibleForApplePay', 'Missing merchant country code');\n return false;\n }\n\n if (!isDeviceEligibleForApplePay(buyerCountryCode)) {\n logWarnClient('getIsEligibleForApplePay', 'Device ineligible for ApplePay');\n return false;\n }\n\n const isBuyerFromChina = chinaCountryCodes.includes(buyerCountryCode.toUpperCase());\n const isMerchantFromChina = chinaCountryCodes.includes(merchantCountryCode.toUpperCase());\n if (isBuyerFromChina && isMerchantFromChina) {\n logWarnClient('getIsEligibleForApplePay', 'China seller and China merchant');\n return false;\n }\n\n if (isIframe()) {\n logWarnClient('getIsEligibleForApplePay', 'IFrame');\n return false;\n }\n\n const supportedCountriesSet = new Set(supportedCountries);\n\n if (!supportedCountriesSet.has(merchantCountryCode)) {\n logWarnClient('getIsEligibleForApplePay', 'Unsupported merchant country code');\n return false;\n }\n\n if (!supportedCountriesSet.has(buyerCountryCode)) {\n logWarnClient('getIsEligibleForApplePay', 'Unsupported buyer country code');\n return false;\n }\n\n if (!window.ApplePaySession?.canMakePayments?.()) {\n logWarnClient(\n 'getIsEligibleForApplePay',\n `canMakePayments false - type(${typeof window.ApplePaySession?.canMakePayments})`\n );\n return false;\n }\n\n return true;\n};\n\nexport default getIsEligibleForApplePay;\n","import { replaceGeoUrl } from '@common/replaceGeoUrl';\nimport serverData from '@client/utils/server-data';\n\nexport const imageLocations = {\n venmo: replaceGeoUrl(\n 'https://www.paypalobjects.com/paypal-ui/logos/svg/venmo-mark-color.svg',\n serverData?.geoAwareDomain\n ),\n paylater: replaceGeoUrl(\n 'https://www.paypalobjects.com/paypal-ui/logos/svg/paypal-mark-color.svg',\n serverData?.geoAwareDomain\n ),\n applepay: replaceGeoUrl(\n 'https://www.paypalobjects.com/paypal-ui/logos/svg/apple-pay-color.svg',\n serverData?.geoAwareDomain\n ),\n card: replaceGeoUrl(\n 'https://www.paypalobjects.com/paypal-ui/icons/v3/svg/credit-card.svg',\n serverData?.geoAwareDomain\n )\n};\n\nexport const PAGE_NAME = 'paywall';\n","import React, { useRef, useEffect, useState } from 'react';\nimport loadable from '@loadable/component';\nimport { FUNDING, usePayPalScriptReducer } from '@paypal/react-paypal-js';\nimport type {\n FUNDING_SOURCE,\n OnShippingAddressChangeData,\n OnShippingOptionsChangeData,\n OnShippingAddressChangeActions,\n OnShippingOptionsChangeActions,\n OnCancelledActions\n} from '@paypal/paypal-js';\nimport { Row, LoadingSpinner } from '@paypalcorp/pp-react';\nimport { spinnerStyle, hideStyle } from '@client/components/common/commonStyles';\nimport { useAppContext } from '@client/contexts/AppContext';\nimport { getFeatureFlags } from '@client/helpers/ucpConfig';\nimport serverData from '@client/utils/server-data';\nimport useOrderStatus from '@client/hooks/useOrderStatus';\nimport { PageName, endCPLTracking, startCPLTracking } from '@common/analytics';\nimport {\n CheckoutPaymentOptionsOtherThanPayPal,\n ShippingPreference,\n TaxRatePreference\n} from '@components/buttons/types';\nimport { getCurrencyConfig } from '@client/utils/localeHelper';\nimport { logErrorClient } from '@client/utils/beaverLogger';\nimport { usePreviewContext } from '@client/contexts/PreviewContext';\nimport { usePaymentContext } from '@client/contexts/PaymentContext';\nimport getPaymentTotalFields from '@client/helpers/getPaymentTotalFields';\nimport { useCartContext } from '@client/contexts/CartContext';\nimport { transformButtonVariables } from '@client/utils/utils';\nimport getIsEligibleForApplePay from '@client/components/ButtonsStack/ApplePayButton/getIsEligibleForApplePay';\nimport { generateOptions } from '@components/FormFields/helpers';\nimport {\n OrderShipping,\n SDKButtonStyle,\n HostedButtonDetails,\n ButtonVariation\n} from '@client/typings/Common';\nimport { useWorldReadyContext } from '@client/contexts/WorldReadyContext';\nimport { ButtonType } from '@client/utils/constants';\nimport { getSessionId } from '@client/utils/storage';\nimport {\n createOrderWrapper,\n captureOrderWrapper,\n updateOrderShippingOptions\n} from '../ordersHelper';\nimport styles from './styles';\nimport { PAGE_NAME } from './constants';\nimport { SDKButtonWrapperProps, PaywallButtonProps } from '../types';\nimport { JSSDKButtonProps } from '../JSSDKButton';\nimport { getViewCartTags } from './utils';\n\nconst LoadableWithRadio = loadable(() => import('./WithRadio'), {\n ssr: false\n});\n\nconst LoadableWithButtons = loadable(() => import('./WithButtons'), {\n ssr: false\n});\n\nconst LoadableWithButtonsV2 = loadable(() => import('./WithButtonsV2'), {\n ssr: false\n});\n\nconst LoadableFireAidButton = loadable(() => import('./FireAidButton'), {\n ssr: false\n});\n\ntype PaywallButtonWrapperProps = SDKButtonWrapperProps & {\n allowedPaymentMethods: `${CheckoutPaymentOptionsOtherThanPayPal}`[];\n merchantCountryCode?: string;\n buttonDetails?: HostedButtonDetails;\n shouldUseNewPPUI?: boolean;\n isUpdating?: boolean;\n};\n\n// TODO: Currently the WithinButtonsV2 is simply copied from Amal's branch for NCPS Settings feature only\n// We will need to migrate the phase 2 components to all use PPUI5.0 later\nconst PaywallHostedButtons = ({\n merchantId,\n hostedButtonId,\n buttonType,\n currencyCode,\n shippingPreference,\n taxRatePreference,\n allowedPaymentMethods,\n merchantCountryCode,\n notCollectShippingAddr,\n buttonVariables,\n buttonDetails,\n shouldUseNewPPUI,\n isUpdating\n}: PaywallButtonWrapperProps) => {\n const [{ isPending }] = usePayPalScriptReducer();\n const appContext = useAppContext();\n const featureFlags = getFeatureFlags(appContext);\n const { isPreview } = usePreviewContext();\n const { cartDetails } = useCartContext();\n const worldReady = useWorldReadyContext();\n const config = appContext?.app?.config;\n const enablePaywallButtons = appContext?.enablePaywallButtons;\n const paypalButtonMessagingEnableData = appContext?.paypalButtonMessagingEnableData;\n const enableBuyerAddToCart = appContext?.enableBuyerAddToCart;\n const isCartFlow = buttonType === ButtonVariation.Cart;\n const isPayLaterDisabled = appContext?.isPayLaterDisabled;\n\n const {\n formErrorMessage,\n userInputs,\n setCaptureStatus,\n setOrderData,\n fptiAdditionalTags,\n setIsLoading,\n setProfileShipping,\n setProfileTax\n } = usePaymentContext();\n\n // we need to use ref for dynamic values because JS SDK seems to only\n // register the first instance of the function passed to it and does\n // not update that function with updated arguments after the first render.\n // If you're feeling adventurous, please check out https://paypal.atlassian.net/browse/DTNCPS-1765\n const userInputsRef = useRef(userInputs);\n const cartDetailsRef = useRef(cartDetails);\n const formErrorMessageRef = useRef(formErrorMessage);\n const [initComplete, setInitComplete] = useState(false);\n const [removeSpinner, setRemoveSpinner] = useState(false);\n const ppBtnLoading = isPending || !initComplete;\n const showSpinner = ppBtnLoading || !removeSpinner;\n const [eligibleMethods, updateEligibleMethods] = useState<FUNDING_SOURCE[]>([]);\n const initialCsrfToken = serverData.csrfToken;\n\n const updateProfileShippingTax = (orderShipping: OrderShipping) => {\n const isShippingFromProfile = shippingPreference === ShippingPreference.FromProfile;\n const isTaxFromProfile = taxRatePreference === TaxRatePreference.FromProfile;\n\n if (isShippingFromProfile) {\n setProfileShipping(orderShipping?.amount?.breakdown?.shipping?.value ?? '0');\n }\n\n if (isTaxFromProfile) {\n setProfileTax(orderShipping?.amount?.breakdown?.tax_total?.value ?? '0');\n }\n };\n\n const onCreateOrder = createOrderWrapper({\n fptiAdditionalTags,\n userInputsRef,\n cartDetailsRef,\n apiParams: {\n csrfToken: initialCsrfToken,\n hostedButtonId,\n merchantId,\n buttonType\n },\n pageName: PAGE_NAME,\n appContext\n });\n\n const onApprove = captureOrderWrapper({\n appContext,\n apiParams: {\n csrfToken: initialCsrfToken,\n hostedButtonId,\n merchantId,\n buttonType\n },\n fptiAdditionalTags,\n pageName: PAGE_NAME,\n setOrderData,\n setIsLoading,\n cartDetailsRef\n });\n\n const onShippingAddressChange = async (\n data: OnShippingAddressChangeData,\n actions: OnShippingAddressChangeActions\n ) => {\n const orderShipping = await updateOrderShippingOptions({\n csrfToken: initialCsrfToken,\n // @ts-ignore workaround for guest xo. Issue: https://paypal.atlassian.net/browse/LI-61763\n contextId: data.orderID || data.orderId,\n hostedButtonId,\n shippingAddress: data.shippingAddress,\n fptiAdditionalTags,\n pageName: PAGE_NAME\n });\n\n if (!orderShipping) {\n // @ts-ignore\n return actions.reject(data.errors?.ADDRESS_ERROR);\n }\n\n updateProfileShippingTax(orderShipping);\n };\n const onShippingOptionsChange = async (\n data: OnShippingOptionsChangeData,\n actions: OnShippingOptionsChangeActions\n ) => {\n const { selectedShippingOption } = data;\n if (!selectedShippingOption) {\n logErrorClient('onShippingOptionsChange', 'No selected shipping option');\n // @ts-ignore\n return actions.reject(data.errors?.METHOD_UNAVAILABLE);\n }\n\n const orderShipping = await updateOrderShippingOptions({\n csrfToken: initialCsrfToken,\n // @ts-ignore workaround for guest xo. Issue: https://paypal.atlassian.net/browse/LI-61763\n contextId: data.orderID || data.orderId,\n hostedButtonId,\n optionId: selectedShippingOption.id,\n fptiAdditionalTags,\n pageName: PAGE_NAME\n });\n\n if (!orderShipping) {\n // @ts-ignore\n return actions.reject(data.errors?.METHOD_UNAVAILABLE);\n }\n\n updateProfileShippingTax(orderShipping);\n };\n\n const onCancel = (data: Record<string, unknown>, actions: OnCancelledActions) => {\n setProfileShipping(undefined);\n setProfileTax(undefined);\n };\n\n const jssdkCommonPayload = { event: 'im', pageName: PAGE_NAME as PageName };\n let buttonStyle: SDKButtonStyle;\n if (enablePaywallButtons) {\n buttonStyle = {\n height: 50 // Explicit height as per UX recommendation\n };\n }\n\n /**\n * Whether to update the order shipping when shipping contact or shipping option is changed\n * This only applies to shipping_from_profile and tax_rate_from_profile\n */\n const shouldUpdateOrderShipping =\n shippingPreference === ShippingPreference.FromProfile ||\n taxRatePreference === TaxRatePreference.FromProfile;\n\n useEffect(() => {\n userInputsRef.current = userInputs;\n }, [userInputs]);\n\n useEffect(() => {\n cartDetailsRef.current = cartDetails;\n }, [cartDetails]);\n\n useEffect(() => {\n formErrorMessageRef.current = formErrorMessage;\n }, [formErrorMessage]);\n\n const getFundingSources = () =>\n window.paypal?.getFundingSources?.()?.filter((source) => {\n if (!(allowedPaymentMethods as Partial<FUNDING_SOURCE>[]).includes(source)) {\n return false;\n }\n if (appContext?.enableFireAid) {\n if (source === FUNDING.VENMO) {\n return window.paypal?.isFundingEligible?.(source);\n }\n return false;\n }\n if (source === FUNDING.VENMO && shouldUpdateOrderShipping) {\n return featureFlags?.venmoShipTaxSupport && window.paypal?.isFundingEligible?.(source);\n }\n if (source === FUNDING.APPLEPAY) {\n return (\n isPreview ||\n getIsEligibleForApplePay({\n buyerCountryCode: appContext?.app.region,\n merchantCountryCode,\n supportedCountries: config?.applepay?.supportedCountries ?? []\n })\n );\n }\n if (source === FUNDING.PAYLATER && isPayLaterDisabled) {\n return false;\n }\n return window.paypal?.isFundingEligible?.(source);\n }) || [];\n\n const getEligibilities = async () => {\n const fundingSources = getFundingSources();\n\n // We should remove the spinner right away if we only need to show the PayPal button.\n // When we have more than one funding method, we will show the radio buttons\n // so that gives us enough lead-time to remove the spinner since we render the PayPalButtons\n // underneath the radio buttons.\n if (!enablePaywallButtons && fundingSources.length !== 1) {\n setRemoveSpinner(true);\n }\n\n updateEligibleMethods(fundingSources);\n\n if (appContext?.enableFireAid) {\n setRemoveSpinner(true);\n }\n\n if (!isPreview) {\n fundingSources.forEach((method) => {\n startCPLTracking(\n {\n ...jssdkCommonPayload,\n ...getViewCartTags(cartDetailsRef),\n eventName: `js_sdk_loaded_${method}`\n },\n `js_sdk_loaded_${method}`\n );\n });\n }\n };\n\n useEffect(() => {\n if (ppBtnLoading) {\n return;\n }\n\n getEligibilities();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ppBtnLoading, shouldUpdateOrderShipping, allowedPaymentMethods]);\n\n useEffect(() => {\n if (isPreview || !ppBtnLoading) return;\n startCPLTracking(\n {\n ...jssdkCommonPayload,\n ...getViewCartTags(cartDetailsRef),\n eventName: 'js_sdk_loaded_paypal'\n },\n 'js_sdk_loaded_paypal'\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ppBtnLoading]);\n\n useEffect(() => {\n if (isPreview) return;\n\n const payLaterFPTITags = {\n xe: paypalButtonMessagingEnableData?.xe,\n xt: paypalButtonMessagingEnableData?.xt\n };\n\n if (showSpinner) {\n startCPLTracking(\n {\n ...jssdkCommonPayload,\n eventName: 'button_load_complete',\n ...(!isCartFlow && payLaterFPTITags)\n },\n 'button_load_complete'\n );\n } else {\n const page_session_id = getSessionId();\n\n endCPLTracking(\n {\n ...jssdkCommonPayload,\n eventName: 'button_load_complete',\n eligible_payment_count: eligibleMethods.length + 1,\n page_session_id,\n ...(!isCartFlow && payLaterFPTITags)\n },\n 'button_load_complete'\n );\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showSpinner]);\n\n useOrderStatus(buttonType as ButtonType | ButtonVariation.Cart);\n\n const commonButtonProps = {\n pageName: PAGE_NAME as PageName,\n userInputs,\n formErrorMessageRef,\n buttonType,\n currencyCode,\n buttonStyle,\n isUpdating,\n cartDetailsRef\n } as JSSDKButtonProps;\n\n const getPayLaterProps = () => {\n const buttonDetailsTransformed = transformButtonVariables(buttonDetails?.link_variables);\n const option_details = buttonDetails?.option_details;\n const options = generateOptions(option_details, buttonVariables?.currency_code, worldReady);\n const currencyConfig = getCurrencyConfig(worldReady, currencyCode);\n\n const fields = getPaymentTotalFields(\n buttonDetailsTransformed,\n userInputs,\n options,\n featureFlags,\n currencyConfig.maxDecimalPlaces.toString()\n );\n\n return {\n paypalButtonMessagingEnabled: paypalButtonMessagingEnableData?.enabled,\n // total value sometimes returns 'ESTIMATE_LATER', so in that case we will return the subtotal\n amount: typeof fields.total.value === 'number' ? fields.total.value : fields.subtotal.value\n };\n };\n\n const commonJSSDKButtonProps = {\n ...commonButtonProps,\n userInputsRef,\n createOrder: onCreateOrder,\n onApprove,\n setCaptureStatus,\n notCollectShippingAddr,\n buttonVariables,\n buttonDetails,\n fundingSource: undefined,\n ...(!isCartFlow && getPayLaterProps()),\n ...(shouldUpdateOrderShipping && { onShippingAddressChange, onShippingOptionsChange, onCancel })\n } as JSSDKButtonProps;\n\n const trackButtonLoaded = (paymentMethod: FUNDING_SOURCE) => {\n if (isPreview) return;\n endCPLTracking(\n {\n ...jssdkCommonPayload,\n ...getViewCartTags(cartDetailsRef),\n eventName: `js_sdk_loaded_${paymentMethod}`\n },\n `js_sdk_loaded_${paymentMethod}`\n );\n };\n\n const getButtons = (buttonProps: PaywallButtonProps) => {\n if (appContext?.enableFireAid) {\n return <LoadableFireAidButton {...buttonProps} showSpinner={showSpinner} />;\n }\n\n if ((enableBuyerAddToCart && isCartFlow) || shouldUseNewPPUI) {\n return <LoadableWithButtonsV2 {...buttonProps} />;\n }\n\n if (enablePaywallButtons) {\n return <LoadableWithButtons {...buttonProps} />;\n }\n\n return (\n <LoadableWithRadio\n {...buttonProps}\n setInitComplete={setInitComplete}\n setRemoveSpinner={setRemoveSpinner}\n />\n );\n };\n\n return (\n <>\n {showSpinner && (\n <Row data-testid=\"spinner\" css={spinnerStyle}>\n <LoadingSpinner size=\"lg\" />\n </Row>\n )}\n <div\n data-testid=\"paypal-buttons-container\"\n css={[enablePaywallButtons && styles.buttonContainer, showSpinner && hideStyle]}\n >\n {getButtons({\n merchantId,\n hostedButtonId,\n eligibleMethods,\n commonButtonProps,\n commonJSSDKButtonProps,\n setInitComplete,\n trackButtonLoaded,\n setRemoveSpinner,\n shouldUpdateOrderShipping\n })}\n </div>\n </>\n );\n};\n\nexport default PaywallHostedButtons;\n","import { css } from '@emotion/react';\n\nconst styles = {\n buttonContainer: css`\n display: grid;\n gap: 1rem;\n `\n};\n\nexport default styles;\n","import React, { MutableRefObject } from 'react';\nimport { FlowVariationType } from '@common/analytics';\nimport { getButtonIdList } from '@components/ViewCart/utils';\nimport { CartDetails } from '@client/typings/Cart';\n\nexport interface toggleFundingProps {\n isShowMoreOptions: boolean;\n onClick: React.MouseEventHandler<HTMLElement>;\n}\n\nexport const getViewCartTags = (cartDetailsRef?: MutableRefObject<CartDetails | undefined>) =>\n cartDetailsRef?.current\n ? {\n cart_id: cartDetailsRef.current.id,\n hosted_button_id: getButtonIdList(cartDetailsRef.current?.items || []),\n flow_variation: 'add_to_cart' as FlowVariationType\n }\n : {};\n","import { Dispatch, SetStateAction, MutableRefObject } from 'react';\nimport type {\n OnApproveActions,\n OnApproveData,\n CreateOrderData,\n OnShippingAddressChangeData\n} from '@paypal/paypal-js';\nimport fetchWrapper from '@client/helpers/fetchWrapper';\nimport { PageName, endCPLTracking, recordImpression, startCPLTracking } from '@common/analytics';\nimport { logErrorClient } from '@client/utils/beaverLogger';\nimport { UserInputsType, OrderShipping, OrderDetails, ServerError } from '@client/typings/Common';\nimport { IAppContext } from '@client/contexts/AppContext';\nimport { CartDetails } from '@client/typings/Cart';\nimport { CartContextType } from '@client/contexts/CartContext';\nimport { ERRORS } from '@common/constants';\nimport { getItemsUpdatedByMerchant } from '@common/isCartInSync';\nimport { PaymentContextType } from '@client/contexts/PaymentContext';\nimport { getLocalizedString, WorldReadyProps } from '@client/utils/localeHelper';\nimport { getViewCartTags } from './PaywallHostedButtons/utils';\n\ntype ApiParams = {\n csrfToken: string;\n hostedButtonId: string;\n merchantId: string | undefined;\n buttonType: string | undefined;\n};\n\nconst createOrder = async (\n data: CreateOrderData,\n userInputsRef: MutableRefObject<UserInputsType>,\n apiParams: ApiParams,\n cartDetailsRef?: MutableRefObject<CartDetails | undefined>\n) => {\n const paymentSource = data.paymentSource.toUpperCase();\n const { csrfToken, hostedButtonId, merchantId, buttonType } = apiParams;\n const tStart = Date.now();\n const { response, responseData: order } = await fetchWrapper(\n '/ncp/api/create-order',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-csrf-token': csrfToken\n },\n body: JSON.stringify({\n link_id: hostedButtonId,\n merchant_id: merchantId,\n ...userInputsRef.current,\n funding_source: paymentSource,\n button_type: buttonType,\n cart_details: cartDetailsRef?.current\n })\n },\n true\n );\n const apiDuration = Date.now() - tStart;\n return { response, order, apiDuration };\n};\n\nconst captureOrder = async (data: OnApproveData, apiParams: ApiParams) => {\n // @ts-ignore: paymentSource type does exist\n const { paymentSource } = data;\n const { csrfToken, hostedButtonId, merchantId, buttonType } = apiParams;\n\n const tStart = Date.now();\n const { response, responseData: order } = await fetchWrapper(\n '/ncp/api/capture-order',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-csrf-token': csrfToken\n },\n body: JSON.stringify({\n link_id: hostedButtonId,\n merchant_id: merchantId,\n context_id: data.orderID,\n source: paymentSource,\n button_type: buttonType\n })\n },\n true\n );\n const apiDuration = Date.now() - tStart;\n return { response, order, apiDuration };\n};\n\nconst csrfResponseHandler = (\n response: Response,\n order: { csrfToken?: string; [key: string]: unknown },\n appContext: IAppContext | null\n): Promise<object> | void => {\n if (response.status === 403) {\n return Promise.reject({ status: 403 });\n }\n\n if (order.csrfToken) {\n appContext?.setCsrfToken(order.csrfToken);\n }\n};\n\nexport const createOrderWrapper =\n ({\n appContext,\n apiParams,\n fptiAdditionalTags,\n pageName,\n userInputsRef,\n cartDetailsRef\n }: {\n appContext: IAppContext | null;\n apiParams: ApiParams;\n fptiAdditionalTags: Record<string, unknown>;\n pageName: PageName;\n userInputsRef: React.MutableRefObject<UserInputsType>;\n cartDetailsRef?: MutableRefObject<CartDetails | undefined>;\n }) =>\n async (data: CreateOrderData) => {\n const paymentSource = data.paymentSource.toUpperCase();\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'create_order_start'\n },\n {\n funding_type: paymentSource\n }\n );\n startCPLTracking({\n pageName,\n eventName: 'create_order',\n event: 'im'\n });\n const { response, order, apiDuration } = await createOrder(\n data,\n userInputsRef,\n {\n ...apiParams,\n csrfToken: appContext?.app?.csrfToken || apiParams.csrfToken\n },\n cartDetailsRef\n );\n endCPLTracking();\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'create_order_end'\n },\n {\n funding_type: paymentSource,\n order_id: order?.context_id,\n api_response_code: response.status,\n api_duration: apiDuration\n }\n );\n const csrfResponse = csrfResponseHandler(response, order, appContext);\n if (csrfResponse) {\n return csrfResponse;\n }\n if (order.context_id) {\n return order.context_id;\n }\n return Promise.reject(order);\n };\n\nexport const handleCreateOrderCartError = (\n error: ServerError,\n clientCartDetails: CartDetails,\n worldReady: WorldReadyProps,\n setStaleCartItems: CartContextType['setStaleCartItems'],\n setCartDetails: CartContextType['setCartDetails'],\n setErrorMessage: PaymentContextType['setErrorMessage']\n): boolean => {\n try {\n if (error.status === 400 && error.message === ERRORS.CART_OUT_OF_SYNC) {\n const errorDetails = error?.details?.[0];\n if (clientCartDetails && errorDetails?.field === 'cart_details' && errorDetails?.value) {\n const serverCart = JSON.parse(errorDetails.value) as CartDetails;\n const staleItemIds = getItemsUpdatedByMerchant(clientCartDetails, serverCart);\n setStaleCartItems(staleItemIds);\n setCartDetails(serverCart);\n return true;\n }\n\n // Fallback to setting an empty array, which will still trigger an info alert\n setStaleCartItems([]);\n return true;\n }\n\n if (\n error.status === 404 ||\n (error.status === 422 &&\n error?.details?.some((detail) => detail.issue === 'INVALID_CART_ITEM'))\n ) {\n // Some item (404) or option (422) has been removed by merchant, but we don't know which item\n setErrorMessage(getLocalizedString(worldReady, 'error.cart.unavailableItem'));\n return true;\n }\n\n return false;\n } catch (err) {\n logErrorClient('handleCreateOrderCartError', err.message);\n return false;\n }\n};\n\nexport const captureOrderWrapper =\n ({\n appContext,\n apiParams,\n fptiAdditionalTags,\n pageName,\n setOrderData,\n setIsLoading,\n cartDetailsRef\n }: {\n appContext: IAppContext | null;\n apiParams: ApiParams;\n fptiAdditionalTags: Record<string, unknown>;\n pageName: PageName;\n setOrderData: Dispatch<SetStateAction<OrderDetails>>;\n setIsLoading?: Dispatch<SetStateAction<boolean>>;\n cartDetailsRef?: MutableRefObject<CartDetails | undefined>;\n }) =>\n async (data: OnApproveData, actions: OnApproveActions) => {\n try {\n // @ts-ignore: paymentSource type does exist\n const { paymentSource } = data;\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'capture_order_start'\n },\n {\n funding_type: paymentSource?.toUpperCase(),\n order_id: data.orderID\n }\n );\n\n /**\n * We don't need to setIsLoading false when capture order complete in this function\n * setIsLoading false will be called in useOrderStatus when thank you page redirection\n * is not required\n */\n setIsLoading?.(true);\n startCPLTracking({\n pageName,\n eventName: 'capture_order',\n event: 'im'\n });\n const {\n response,\n order: orderData,\n apiDuration\n } = await captureOrder(data, {\n ...apiParams,\n csrfToken: appContext?.app?.csrfToken || apiParams.csrfToken\n });\n endCPLTracking();\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'capture_order_end'\n },\n {\n funding_type: paymentSource?.toUpperCase(),\n order_id: data.orderID,\n api_response_code: response.status,\n api_duration: apiDuration\n }\n );\n const csrfResponse = csrfResponseHandler(response, orderData, appContext);\n if (csrfResponse) {\n setIsLoading?.(false);\n return csrfResponse;\n }\n if (orderData.name === 'INSTRUMENT_DECLINED') {\n setIsLoading?.(false);\n return actions.restart();\n }\n\n setOrderData(orderData);\n return orderData;\n } catch (err) {\n setIsLoading?.(false);\n }\n };\n\nexport const updateOrderShippingOptions = async ({\n csrfToken,\n contextId,\n hostedButtonId,\n shippingAddress,\n optionId,\n fptiAdditionalTags,\n pageName\n}: {\n csrfToken: string;\n contextId: string | undefined;\n hostedButtonId: string;\n shippingAddress?: OnShippingAddressChangeData['shippingAddress'];\n optionId?: string;\n fptiAdditionalTags: Record<string, unknown>;\n pageName: PageName;\n}): Promise<OrderShipping | null> => {\n try {\n if (!contextId) {\n throw Error('Invalid context id');\n }\n\n if (!shippingAddress && !optionId) {\n throw Error('Invalid payload');\n }\n\n recordImpression({\n ...fptiAdditionalTags,\n pageName,\n eventName: optionId ? 'ship_option_change_start' : 'ship_address_change_start'\n });\n startCPLTracking({\n pageName,\n eventName: optionId ? 'ship_option_change' : 'ship_address_change',\n event: 'im'\n });\n const { responseData, response } = await fetchWrapper(\n `/ncp/api/order-shipping-options/${hostedButtonId}/${contextId}`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-csrf-token': csrfToken\n },\n body: JSON.stringify({\n ...(shippingAddress && {\n shipping_address: {\n admin_area_2: shippingAddress.city,\n admin_area_1: shippingAddress.state,\n country_code: shippingAddress.countryCode,\n postal_code: shippingAddress.postalCode\n }\n }),\n ...(optionId && { option_id: optionId })\n })\n },\n true\n );\n endCPLTracking();\n recordImpression({\n ...fptiAdditionalTags,\n pageName,\n eventName: optionId ? 'ship_option_change_end' : 'ship_address_change_end'\n });\n const body = responseData as OrderShipping;\n if (response.status !== 200) {\n throw Error(responseData?.message || 'Failed updating shipping options');\n }\n return body;\n } catch (err) {\n logErrorClient('updateOrderShippingOptions', err.message);\n return null;\n }\n};\n","import type { OrderDetails } from '@client/typings/Common';\nimport { OrderStatus, CaptureStatus } from '@client/utils/constants';\nimport type { ConfirmationDetails } from '@components/ConfirmationCart/types';\n\nexport const isOrderCompleted = (orderDetails: OrderDetails | ConfirmationDetails) =>\n orderDetails &&\n orderDetails.status === OrderStatus.COMPLETED &&\n orderDetails.payment_status === CaptureStatus.COMPLETED;\nexport const isOrderDeclined = (orderDetails: OrderDetails) =>\n orderDetails &&\n orderDetails.status === OrderStatus.COMPLETED &&\n orderDetails.payment_status === CaptureStatus.DECLINED;\nexport const isOrderPending = (orderDetails: OrderDetails | ConfirmationDetails) =>\n orderDetails &&\n orderDetails.status === OrderStatus.COMPLETED &&\n orderDetails.payment_status === CaptureStatus.PENDING;\nexport const isOrderFailed = (orderDetails: OrderDetails) =>\n orderDetails &&\n orderDetails.status === OrderStatus.COMPLETED &&\n orderDetails.payment_status === CaptureStatus.FAILED;\nexport const isOrderInstrumentDeclined = (orderDetails: OrderDetails) =>\n orderDetails && orderDetails.name === 'INSTRUMENT_DECLINED';\nexport const isOrderDuplicateInvoiceId = (orderDetails: OrderDetails) =>\n orderDetails && orderDetails.name === 'DUPLICATE_INVOICE_ID';\nexport const isOrderPaymentNotCaptured = (orderDetails: OrderDetails) =>\n orderDetails && orderDetails.name === 'PAYMENT_NOT_CAPTURED';\nexport const isSomethingWentWrong = (orderDetails: OrderDetails) =>\n orderDetails && orderDetails.name === 'SOMETHING_WENT_WRONG';\nexport const isOrderNotFound = (orderDetails: OrderDetails) =>\n orderDetails && orderDetails.error && orderDetails.name === 'RESOURCE_NOT_FOUND';\n","export type Restrictions = {\n min: number;\n max: number;\n};\n\nexport type ValidationRule = {\n isInvalid: (restrictions: Restrictions, val?: string | number) => boolean;\n messageId: string;\n};\n\nexport default {\n quantity: [\n {\n isInvalid: (restrictions, val) => !Number.isInteger(val),\n messageId: 'error.text.blank'\n },\n {\n isInvalid: (restrictions, val: number) => !!val && val > restrictions.max,\n messageId: 'error.cart.quantityExceeded'\n },\n {\n isInvalid: (restrictions, val: number) => !val || val < restrictions.min,\n messageId: 'error.invalidQuantity'\n }\n ]\n};\n","import { CartDetails, CartItemType } from '@client/typings/Cart';\nimport { UserInputsType, FormErrorMessageType, CartItemErrorType } from '@client/typings/Common';\nimport validationRules from './rules';\n\nconst ITEM_ERROR_CODE_TO_MESSAGE = {\n CART_ITEM_QUANTITY_OUT_OF_RANGE: 'error.cart.quantityExceeded',\n INVALID_BUTTON_ID: 'error.cart.inline.unavailableItem',\n CART_ITEM_CURRENCY_CODE_MISMATCH: 'error.cart.inline.multipleCurrencies'\n};\n\nconst ITEM_ERROR_CODE_TO_FIELD = {\n CART_ITEM_QUANTITY_OUT_OF_RANGE: 'quantity',\n INVALID_BUTTON_ID: 'link_id',\n CART_ITEM_CURRENCY_CODE_MISMATCH: 'link_id'\n};\n\nconst INVALID_BUTTON_ID = 'INVALID_BUTTON_ID';\nconst DEFAULT_ERROR_MESSAGE = 'error.cart.inline.generic';\nconst DEFAULT_ERROR_FIELD = 'id';\n\nconst getErrorForItemFields = (item: CartItemType, userInputs: UserInputsType) => {\n const quantity = Number(userInputs?.cartItems?.[item.id]?.quantity || item.purchase_quantity);\n const maxQuantity = Number(item?.max_allowed_quantity || '1');\n const restrictions = { min: 1, max: maxQuantity };\n const rules = validationRules.quantity;\n const itemError = {} as CartItemErrorType;\n\n rules.forEach((rule) => {\n if (rule.isInvalid(restrictions, quantity)) {\n itemError.quantity = rule.messageId;\n }\n });\n\n return itemError;\n};\n\nconst getErrorForItem = (item: CartItemType, userInputs: UserInputsType) => {\n const itemError = {} as CartItemErrorType;\n\n if (!item.valid) {\n const errorMessage =\n (item.error_message && ITEM_ERROR_CODE_TO_MESSAGE[item.error_message]) ||\n DEFAULT_ERROR_MESSAGE;\n const errorField =\n (item.error_message && ITEM_ERROR_CODE_TO_FIELD[item.error_message]) || DEFAULT_ERROR_FIELD;\n itemError[errorField] = errorMessage;\n\n // Return back the error, skip through rest of the validation only for invalid button\n if (item.error_message === INVALID_BUTTON_ID) {\n return itemError;\n }\n }\n\n return {\n ...itemError,\n ...getErrorForItemFields(item, userInputs)\n };\n};\n\nexport default function validateForm(\n cartDetails: CartDetails | undefined,\n userInputs: UserInputsType\n): FormErrorMessageType {\n const invalidItems: FormErrorMessageType = {\n isFormValid: true,\n isFocused: false,\n msgVariables: {}\n };\n\n const cartItems =\n cartDetails?.items?.reduce((acc, item) => {\n const itemErrors = getErrorForItem(item, userInputs);\n const hasErrors = Object.keys(itemErrors).length > 0;\n\n if (hasErrors) {\n acc[item.id] = itemErrors;\n }\n\n return acc;\n }, {}) || {};\n\n const hasErrors = Object.keys(cartItems).length > 0;\n\n if (hasErrors) {\n invalidItems.isFormValid = false;\n invalidItems.cartItems = cartItems;\n }\n\n return invalidItems;\n}\n","const fetchWrapper = async (\n path: string,\n options: RequestInit | undefined,\n csrfRetryEnabled = false\n) => {\n let initialOptions = options;\n\n // If the call should be retried in case there is a CSRF mismatch,\n // we need to add a flag to distinguish the first pre-retry call and the\n // second call.\n if (csrfRetryEnabled) {\n const oldBody =\n options?.body && (typeof options.body === 'string' ? JSON.parse(options.body) : options.body);\n initialOptions = {\n ...options,\n body: JSON.stringify({\n ...oldBody,\n csrfRetryEnabled\n })\n };\n }\n\n let response = await fetch(path, initialOptions);\n let responseData = await response.json();\n\n const shouldRetry =\n csrfRetryEnabled && responseData?.csrfToken && responseData?.message === 'CSRF_MISMATCH_RETRY';\n\n // If the first call had a CSRF mismatch, then we should redo the call\n // but with the new CSRF token.\n if (shouldRetry) {\n response = await fetch(path, {\n ...options,\n headers: {\n ...options?.headers,\n 'x-csrf-token': responseData.csrfToken\n }\n });\n responseData = await response.json();\n }\n\n return { response, responseData };\n};\n\nexport default fetchWrapper;\n","import { ButtonType } from '@client/utils/constants';\nimport { getTaxAmount } from '@client/utils/utils';\nimport {\n OptionItem,\n UcpConfig,\n FieldValueContent,\n Field,\n TotalFields\n} from '@client/typings/Common';\nimport { UserInputsType } from '@customTypes/client/Common';\nimport { ShippingPreference, TaxRatePreference } from '@components/buttons/types';\n\n// For Variable Price Button, not showing the quantity\n// For Fixed Price Button & Single Select Button, show quantity only if there is quantity option\nconst showItemQuantity = (buttonVariables: Record<string, string | undefined>) => {\n if (buttonVariables.button_type === ButtonType.VARIABLE_PRICE) {\n return false;\n }\n if (buttonVariables.quantity_option) {\n return true;\n }\n return false;\n};\n\nconst getQuantity = (\n userInputs: UserInputsType | undefined,\n buttonVariables: Record<string, string | undefined>\n) => {\n const quantityOption = parseInt(buttonVariables?.quantity_option || '1', 10);\n const quantityUserInput = parseInt(userInputs?.quantity || '1', 10);\n return quantityUserInput <= quantityOption ? quantityUserInput : 1;\n};\n\nconst getItemPrice = (\n buttonVariables: Record<string, string | undefined>,\n userInputs: UserInputsType | undefined,\n options: OptionItem[] | undefined\n) => {\n if (buttonVariables?.button_type === ButtonType.SINGLE_SELECT_LIST) {\n return options?.find((_) => _.value === userInputs?.item)?.price || 0;\n }\n return buttonVariables.amount || 0;\n};\n\nconst getSubtotal = (\n buttonVariables: Record<string, string | undefined>,\n userInputs: UserInputsType | undefined,\n options: OptionItem[] | undefined\n) => {\n if (buttonVariables.button_type === ButtonType.VARIABLE_PRICE) {\n return Number(userInputs?.amount ?? '0');\n }\n const quantity = getQuantity(userInputs, buttonVariables);\n const itemPrice = getItemPrice(buttonVariables, userInputs, options);\n const subtotal = quantity * Number(itemPrice);\n return subtotal;\n};\n\nexport interface PaymentTotalFields extends TotalFields {\n quantity: Field<number>;\n}\n\nconst getShippingField = (\n buttonVariables: Record<string, string | undefined>,\n featureFlags: UcpConfig['featureFlags'],\n profileShipping?: string\n) => {\n const { button_type, shipping_preference } = buttonVariables;\n const shipping = Number(buttonVariables.shipping || '0');\n if (button_type === ButtonType.VARIABLE_PRICE && !featureFlags.shippingTaxExpansion) {\n return {\n showField: false,\n value: 0\n };\n }\n\n // \"shipping_preference === undefined and shipping fee is not 0\" case happens in phase 1 button\n if (shipping_preference === ShippingPreference.Custom || shipping_preference === undefined) {\n return {\n showField: shipping > 0,\n value: shipping\n };\n }\n\n if (shipping_preference === ShippingPreference.FromProfile) {\n if (profileShipping !== undefined) {\n return {\n showField: true,\n value: Number(profileShipping)\n };\n }\n return {\n showField: true,\n value: FieldValueContent.EstimateLater\n };\n }\n\n if (shipping_preference === ShippingPreference.Free) {\n return {\n showField: true,\n value: FieldValueContent.Free\n };\n }\n\n return {\n showField: false,\n value: 0\n };\n};\n\nconst getTaxField = (\n tax: number,\n buttonVariables: Record<string, string | undefined>,\n featureFlags: UcpConfig['featureFlags'],\n profileTax?: string\n) => {\n const { button_type, tax_rate_preference } = buttonVariables;\n if (button_type === ButtonType.VARIABLE_PRICE && !featureFlags.shippingTaxExpansion) {\n return {\n showField: false,\n value: 0\n };\n }\n\n // \"tax_rate_preference === undefined and tax is not 0\" case happens in phase 1 button\n if (tax_rate_preference === TaxRatePreference.Custom || tax_rate_preference === undefined) {\n return {\n showField: tax > 0,\n value: tax\n };\n }\n\n if (tax_rate_preference === TaxRatePreference.FromProfile) {\n if (profileTax !== undefined) {\n return {\n showField: true,\n value: Number(profileTax)\n };\n }\n return {\n showField: true,\n value: FieldValueContent.EstimateLater as `${FieldValueContent.EstimateLater}`\n };\n }\n\n return {\n showField: false,\n value: 0\n };\n};\n\nconst getTotalField = (\n subtotal: number,\n taxField: PaymentTotalFields['tax'],\n shippingField: PaymentTotalFields['shipping'],\n buttonVariables: Record<string, string | undefined>\n) => {\n const totalField: PaymentTotalFields['total'] = {\n showField: true,\n value: subtotal\n };\n if (\n taxField.value === FieldValueContent.EstimateLater ||\n shippingField.value === FieldValueContent.EstimateLater\n ) {\n totalField.value = FieldValueContent.EstimateLater;\n } else if (shippingField.value === FieldValueContent.Free) {\n totalField.value = subtotal + (taxField.showField ? taxField.value : 0) + 0;\n } else {\n totalField.value =\n subtotal +\n (taxField.showField ? taxField.value : 0) +\n (shippingField.showField ? shippingField.value : 0);\n }\n\n // We need to only show the total field when there is a non-zero value there or if\n // it is a variable price button since we're showing total now for that in Phase 2\n totalField.showField =\n !!totalField.value || buttonVariables.button_type === ButtonType.VARIABLE_PRICE;\n\n return totalField;\n};\n\nconst getPaymentTotalFields = (\n buttonVariables: Record<string, string | undefined>,\n userInputs: UserInputsType | undefined,\n options: OptionItem[] | undefined,\n featureFlags: UcpConfig['featureFlags'],\n profileShipping?: string,\n profileTax?: string,\n maximumFractionDigits: number = 2\n): PaymentTotalFields => {\n const quantity = getQuantity(userInputs, buttonVariables);\n const subtotal = getSubtotal(buttonVariables, userInputs, options);\n\n // Shipping\n const shippingField: PaymentTotalFields['shipping'] = getShippingField(\n buttonVariables,\n featureFlags,\n profileShipping\n );\n\n // Tax rate\n const tax = getTaxAmount(\n subtotal,\n Number(buttonVariables.tax_rate || '0'),\n maximumFractionDigits\n );\n const taxField: PaymentTotalFields['tax'] = getTaxField(\n tax,\n buttonVariables,\n featureFlags,\n profileTax\n );\n\n // Subtotal\n const subtotalField: PaymentTotalFields['subtotal'] = {\n showField: shippingField.showField || taxField.showField,\n value: subtotal\n };\n\n // Total\n const totalField: PaymentTotalFields['total'] = getTotalField(\n subtotal,\n taxField,\n shippingField,\n buttonVariables\n );\n\n return {\n quantity: {\n showField: showItemQuantity(buttonVariables),\n value: quantity\n },\n tax: taxField,\n shipping: shippingField,\n subtotal: subtotalField,\n total: totalField\n };\n};\n\nexport default getPaymentTotalFields;\n","import { useEffect, useContext } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Context as WorldReadyContext } from '@paypalcorp/worldready-react';\nimport { usePaymentContext } from '@client/contexts/PaymentContext';\nimport { ButtonType } from '@client/utils/constants';\nimport { ButtonVariation } from '@client/typings/Common';\nimport { CaptureStatus } from '../utils/constants';\nimport { getLocalizedString, WorldReadyProps } from '../utils/localeHelper';\nimport {\n isOrderCompleted,\n isOrderDeclined,\n isOrderFailed,\n isOrderPending,\n isOrderInstrumentDeclined,\n isOrderDuplicateInvoiceId\n} from '../components/OrderStatus/utils';\n\nconst useOrderStatus = (buttonType?: ButtonType | ButtonVariation.Cart) => {\n const worldReady = useContext<WorldReadyProps>(WorldReadyContext);\n const {\n setCaptureStatus,\n orderData,\n setErrorMessage,\n fptiAdditionalTags = {},\n setIsLoading\n } = usePaymentContext();\n const navigate = useNavigate();\n\n useEffect(() => {\n if (isOrderCompleted(orderData) || isOrderPending(orderData)) {\n const queryParams: { key: string; value: string }[] = [];\n if (orderData.name === 'UNKNOWN') {\n queryParams.push({ key: 'status', value: 'UNKNOWN' });\n }\n if (fptiAdditionalTags.source_type === 'qr_code') {\n queryParams.push({ key: 'qrcode', value: 'true' });\n }\n const paramStr = queryParams.length\n ? `?${queryParams.map(({ key, value }) => `${key}=${value}`).join('&')}`\n : '';\n\n if (buttonType === ButtonVariation.Cart) {\n navigate(`/viewcart/${orderData.link_id}/${orderData.context_id}${paramStr}`, {\n replace: true\n });\n } else {\n window.location.assign(\n `/ncp/payment/${orderData.link_id}/${orderData.context_id}${paramStr}`\n );\n }\n } else {\n setIsLoading?.(false);\n if (isOrderInstrumentDeclined(orderData)) {\n setCaptureStatus(CaptureStatus.FAILED);\n setErrorMessage(getLocalizedString(worldReady, 'error.text.instrumentDeclined.alert'));\n } else if (isOrderDuplicateInvoiceId(orderData)) {\n setCaptureStatus(CaptureStatus.FAILED);\n setErrorMessage(getLocalizedString(worldReady, 'error.text.duplicateInvoiceId.alert'));\n } else if (isOrderDeclined(orderData) || isOrderFailed(orderData) || orderData.error) {\n setCaptureStatus(CaptureStatus.FAILED);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [orderData]);\n};\n\nexport default useOrderStatus;\n","const XSS_REGEX = [/<\\/?(\\w|<|>)*>/g, /<\\/?(.)*>/g, /</g, />/g, /[<>]/g];\n\nexport const sanitizeString = (value: string): string => {\n const regExList = new Set(XSS_REGEX);\n let sanitizedValue = value;\n regExList.forEach((regex) => {\n sanitizedValue = value.replace(regex, '');\n });\n\n return sanitizedValue;\n};\n\nexport function sanitize(value: string): string;\n\nexport function sanitize(value: object): object;\n\n// the object should be flattened, otherwise this would not work properly\nexport function sanitize(value: string | object): string | object {\n if (typeof value === 'string') {\n return sanitizeString(value).toString().trim();\n }\n\n if (typeof value === 'object') {\n for (const key in value) {\n if (typeof value[key] === 'string') {\n value[key] = sanitizeString(value[key]).toString().trim();\n }\n }\n }\n\n return value;\n}\n"],"names":["chinaCountryCodes","getIsEligibleForApplePay","buyerCountryCode","merchantCountryCode","supportedCountries","window","ApplePaySession","logErrorClient","isDeviceEligibleForApplePay","buyerCountry","parser","UAParser","model","getDevice","version","getOS","includes","toUpperCase","indexOf","major","minor","split","intMajor","parseInt","intMinor","logWarnClient","isBuyerFromChina","isMerchantFromChina","top","self","supportedCountriesSet","Set","has","canMakePayments","imageLocations","venmo","replaceGeoUrl","serverData","geoAwareDomain","paylater","applepay","card","PAGE_NAME","LoadableWithRadio","loadable","resolved","chunkName","isReady","props","key","resolve","__webpack_modules__","importAsync","requireAsync","then","requireSync","id","__webpack_require__","ssr","LoadableWithButtons","LoadableWithButtonsV2","LoadableFireAidButton","PaywallHostedButtons","merchantId","hostedButtonId","buttonType","currencyCode","shippingPreference","taxRatePreference","allowedPaymentMethods","notCollectShippingAddr","buttonVariables","buttonDetails","shouldUseNewPPUI","isUpdating","isPending","usePayPalScriptReducer","appContext","useAppContext","featureFlags","getFeatureFlags","isPreview","usePreviewContext","cartDetails","useCartContext","worldReady","useWorldReadyContext","config","app","enablePaywallButtons","paypalButtonMessagingEnableData","enableBuyerAddToCart","isCartFlow","ButtonVariation","Cart","isPayLaterDisabled","formErrorMessage","userInputs","setCaptureStatus","setOrderData","fptiAdditionalTags","setIsLoading","setProfileShipping","setProfileTax","usePaymentContext","userInputsRef","useRef","cartDetailsRef","formErrorMessageRef","initComplete","setInitComplete","useState","removeSpinner","setRemoveSpinner","ppBtnLoading","showSpinner","eligibleMethods","updateEligibleMethods","initialCsrfToken","csrfToken","updateProfileShippingTax","orderShipping","isShippingFromProfile","ShippingPreference","FromProfile","isTaxFromProfile","TaxRatePreference","amount","breakdown","shipping","value","tax_total","onCreateOrder","createOrderWrapper","apiParams","pageName","onApprove","captureOrderWrapper","jssdkCommonPayload","event","buttonStyle","height","shouldUpdateOrderShipping","useEffect","current","async","fundingSources","paypal","getFundingSources","filter","source","enableFireAid","FUNDING","VENMO","isFundingEligible","venmoShipTaxSupport","APPLEPAY","region","PAYLATER","length","forEach","method","startCPLTracking","getViewCartTags","eventName","getEligibilities","payLaterFPTITags","xe","xt","page_session_id","getSessionId","endCPLTracking","eligible_payment_count","useOrderStatus","commonButtonProps","commonJSSDKButtonProps","createOrder","fundingSource","undefined","getPayLaterProps","buttonDetailsTransformed","transformButtonVariables","link_variables","option_details","options","generateOptions","currency_code","currencyConfig","getCurrencyConfig","fields","getPaymentTotalFields","maxDecimalPlaces","toString","paypalButtonMessagingEnabled","enabled","total","subtotal","onShippingAddressChange","data","actions","updateOrderShippingOptions","contextId","orderID","orderId","shippingAddress","reject","errors","ADDRESS_ERROR","onShippingOptionsChange","selectedShippingOption","METHOD_UNAVAILABLE","optionId","onCancel","_jsxs","_Fragment","children","_jsx","_Row","css","spinnerStyle","_LoadingSpinner","size","styles","buttonContainer","hideStyle","buttonProps","trackButtonLoaded","paymentMethod","cart_id","hosted_button_id","getButtonIdList","items","flow_variation","csrfResponseHandler","response","order","status","Promise","setCsrfToken","paymentSource","recordImpression","funding_type","apiDuration","tStart","Date","now","responseData","fetchWrapper","headers","body","JSON","stringify","link_id","merchant_id","funding_source","button_type","cart_details","order_id","context_id","api_response_code","api_duration","handleCreateOrderCartError","error","clientCartDetails","setStaleCartItems","setCartDetails","setErrorMessage","message","ERRORS","CART_OUT_OF_SYNC","errorDetails","details","field","serverCart","parse","getItemsUpdatedByMerchant","some","detail","issue","getLocalizedString","err","orderData","captureOrder","csrfResponse","name","restart","Error","shipping_address","admin_area_2","city","admin_area_1","state","country_code","countryCode","postal_code","postalCode","option_id","isOrderCompleted","orderDetails","OrderStatus","COMPLETED","payment_status","CaptureStatus","isOrderDeclined","DECLINED","isOrderPending","PENDING","isOrderFailed","FAILED","isOrderInstrumentDeclined","isOrderDuplicateInvoiceId","quantity","isInvalid","restrictions","val","Number","isInteger","messageId","max","min","ITEM_ERROR_CODE_TO_MESSAGE","CART_ITEM_QUANTITY_OUT_OF_RANGE","INVALID_BUTTON_ID","CART_ITEM_CURRENCY_CODE_MISMATCH","ITEM_ERROR_CODE_TO_FIELD","getErrorForItemFields","item","cartItems","purchase_quantity","max_allowed_quantity","itemError","validationRules","rule","getErrorForItem","valid","errorMessage","error_message","validateForm","invalidItems","isFormValid","isFocused","msgVariables","reduce","acc","itemErrors","Object","keys","path","csrfRetryEnabled","initialOptions","oldBody","fetch","json","showItemQuantity","ButtonType","VARIABLE_PRICE","quantity_option","getQuantity","quantityOption","quantityUserInput","profileShipping","profileTax","maximumFractionDigits","getSubtotal","itemPrice","getItemPrice","SINGLE_SELECT_LIST","find","_","price","shippingField","getShippingField","shipping_preference","shippingTaxExpansion","Custom","showField","FieldValueContent","EstimateLater","Free","taxField","getTaxField","tax","tax_rate_preference","getTaxAmount","tax_rate","subtotalField","totalField","getTotalField","useContext","WorldReadyContext","navigate","useNavigate","queryParams","push","source_type","paramStr","map","join","replace","location","assign","XSS_REGEX","sanitizeString","regExList","sanitizedValue","regex","sanitize","trim"],"sourceRoot":""}