@adyen/adyen-web 6.20.0 → 6.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/adyen.css +5 -6
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +14 -3
  6. package/dist/es/adyen.css +5 -6
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Ach/Ach.js +1 -1
  9. package/dist/es/components/Ach/Ach.js.map +1 -1
  10. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  12. package/dist/es/components/Card/Card.js +1 -1
  13. package/dist/es/components/Card/Card.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  19. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  20. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  21. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  22. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  23. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  24. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  25. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  26. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  27. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  28. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  29. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  30. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  31. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  32. package/dist/es/components/internal/PayButton/PayButton.js +1 -1
  33. package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
  34. package/dist/es/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  35. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  36. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  37. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  38. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  39. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  40. package/dist/es/core/core.js +1 -1
  41. package/dist/es/index.d.ts +14 -3
  42. package/dist/es-legacy/adyen.css +5 -6
  43. package/dist/es-legacy/adyen.css.map +1 -1
  44. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  45. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  46. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  47. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  48. package/dist/es-legacy/components/Card/Card.js +1 -1
  49. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  50. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  51. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  52. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  53. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  54. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  55. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  56. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  57. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  58. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  59. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  60. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  61. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  62. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  63. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  64. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  65. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  66. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  67. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  68. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  69. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  70. package/dist/es-legacy/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  71. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  72. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  73. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  74. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  75. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  76. package/dist/es-legacy/core/core.js +1 -1
  77. package/package.json +7 -7
  78. package/styles/adyen.css +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/components/Card/components/CardInput/utils.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { AddressModeOptions, CardInputProps, LayoutObj } from './types';\nimport {\n CREDIT_CARD,\n CREDIT_CARD_NAME_BOTTOM,\n CREDIT_CARD_NAME_TOP,\n KCP_CARD,\n KCP_CARD_NAME_BOTTOM,\n KCP_CARD_NAME_TOP,\n SSN_CARD,\n SSN_CARD_NAME_BOTTOM,\n SSN_CARD_NAME_TOP\n} from './layouts';\nimport { AddressSpecifications, StringObject } from '../../../internal/Address/types';\nimport { PARTIAL_ADDRESS_SCHEMA } from '../../../internal/Address/constants';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { SFPProps } from '../../../internal/SecuredFields/SFP/types';\nimport { BRAND_READABLE_NAME_MAP, DEFAULT_CARD_GROUP_TYPES } from '../../../internal/SecuredFields/lib/constants';\nimport useImage, { UseImageHookType } from '../../../../core/Context/useImage';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { CardBrandsConfiguration, CardConfiguration, DualBrandSelectElement } from '../../types';\nimport { CardConfigData } from '../../../../core/Analytics/types';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE } from '../../../ThreeDS2/constants';\nimport CardInputDefaultProps from './defaultProps';\nimport { isConfigurationValid as isFastlaneComponentConfigValid } from '../Fastlane/utils/validate-configuration';\nimport { notFalsy } from '../../../../utils/commonUtils';\n\nexport const getCardImageUrl = (brand: string, getImage: UseImageHookType): string => {\n const imageOptions = {\n type: brand === 'card' ? 'nocard' : brand || 'nocard',\n extension: 'svg'\n };\n\n return getImage(imageOptions)(brand);\n};\n\n/**\n * Verifies that installment object is valid to send to the Backend.\n * Valid means that it has 'revolving' plan set, or the number of installments is bigger than one\n */\nexport const hasValidInstallmentsObject = (installments?: InstallmentsObj) => {\n return installments?.plan === 'revolving' || installments?.value > 1;\n};\n\nexport const getLayout = ({\n props,\n showKCP,\n showBrazilianSSN,\n countrySpecificSchemas = null,\n billingAddressRequiredFields = null\n}: LayoutObj): string[] => {\n let layout = CREDIT_CARD;\n const hasRequiredHolderName = props.hasHolderName && props.holderNameRequired;\n\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? CREDIT_CARD_NAME_TOP : CREDIT_CARD_NAME_BOTTOM;\n }\n\n if (showKCP) {\n layout = KCP_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? KCP_CARD_NAME_TOP : KCP_CARD_NAME_BOTTOM;\n }\n }\n\n if (showBrazilianSSN) {\n layout = SSN_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? SSN_CARD_NAME_TOP : SSN_CARD_NAME_BOTTOM;\n }\n }\n\n // w. Billing address\n if (countrySpecificSchemas) {\n // Flatten array and remove any numbers that describe how fields should be aligned\n const countrySpecificSchemasFlat: string[] = countrySpecificSchemas['flat'](2).filter(item => typeof item !== 'number') as string[];\n\n let countryBasedAddressLayout = countrySpecificSchemasFlat;\n\n if (billingAddressRequiredFields) {\n // Get intersection of the 2 arrays\n countryBasedAddressLayout = countrySpecificSchemasFlat.filter(x => billingAddressRequiredFields.includes(x));\n }\n\n layout = CREDIT_CARD.concat(countryBasedAddressLayout);\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop\n ? CREDIT_CARD_NAME_TOP.concat(countryBasedAddressLayout)\n : CREDIT_CARD_NAME_BOTTOM.concat(countryBasedAddressLayout);\n }\n // TODO we are not yet creating a layout for AVS + SSN field (w. or w/o holderName) - is AVS + SSN a real world scenario?\n }\n return layout;\n};\n\n/**\n * Lookup service to map local (CardInput) field refs to a key, possibly region specific, by which to retrieve the translation\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n // console.log('### utils::mapFieldKey:: key', key);\n switch (key) {\n case 'socialSecurityNumber':\n return i18n.get(`boleto.${key}`);\n // Address related - if we have a country specific key for the field - use that to get the translation\n case 'street':\n case 'houseNumberOrName':\n case 'postalCode':\n case 'stateOrProvince':\n case 'city':\n case 'country':\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them (currently applies mostly to SecuredFields related errors)\n default:\n return null;\n }\n};\n\nexport const extractPropsForCardFields = (props: CardInputProps) => {\n return {\n // Extract props for CardFieldsWrapper & StoredCardFieldsWrapper(just needs amount, hasCVC, installmentOptions)\n amount: props.amount,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressRequiredFields: props.billingAddressRequiredFields,\n billingAddressAllowedCountries: props.billingAddressAllowedCountries,\n brandsConfiguration: props.brandsConfiguration,\n showStoreDetailsCheckbox: props.showStoreDetailsCheckbox,\n hasCVC: props.hasCVC,\n hasHolderName: props.hasHolderName,\n holderNameRequired: props.holderNameRequired,\n installmentOptions: props.installmentOptions,\n placeholders: props.placeholders,\n positionHolderNameOnTop: props.positionHolderNameOnTop,\n // Extract props for CardFields > CardNumber\n showBrandIcon: props.showBrandIcon,\n showContextualElement: props.showContextualElement,\n // Extract props for StoredCardFields\n lastFour: props.lastFour,\n expiryMonth: props.expiryMonth,\n expiryYear: props.expiryYear,\n disclaimerMessage: props.disclaimerMessage\n };\n};\n\nexport const extractPropsForSFP = (props: CardInputProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n countryCode: props.countryCode,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n maskSecurityCode: props.maskSecurityCode,\n exposeExpiryDate: props.exposeExpiryDate,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyPress: props.handleKeyPress,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onLoad: props.onLoad,\n placeholders: props.placeholders,\n resources: props.resources,\n showContextualElement: props.showContextualElement,\n showWarnings: props.showWarnings,\n trimTrailingSeparator: props.trimTrailingSeparator\n } as SFPProps; // Can't set as return type on fn or it will complain about missing, mandatory, props\n};\n\nexport const handlePartialAddressMode = (addressMode: AddressModeOptions): AddressSpecifications | null => {\n return addressMode == AddressModeOptions.partial ? PARTIAL_ADDRESS_SCHEMA : null;\n};\n\n// Almost all errors are blur based, but some SF ones are not i.e. when an unsupported card is entered or the expiry date is out of range\nexport function lookupBlurBasedErrors(errorCode) {\n // If it's NOT one of these, then it's a blur based error\n return ![\n SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_OLD,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,\n SF_ErrorCodes.ERROR_MSG_CARD_EXPIRES_TOO_SOON\n ].includes(errorCode);\n}\n\nexport function getFullBrandName(brand) {\n return BRAND_READABLE_NAME_MAP[brand] ?? brand;\n}\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n const MAX_LENGTH = 128;\n\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n fastlaneConfiguration,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const isFastlaneConfigValid = isFastlaneComponentConfigValid(fastlaneConfiguration);\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n const configData: CardConfigData = {\n autoFocus,\n ...(billingAddressAllowedCountries?.length > 0 && {\n billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)\n }),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n brands: brands?.toString()?.substring(0, MAX_LENGTH),\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad,\n // Card level props\n hasOnBinLookup: !!onBinLookup,\n hasOnEnterKeyPressed: !!onEnterKeyPressed,\n /**\n * Fastlane\n */\n ...(isFastlaneConfigValid && {\n hasFastlaneConfigured: true,\n isFastlaneConsentDefaultOn: fastlaneConfiguration.defaultToggleState\n })\n };\n\n return configData;\n};\n\nexport const mapDualBrandButtons = (dualBrandSelectElements: DualBrandSelectElement[], brandsConfiguration: CardBrandsConfiguration): any => {\n return dualBrandSelectElements.map(item => {\n const brand = item.id;\n const getImage = useImage();\n const imageName = brand === 'card' ? 'nocard' : brand;\n const imageURL = brandsConfiguration[brand]?.icon ?? getCardImageUrl(imageName, getImage);\n\n // TODO - check below if we have to still generate altName through the mapping function or whether it just\n // corresponds to item.brandObject.localeBrand\n return {\n id: item.id,\n name: item.brandObject.localeBrand || item.brandObject.brand,\n imageURL,\n altName: getFullBrandName(brand)\n };\n });\n};\n"],"names":["getCardImageUrl","brand","getImage","type","extension","hasValidInstallmentsObject","installments","plan","value","getLayout","props","showKCP","showBrazilianSSN","countrySpecificSchemas","billingAddressRequiredFields","layout","CREDIT_CARD","hasRequiredHolderName","hasHolderName","holderNameRequired","positionHolderNameOnTop","CREDIT_CARD_NAME_TOP","CREDIT_CARD_NAME_BOTTOM","KCP_CARD","KCP_CARD_NAME_TOP","KCP_CARD_NAME_BOTTOM","SSN_CARD","SSN_CARD_NAME_TOP","SSN_CARD_NAME_BOTTOM","countrySpecificSchemasFlat","filter","item","countryBasedAddressLayout","x","includes","concat","mapFieldKey","key","i18n","countrySpecificLabels","get","extractPropsForCardFields","amount","billingAddressRequired","billingAddressAllowedCountries","brandsConfiguration","showStoreDetailsCheckbox","hasCVC","installmentOptions","placeholders","showBrandIcon","showContextualElement","lastFour","expiryMonth","expiryYear","disclaimerMessage","extractPropsForSFP","autoFocus","brands","clientKey","countryCode","forceCompat","implementationType","keypadFix","legacyInputMode","loadingContext","maskSecurityCode","exposeExpiryDate","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onConfigSuccess","handleKeyPress","onError","onFieldValid","onLoad","resources","showWarnings","trimTrailingSeparator","handlePartialAddressMode","addressMode","AddressModeOptions","partial","PARTIAL_ADDRESS_SCHEMA","lookupBlurBasedErrors","errorCode","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","ERROR_MSG_CARD_TOO_OLD","ERROR_MSG_CARD_TOO_FAR_IN_FUTURE","ERROR_MSG_CARD_EXPIRES_TOO_SOON","getFullBrandName","BRAND_READABLE_NAME_MAP","getCardConfigData","cardProps","billingAddressMode","DEFAULT_CARD_GROUP_TYPES","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","data","disableIOSArrowKeys","doBinLookup","enableStoreDetails","fastlaneConfiguration","hideCVC","name","showInstallmentAmounts","showPayButton","styles","onBinLookup","onBlur","onBrand","onEnterKeyPressed","onFocus","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","isFastlaneConfigValid","isFastlaneComponentConfigValid","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","length","toString","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnFieldValid","hasOnFocus","hasOnLoad","hasOnBinLookup","hasOnEnterKeyPressed","hasFastlaneConfigured","isFastlaneConsentDefaultOn","defaultToggleState","mapDualBrandButtons","dualBrandSelectElements","map","id","useImage","imageName","imageURL","icon","brandObject","localeBrand","altName"],"mappings":"i1BA2BO,MAAMA,EAAkB,CAACC,EAAeC,IAMpCA,EALc,CACjBC,KAAgB,SAAVF,EAAmB,SAAWA,GAAS,SAC7CG,UAAW,OAGRF,CAAuBD,GAOrBI,EAA8BC,GACT,cAAvBA,GAAcC,MAAwBD,GAAcE,MAAQ,EAG1DC,EAAY,EACrBC,QACAC,UACAC,mBACAC,yBAAyB,KACzBC,+BAA+B,SAE/B,IAAIC,EAASC,EACb,MAAMC,EAAwBP,EAAMQ,eAAiBR,EAAMS,mBAqB3D,GAnBIF,IACAF,EAASL,EAAMU,wBAA0BC,EAAuBC,GAGhEX,IACAI,EAASQ,EACLN,IACAF,EAASL,EAAMU,wBAA0BI,EAAoBC,IAIjEb,IACAG,EAASW,EACLT,IACAF,EAASL,EAAMU,wBAA0BO,EAAoBC,IAKjEf,EAAwB,CAExB,MAAMgB,EAAuChB,EAAuB,KAAQ,GAAGiB,OAAOC,GAAwB,iBAATA,GAErG,IAAIC,EAA4BH,EAE5Bf,IAEAkB,EAA4BH,EAA2BC,OAAOG,GAAKnB,EAA6BoB,SAASD,KAG7GlB,EAASC,EAAYmB,OAAOH,GACxBf,IACAF,EAASL,EAAMU,wBACTC,EAAqBc,OAAOH,GAC5BV,EAAwBa,OAAOH,GAG7C,CACA,OAAOjB,GAMEqB,EAAc,CAACC,EAAaC,EAAgBC,KAErD,OAAQF,GACJ,IAAK,uBACD,OAAOC,EAAKE,IAAI,UAAUH,KAE9B,IAAK,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D,EAAsBqD,sBAOjDC,EAAsB,CAACC,EAAmDrH,IAC5EqH,EAAwBC,IAAIpI,IAC/B,MAAM9B,EAAQ8B,EAAKqI,GACblK,EAAWmK,IACXC,EAAsB,SAAVrK,EAAmB,SAAWA,EAC1CsK,EAAW1H,EAAoB5C,IAAQuK,MAAQxK,EAAgBsK,EAAWpK,GAIhF,MAAO,CACHkK,GAAIrI,EAAKqI,GACTvD,KAAM9E,EAAK0I,YAAYC,aAAe3I,EAAK0I,YAAYxK,MACvDsK,WACAI,QAAS7E,EAAiB7F"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/components/Card/components/CardInput/utils.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { AddressModeOptions, CardInputProps, LayoutObj } from './types';\nimport {\n CREDIT_CARD,\n CREDIT_CARD_NAME_BOTTOM,\n CREDIT_CARD_NAME_TOP,\n KCP_CARD,\n KCP_CARD_NAME_BOTTOM,\n KCP_CARD_NAME_TOP,\n SSN_CARD,\n SSN_CARD_NAME_BOTTOM,\n SSN_CARD_NAME_TOP\n} from './layouts';\nimport { AddressSpecifications, StringObject } from '../../../internal/Address/types';\nimport { PARTIAL_ADDRESS_SCHEMA } from '../../../internal/Address/constants';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { SFPProps } from '../../../internal/SecuredFields/SFP/types';\nimport { BRAND_READABLE_NAME_MAP, DEFAULT_CARD_GROUP_TYPES } from '../../../internal/SecuredFields/lib/constants';\nimport useImage, { UseImageHookType } from '../../../../core/Context/useImage';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BrandObject, CardBrandsConfiguration, CardConfiguration, DualBrandSelectElement } from '../../types';\nimport { CardConfigData } from '../../../../core/Analytics/types';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE } from '../../../ThreeDS2/constants';\nimport CardInputDefaultProps from './defaultProps';\nimport { isConfigurationValid as isFastlaneComponentConfigValid } from '../Fastlane/utils/validate-configuration';\nimport { notFalsy } from '../../../../utils/commonUtils';\n\nexport const getCardImageUrl = (brand: string, getImage: UseImageHookType): string => {\n const imageOptions = {\n type: brand === 'card' ? 'nocard' : brand || 'nocard',\n extension: 'svg'\n };\n\n return getImage(imageOptions)(brand);\n};\n\n/**\n * Verifies that installment object is valid to send to the Backend.\n * Valid means that it has 'revolving' plan set, or the number of installments is bigger than one\n */\nexport const hasValidInstallmentsObject = (installments?: InstallmentsObj) => {\n return installments?.plan === 'revolving' || installments?.value > 1;\n};\n\nexport const getLayout = ({\n props,\n showKCP,\n showBrazilianSSN,\n countrySpecificSchemas = null,\n billingAddressRequiredFields = null\n}: LayoutObj): string[] => {\n let layout = CREDIT_CARD;\n const hasRequiredHolderName = props.hasHolderName && props.holderNameRequired;\n\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? CREDIT_CARD_NAME_TOP : CREDIT_CARD_NAME_BOTTOM;\n }\n\n if (showKCP) {\n layout = KCP_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? KCP_CARD_NAME_TOP : KCP_CARD_NAME_BOTTOM;\n }\n }\n\n if (showBrazilianSSN) {\n layout = SSN_CARD;\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop ? SSN_CARD_NAME_TOP : SSN_CARD_NAME_BOTTOM;\n }\n }\n\n // w. Billing address\n if (countrySpecificSchemas) {\n // Flatten array and remove any numbers that describe how fields should be aligned\n const countrySpecificSchemasFlat: string[] = countrySpecificSchemas['flat'](2).filter(item => typeof item !== 'number') as string[];\n\n let countryBasedAddressLayout = countrySpecificSchemasFlat;\n\n if (billingAddressRequiredFields) {\n // Get intersection of the 2 arrays\n countryBasedAddressLayout = countrySpecificSchemasFlat.filter(x => billingAddressRequiredFields.includes(x));\n }\n\n layout = CREDIT_CARD.concat(countryBasedAddressLayout);\n if (hasRequiredHolderName) {\n layout = props.positionHolderNameOnTop\n ? CREDIT_CARD_NAME_TOP.concat(countryBasedAddressLayout)\n : CREDIT_CARD_NAME_BOTTOM.concat(countryBasedAddressLayout);\n }\n // TODO we are not yet creating a layout for AVS + SSN field (w. or w/o holderName) - is AVS + SSN a real world scenario?\n }\n return layout;\n};\n\n/**\n * Lookup service to map local (CardInput) field refs to a key, possibly region specific, by which to retrieve the translation\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n // console.log('### utils::mapFieldKey:: key', key);\n switch (key) {\n case 'socialSecurityNumber':\n return i18n.get(`boleto.${key}`);\n // Address related - if we have a country specific key for the field - use that to get the translation\n case 'street':\n case 'houseNumberOrName':\n case 'postalCode':\n case 'stateOrProvince':\n case 'city':\n case 'country':\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them (currently applies mostly to SecuredFields related errors)\n default:\n return null;\n }\n};\n\nexport const extractPropsForCardFields = (props: CardInputProps) => {\n return {\n // Extract props for CardFieldsWrapper & StoredCardFieldsWrapper(just needs amount, hasCVC, installmentOptions)\n amount: props.amount,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressRequiredFields: props.billingAddressRequiredFields,\n billingAddressAllowedCountries: props.billingAddressAllowedCountries,\n brandsConfiguration: props.brandsConfiguration,\n showStoreDetailsCheckbox: props.showStoreDetailsCheckbox,\n hasCVC: props.hasCVC,\n hasHolderName: props.hasHolderName,\n holderNameRequired: props.holderNameRequired,\n installmentOptions: props.installmentOptions,\n placeholders: props.placeholders,\n positionHolderNameOnTop: props.positionHolderNameOnTop,\n // Extract props for CardFields > CardNumber\n showBrandIcon: props.showBrandIcon,\n showContextualElement: props.showContextualElement,\n // Extract props for StoredCardFields\n lastFour: props.lastFour,\n expiryMonth: props.expiryMonth,\n expiryYear: props.expiryYear,\n disclaimerMessage: props.disclaimerMessage\n };\n};\n\nexport const extractPropsForSFP = (props: CardInputProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n countryCode: props.countryCode,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n maskSecurityCode: props.maskSecurityCode,\n exposeExpiryDate: props.exposeExpiryDate,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyPress: props.handleKeyPress,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onLoad: props.onLoad,\n placeholders: props.placeholders,\n resources: props.resources,\n showContextualElement: props.showContextualElement,\n showWarnings: props.showWarnings,\n trimTrailingSeparator: props.trimTrailingSeparator\n } as SFPProps; // Can't set as return type on fn or it will complain about missing, mandatory, props\n};\n\nexport const handlePartialAddressMode = (addressMode: AddressModeOptions): AddressSpecifications | null => {\n return addressMode == AddressModeOptions.partial ? PARTIAL_ADDRESS_SCHEMA : null;\n};\n\n// Almost all errors are blur based, but some SF ones are not i.e. when an unsupported card is entered or the expiry date is out of range\nexport function lookupBlurBasedErrors(errorCode) {\n // If it's NOT one of these, then it's a blur based error\n return ![\n SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_OLD,\n SF_ErrorCodes.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE,\n SF_ErrorCodes.ERROR_MSG_CARD_EXPIRES_TOO_SOON\n ].includes(errorCode);\n}\n\nexport function getFullBrandName(brand) {\n return BRAND_READABLE_NAME_MAP[brand] ?? brand;\n}\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n const MAX_LENGTH = 128;\n\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n fastlaneConfiguration,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const isFastlaneConfigValid = isFastlaneComponentConfigValid(fastlaneConfiguration);\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n const configData: CardConfigData = {\n autoFocus,\n ...(billingAddressAllowedCountries?.length > 0 && {\n billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)\n }),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n brands: brands?.toString()?.substring(0, MAX_LENGTH),\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad,\n // Card level props\n hasOnBinLookup: !!onBinLookup,\n hasOnEnterKeyPressed: !!onEnterKeyPressed,\n /**\n * Fastlane\n */\n ...(isFastlaneConfigValid && {\n hasFastlaneConfigured: true,\n isFastlaneConsentDefaultOn: fastlaneConfiguration.defaultToggleState\n })\n };\n\n return configData;\n};\n\nexport const mapDualBrandButtons = (dualBrandSelectElements: DualBrandSelectElement[], brandsConfiguration: CardBrandsConfiguration): any => {\n return dualBrandSelectElements.map(item => {\n const brand = item.id;\n const getImage = useImage();\n const imageName = brand === 'card' ? 'nocard' : brand;\n const imageURL = brandsConfiguration[brand]?.icon ?? getCardImageUrl(imageName, getImage);\n\n // TODO - check below if we have to still generate altName through the mapping function or whether it just\n // corresponds to item.brandObject.localeBrand\n return {\n id: item.id,\n name: item.brandObject.localeBrand || item.brandObject.brand,\n imageURL,\n altName: getFullBrandName(brand)\n };\n });\n};\n\n/**\n * Only if the brands in EU_BrandArray are present in the binLookup response should we handle dual branding based on EU regulations\n *\n * If the result from Array.filter contains anything - then we are in a EU dual branding regulation scenario, i.e.\n * - Show the new dualBranding UI Buttons\n * - Preselect a card brand\n */\nexport const mustHandleDualBrandingAccordingToEURegulations = (\n EU_BrandArray: string[],\n returnedDualBrandingObjects: DualBrandSelectElement[] | BrandObject[],\n key: string\n) => !!returnedDualBrandingObjects.filter(item => EU_BrandArray.includes(item[key])).length;\n"],"names":["getCardImageUrl","brand","getImage","type","extension","hasValidInstallmentsObject","installments","plan","value","getLayout","props","showKCP","showBrazilianSSN","countrySpecificSchemas","billingAddressRequiredFields","layout","CREDIT_CARD","hasRequiredHolderName","hasHolderName","holderNameRequired","positionHolderNameOnTop","CREDIT_CARD_NAME_TOP","CREDIT_CARD_NAME_BOTTOM","KCP_CARD","KCP_CARD_NAME_TOP","KCP_CARD_NAME_BOTTOM","SSN_CARD","SSN_CARD_NAME_TOP","SSN_CARD_NAME_BOTTOM","countrySpecificSchemasFlat","filter","item","countryBasedAddressLayout","x","includes","concat","mapFieldKey","key","i18n","countrySpecificLabels","get","extractPropsForCardFields","amount","billingAddressRequired","billingAddressAllowedCountries","brandsConfiguration","showStoreDetailsCheckbox","hasCVC","installmentOptions","placeholders","showBrandIcon","showContextualElement","lastFour","expiryMonth","expiryYear","disclaimerMessage","extractPropsForSFP","autoFocus","brands","clientKey","countryCode","forceCompat","implementationType","keypadFix","legacyInputMode","loadingContext","maskSecurityCode","exposeExpiryDate","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onConfigSuccess","handleKeyPress","onError","onFieldValid","onLoad","resources","showWarnings","trimTrailingSeparator","handlePartialAddressMode","addressMode","AddressModeOptions","partial","PARTIAL_ADDRESS_SCHEMA","lookupBlurBasedErrors","errorCode","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","ERROR_MSG_CARD_TOO_OLD","ERROR_MSG_CARD_TOO_FAR_IN_FUTURE","ERROR_MSG_CARD_EXPIRES_TOO_SOON","getFullBrandName","BRAND_READABLE_NAME_MAP","getCardConfigData","cardProps","billingAddressMode","DEFAULT_CARD_GROUP_TYPES","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","data","disableIOSArrowKeys","doBinLookup","enableStoreDetails","fastlaneConfiguration","hideCVC","name","showInstallmentAmounts","showPayButton","styles","onBinLookup","onBlur","onBrand","onEnterKeyPressed","onFocus","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","isFastlaneConfigValid","isFastlaneComponentConfigValid","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","length","toString","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnFieldValid","hasOnFocus","hasOnLoad","hasOnBinLookup","hasOnEnterKeyPressed","hasFastlaneConfigured","isFastlaneConsentDefaultOn","defaultToggleState","mapDualBrandButtons","dualBrandSelectElements","map","id","useImage","imageName","imageURL","icon","brandObject","localeBrand","altName","mustHandleDualBrandingAccordingToEURegulations","EU_BrandArray","returnedDualBrandingObjects"],"mappings":"i1BA2BO,MAAMA,EAAkB,CAACC,EAAeC,IAMpCA,EALc,CACjBC,KAAgB,SAAVF,EAAmB,SAAWA,GAAS,SAC7CG,UAAW,OAGRF,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G"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import{TxVariants as s}from"../tx-variants.js";import{UIElement as i}from"../internal/UIElement/UIElement.js";import n from"../../core/Errors/SRPanelProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import o,{ERROR as a}from"../../core/Errors/AdyenCheckoutError.js";import{PasskeyService as p}from"./services/PasskeyService.js";import{authorizeEnrollment as d}from"./services/authorizeEnrollment.js";import{authorizePayment as h}from"./services/authorizePayment.js";import l from"./components/StoredPayment/StoredPayment.js";import c from"./components/Enrollment/Enrollment.js";function m(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class y extends i{get isValid(){return!(this.props._isAdyenHosted&&!this.props.storedPaymentMethodId)||!!this.state?.isValid}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("paybybankpix.storedPayment.additionalLabel",{values:{receiver:this.props?.payByBankPixDetails?.receiver}}):""}get icon(){return this.props.storedPaymentMethodId?this.resources.getImage({parentFolder:`${y.type}/`})(this.props?.payByBankPixDetails?.ispb):super.icon}async isAvailable(){const t=await this.passkeyService.getWebAuthnUnsupportedReason();if(t)return Promise.reject(new o(a,t));if(!this.props._isAdyenHosted)return Promise.resolve();try{if(await this.passkeyService.initialize(),this.props.storedPaymentMethodId){return await this.passkeyService.canUseStoredCredential()?Promise.resolve():Promise.reject(new o("ERROR","The stored payment method is not available on this device"))}return Promise.resolve()}catch(t){return Promise.reject(t instanceof Error?t?.message:"Unknown error")}}handleAction(t,e={}){const s=this.core.createFromAction(t,{...this.elementRef.props,...e,onAdditionalDetails:this.handleAdditionalDetails});return s?(this.unmount(),s.isAvailable().then(()=>{s.mount(this._node)}),s):null}formatData(){if(!this.props._isAdyenHosted)return{paymentMethod:{type:s.paybybank_pix}};const t=null==this.props.storedPaymentMethodId;return{paymentMethod:{type:s.paybybank_pix,...this.state.data},...t?{storePaymentMethod:!0}:{}}}render(){return this.props._isAdyenHosted?t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{srPanel:this.props.modules.srPanel},null!=this.props.storedPaymentMethodId?t(l,{txVariant:y.type,type:this.props.type,clientKey:this.props.clientKey,amount:this.props.amount,issuer:this.props?.payByBankPixDetails?.ispb,receiver:this.props?.payByBankPixDetails?.receiver,enrollmentId:this.props.paymentMethodData?.enrollmentId,initiationId:this.props.paymentMethodData?.initiationId,setComponentRef:this.setComponentRef,onPay:this.payWithStoredPayment,onAuthorize:this.authorizePayment}):t(c,{onError:this.handleError,txVariant:y.type,type:this.props.type,clientKey:this.props.clientKey,enrollmentId:this.props.paymentMethodData?.enrollmentId,countdownTime:this.props.countdownTime,onEnroll:this.authorizeEnrollment,issuers:this.props.issuers,payButton:this.payButton,onChange:this.onIssuerSelected,onSubmitAnalytics:this.submitAnalytics,setComponentRef:this.setComponentRef}))):t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{srPanel:this.props.modules.srPanel},t(r,{showPayButton:this.props.showPayButton,name:this.displayName,label:this.props.i18n.get("paybybankpix.redirectBtn.label"),amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}})))}constructor(t,e){super(t,e),m(this,"passkeyService",void 0),m(this,"onIssuerSelected",async t=>{try{const{data:e={}}=t;if(!e.issuer)return;const{deviceId:s,...i}=await this.passkeyService.captureRiskSignalsEnrollment();this.setState({...t,data:{...e,riskSignals:i,deviceId:s}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the onIssuerSelected";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"authorizeEnrollment",async t=>{try{const e=await this.passkeyService.createCredentialForEnrollment(t),s={enrollmentId:this.props.paymentMethodData?.enrollmentId,fidoAssertion:e},{redirectResult:i}=await d({enrollment:s,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:i}}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the authorizeEnrollment";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"payWithStoredPayment",async()=>{try{const{deviceId:t,...e}=await this.passkeyService.captureRiskSignalsAuthentication();this.state={...this.state,data:{storedPaymentMethodId:this.props.storedPaymentMethodId,riskSignals:e,deviceId:t}},super.submit()}catch(t){const e=t instanceof Error?t.message:"Unknown error in the payWithStoredPayment";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"authorizePayment",async t=>{try{const e=await this.passkeyService.authenticateWithCredential(t),s={enrollmentId:this.props.paymentMethodData?.enrollmentId,initiationId:this.props.paymentMethodData?.initiationId,fidoAssertion:e},{redirectResult:i}=await h({payment:s,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:i}}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the authorizePayment";this.handleError(t instanceof o?t:new o(a,e))}});const s=this.props.storedPaymentMethodId?this.props?.payByBankPixDetails?.deviceId:this.props.deviceId;this.passkeyService=new p({environment:this.props.environment,deviceId:s}),this.props._isAdyenHosted&&this.passkeyService.initialize()}}m(y,"type",s.paybybank_pix),m(y,"TIMEOUT_MINUTES",1),m(y,"defaultProps",{showPayButton:!0,_isAdyenHosted:(()=>{try{return new URL(window.location.href).hostname.endsWith(".adyen.com")}catch(t){return!1}})(),countdownTime:y.TIMEOUT_MINUTES});export{y as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import{TxVariants as s}from"../tx-variants.js";import{UIElement as n}from"../internal/UIElement/UIElement.js";import i from"../../core/Errors/SRPanelProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import o,{ERROR as a}from"../../core/Errors/AdyenCheckoutError.js";import{PasskeyService as p}from"./services/PasskeyService.js";import{authorizeEnrollment as d}from"./services/authorizeEnrollment.js";import{authorizePayment as h}from"./services/authorizePayment.js";import l from"./components/StoredPayment/StoredPayment.js";import c from"./components/Enrollment/Enrollment.js";function m(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class y extends n{get isValid(){return!(this.props._isAdyenHosted&&!this.props.storedPaymentMethodId)||!!this.state?.isValid}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("paybybankpix.storedPayment.additionalLabel",{values:{receiver:this.props?.payByBankPixDetails?.receiver}}):""}get icon(){return this.props.storedPaymentMethodId?this.resources.getImage({parentFolder:`${y.type}/`})(this.props?.payByBankPixDetails?.ispb):super.icon}async isAvailable(){const t=await this.passkeyService.getWebAuthnUnsupportedReason();if(t)return Promise.reject(new o(a,t));if(!this.props._isAdyenHosted)return Promise.resolve();try{if(await this.passkeyService.initialize(),this.props.storedPaymentMethodId){return await this.passkeyService.canUseStoredCredential()?Promise.resolve():Promise.reject(new o("ERROR","The stored payment method is not available on this device"))}return Promise.resolve()}catch(t){return Promise.reject(t instanceof Error?t?.message:"Unknown error")}}handleAction(t,e={}){const s=this.core.createFromAction(t,{...this.elementRef.props,...e,onAdditionalDetails:this.handleAdditionalDetails});return s?(this.unmount(),s.isAvailable().then(()=>{s.mount(this._node)}),s):null}formatData(){if(!this.props._isAdyenHosted)return{paymentMethod:{type:s.paybybank_pix}};const t=null==this.props.storedPaymentMethodId;return{paymentMethod:{type:s.paybybank_pix,...this.state.data},...t?{storePaymentMethod:!0}:{}}}render(){return this.props._isAdyenHosted?t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},null!=this.props.storedPaymentMethodId?t(l,{txVariant:y.type,type:this.props.type,clientKey:this.props.clientKey,amount:this.props.amount,enrollmentId:this.props.paymentMethodData?.enrollmentId,initiationId:this.props.paymentMethodData?.initiationId,setComponentRef:this.setComponentRef,onPay:this.payWithStoredPayment,onAuthorize:this.authorizePayment}):t(c,{onError:this.handleError,txVariant:y.type,type:this.props.type,clientKey:this.props.clientKey,enrollmentId:this.props.paymentMethodData?.enrollmentId,countdownTime:this.props.countdownTime,onEnroll:this.authorizeEnrollment,issuers:this.props.issuers,payButton:this.payButton,onChange:this.onIssuerSelected,onSubmitAnalytics:this.submitAnalytics,setComponentRef:this.setComponentRef}))):t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},t(r,{showPayButton:this.props.showPayButton,name:this.displayName,label:this.props.i18n.get("paybybankpix.redirectBtn.label"),amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}})))}constructor(t,e){super(t,e),m(this,"passkeyService",void 0),m(this,"onIssuerSelected",async t=>{try{const{data:e={}}=t;if(!e.issuer)return;const{deviceId:s,...n}=await this.passkeyService.captureRiskSignalsEnrollment();this.setState({...t,data:{...e,riskSignals:n,deviceId:s}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the onIssuerSelected";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"authorizeEnrollment",async t=>{try{const e=await this.passkeyService.createCredentialForEnrollment(t),s={enrollmentId:this.props.paymentMethodData?.enrollmentId,fidoAssertion:e},{redirectResult:n}=await d({enrollment:s,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:n}}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the authorizeEnrollment";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"payWithStoredPayment",async()=>{try{const{deviceId:t,...e}=await this.passkeyService.captureRiskSignalsAuthentication();this.state={...this.state,data:{storedPaymentMethodId:this.props.storedPaymentMethodId,riskSignals:e,deviceId:t}},super.submit()}catch(t){const e=t instanceof Error?t.message:"Unknown error in the payWithStoredPayment";this.handleError(t instanceof o?t:new o(a,e))}}),m(this,"authorizePayment",async t=>{try{const e=await this.passkeyService.authenticateWithCredential(t),s={enrollmentId:this.props.paymentMethodData?.enrollmentId,initiationId:this.props.paymentMethodData?.initiationId,fidoAssertion:e},{redirectResult:n}=await h({payment:s,clientKey:this.props.clientKey,loadingContext:this.props.loadingContext});this.handleAdditionalDetails({data:{details:{redirectResult:n}}})}catch(t){const e=t instanceof Error?t.message:"Unknown error in the authorizePayment";this.handleError(t instanceof o?t:new o(a,e))}});const s=this.props.storedPaymentMethodId?this.props?.payByBankPixDetails?.deviceId:this.props.deviceId;this.passkeyService=new p({environment:this.props.environment,deviceId:s}),this.props._isAdyenHosted&&this.passkeyService.initialize()}}m(y,"type",s.paybybank_pix),m(y,"TIMEOUT_MINUTES",1),m(y,"defaultProps",{showPayButton:!0,_isAdyenHosted:(()=>{try{return new URL(window.location.href).hostname.endsWith(".adyen.com")}catch(t){return!1}})(),countdownTime:y.TIMEOUT_MINUTES});export{y as default};
2
2
  //# sourceMappingURL=PayByBankPix.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayByBankPix.js","sources":["../../../../src/components/PayByBankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n issuer={this.props?.payByBankPixDetails?.ispb}\n receiver={this.props?.payByBankPixDetails?.receiver}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","issuer","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","deviceId","riskSignals","captureRiskSignalsEnrollment","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEOUT_MINUTES","defaultProps","URL","window","location","href","hostname","endsWith","e","isAdyenHosted"],"mappings":"w1BAyBA,MAAMA,UAA4BC,EAoB9B,WAAIC,GAEA,QAAKC,KAAKC,MAAMC,iBAAkBF,KAAKC,MAAME,0BAGpCH,KAAKI,OAAOL,OACzB,CAKA,kBAAIM,GACA,OAAOL,KAAKC,MAAME,sBACZH,KAAKC,MAAMK,KAAKC,IAAI,6CAA8C,CAAEC,OAAQ,CAAEC,SAAUT,KAAKC,OAAOS,qBAAqBD,YACzH,EACV,CAKA,QAAoBE,GAChB,OAAOX,KAAKC,MAAME,sBACZH,KAAKY,UAAUC,SAAS,CAAEC,aAAc,GAAGjB,EAAoBkB,SAA/Df,CAA0EA,KAAKC,OAAOS,qBAAqBM,MAC3GC,MAAMN,IAChB,CAKA,iBAAsBO,GAClB,MAAMC,QAA0BnB,KAAKoB,eAAeC,+BACpD,GAAIF,EACA,OAAOG,QAAQC,OAAO,IAAIC,EAAmBC,EAAON,IAExD,IAAKnB,KAAKC,MAAMC,eACZ,OAAOoB,QAA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BD,aAC5CE,aAAcjE,KAAKC,MAAM+D,mBAAmBC,aAC5CsC,kBAEEG,eAAEA,SAAyBpC,EAAiB,CAC9CyC,UACAnD,UAAW5D,KAAKC,MAAM2D,UACtBN,eAAgBtD,KAAKC,MAAMqD,iBAE/BtD,KAAKuC,wBAAwB,CAAEU,KAAM,CAAE0D,QAAS,CAAED,oBACtD,CAAE,MAAO7E,GACL,MAAMwE,EAAWxE,aAAiBC,MAAQD,EAAME,QAAU,wCAC1D/B,KAAKyE,YAAY5C,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAO4E,GACjG,IA1KA,MAAMJ,EAAWjG,KAAKC,MAAME,sBAAwBH,KAAKC,OAAOS,qBAAqBuF,SAAWjG,KAAKC,MAAMgG,SAC3GjG,KAAKoB,eAAiB,IAAI4F,EAAe,CAAEC,YAAajH,KAAKC,MAAMgH,YAAahB,aAC5EjG,KAAKC,MAAMC,gBACNF,KAAKoB,eAAeO,YAEjC,EAjBAmE,EADEjG,EACqBkB,OAAO+B,EAAWC,eACzC+C,EAFEjG,EAEsBqH,kBAAkB,GAG1CpB,EALEjG,EAKqBsH,eAA0C,CAC7D/B,eAAe,EACflF,eAhBc,MAClB,IAEI,OADmB,IAAIkH,IAAIC,OAAOC,SAASC,MACzBC,SAASC,SAAS,aACxC,CAAE,MAAOC,GAEL,OAAO,CACX,GASoBC,GAChBjD,cAAe7E,EAAoBqH"}
1
+ {"version":3,"file":"PayByBankPix.js","sources":["../../../../src/components/PayByBankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","issuer","deviceId","riskSignals","captureRiskSignalsEnrollment","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEOUT_MINUTES","defaultProps","URL","window","location","href","hostname","endsWith","e","isAdyenHosted"],"mappings":"w1BAyBA,MAAMA,UAA4BC,EAoB9B,WAAIC,GAEA,QAAKC,KAAKC,MAAMC,iBAAkBF,KAAKC,MAAME,0BAGpCH,KAAKI,OAAOL,OACzB,CAKA,kBAAIM,GACA,OAAOL,KAAKC,MAAME,sBACZH,KAAKC,MAAMK,KAAKC,IAAI,6CAA8C,CAAEC,OAAQ,CAAEC,SAAUT,KAAKC,OAAOS,qBAAqBD,YACzH,EACV,CAKA,QAAoBE,GAChB,OAAOX,KAAKC,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AY3C,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAO4E,GACjG,IAGJR,EAAA7F,KAAiBqE,mBAAmByB,MAAOe,IACvC,IACI,MAAMN,QAAsBvG,KAAKoB,eAAe0F,2BAA2BD,GACrEE,EAAU,CACZjD,aAAc9D,KAAKC,MAAM8D,mBAAmBD,aAC5CE,aAAchE,KAAKC,MAAM8D,mBAAmBC,aAC5CuC,kBAEEG,eAAEA,SAAyBrC,EAAiB,CAC9C0C,UACAnD,UAAW5D,KAAKC,MAAM2D,UACtBN,eAAgBtD,KAAKC,MAAMqD,iBAE/BtD,KAAKuC,wBAAwB,CAAEU,KAAM,CAAE0D,QAAS,CAAED,oBACtD,CAAE,MAAO7E,GACL,MAAMwE,EAAWxE,aAAiBC,MAAQD,EAAME,QAAU,wCAC1D/B,KAAKwE,YAAY3C,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAO4E,GACjG,IA1KA,MAAMJ,EAAWjG,KAAKC,MAAME,sBAAwBH,KAAKC,OAAOS,qBAAqBuF,SAAWjG,KAAKC,MAAMgG,SAC3GjG,KAAKoB,eAAiB,IAAI4F,EAAe,CAAEC,YAAajH,KAAKC,MAAMgH,YAAahB,aAC5EjG,KAAKC,MAAMC,gBACNF,KAAKoB,eAAeO,YAEjC,EAjBAkE,EADEhG,EACqBkB,OAAO+B,EAAWC,eACzC8C,EAFEhG,EAEsBqH,kBAAkB,GAG1CrB,EALEhG,EAKqBsH,eAA0C,CAC7DhC,eAAe,EACfjF,eAhBc,MAClB,IAEI,OADmB,IAAIkH,IAAIC,OAAOC,SAASC,MACzBC,SAASC,SAAS,aACxC,CAAE,MAAOC,GAEL,OAAO,CACX,GASoBC,GAChBlD,cAAe5E,EAAoBqH"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as r}from"./useIssuerWithLogo.js";import s from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[x,f]=n(null),b=[{name:"open-finance",alt:y.get("paybybankpix.await.logoAlt.openFinance"),src:`${g({parentFolder:`${u.txVariant}/`})("open-finance")}`},{name:"arrow-down",alt:y.get("paybybankpix.await.logoAlt.arrowDown"),src:`${g({imageFolder:"components/"})("arrow_down")}`},{name:"bank",alt:y.get("paybybankpix.await.logoAlt.bank"),src:`${g({imageFolder:"components/"})("bank")}`}],k=e({showValidation:()=>{w?.current?.showValidation()},setStatus:t=>{w?.current?.setStatus(t)}});return a(()=>{u.setComponentRef(k.current)},[u.setComponentRef]),a(()=>{x&&u.onEnroll(x)},[x]),t("div",{className:"adyen-checkout-pix-enrollment"},(t=>"await"===t.type)(u)?t(m,{logos:b,type:u.txVariant,countdownTime:u.countdownTime,clientKey:u.clientKey,onError:u.onError,awaitText:y.get("paybybankpix.await.waitForConfirmation"),instructions:y.get("paybybankpix.await.timeToPay",{values:{numberOfMin:u.countdownTime}}),pollStatus:async()=>{if(x)return;const{enrollmentId:t,clientKey:e}=u,n=await s({enrollmentId:t,clientKey:e,loadingContext:d});return n.registrationOptions&&f(n.registrationOptions),n},endSlot:()=>t("span",null,y.get("paybybankpix.await.withOpenFinance"))}):t("div",{className:"adyen-checkout-pix-enrollment-issuer-list"},t(l,{txVariant:u.txVariant}),t(i,{items:r({issuers:u.issuers,txVariant:u.txVariant}),onSubmitAnalytics:u.onSubmitAnalytics,onChange:u.onChange,payButton:u.payButton,showPayButton:!0,ref:w}),t("span",{className:"adyen-checkout-disclaimer__label"},t(c,{message:y.get("paybybankpix.issuerList.disclaimer"),urls:[""]}))))}export{u as default};
1
+ import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as s}from"./useIssuerWithLogo.js";import r from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[b,x]=n(null),f=[{name:"open-finance",alt:y.get("paybybankpix.await.logoAlt.openFinance"),src:`${g({parentFolder:`${u.txVariant}/`})("open-finance")}`},{name:"arrow-down",alt:y.get("paybybankpix.await.logoAlt.arrowDown"),src:`${g({imageFolder:"components/"})("arrow_down")}`},{name:"bank",alt:y.get("paybybankpix.await.logoAlt.bank"),src:`${g({imageFolder:"components/"})("bank")}`}],k=e({showValidation:()=>{w?.current?.showValidation()},setStatus:t=>{w?.current?.setStatus(t)}});return a(()=>{u.setComponentRef(k.current)},[u.setComponentRef]),a(()=>{b&&u.onEnroll(b)},[b]),t("div",{className:"adyen-checkout-pix-enrollment"},(t=>"await"===t.type)(u)?t(m,{logos:f,type:u.txVariant,countdownTime:u.countdownTime,clientKey:u.clientKey,onError:u.onError,awaitText:y.get("paybybankpix.await.waitForConfirmation"),instructions:y.get("paybybankpix.await.timeToPay",{values:{numberOfMin:u.countdownTime}}),pollStatus:async()=>{if(b)return;const{enrollmentId:t,clientKey:e}=u,n=await r({enrollmentId:t,clientKey:e,loadingContext:d});return n.registrationOptions&&x(n.registrationOptions),n},endSlot:()=>t("span",null,y.get("paybybankpix.await.withOpenFinance"))}):t("div",{className:"adyen-checkout-pix-enrollment-issuer-list"},t(l,{txVariant:u.txVariant}),t(i,{items:s({issuers:u.issuers,txVariant:u.txVariant}),selectFieldLabel:y.get("paybybankpix.issuerList.selectField.label"),onSubmitAnalytics:u.onSubmitAnalytics,onChange:u.onChange,payButton:u.payButton,showPayButton:!0,ref:w}),t("span",{className:"adyen-checkout-disclaimer__label"},t(c,{message:y.get("paybybankpix.issuerList.disclaimer"),urls:["https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br"]}))))}export{u as default};
2
2
  //# sourceMappingURL=Enrollment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\n//todo: add\nconst TERMS_CONDITIONS_URL = '';\n\nfunction Enrollment(props: EnrollmentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const issuerListRef = useRef<ComponentMethodsRef>(null);\n const [registrationOptions, setRegistrationOptions] = useState<string>(null);\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${props.txVariant}/` })('open-finance')}`\n },\n {\n name: 'arrow-down',\n alt: i18n.get('paybybankpix.await.logoAlt.arrowDown'),\n src: `${getImage({ imageFolder: 'components/' })('arrow_down')}`\n },\n { name: 'bank', alt: i18n.get('paybybankpix.await.logoAlt.bank'), src: `${getImage({ imageFolder: 'components/' })('bank')}` }\n ];\n const self = useRef({\n showValidation: () => {\n issuerListRef?.current?.showValidation();\n },\n setStatus: (newStatus: UIElementStatus) => {\n issuerListRef?.current?.setStatus(newStatus);\n }\n });\n\n const pollStatus = async () => {\n if (registrationOptions) return;\n\n const { enrollmentId, clientKey } = props as AwaitProps;\n const response = await getEnrollmentStatus({ enrollmentId, clientKey, loadingContext });\n if (response.registrationOptions) {\n setRegistrationOptions(response.registrationOptions);\n }\n return response;\n };\n // Assist typescript to narrow down the type.\n const isAwait = (props: EnrollmentProps): props is AwaitProps => props.type === 'await';\n const awaitEndSlot = () => <span>{i18n.get('paybybankpix.await.withOpenFinance')}</span>;\n\n useEffect(() => {\n props.setComponentRef(self.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (registrationOptions) {\n props.onEnroll(registrationOptions);\n }\n }, [registrationOptions]);\n\n return (\n <div className={'adyen-checkout-pix-enrollment'}>\n {isAwait(props) ? (\n <PayByBankPixAwait\n logos={logos}\n type={props.txVariant}\n countdownTime={props.countdownTime}\n clientKey={props.clientKey}\n onError={props.onError}\n awaitText={i18n.get('paybybankpix.await.waitForConfirmation')}\n instructions={i18n.get('paybybankpix.await.timeToPay', {\n values: { numberOfMin: props.countdownTime }\n })}\n pollStatus={pollStatus}\n endSlot={awaitEndSlot}\n ></PayByBankPixAwait>\n ) : (\n <div className=\"adyen-checkout-pix-enrollment-issuer-list\">\n <IssuerListIntroduction txVariant={props.txVariant} />\n <IssuerList\n items={useIssuerWithLogo({ issuers: props.issuers, txVariant: props.txVariant })}\n onSubmitAnalytics={props.onSubmitAnalytics}\n onChange={props.onChange}\n payButton={props.payButton}\n showPayButton={true}\n ref={issuerListRef}\n ></IssuerList>\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={i18n.get('paybybankpix.issuerList.disclaimer')} urls={[TERMS_CONDITIONS_URL]} />\n </span>\n </div>\n )}\n </div>\n );\n}\n\nexport default Enrollment;\n"],"names":["Enrollment","props","i18n","loadingContext","useCoreContext","getImage","useImage","issuerListRef","useRef","registrationOptions","setRegistrationOptions","useState","logos","name","alt","get","src","parentFolder","txVariant","imageFolder","self","showValidation","current","setStatus","newStatus","useEffect","setComponentRef","onEnroll","h","div","className","type","isAwait","PayByBankPixAwait","countdownTime","clientKey","onError","awaitText","instructions","values","numberOfMin","pollStatus","async","enrollmentId","response","getEnrollmentStatus","endSlot","span","IssuerListIntroduction","IssuerList","items","useIssuerWithLogo","issuers","onSubmitAnalytics","onChange","payButton","showPayButton","ref","LabelOnlyDisclaimerMessage","message","urls"],"mappings":"ypBAiBA,SAASA,EAAWC,GAChB,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAgBC,EAA4B,OAC3CC,EAAqBC,GAA0BC,EAAiB,MACjEC,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGhB,EAAMiB,cAAlCb,CAAkD,mBAE9D,CACIQ,KAAM,aACNC,IAAKZ,EAAKa,IAAI,wCACdC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAErD,CAAEQ,KAAM,OAAQC,IAAKZ,EAAKa,IAAI,mCAAoCC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,YAEjHe,EAAOZ,EAAO,CAChBa,eAAgB,KACZd,GAAee,SAASD,kBAE5BE,UAAYC,IACRjB,GAAee,SAASC,UAAUC,MA4B1C,OAVAC,EAAU,KACNxB,EAAMyB,gBAAgBN,EAAKE,UAC5B,CAACrB,EAAMyB,kBAEVD,EAAU,KACFhB,GACAR,EAAM0B,SAASlB,IAEpB,CAACA,IAGAmB,EAACC,MAAAA,CAAIC,UAAW,iCAdJ,CAAC7B,GAA+D,UAAfA,EAAM8B,KAe9DC,CAAQ/B,GACL2B,EAACK,EAAAA,CACGrB,MAAOA,EACPmB,KAAM9B,EAAMiB,UACZgB,cAAejC,EAAMiC,cACrBC,UAAWlC,EAAMkC,UACjBC,QAASnC,EAAMmC,QACfC,UAAWnC,EAAKa,IAAI,0CACpBuB,aAAcpC,EAAKa,IAAI,+BAAgC,CACnDwB,OAAQ,CAAEC,YAAavC,EAAMiC,iBAEjCO,WArCGC,UACf,GAAIjC,EAAqB,OAEzB,MAAMkC,aAAEA,EAAYR,UAAEA,GAAclC,EAC9B2C,QAAiBC,EAAoB,CAAEF,eAAcR,YAAWhC,mBAItE,OAHIyC,EAASnC,qBACTC,EAAuBkC,EAASnC,qBAE7BmC,GA8BKE,QA1BK,IAAMlB,EAACmB,OAAAA,KAAM7C,EAAKa,IAAI,yCA6B/Ba,EAACC,MAAAA,CAAIC,UAAU,6CACXF,EAACoB,EAAAA,CAAuB9B,UAAWjB,EAAMiB,YACzCU,EAACqB,EAAAA,CACGC,MAAOC,EAAkB,CAAEC,QAASnD,EAAMmD,QAASlC,UAAWjB,EAAMiB,YACpEmC,kBAAmBpD,EAAMoD,kBACzBC,SAAUrD,EAAMqD,SAChBC,UAAWtD,EAAMsD,UACjBC,eAAe,EACfC,IAAKlD,IAETqB,EAACmB,OAAAA,CAAKjB,UAAU,oCACZF,EAAC8B,EAAAA,CAA2BC,QAASzD,EAAKa,IAAI,sCAAuC6C,KAAM,CAjFtF,QAuF7B"}
1
+ {"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\nconst TERMS_CONDITIONS_URL = 'https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br';\n\nfunction Enrollment(props: EnrollmentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const issuerListRef = useRef<ComponentMethodsRef>(null);\n const [registrationOptions, setRegistrationOptions] = useState<string>(null);\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${props.txVariant}/` })('open-finance')}`\n },\n {\n name: 'arrow-down',\n alt: i18n.get('paybybankpix.await.logoAlt.arrowDown'),\n src: `${getImage({ imageFolder: 'components/' })('arrow_down')}`\n },\n { name: 'bank', alt: i18n.get('paybybankpix.await.logoAlt.bank'), src: `${getImage({ imageFolder: 'components/' })('bank')}` }\n ];\n const self = useRef({\n showValidation: () => {\n issuerListRef?.current?.showValidation();\n },\n setStatus: (newStatus: UIElementStatus) => {\n issuerListRef?.current?.setStatus(newStatus);\n }\n });\n\n const pollStatus = async () => {\n if (registrationOptions) return;\n\n const { enrollmentId, clientKey } = props as AwaitProps;\n const response = await getEnrollmentStatus({ enrollmentId, clientKey, loadingContext });\n if (response.registrationOptions) {\n setRegistrationOptions(response.registrationOptions);\n }\n return response;\n };\n // Assist typescript to narrow down the type.\n const isAwait = (props: EnrollmentProps): props is AwaitProps => props.type === 'await';\n const awaitEndSlot = () => <span>{i18n.get('paybybankpix.await.withOpenFinance')}</span>;\n\n useEffect(() => {\n props.setComponentRef(self.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (registrationOptions) {\n props.onEnroll(registrationOptions);\n }\n }, [registrationOptions]);\n\n return (\n <div className={'adyen-checkout-pix-enrollment'}>\n {isAwait(props) ? (\n <PayByBankPixAwait\n logos={logos}\n type={props.txVariant}\n countdownTime={props.countdownTime}\n clientKey={props.clientKey}\n onError={props.onError}\n awaitText={i18n.get('paybybankpix.await.waitForConfirmation')}\n instructions={i18n.get('paybybankpix.await.timeToPay', {\n values: { numberOfMin: props.countdownTime }\n })}\n pollStatus={pollStatus}\n endSlot={awaitEndSlot}\n ></PayByBankPixAwait>\n ) : (\n <div className=\"adyen-checkout-pix-enrollment-issuer-list\">\n <IssuerListIntroduction txVariant={props.txVariant} />\n <IssuerList\n items={useIssuerWithLogo({ issuers: props.issuers, txVariant: props.txVariant })}\n selectFieldLabel={i18n.get('paybybankpix.issuerList.selectField.label')}\n onSubmitAnalytics={props.onSubmitAnalytics}\n onChange={props.onChange}\n payButton={props.payButton}\n showPayButton={true}\n ref={issuerListRef}\n ></IssuerList>\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={i18n.get('paybybankpix.issuerList.disclaimer')} urls={[TERMS_CONDITIONS_URL]} />\n </span>\n </div>\n )}\n </div>\n );\n}\n\nexport default Enrollment;\n"],"names":["Enrollment","props","i18n","loadingContext","useCoreContext","getImage","useImage","issuerListRef","useRef","registrationOptions","setRegistrationOptions","useState","logos","name","alt","get","src","parentFolder","txVariant","imageFolder","self","showValidation","current","setStatus","newStatus","useEffect","setComponentRef","onEnroll","h","div","className","type","isAwait","PayByBankPixAwait","countdownTime","clientKey","onError","awaitText","instructions","values","numberOfMin","pollStatus","async","enrollmentId","response","getEnrollmentStatus","endSlot","span","IssuerListIntroduction","IssuerList","items","useIssuerWithLogo","issuers","selectFieldLabel","onSubmitAnalytics","onChange","payButton","showPayButton","ref","LabelOnlyDisclaimerMessage","message","urls"],"mappings":"ypBAgBA,SAASA,EAAWC,GAChB,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAgBC,EAA4B,OAC3CC,EAAqBC,GAA0BC,EAAiB,MACjEC,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0C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,EAAMmD,QAASlC,UAAWjB,EAAMiB,YACpEmC,iBAAkBnD,EAAKa,IAAI,6CAC3BuC,kBAAmBrD,EAAMqD,kBACzBC,SAAUtD,EAAMsD,SAChBC,UAAWvD,EAAMuD,UACjBC,eAAe,EACfC,IAAKnD,IAETqB,EAACmB,OAAAA,CAAKjB,UAAU,oCACZF,EAAC+B,EAAAA,CAA2BC,QAAS1D,EAAKa,IAAI,sCAAuC8C,KAAM,CAlFtF,mEAwF7B"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import n from"../../../../../core/Context/useImage.js";const i="open-finance",o="paybybankpix.await.logoAlt.openFinance";function s({txVariant:s}){const{i18n:c}=e(),a=n();return t("div",{className:"adyen-checkout-issuer-list-introduction"},t("div",{className:"adyen-checkout-issuer-list-introduction-logo-container"},t("img",{src:a({parentFolder:`${s}/`})(i),alt:c.get(o),className:"adyen-checkout-issuer-list-introduction-logo-container__logo"}),t("p",{className:"adyen-checkout-issuer-list-introduction-logo-container__title"},c.get("paybybankpix.issuerList.introduction.logo.content"))),t("div",{className:"adyen-checkout-issuer-list-introduction-text-container"},t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__title"},c.get("paybybankpix.issuerList.introduction.title")),t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__content"},c.get("paybybankpix.issuerList.introduction.content1")),t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__content"},c.get("paybybankpix.issuerList.introduction.content2"))))}export{s as default};
1
+ import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import o from"../../../../../core/Context/useImage.js";const n="open-finance",i="paybybankpix.await.logoAlt.openFinance";function a({txVariant:a}){const{i18n:r}=e(),s=o();return t("div",{className:"adyen-checkout-issuer-list-introduction"},t("div",{className:"adyen-checkout-issuer-list-introduction-logo-container"},t("img",{src:s({parentFolder:`${a}/`})(n),alt:r.get(i),className:"adyen-checkout-issuer-list-introduction-logo-container__logo"}),t("p",{className:"adyen-checkout-issuer-list-introduction-logo-container__title"},r.get("paybybankpix.issuerList.introduction.logo.content"))))}export{a as default};
2
2
  //# sourceMappingURL=IssuerListIntroduction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n <div className=\"adyen-checkout-issuer-list-introduction-text-container\">\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.title')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content1')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content2')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAGlBP,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,+CAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,kDAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,mDAK9B"}
1
+ {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAK9B"}
@@ -1,2 +1,2 @@
1
- import{useState as t,useEffect as o}from"../../../../external/preact/hooks/dist/hooks.js";import e from"../../../../utils/get-issuer-image.js";import{useCoreContext as r}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Context/useImage.js";const i=({issuers:i,txVariant:n})=>{const{loadingContext:a}=r(),m=s(),[c,f]=t(i);return o(()=>{if(i?.length>0){const t=e({loadingContext:a},n,m);f(i.map(o=>({...o,icon:t(o.id)})))}},[i,n]),c};export{i as useIssuerWithLogo};
1
+ import{useState as t,useEffect as o}from"../../../../external/preact/hooks/dist/hooks.js";import e from"../../../../utils/get-issuer-image.js";import{useCoreContext as r}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Context/useImage.js";const i=({issuers:i=[],txVariant:n})=>{const{loadingContext:a}=r(),m=s(),[c,f]=t(i);return o(()=>{if(i?.length>0){const t=e({loadingContext:a},n,m);f(i.map(o=>({...o,icon:t(o.id)})))}},[i,n]),c};export{i as useIssuerWithLogo};
2
2
  //# sourceMappingURL=useIssuerWithLogo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers, txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","icon","id"],"mappings":"mRAUaA,EAAoB,EAAGC,UAASC,gBACzC,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,GAAIT,GAASU,OAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,QACLA,EACHC,KAAMJ,EAAcG,EAAKE,OAGrC,GACD,CAAChB,EAASC,IAENK"}
1
+ {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers = [], txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","icon","id"],"mappings":"6QAUO,MAAMA,EAAoB,EAAGC,UAAU,GAAIC,gBAC9C,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,GAAIT,GAASU,OAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,QACLA,EACHC,KAAMJ,EAAcG,EAAKE,OAGrC,GACD,CAAChB,EAASC,IAENK"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useRef as n,useCallback as o,useEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import l from"../../../internal/Voucher/Voucher.js";import s from"../../../../core/Context/useImage.js";import p from"../../../internal/PayButton/PayButton.js";import m from"./getAuthorizationStatus.js";import u from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:y,countdownTime:b,receiver:d,amount:f,txVariant:x,issuer:g,setComponentRef:h,enrollmentId:k,initiationId:w,clientKey:j,onAuthorize:v,onError:C}){const{i18n:P,loadingContext:I}=i(),B=s(),[E,F]=a("ready"),[S,z]=a(null),A=[{name:"open-finance",alt:P.get("paybybankpix.await.logoAlt.openFinance"),src:`${B({parentFolder:`${x}/`})("open-finance")}`}],D=[{label:P.get("paybybankpix.payment.receiver.label"),value:d},{label:P.get("paybybankpix.payment.paymentDate.label"),value:P.date((new Date).toString())},{label:P.get("paybybankpix.payment.paymentMethod.label"),value:"Pix Open Finance"}],T=n({setStatus:F}),K=o(async()=>{if(S)return;const e=await m({enrollmentId:k,initiationId:w,clientKey:j,loadingContext:I});return e.authorizationOptions&&z(e.authorizationOptions),e},[S,k,w,j,I]);return r(()=>{h(T.current)},[h]),r(()=>{S&&v(S)},[S]),"await"===y?e(u,{logos:A,type:x,countdownTime:b,clientKey:j,onError:C,awaitText:P.get("paybybankpix.await.fetchDetails"),pollStatus:K}):e(t,null,e(l,{issuerImageUrl:B({imageFolder:`${x}/`})(g),paymentMethodType:x,amount:P.amount(f.value,f.currency),voucherDetails:D}),e(p,{classNameModifiers:["standalone"],label:P.get("paybybankpix.storedPayment.payButton.label"),status:E,amount:f,onClick:c}))}export{c as default};
1
+ import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useState as e,useRef as n,useCallback as o,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import s from"../../../internal/PayButton/PayButton.js";import l from"./getAuthorizationStatus.js";import p from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:m,countdownTime:u,amount:f,txVariant:y,setComponentRef:d,enrollmentId:x,initiationId:b,clientKey:g,onAuthorize:k,onError:w}){const{i18n:C,loadingContext:h}=i(),j=r(),[P,B]=e("ready"),[E,I]=e(null),z=[{name:"open-finance",alt:C.get("paybybankpix.await.logoAlt.openFinance"),src:`${j({parentFolder:`${y}/`})("open-finance")}`}],A=n({setStatus:B}),S=o(async()=>{if(E)return;const t=await l({enrollmentId:x,initiationId:b,clientKey:g,loadingContext:h});return t.authorizationOptions&&I(t.authorizationOptions),t},[E,x,b,g,h]);return a(()=>{d(A.current)},[d]),a(()=>{E&&k(E)},[E]),"await"===m?t(p,{logos:z,type:y,countdownTime:u,clientKey:g,onError:w,awaitText:C.get("paybybankpix.await.fetchDetails"),pollStatus:S}):t(s,{classNameModifiers:["standalone"],label:C.get("paybybankpix.redirectBtn.label"),status:P,amount:f,onClick:c})}export{c as default};
2
2
  //# sourceMappingURL=StoredPayment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport PaymentDetails from '../../../internal/Voucher';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n receiver,\n amount,\n txVariant,\n issuer,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n const details = [\n { label: i18n.get('paybybankpix.payment.receiver.label'), value: receiver },\n { label: i18n.get('paybybankpix.payment.paymentDate.label'), value: i18n.date(new Date().toString()) },\n { label: i18n.get('paybybankpix.payment.paymentMethod.label'), value: 'Pix Open Finance' }\n ];\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <Fragment>\n <PaymentDetails\n issuerImageUrl={getImage({ imageFolder: `${txVariant}/` })(issuer)}\n paymentMethodType={txVariant}\n amount={i18n.amount(amount.value, amount.currency)}\n voucherDetails={details}\n ></PaymentDetails>\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.storedPayment.payButton.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n </Fragment>\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","receiver","amount","txVariant","issuer","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","details","label","value","date","Date","toString","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","Fragment","PaymentDetails","issuerImageUrl","imageFolder","paymentMethodType","currency","voucherDetails","PayButton","classNameModifiers","onClick"],"mappings":"kiBAWA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,SACbA,EAAQC,OACRA,EAAMC,UACNA,EAAS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AA,CACGC,mBAzDY,CAAC,cA0DbzB,MAAOjB,EAAKa,IAAI,8CAChBR,OAAQA,EACRd,OAAQA,EACRoD,QAASxD,IAIzB"}
1
+ {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n amount,\n txVariant,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.redirectBtn.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","amount","txVariant","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","PayButton","classNameModifiers","label","onClick"],"mappings":"geAUA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,OACbA,EAAMC,UACNA,EAASC,gBACTA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGtB,MAA5BU,CAA4C,oBAItDa,EAAOC,EAAO,CAChBX,cAGEY,EAAaC,EAAYC,UAC3B,GAAIZ,EAAsB,OAE1B,MAAMa,QAAiBC,EAAuB,CAAE3B,eAAcC,eAAcC,YAAWI,mBAKvF,OAJIoB,EAASb,sBACTC,EAAwBY,EAASb,sBAG9Ba,GACR,CAACb,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVAsB,EAAU,KACN7B,EAAgBsB,EAAKQ,UACtB,CAAC9B,IAEJ6B,EAAU,KACFf,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATlB,EACHmC,EAACC,EAAAA,CACGhB,MAAOA,EACPpB,KAAMG,EACNF,cAAeA,EACfM,UAAWA,EACXE,QAASA,EACT4B,UAAW3B,EAAKa,IAAI,mCACpBK,WAAYA,IAGhBO,EAACG,EAAAA,CACGC,mBA9CgB,CAAC,cA+CjBC,MAAO9B,EAAKa,IAAI,kCAChBR,OAAQA,EACRb,OAAQA,EACRuC,QAAS1C,GAGrB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../../utils/useForm/useForm.js";import n from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as m}from"../../../core/Context/CoreProvider.js";import c from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as f,ANALYTICS_FEATURED_ISSUER as y,ANALYTICS_SELECTED_STR as C,ANALYTICS_DISPLAYED_STR as j,ANALYTICS_SEARCH_DEBOUNCE_TIME as F,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as S}from"../../../core/Analytics/constants.js";import{debounce as _}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b}from"../../../core/Analytics/AnalyticsInfoEvent.js";const v=({issuer:e,items:s},t)=>{const r=s.find(s=>s.id===e)?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},A=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function M({items:M,placeholder:k,issuer:w,highlightedIds:E=[],showContextualElement:V,contextualText:T,...B}){const{i18n:N}=m(),{handleChangeFor:P,triggerValidation:R,data:D,valid:L,errors:G,isValid:$}=a({schema:A,defaultData:{issuer:w},rules:I}),[K,O]=t("ready"),[q,z]=t(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=c(),Q=H?.({});this.setStatus=e=>{O(e)};const U=r(e=>s=>{const t=1===e?f:y,r=M.find(e=>e.id===s.target.value),o=new b({type:C,target:t,issuer:r.name});B.onSubmitAnalytics(o),z(e),P("issuer")(s)},[P]),W=r(e=>{if(e){const e=new b({type:j,target:f});B.onSubmitAnalytics(e)}},[]),X=o(_(B.onSubmitAnalytics,F)),Y=r(()=>{X.current({type:S,target:x})},[]);i(()=>{B.onChange({data:D,valid:L,errors:G,isValid:$});const e=Q?.({errors:G,isValidating:!0});e?.action===d&&J&&g(".adyen-checkout__issuer-list","issuer-list")},[D,L,G,$]),this.showValidation=()=>{R()};const{highlightedItems:Z}=M.reduce((e,s)=>(E.includes(s.id)&&e.highlightedItems.push({...s}),e),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!Z.length&&e(s,null,e(l,{selectedIssuerId:0===q?D.issuer:null,items:Z,onChange:U(0)}),e(u,null)),e(n,{label:N.get("issuerList.selectField.label"),errorMessage:(ee=G.issuer,ee&&ee.errorMessage?N.get(ee.errorMessage):!!ee),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:V,contextualText:T},e(p,{items:M,selectedValue:1===q?D.issuer:null,placeholder:k,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:U(1),onListToggle:W,onInput:Y})),B.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:N.get(B.termsAndConditions.translationKey),urls:B.termsAndConditions.urls})),B.showPayButton&&B.payButton({status:K,label:v({issuer:D.issuer,items:[...M,...Z]},N)}));var ee}M.defaultProps={onChange:()=>{}};export{M as default};
1
+ import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../../utils/useForm/useForm.js";import n from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as m}from"../../../core/Context/CoreProvider.js";import c from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as f,ANALYTICS_FEATURED_ISSUER as y,ANALYTICS_SELECTED_STR as C,ANALYTICS_DISPLAYED_STR as j,ANALYTICS_SEARCH_DEBOUNCE_TIME as F,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as S}from"../../../core/Analytics/constants.js";import{debounce as _}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b}from"../../../core/Analytics/AnalyticsInfoEvent.js";const v=({issuer:e,items:s},t)=>{const r=s.find(s=>s.id===e)?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},A=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function M({items:M,placeholder:k,issuer:w,highlightedIds:E=[],showContextualElement:V,contextualText:T,selectFieldLabel:B,...L}){const{i18n:N}=m(),{handleChangeFor:P,triggerValidation:R,data:D,valid:G,errors:$,isValid:K}=a({schema:A,defaultData:{issuer:w},rules:I}),[O,q]=t("ready"),[z,H]=t(1),{setSRMessagesFromObjects:J,shouldMoveFocusSR:Q}=c(),U=J?.({});this.setStatus=e=>{q(e)};const W=r(e=>s=>{const t=1===e?f:y,r=M.find(e=>e.id===s.target.value),o=new b({type:C,target:t,issuer:r.name});L.onSubmitAnalytics(o),H(e),P("issuer")(s)},[P]),X=r(e=>{if(e){const e=new b({type:j,target:f});L.onSubmitAnalytics(e)}},[]),Y=o(_(L.onSubmitAnalytics,F)),Z=r(()=>{Y.current({type:S,target:x})},[]);i(()=>{L.onChange({data:D,valid:G,errors:$,isValid:K});const e=U?.({errors:$,isValidating:!0});e?.action===d&&Q&&g(".adyen-checkout__issuer-list","issuer-list")},[D,G,$,K]),this.showValidation=()=>{R()};const{highlightedItems:ee}=M.reduce((e,s)=>(E.includes(s.id)&&e.highlightedItems.push({...s}),e),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!ee.length&&e(s,null,e(l,{selectedIssuerId:0===z?D.issuer:null,items:ee,onChange:W(0)}),e(u,null)),e(n,{label:B??N.get("issuerList.selectField.label"),errorMessage:(se=$.issuer,se&&se.errorMessage?N.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:V,contextualText:T},e(p,{items:M,selectedValue:1===z?D.issuer:null,placeholder:k,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),L.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:N.get(L.termsAndConditions.translationKey),urls:L.termsAndConditions.urls})),L.showPayButton&&L.payButton({status:O,label:v({issuer:D.issuer,items:[...M,...ee]},N)}));var se}M.defaultProps={onChange:()=>{}};export{M as default};
2
2
  //# sourceMappingURL=IssuerList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n type: ANALYTICS_SELECTED_STR,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DISPLAYED_STR,\n target: ANALYTICS_LIST\n });\n props.onSubmitAnalytics(event);\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","ANALYTICS_SELECTED_STR","onSubmitAnalytics","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"soCA8BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACvC,MAAMC,EAAaF,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,IAASO,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,GAAWd,MAAEA,EAAKe,YAAEA,EAAWhB,OAAEA,EAAMiB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,KAAmBC,IAC7G,MAAMlB,KAAEA,GAASmB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFnB,SACAoB,YAAa,CAAE7B,UACf8B,MAAOpB,KAEJqB,EAAQC,GAAaC,EAAS,UAC9BC,EAAWC,GAAgBF,EAAAA,IAE5BG,yBAAEA,EAAwBC,kBAAEA,GAAsBC,IAClDC,EAAuCH,IAA2B,IAIxEI,KAAKR,UAAYS,IACbT,EAAUS,IAGd,MAAMC,EAAoBC,EACrBC,GAAgCC,IAC7B,MAAMC,MAASF,EAAyCG,EAAiBC,EACnEC,EAAYhD,EAAMG,KAAKJ,GAAUA,EAAOM,KAAQuC,EAAMC,OAA8BI,OAEpFC,EAAiB,IAAIC,EAAmB,CAC1CR,KAAMS,EACNP,SACA9C,OAAQiD,EAAU1C,OAEtBa,EAAMkC,kBAAkBH,GAExBhB,EAAaS,GACbtB,EAAgB,SAAhBA,CAA0BuB,IAE9B,CAACvB,I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,EAAAA,GACVmD,aAActC,EACduC,QAAShC,KAIhB1C,EAAM2E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAAS/F,EAAKM,IAAIY,EAAM2E,mBAAmBG,gBAAiBC,KAAM/E,EAAM2E,mBAAmBI,QAIrH/E,EAAMgF,eACHhF,EAAMiF,UAAU,CACZtE,SACAyD,MAAOzF,EAAe,CAAEC,OAAQwB,EAAK,OAAWvB,MAAO,IAAIA,KAAUyE,IAAqBxE,MAxGlFuF,IAAAA,EA4G5B,CAEA1E,EAAWuF,aAAe,CACtBnC,SAAU"}
1
+ {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n type: ANALYTICS_SELECTED_STR,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DISPLAYED_STR,\n target: ANALYTICS_LIST\n });\n props.onSubmitAnalytics(event);\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","ANALYTICS_SELECTED_STR","onSubmitAnalytics","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"soCA8BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACvC,MAAMC,EAAaF,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,IAASO,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,I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BzE,MAxGlFwF,IAAAA,EA4G5B,CAEA3E,EAAWwF,aAAe,CACtBnC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{payAmountLabel as r,secondaryAmountLabel as a}from"./utils.js";import s from"./components/SecondaryButtonLabel.js";const l=({amount:l,secondaryAmount:n,classNameModifiers:i=[],label:m,...c})=>{const{i18n:u}=o(),d=l&&{}.hasOwnProperty.call(l,"value")&&0===l.value,p=d?u.get("confirmPreauthorization"):r(u,l),f=!d&&!m&&l&&n&&Object.keys(n).length?a(u,n):null;return e(t,{...c,disabled:c.disabled||"loading"===c.status,classNameModifiers:[...i,"pay"],label:m||p},f&&e(s,{label:f}))};export{l as default,r as payAmountLabel};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{payAmountLabel as r,secondaryAmountLabel as a}from"./utils.js";import s from"./components/SecondaryButtonLabel.js";const l=({amount:l,secondaryAmount:n,classNameModifiers:i=[],label:m,...c})=>{const{i18n:u}=o(),d=l&&{}.hasOwnProperty.call(l,"value")&&0===l.value,p=d?u.get("confirmPreauthorization"):r(u,l),f=l&&"number"==typeof l.value&&!!l.currency,b=n&&Object.keys(n).length>0,y=!d&&!m&&f&&b?a(u,n):null;return e(t,{...c,disabled:c.disabled||"loading"===c.status,classNameModifiers:[...i,"pay"],label:m||p},y&&e(s,{label:y}))};export{l as default,r as payAmountLabel};
2
2
  //# sourceMappingURL=PayButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { payAmountLabel, secondaryAmountLabel } from './utils';\nimport { PaymentAmountExtended } from '../../../types/global-types';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n label?: string;\n amount: PaymentAmountExtended;\n secondaryAmount?: PaymentAmountExtended;\n status?: string;\n disabled?: boolean;\n icon?: string;\n onClick?(): void;\n}\n\nconst PayButton = ({ amount, secondaryAmount, classNameModifiers = [], label, ...props }: PayButtonProps) => {\n const { i18n } = useCoreContext();\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n const defaultLabel = isZeroAuth ? i18n.get('confirmPreauthorization') : payAmountLabel(i18n, amount);\n\n /**\n * Show the secondaryLabel if:\n * - it's not zero auth, and\n * - we don't have a predefined label (i.e. redirect, qrcode, await based comps...), and\n * - we do have an amount object (merchant might not be passing this in order to not show the amount on the button), and\n * - we have a secondaryAmount object with some properties\n */\n const secondaryLabel =\n !isZeroAuth && !label && amount && secondaryAmount && Object.keys(secondaryAmount).length\n ? secondaryAmountLabel(i18n, secondaryAmount)\n : null;\n\n return (\n <Button\n {...props}\n disabled={props.disabled || props.status === 'loading'}\n classNameModifiers={[...classNameModifiers, 'pay']}\n label={label || defaultLabel}\n >\n {secondaryLabel && <SecondaryButtonLabel label={secondaryLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\nexport { payAmountLabel };\n"],"names":["PayButton","amount","secondaryAmount","classNameModifiers","label","props","i18n","useCoreContext","isZeroAuth","hasOwnProperty","call","value","defaultLabel","get","payAmountLabel","secondaryLabel","Object","keys","length","secondaryAmountLabel","h","Button","disabled","status","SecondaryButtonLabel"],"mappings":"4SAsBA,MAAMA,EAAY,EAAGC,SAAQC,kBAAiBC,qBAAqB,GAAIC,WAAUC,MAC7E,MAAMC,KAAEA,GAASC,IACXC,EAAaP,GAAU,CAAC,EAAEQ,eAAeC,KAAKT,EAAQ,UAA6B,IAAjBA,EAAOU,MACzEC,EAAeJ,EAAaF,EAAKO,IAAI,2BAA6BC,EAAeR,EAAML,GASvFc,GACDP,IAAeJ,GAASH,GAAUC,GAAmBc,OAAOC,KAAKf,GAAiBgB,OAC7EC,EAAqBb,EAAMJ,GAC3B,KAEV,OACIkB,EAACC,EAAAA,IACOhB,EACJiB,SAAUjB,EAAMiB,UAA6B,YAAjBjB,EAAMkB,OAClCpB,mBAAoB,IAAIA,EAAoB,OAC5CC,MAAOA,GAASQ,GAEfG,GAAkBK,EAACI,EAAAA,CAAqBpB,MAAOW"}
1
+ {"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { payAmountLabel, secondaryAmountLabel } from './utils';\nimport { PaymentAmountExtended } from '../../../types/global-types';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n label?: string;\n amount?: PaymentAmountExtended;\n secondaryAmount?: PaymentAmountExtended;\n status?: string;\n disabled?: boolean;\n icon?: string;\n onClick?(): void;\n}\n\nconst PayButton = ({ amount, secondaryAmount, classNameModifiers = [], label, ...props }: PayButtonProps) => {\n const { i18n } = useCoreContext();\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n const defaultLabel = isZeroAuth ? i18n.get('confirmPreauthorization') : payAmountLabel(i18n, amount);\n\n /**\n * Show the secondaryLabel if:\n * - it's not zero auth, and\n * - we don't have a predefined label (i.e. redirect, qrcode, await based comps...), and\n * - we do have an amount object (merchant might not be passing this in order to not show the amount on the button), and\n * - we have a secondaryAmount object with some properties\n */\n const hasValidAmount = amount && typeof amount.value === 'number' && !!amount.currency;\n const hasSecondaryAmount = secondaryAmount && Object.keys(secondaryAmount).length > 0;\n\n const secondaryLabel = !isZeroAuth && !label && hasValidAmount && hasSecondaryAmount ? secondaryAmountLabel(i18n, secondaryAmount) : null;\n\n return (\n <Button\n {...props}\n disabled={props.disabled || props.status === 'loading'}\n classNameModifiers={[...classNameModifiers, 'pay']}\n label={label || defaultLabel}\n >\n {secondaryLabel && <SecondaryButtonLabel label={secondaryLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\nexport { payAmountLabel };\n"],"names":["PayButton","amount","secondaryAmount","classNameModifiers","label","props","i18n","useCoreContext","isZeroAuth","hasOwnProperty","call","value","defaultLabel","get","payAmountLabel","hasValidAmount","currency","hasSecondaryAmount","Object","keys","length","secondaryLabel","secondaryAmountLabel","h","Button","disabled","status","SecondaryButtonLabel"],"mappings":"4SAsBA,MAAMA,EAAY,EAAGC,SAAQC,kBAAiBC,qBAAqB,GAAIC,WAAUC,MAC7E,MAAMC,KAAEA,GAASC,IACXC,EAAaP,GAAU,CAAC,EAAEQ,eAAeC,KAAKT,EAAQ,UAA6B,IAAjBA,EAAOU,MACzEC,EAAeJ,EAAaF,EAAKO,IAAI,2BAA6BC,EAAeR,EAAML,GASvFc,EAAiBd,GAAkC,iBAAjBA,EAAOU,SAAwBV,EAAOe,SACxEC,EAAqBf,GAAmBgB,OAAOC,KAAKjB,GAAiBkB,OAAS,EAE9EC,GAAkBb,IAAeJ,GAASW,GAAkBE,EAAqBK,EAAqBhB,EAAMJ,GAAmB,KAErI,OACIqB,EAACC,EAAAA,IACOnB,EACJoB,SAAUpB,EAAMoB,UAA6B,YAAjBpB,EAAMqB,OAClCvB,mBAAoB,IAAIA,EAAoB,OAC5CC,MAAOA,GAASQ,GAEfS,GAAkBE,EAACI,EAAAA,CAAqBvB,MAAOiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecondaryButtonLabel.js","sources":["../../../../../../src/components/internal/PayButton/components/SecondaryButtonLabel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport './SecondaryButtonLabel.scss';\n\nconst SecondaryButtonLabel = ({ label }) => {\n return <span className={'checkout-secondary-button__text'}>{label}</span>;\n};\n\nexport default SecondaryButtonLabel;\n"],"names":["SecondaryButtonLabel","label","h","span","className"],"mappings":"2EAGA,MAAMA,EAAuB,EAAGC,WACrBC,EAACC,OAAAA,CAAKC,UAAW,mCAAoCH"}
1
+ {"version":3,"file":"SecondaryButtonLabel.js","sources":["../../../../../../src/components/internal/PayButton/components/SecondaryButtonLabel.tsx"],"sourcesContent":["import { h } from 'preact';\n\nconst SecondaryButtonLabel = ({ label }) => {\n return <span className={'checkout-secondary-button__text'}>{label}</span>;\n};\n\nexport default SecondaryButtonLabel;\n"],"names":["SecondaryButtonLabel","label","h","span","className"],"mappings":"2EAEA,MAAMA,EAAuB,EAAGC,WACrBC,EAACC,OAAAA,CAAKC,UAAW,mCAAoCH"}
@@ -1,2 +1,2 @@
1
- function d(d){const[e,a]=d;return{dualBrandSelectElements:[{id:e.brand,brandObject:e},{id:a.brand,brandObject:a}],selectedBrandValue:e.brand,leadBrand:e}}export{d as default};
1
+ function d(d,e){const[a,n]=d;return{dualBrandSelectElements:[{id:a.brand,brandObject:a},{id:n.brand,brandObject:n}],selectedBrandValue:e?a.brand:"",leadBrand:a}}export{d as default};
2
2
  //# sourceMappingURL=createCardVariantSwitcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCardVariantSwitcher.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.ts"],"sourcesContent":["import { BrandObject, DualBrandSelectElement } from '../../../Card/types';\n\n/**\n * Creates an object used for setting state - that will trigger the rendering of a select element to allow a choice between 2 different card variants\n * @param brandObjArr - array containing 2 card brands objects\n */\nexport default function createCardVariantSwitcher(brandObjArr: BrandObject[]) {\n const [leadBrand, subBrand] = brandObjArr;\n\n return {\n dualBrandSelectElements: [\n { id: leadBrand.brand, brandObject: leadBrand },\n { id: subBrand.brand, brandObject: subBrand }\n ] as DualBrandSelectElement[],\n selectedBrandValue: leadBrand.brand, // set to leadBrand.brand if an initial selection is to be made; else set to empty string\n leadBrand\n };\n}\n"],"names":["createCardVariantSwitcher","brandObjArr","leadBrand","subBrand","dualBrandSelectElements","id","brand","brandObject","selectedBrandValue"],"mappings":"AAMe,SAASA,EAA0BC,GAC9C,MAAOC,EAAWC,GAAYF,EAE9B,MAAO,CACHG,wBAAyB,CACrB,CAAEC,GAAIH,EAAUI,MAAOC,YAAaL,GACpC,CAAEG,GAAIF,EAASG,MAAOC,YAAaJ,IAEvCK,mBAAoBN,EAAUI,MAC9BJ,YAER"}
1
+ {"version":3,"file":"createCardVariantSwitcher.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.ts"],"sourcesContent":["import { BrandObject, DualBrandSelectElement } from '../../../Card/types';\n\n/**\n * Creates an object used for setting state - that will trigger the rendering of a select element to allow a choice between 2 different card variants\n * @param brandObjArr - array containing 2 card brands objects\n */\nexport default function createCardVariantSwitcher(brandObjArr: BrandObject[], preselectBrand: boolean) {\n const [leadBrand, subBrand] = brandObjArr;\n\n return {\n dualBrandSelectElements: [\n { id: leadBrand.brand, brandObject: leadBrand },\n { id: subBrand.brand, brandObject: subBrand }\n ] as DualBrandSelectElement[],\n selectedBrandValue: preselectBrand ? leadBrand.brand : '', // set to leadBrand.brand if an initial selection is to be made; else set to empty string\n leadBrand\n };\n}\n"],"names":["createCardVariantSwitcher","brandObjArr","preselectBrand","leadBrand","subBrand","dualBrandSelectElements","id","brand","brandObject","selectedBrandValue"],"mappings":"AAMe,SAASA,EAA0BC,EAA4BC,GAC1E,MAAOC,EAAWC,GAAYH,EAE9B,MAAO,CACHI,wBAAyB,CACrB,CAAEC,GAAIH,EAAUI,MAAOC,YAAaL,GACpC,CAAEG,GAAIF,EAASG,MAAOC,YAAaJ,IAEvCK,mBAAoBP,EAAiBC,EAAUI,MAAQ,GACvDJ,YAER"}