@adyen/adyen-web 6.20.0 → 6.22.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 (133) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/adyen.css +9 -10
  3. package/dist/cjs/adyen.css.map +1 -1
  4. package/dist/cjs/index.cjs +2 -2
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.cts +33 -9
  7. package/dist/es/adyen.css +9 -10
  8. package/dist/es/adyen.css.map +1 -1
  9. package/dist/es/components/Ach/Ach.js +1 -1
  10. package/dist/es/components/Ach/Ach.js.map +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  12. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  13. package/dist/es/components/Card/Card.js +1 -1
  14. package/dist/es/components/Card/Card.js.map +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  20. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  21. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  22. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  23. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  24. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  25. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  26. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  27. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  28. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  29. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  30. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  31. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  32. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  33. package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
  34. package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
  35. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  36. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  37. package/dist/es/components/UPI/UPI.js +1 -1
  38. package/dist/es/components/UPI/UPI.js.map +1 -1
  39. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  40. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  41. package/dist/es/components/UPI/components/UPIMandate/UPIMandate.js +2 -0
  42. package/dist/es/components/UPI/components/UPIMandate/UPIMandate.js.map +1 -0
  43. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  44. package/dist/es/components/internal/Await/Await.js +1 -1
  45. package/dist/es/components/internal/Await/Await.js.map +1 -1
  46. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  47. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  48. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  49. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  50. package/dist/es/components/internal/PayButton/PayButton.js +1 -1
  51. package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
  52. package/dist/es/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  53. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  54. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  55. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  56. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  57. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  58. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  59. package/dist/es/core/Analytics/Analytics.js +1 -1
  60. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  61. package/dist/es/core/Analytics/utils.js +1 -1
  62. package/dist/es/core/Analytics/utils.js.map +1 -1
  63. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  64. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  65. package/dist/es/core/core.js +1 -1
  66. package/dist/es/core/core.js.map +1 -1
  67. package/dist/es/index.d.ts +33 -9
  68. package/dist/es/utils/setFocus.js +1 -1
  69. package/dist/es/utils/setFocus.js.map +1 -1
  70. package/dist/es-legacy/adyen.css +9 -10
  71. package/dist/es-legacy/adyen.css.map +1 -1
  72. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  73. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  74. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  75. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  76. package/dist/es-legacy/components/Card/Card.js +1 -1
  77. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  78. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  79. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  80. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  81. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  82. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  83. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  84. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  85. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  86. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  87. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  88. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  89. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  90. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  91. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  92. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  93. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  94. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  95. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  96. package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
  97. package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
  98. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  99. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  100. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  101. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  102. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  103. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  104. package/dist/es-legacy/components/UPI/components/UPIMandate/UPIMandate.js +2 -0
  105. package/dist/es-legacy/components/UPI/components/UPIMandate/UPIMandate.js.map +1 -0
  106. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  107. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  108. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  109. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  110. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  111. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  112. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  113. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  114. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  115. package/dist/es-legacy/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  116. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  117. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  118. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  119. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  120. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  121. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  122. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  123. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  124. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  125. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  126. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  127. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  128. package/dist/es-legacy/core/core.js +1 -1
  129. package/dist/es-legacy/core/core.js.map +1 -1
  130. package/dist/es-legacy/utils/setFocus.js +1 -1
  131. package/dist/es-legacy/utils/setFocus.js.map +1 -1
  132. package/package.json +157 -159
  133. package/styles/adyen.css +9 -10
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n void copyToClipboard(this.props.qrCodeData);\n\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n this.props.onSubmitAnalytics(event);\n\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","event","AnalyticsInfoEvent","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","onSubmitAnalytics","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"slCAuBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,WAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH,YAAYC,MACxBX,KAAKC,eAAea,KAAKC,MAAMF,EAAMJ,KACtCH,EACP,CAiEAU,MAAAA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAIC,gBAAEA,IAAkCC,QAAEA,EAAOC,UAAEA,EAASC,QAAEA,IACrH,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IAEXC,EAAchC,KAAKiC,MAAMC,WACzB,GAAGN,4CAA8B5B,KAAKiC,MAAMC,wBAAwBlC,KAAKiC,MAAME,YAC/EnC,KAAKiC,MAAMD,YAEXI,EAAa,CAACC,EAAOC,KACvB,MAAMC,EAASZ,EAAKa,IAAIF,GAExB,OADAG,EAAgBF,GAEZG,EAACC,MAAAA,CAAIC,UAAU,+DACXF,EAACG,MAAAA,CACGD,UAAU,0EACVE,IAAKhB,EAAS,CAAEiB,YAAa,eAAxBjB,CAAyCO,GAC9CW,IAAKT,IAETG,EAACC,MAA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DW,KAAKC,GACLC,MAAMC,IAAAA,CAAexG,KAAM,gBAAiBW,MAAO6F,KACnDH,KAAMpF,IACH,OAAQA,EAAOjB,MACX,IAAK,UACDtB,KAAKoH,WAAW7E,GAChB,MACJ,IAAK,QACDvC,KAAKkH,QAAQ3E,GACb,MACJ,QACIvC,KAAK2G,SAAS,CAAEjF,SAAS,IAEjC,OAAOa,MAxHfvC,KAAK8E,MAAQ,CACTiD,aAAc,UACdtG,WAAW,EACXnB,MAAO2B,EAAM3B,MACbkB,SAAS,EACTE,SAAS,EACTqD,WAAY,IACZ8B,WAAY,EAEpB,EAEAP,EAjBEzG,EAiBYmI,eAAe,CACzB1H,MAAO,IACPe,cAAe,GACf6F,QAAS,OACTE,WAAY,OACZL,aAAc,IACdvD,mBAAoB,GACpBwD,kBAAmB,IACnBzC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
1
+ {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp',\n showAmount: true\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, showAmount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {showAmount && amount && amount.value !== null && !!amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n void copyToClipboard(this.props.qrCodeData);\n\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n this.props.onSubmitAnalytics(event);\n\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","showAmount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","event","AnalyticsInfoEvent","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","onSubmitAnalytics","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"slCAuBA,MAAMA,UAAiBC,EA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IACZ8B,WAAY,EAEpB,EAEAP,EAjBE1G,EAiBYoI,eAAe,CACzB3H,MAAO,IACPgB,cAAe,GACf6F,QAAS,OACTE,WAAY,OACZL,aAAc,IACdvD,mBAAoB,GACpBwD,kBAAmB,IACnBzC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa,UACblD,YAAY"}
@@ -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"}
@@ -1,2 +1,2 @@
1
- import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";const t=(e,n)=>e.reduce((e,t)=>e||n.includes(t.brand),!1),r=e=>e.map(e=>({...e})),s=(e,n="mc",t="visa")=>{const s=r(e);return s[0].brand!==n&&s[0].brand!==t&&s.reverse(),s.length=1,s};function o(o,u,a,d={}){const{type:c,cvcPolicy:i}=o,{sfp:l}=u,{dualBrandSelectElements:p,setDualBrandSelectElements:B,setSelectedBrandValue:g,issuingCountryCode:C,setIssuingCountryCode:b}=a;return{processBinLookup:(o,u)=>{const a=o?.issuingCountryCode?o.issuingCountryCode.toLowerCase():null;if(b(a),!o||!Object.keys(o).length){B([]),g("");const e=u&&"card"!==c?c:null;return l.current.processBinLookupResponse(o,{brand:e,cvcPolicy:i}),void(d.current=0)}if(o.supportedBrands?.length){const u=t(o.supportedBrands,n),a=u?s(o.supportedBrands):r(o.supportedBrands);if(a.length>1){const n=e(a);B(n.dualBrandSelectElements),g(n.selectedBrandValue),l.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:[n.leadBrand]}),n.leadBrand.panLength>0&&(d.current=n.leadBrand.panLength)}else B([]),g(""),u||g(a[0].brand),l.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:a}),a[0].panLength>0&&(d.current=a[0].panLength)}},handleDualBrandSelection:e=>{let n=e;if(e instanceof Event){const t=e.target;n=t.getAttribute("data-value")||t.getAttribute("value")}let t=[];n&&(t=p.reduce((e,t)=>(t.brandObject.brand===n&&e.push(t.brandObject),e),[]),t.length&&(g(n),l.current.processBinLookupResponse({issuingCountryCode:C,supportedBrands:t,isDualBrandSelection:!0})))}}}export{r as cloneBrandsArr,t as containsExcludedBrand,o as default,s as removeExcludedBrand};
1
+ import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";import{mustHandleDualBrandingAccordingToEURegulations as r}from"../../../Card/components/CardInput/utils.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as t}from"../../../Card/Card.js";const s=(e,n)=>e.reduce((e,r)=>e||n.includes(r.brand),!1),o=e=>e.map(e=>({...e})),a=(e,n="mc",r="visa")=>{const t=o(e);return t[0].brand!==n&&t[0].brand!==r&&t.reverse(),t.length=1,t};function d(d,u,c,i={}){const{type:p,cvcPolicy:l}=d,{sfp:C}=u,{dualBrandSelectElements:B,setDualBrandSelectElements:g,setSelectedBrandValue:b,issuingCountryCode:m,setIssuingCountryCode:y}=c;return{processBinLookup:(d,u)=>{const c=d?.issuingCountryCode?d.issuingCountryCode.toLowerCase():null;if(y(c),!d||!Object.keys(d).length){g([]),b("");const e=u&&"card"!==p?p:null;return C.current.processBinLookupResponse(d,{brand:e,cvcPolicy:l}),void(i.current=0)}if(d.supportedBrands?.length){const u=s(d.supportedBrands,n),c=u?a(d.supportedBrands):o(d.supportedBrands);if(c.length>1){const n=r(t,c,"brand"),s=e(c,n);g(s.dualBrandSelectElements),b(s.selectedBrandValue),C.current.processBinLookupResponse({issuingCountryCode:d.issuingCountryCode,supportedBrands:[s.leadBrand]}),s.leadBrand.panLength>0&&(i.current=s.leadBrand.panLength)}else g([]),b(""),u||b(c[0].brand),C.current.processBinLookupResponse({issuingCountryCode:d.issuingCountryCode,supportedBrands:c}),c[0].panLength>0&&(i.current=c[0].panLength)}},handleDualBrandSelection:e=>{let n=e;if(e instanceof Event){const r=e.target;n=r.getAttribute("data-value")||r.getAttribute("value")}let r=[];n&&(r=B.reduce((e,r)=>(r.brandObject.brand===n&&e.push(r.brandObject),e),[]),r.length&&(b(n),C.current.processBinLookupResponse({issuingCountryCode:m,supportedBrands:r,isDualBrandSelection:!0})))}}}export{o as cloneBrandsArr,s as containsExcludedBrand,d as default,a as removeExcludedBrand};
2
2
  //# sourceMappingURL=extensions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n const switcherObj = createCardVariantSwitcher(supportedBrands);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (e: Event | string): void => {\n let value: Event | string = e;\n if (e instanceof Event) {\n const target = e.target as HTMLLIElement;\n value = target.getAttribute('data-value') || target.getAttribute('value');\n }\n\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (value) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === value) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(value);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr,\n isDualBrandSelection: true\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","e","value","Event","target","getAttribute","brandObjArr","brandObject","push","isDualBrandSelection"],"mappings":"iHAMO,MAAMA,EAAwB,CAACC,EAA0BC,IACrDD,EAAUE,OAAO,CAACC,EAAKC,IAAaD,GAAOF,EAAeI,SAASD,EAASE,QAAQ,GAGlFC,EAAkBP,GAA4CA,EAAUQ,IAAIC,IAAAA,IAAcA,KAE1FC,EAAsB,CAACV,EAA0BW,EAAa,KAAMC,EAAa,UAC1F,MAAMC,EAA8BN,EAAeP,GAInD,OAFIa,EAAa,GAAGP,QAAUK,GAAcE,EAAa,GAAGP,QAAUM,GAAYC,EAAaC,UAC/FD,EAAaE,OAAS,EACfF,GAII,SAASG,EAAWC,EAAOC,EAAMC,EAAQC,EAAwC,CAAA,GAE5F,MAAMC,KAAEA,EAAIC,UAAEA,GAAcL,GACtBM,IAAEA,GAAQL,GACVM,wBAAEA,EAAuBC,2BAAEA,EAA0BC,sBAAEA,EAAqBC,mBAAEA,EAAkBC,sBAAEA,GAA0BT,EAElI,MAAO,CAQHU,iBAAkB,CAACC,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YhD,QAAU2C,GAC3B9C,EAAIoD,KAAK9C,EAAK6C,aAEXnD,GACR,IAEEkD,EAAYtC,SAOrBW,EAAsBuB,GAGtB1B,EAAIc,QAAQC,yBAAyB,CACjCX,qBACAY,gBAAiBc,EACjBG,sBAAsB,OAItC"}
1
+ {"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\nimport { mustHandleDualBrandingAccordingToEURegulations } from '../../../Card/components/CardInput/utils';\nimport { DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM } from '../../../Card/Card';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n\n // Only if the brands in DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM are present in the binLookup response should we handle dual branding based on EU regulations\n const preselectBrand = mustHandleDualBrandingAccordingToEURegulations(\n DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM,\n supportedBrands,\n 'brand'\n );\n\n const switcherObj = createCardVariantSwitcher(supportedBrands, preselectBrand);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (e: Event | string): void => {\n let value: Event | string = e;\n if (e instanceof Event) {\n const target = e.target as HTMLLIElement;\n value = target.getAttribute('data-value') || target.getAttribute('value');\n }\n\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (value) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === value) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(value);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr,\n isDualBrandSelection: true\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","preselectBrand","mustHandleDualBrandingAccordingToEURegulations","DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","e","value","Event","target","getAttribute","brandObjArr","brandObject","push","isDualBrandSelection"],"mappings":"gTAQO,MAAMA,EAAwB,CAACC,EAA0BC,IACrDD,EAAUE,OAAO,CAACC,EAAKC,IAAaD,GAAOF,EAAeI,SAASD,EAASE,QAAQ,GAGlFC,EAAkBP,GAA4CA,EAAUQ,IAAIC,IAAAA,IAAcA,KAE1FC,EAAsB,CAACV,EAA0BW,EAAa,KAAMC,EAAa,UAC1F,MAAMC,EAA8BN,EAAeP,GAInD,OAFIa,EAAa,GAAGP,QAAUK,GAAcE,EAAa,GAAGP,QAAUM,GAAYC,EAAaC,UAC/FD,EAAaE,OAAS,EACfF,GAII,SAASG,EAAWC,EAAOC,EAAMC,EAAQC,EAAwC,CAAA,GAE5F,MAAMC,KAAEA,EAAIC,UAAEA,GAAcL,GACtBM,IAAEA,GAAQL,GACVM,wBAAEA,EAAuBC,2BAAEA,EAA0BC,sBAAEA,EAAqBC,mBAAEA,EAAkBC,sBAAEA,GAA0BT,EAElI,MAAO,CAQHU,iBAAkB,CAACC,EAAmBC,KAClC,MAAMC,EAAcF,GAAmBH,mBAAqBG,EAAkBH,mBAAmBM,cAAgB,KAIjH,GAHAL,EAAsBI,IAGjBF,IAAsBI,OAAOC,KAAKL,GAAmBf,OAAQ,CAC9DU,EAA2B,IAC3BC,EAAsB,IAItB,MAAMU,EAAeL,GAAoB,SAATV,EAAkBA,EAAO,KASzD,OAPAE,EAAIc,Q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t from"../Services/analytics/collect-id.js";import e from"./EventsQueue.js";import{ANALYTIC_LEVEL as l,ANALYTICS_EVENT as n,ANALYTICS_INFO_TIMER_INTERVAL as a,ANALYTICS_PATH as o}from"./constants.js";import{debounce as c}from"../../utils/debounce.js";import{processAnalyticsData as i}from"./utils.js";let s=null,r=null;const u=({locale:u,clientKey:y,analytics:d,amount:m,analyticsContext:p,bundleType:f})=>{const b={enabled:!0,checkoutAttemptId:null,analyticsData:{},...d},g=t({analyticsContext:p,clientKey:y,locale:u,analyticsPath:o,bundleType:f}),h=e({analyticsContext:p,clientKey:y,analyticsPath:o}),j=()=>s?h.run(s):Promise.resolve(null);return{setUp:async t=>{const{payload:e,enabled:n}=b,a=n?l.all:l.initial,o=i(b.analyticsData);if(!s)try{s=await g({...t,...e&&{...e},...Object.keys(o).length&&{...o},level:a})}catch(t){console.warn("Fetching checkoutAttemptId failed."+(t?` Error=${t}`:""))}},getCheckoutAttemptId:()=>s,getEventsQueue:()=>h,getEnabled:()=>b.enabled,sendAnalytics:t=>{if(!b.enabled)return!1;return((t,e)=>{const l=t===n.info?t:`${t}s`;h.add(`${l}`,e),t===n.info&&(clearTimeout(r),r=setTimeout(()=>{j()},a)),t!==n.log&&t!==n.error||(clearTimeout(r),c(j)())})(t.getEventCategory(),t),!0}}};export{u as default};
1
+ import t from"../Services/analytics/collect-id.js";import e from"./EventsQueue.js";import{ANALYTIC_LEVEL as n,ANALYTICS_EVENT as a,ANALYTICS_INFO_TIMER_INTERVAL as o,ANALYTICS_PATH as l}from"./constants.js";import{debounce as s}from"../../utils/debounce.js";import{processAnalyticsData as i}from"./utils.js";import c from"../../utils/Storage.js";let r=null,u=null;const m=({locale:m,clientKey:d,analytics:p,analyticsContext:y,bundleType:f})=>{const g={enabled:!0,...p},b=t({analyticsContext:y,clientKey:d,locale:m,analyticsPath:l,bundleType:f}),h=new c("checkout-attempt-id","sessionStorage"),j=e({analyticsContext:y,clientKey:d,analyticsPath:l}),v=()=>r?j.run(r):Promise.resolve(null);return{setUp:async t=>{try{const e={...{},...t},a=h.get(),o=function(t){if(!t?.timestamp)return!1;const e=Date.now()-9e5;return t.timestamp>e}(a),{payload:l,enabled:s}=g,c=s?n.all:n.initial,u=i(g.analyticsData),m=o?a.id:u?.checkoutAttemptId,d={...e,...l,...u,...m&&{checkoutAttemptId:m},level:c};r=await b(d),h.set({id:r,timestamp:o?a.timestamp:Date.now()})}catch(t){console.warn(t)}},getCheckoutAttemptId:()=>r,getEventsQueue:()=>j,getEnabled:()=>g.enabled,flush:()=>{v()},sendAnalytics:t=>{if(!g.enabled)return!1;return((t,e)=>{const n=t===a.info?t:`${t}s`;j.add(`${n}`,e),t===a.info&&(clearTimeout(u),u=setTimeout(()=>{v()},o)),t!==a.log&&t!==a.error||(clearTimeout(u),s(v)())})(t.getEventCategory(),t),!0}}};export{m as default};
2
2
  //# sourceMappingURL=Analytics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { AnalyticsEventCategory, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps } from './types';\nimport { ANALYTIC_LEVEL, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH, ANALYTICS_EVENT } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { processAnalyticsData } from './utils';\nimport { AnalyticsEvent } from './AnalyticsEvent';\n\nlet capturedCheckoutAttemptId = null;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n checkoutAttemptId: null,\n analyticsData: {}\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (eventCat: AnalyticsEventCategory, obj: AnalyticsObject) => {\n const arrayName = eventCat === ANALYTICS_EVENT.info ? eventCat : `${eventCat}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (eventCat === ANALYTICS_EVENT.info) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(() => void sendAnalyticsEvents(), ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (eventCat === ANALYTICS_EVENT.log || eventCat === ANALYTICS_EVENT.error) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n return {\n /**\n * Make \"setup\" call, to pass containerWidth, buildType, channel etc, and receive a checkoutAttemptId in return\n * @param initialEvent -\n */\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { payload, enabled } = props; // TODO what is payload, is it ever used?\n const level = enabled ? ANALYTIC_LEVEL.all : ANALYTIC_LEVEL.initial;\n const analyticsData = processAnalyticsData(props.analyticsData);\n if (!capturedCheckoutAttemptId) {\n try {\n capturedCheckoutAttemptId = await collectId({\n ...initialEvent,\n ...(payload && { ...payload }),\n ...(Object.keys(analyticsData).length && { ...analyticsData }),\n ...{ level }\n });\n } catch (e: any) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: (analyticsObj: AnalyticsEvent): boolean => {\n if (!props.enabled) return false;\n\n const eventCategory: AnalyticsEventCategory = analyticsObj.getEventCategory();\n\n addAnalyticsEvent(eventCategory, analyticsObj);\n\n return true;\n }\n } as AnalyticsModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","sendEventsTimerId","Analytics","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","enabled","checkoutAttemptId","analyticsData","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","setUp","async","initialEvent","payload","level","ANALYTIC_LEVEL","all","initial","processAnalyticsData","Object","keys","length","e","console","warn","getCheckoutAttemptId","getEventsQueue","getEnabled","sendAnalytics","analyticsObj","eventCat","obj","arrayName","ANALYTICS_EVENT","info","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","log","error","debounce","addAnalyticsEvent","getEventCategory"],"mappings":"oTASA,IAAIA,EAA4B,KAC5BC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzE,MAMMC,EAAQ,CALVC,SAAS,EACTC,kBAAmB,KACnBC,cAAe,CAAA,KAGiBP,GAE9BQ,EAAYC,EAAU,CAAEP,mBAAkBH,YAAWD,SAAgBY,cAAeC,EAAgBR,eACpGS,EAAiCC,EAAY,CAAEX,mBAAkBH,YAAWW,cAAeC,IAE3FG,EAAsB,IACpBnB,EACOiB,EAAYG,IAAIpB,GAEpBqB,QAAQC,QAAQ,MA8B3B,MAAO,CAKHC,MAAOC,MAAOC,IACV,MAAMC,QAAEA,EAAOhB,QAAEA,GAAYD,EACvBkB,EAAQjB,EAAUkB,EAAeC,IAAMD,EAAeE,QACtDlB,EAAgBmB,EAAqBtB,EAAMG,eACjD,IAAKZ,EACD,IACIA,QAAkCa,EAAU,IACrCY,KACCC,GAAW,IAAKA,MAChBM,OAAOC,KAAKrB,GAAesB,QAAU,IAAKtB,GACzCe,SAEb,CAAE,MAAOQ,GACLC,QAAQC,KAAK,sCAAqCF,EAAI,UAAUA,IAAM,IAC1E,GAIRG,qBAAsB,IAActC,EAGpCuC,eAAgB,IAAMtB,EAEtBuB,WAAY,IAAM/B,EAAMC,QAExB+B,cAAgBC,IACZ,IAAKjC,EAAMC,QAAS,OAAO,EAM3B,MAhEkB,EAACiC,EAAkCC,KACzD,MAAMC,EAAYF,IAAaG,EAAgBC,KAAOJ,EAAW,GAAGA,KACpE1B,EAAY+B,IAAI,GAAGH,IAAaD,GAO5BD,IAAaG,EAAgBC,OAC7BE,aAAahD,GACbA,EAAoBiD,WAAW,KAAW/B,KAAuBgC,IASjER,IAAaG,EAAgBM,KAAOT,IAAaG,EAAgBO,QACjEJ,aAAahD,GAEbqD,EAASnC,EAATmC,KAuCAC,CAF8Cb,EAAac,mBAE1Bd,IAE1B"}
1
+ {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { AnalyticsEventCategory, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps } from './types';\nimport { ANALYTIC_LEVEL, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH, ANALYTICS_EVENT } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { processAnalyticsData } from './utils';\nimport { AnalyticsEvent } from './AnalyticsEvent';\nimport Storage from '../../utils/Storage';\nimport { CheckoutAttemptIdSession } from '../Services/analytics/types';\n\nlet capturedCheckoutAttemptId: string | null = null;\nlet sendEventsTimerId = null;\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction isSessionCreatedUnderFifteenMinutes(session: CheckoutAttemptIdSession): boolean {\n const FIFTEEN_MINUTES_IN_MS = 15 * 60 * 1000;\n if (!session?.timestamp) return false;\n const fifteenMinutesAgo = Date.now() - FIFTEEN_MINUTES_IN_MS;\n return session.timestamp > fifteenMinutesAgo;\n}\n\nconst Analytics = ({ locale, clientKey, analytics, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const collectId = CollectId({\n analyticsContext,\n clientKey,\n locale,\n analyticsPath: ANALYTICS_PATH,\n bundleType\n });\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (eventCat: AnalyticsEventCategory, obj: AnalyticsObject) => {\n const arrayName = eventCat === ANALYTICS_EVENT.info ? eventCat : `${eventCat}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (eventCat === ANALYTICS_EVENT.info) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(() => void sendAnalyticsEvents(), ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (eventCat === ANALYTICS_EVENT.log || eventCat === ANALYTICS_EVENT.error) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n return {\n setUp: async (setupProps?: AnalyticsInitialEvent): Promise<void> => {\n try {\n const defaultProps: Partial<AnalyticsInitialEvent> = {};\n const finalSetupProps = { ...defaultProps, ...setupProps };\n\n const checkoutAttemptIdSession = storage.get();\n const isSessionReusable = isSessionCreatedUnderFifteenMinutes(checkoutAttemptIdSession);\n\n const { payload, enabled } = props;\n const level = enabled ? ANALYTIC_LEVEL.all : ANALYTIC_LEVEL.initial;\n const analyticsData = processAnalyticsData(props.analyticsData);\n\n const availableCheckoutAttemptId: string | undefined = isSessionReusable\n ? checkoutAttemptIdSession.id\n : analyticsData?.checkoutAttemptId;\n\n const collectIdPayload = {\n ...finalSetupProps,\n ...payload,\n ...analyticsData,\n ...(availableCheckoutAttemptId && { checkoutAttemptId: availableCheckoutAttemptId }),\n level\n };\n\n capturedCheckoutAttemptId = await collectId(collectIdPayload);\n\n storage.set({\n id: capturedCheckoutAttemptId,\n timestamp: isSessionReusable ? checkoutAttemptIdSession.timestamp : Date.now()\n });\n } catch (error: unknown) {\n console.warn(error);\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n getEnabled: () => props.enabled,\n\n flush: () => {\n void sendAnalyticsEvents();\n },\n\n sendAnalytics: (analyticsObj: AnalyticsEvent): boolean => {\n if (!props.enabled) return false;\n\n const eventCategory: AnalyticsEventCategory = analyticsObj.getEventCategory();\n\n addAnalyticsEvent(eventCategory, analyticsObj);\n\n return true;\n }\n } as AnalyticsModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","sendEventsTimerId","Analytics","locale","clientKey","analytics","analyticsContext","bundleType","props","enabled","collectId","CollectId","analyticsPath","ANALYTICS_PATH","storage","Storage","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","setUp","async","setupProps","finalSetupProps","checkoutAttemptIdSession","get","isSessionReusable","session","timestamp","fifteenMinutesAgo","Date","now","isSessionCreatedUnderFifteenMinutes","payload","level","ANALYTIC_LEVEL","all","initial","analyticsData","processAnalyticsData","availableCheckoutAttemptId","id","checkoutAttemptId","collectIdPayload","set","error","console","warn","getCheckoutAttemptId","getEventsQueue","getEnabled","flush","sendAnalytics","analyticsObj","eventCat","obj","arrayName","ANALYTICS_EVENT","info","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","log","debounce","addAnalyticsEvent","getEventCategory"],"mappings":"0VAWA,IAAIA,EAA2C,KAC3CC,EAAoB,KAaxB,MAAMC,EAAY,EAAGC,SAAQC,YAAWC,YAAWC,mBAAkBC,iBACjE,MAIMC,EAAQ,CAHVC,SAAS,KAGuBJ,GAE9BK,EAAYC,EAAU,CACxBL,mBACAF,YACAD,SACAS,cAAeC,EACfN,eAGEO,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAAiCC,EAAY,CAAEX,mBAAkBF,YAAWQ,cAAeC,IAE3FK,EAAsB,IACpBlB,EACOgB,EAAYG,IAAInB,GAEpBoB,QAAQC,QAAQ,MA8B3B,MAAO,CACHC,MAAOC,MAAOC,IACV,IACI,MACMC,EAAkB,IAD6B,CAAA,KACPD,GAExCE,EAA2BZ,EAAQa,MACnCC,EAlEtB,SAA6CC,GAEzC,IAAKA,GAASC,UAAW,OAAO,EAChC,MAAMC,EAAoBC,KAAKC,MAFD,IAG9B,OAAOJ,EAAQC,UAAYC,CAC/B,CA6D0CG,CAAoCR,IAExDS,QAAEA,EAAO1B,QAAEA,GAAYD,EACvB4B,EAAQ3B,EAAU4B,EAAeC,IAAMD,EAAeE,QACtDC,EAAgBC,EAAqBjC,EAAMgC,eAE3CE,EAAiDd,EACjDF,EAAyBiB,GACzBH,GAAeI,kBAEfC,EAAmB,IAClBpB,KACAU,KACAK,KACCE,GAA8B,CAAEE,kBAAmBF,GACvDN,SAGJpC,QAAkCU,EAAUmC,GAE5C/B,EAAQgC,IAAI,CACRH,GAAI3C,EACJ8B,UAAWF,EAAoBF,EAAyBI,UAAYE,KAAKC,OAEjF,CAAE,MAAOc,GACLC,QAAQC,KAAKF,EACjB,GAGJG,qBAAsB,IAAclD,EAGpCmD,eAAgB,IAAMnC,EAEtBoC,WAAY,IAAM5C,EAAMC,QAExB4C,MAAO,KACEnC,KAGToC,cAAgBC,IACZ,IAAK/C,EAAMC,QAAS,OAAO,EAM3B,MAjFkB,EAAC+C,EAAkCC,KACzD,MAAMC,EAAYF,IAAaG,EAAgBC,KAAOJ,EAAW,GAAGA,KACpExC,EAAY6C,IAAI,GAAGH,IAAaD,GAO5BD,IAAaG,EAAgBC,OAC7BE,aAAa7D,GACbA,EAAoB8D,WAAW,KAAW7C,KAAuB8C,IASjER,IAAaG,EAAgBM,KAAOT,IAAaG,EAAgBZ,QACjEe,aAAa7D,GAEbiE,EAAShD,EAATgD,KAwDAC,CAF8CZ,EAAaa,mBAE1Bb,IAE1B"}
@@ -1,2 +1,2 @@
1
- import{errorCodeMapping as r,ALLOWED_ANALYTICS_DATA as t}from"./constants.js";import{digitsOnlyFormatter as s}from"../../utils/Formatters/formatters.js";import{ERROR_FIELD_REQUIRED as o,ERROR_INVALID_FORMAT_EXPECTS as e}from"../Errors/constants.js";const m=()=>Date.now(),n=(t,m)=>{if(t===o||t===e)return r[`${t}.${m}`]??t;let n=r[t]??t;return isNaN(Number(n))&&(n=s(n)),n},i=r=>Object.keys(r).reduce((s,o)=>(t.includes(o)&&(s[o]=r[o]),s),{});export{m as getUTCTimestamp,n as mapErrorCodesForAnalytics,i as processAnalyticsData};
1
+ import{errorCodeMapping as r,ALLOWED_ANALYTICS_DATA as t}from"./constants.js";import{digitsOnlyFormatter as s}from"../../utils/Formatters/formatters.js";import{ERROR_FIELD_REQUIRED as o,ERROR_INVALID_FORMAT_EXPECTS as e}from"../Errors/constants.js";const m=()=>Date.now(),n=(t,m)=>{if(t===o||t===e)return r[`${t}.${m}`]??t;let n=r[t]??t;return isNaN(Number(n))&&(n=s(n)),n},i=r=>r?Object.keys(r).reduce((s,o)=>(t.includes(o)&&(s[o]=r[o]),s),{}):{};export{m as getUTCTimestamp,n as mapErrorCodesForAnalytics,i as processAnalyticsData};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsData } from './types';\nimport { errorCodeMapping, ALLOWED_ANALYTICS_DATA } from './constants';\nimport { digitsOnlyFormatter } from '../../utils/Formatters/formatters';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../Errors/constants';\n\nexport const getUTCTimestamp = () => Date.now();\n\nexport const mapErrorCodesForAnalytics = (errorCode: string, target: string) => {\n // Some of the more generic error codes required combination with target to retrieve a specific code\n if (errorCode === ERROR_FIELD_REQUIRED || errorCode === ERROR_INVALID_FORMAT_EXPECTS) {\n return errorCodeMapping[`${errorCode}.${target}`] ?? errorCode;\n }\n\n let errCode = errorCodeMapping[errorCode] ?? errorCode;\n\n // If errCode isn't now a number - then we just need to remove any non-digits\n // since the correct error code is already contained within the string e.g. securedField related errors\n if (isNaN(Number(errCode))) {\n errCode = digitsOnlyFormatter(errCode);\n }\n\n return errCode;\n};\n\nexport const processAnalyticsData = (analyticsData: AnalyticsData): AnalyticsData => {\n return Object.keys(analyticsData).reduce((acc, prop) => {\n if (ALLOWED_ANALYTICS_DATA.includes(prop)) acc[prop] = analyticsData[prop];\n return acc;\n }, {});\n};\n"],"names":["getUTCTimestamp","Date","now","mapErrorCodesForAnalytics","errorCode","target","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","errorCodeMapping","errCode","isNaN","Number","digitsOnlyFormatter","processAnalyticsData","analyticsData","Object","keys","reduce","acc","prop","ALLOWED_ANALYTICS_DATA","includes"],"mappings":"yPAKO,MAAMA,EAAkB,IAAMC,KAAKC,MAE7BC,EAA4B,CAACC,EAAmBC,KAEzD,GAAID,IAAcE,GAAwBF,IAAcG,EACpD,OAAOC,EAAiB,GAAGJ,KAAaC,MAAaD,EAGzD,IAAIK,EAAUD,EAAiBJ,IAAcA,EAQ7C,OAJIM,MAAMC,OAAOF,MACbA,EAAUG,EAAoBH,IAG3BA,GAGEI,EAAwBC,GAC1BC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAAKC,KACvCC,EAAuBC,SAASF,KAAOD,EAAIC,GAAQL,EAAcK,IAC9DD,GACR,CAAA"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsData } from './types';\nimport { errorCodeMapping, ALLOWED_ANALYTICS_DATA } from './constants';\nimport { digitsOnlyFormatter } from '../../utils/Formatters/formatters';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../Errors/constants';\n\nexport const getUTCTimestamp = () => Date.now();\n\nexport const mapErrorCodesForAnalytics = (errorCode: string, target: string) => {\n // Some of the more generic error codes required combination with target to retrieve a specific code\n if (errorCode === ERROR_FIELD_REQUIRED || errorCode === ERROR_INVALID_FORMAT_EXPECTS) {\n return errorCodeMapping[`${errorCode}.${target}`] ?? errorCode;\n }\n\n let errCode = errorCodeMapping[errorCode] ?? errorCode;\n\n // If errCode isn't now a number - then we just need to remove any non-digits\n // since the correct error code is already contained within the string e.g. securedField related errors\n if (isNaN(Number(errCode))) {\n errCode = digitsOnlyFormatter(errCode);\n }\n\n return errCode;\n};\n\nexport const processAnalyticsData = (analyticsData?: AnalyticsData): AnalyticsData => {\n if (!analyticsData) return {};\n\n return Object.keys(analyticsData).reduce((acc, prop) => {\n if (ALLOWED_ANALYTICS_DATA.includes(prop)) acc[prop] = analyticsData[prop];\n return acc;\n }, {});\n};\n"],"names":["getUTCTimestamp","Date","now","mapErrorCodesForAnalytics","errorCode","target","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","errorCodeMapping","errCode","isNaN","Number","digitsOnlyFormatter","processAnalyticsData","analyticsData","Object","keys","reduce","acc","prop","ALLOWED_ANALYTICS_DATA","includes"],"mappings":"yPAKO,MAAMA,EAAkB,IAAMC,KAAKC,MAE7BC,EAA4B,CAACC,EAAmBC,KAEzD,GAAID,IAAcE,GAAwBF,IAAcG,EACpD,OAAOC,EAAiB,GAAGJ,KAAaC,MAAaD,EAGzD,IAAIK,EAAUD,EAAiBJ,IAAcA,EAQ7C,OAJIM,MAAMC,OAAOF,MACbA,EAAUG,EAAoBH,IAG3BA,GAGEI,EAAwBC,GAC5BA,EAEEC,OAAOC,KAAKF,GAAeG,OAAO,CAACC,EAAKC,KACvCC,EAAuBC,SAASF,KAAOD,EAAIC,GAAQL,EAAcK,IAC9DD,GACR,CAAA,GALwB,CAAA"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.20.0",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then(e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId}).catch(()=>Promise.reject(o)),l)}};export{o as FAILURE_MSG,n as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../Errors/AdyenCheckoutError.js";const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.',n=({analyticsContext:n,clientKey:o,locale:l,analyticsPath:a,bundleType:c})=>{let s=null;const i={errorLevel:"fatal",loadingContext:n,path:`${a}?clientKey=${o}`,errorMessage:r};return r=>{if(null!==s)return s;const n={version:"6.22.0",channel:"Web",platform:"Web",buildType:c,locale:l,referrer:window.location.href,screenWidth:window.screen.width,...r};return s=e(i,n).then(e=>{if(e?.checkoutAttemptId)return e.checkoutAttemptId;throw new t("NETWORK_ERROR","Analytics: Attempt ID request was successfully but no ID was returned")}),s}};export{r as FAILURE_MSG,n as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","catch"],"mappings":"+EAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,EAAiC,CAEnCC,QAAS,SAETC,QAAS,MACTC,SAAU,MACVC,UAAWX,EACXF,SACAc,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,SACxBZ,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKJ,EAAW,OAAOsB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,IAAKA,GAA0BE,GAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDxB,EAAU+B,EAAS9B,EAASK,GACvB0B,KAAKC,IACF,GAAIA,GAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,oBAIzBE,MAAM,IACIlB,QAAQC,OAAO1B,IAGvBO"}
1
+ {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { HttpOptions, httpPost } from '../http';\nimport type { CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\nimport AdyenCheckoutError from '../../Errors/AdyenCheckoutError';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let memoizedPromise: Promise<string> | null = null;\n\n const options: HttpOptions = {\n errorLevel: 'fatal' as const,\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`,\n errorMessage: FAILURE_MSG\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (memoizedPromise !== null) {\n return memoizedPromise;\n }\n\n const telemetryEvent: TelemetryEvent = {\n version: process.env.VERSION,\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n memoizedPromise = httpPost<{ checkoutAttemptId: string }>(options, telemetryEvent).then(conversion => {\n if (conversion?.checkoutAttemptId) {\n return conversion.checkoutAttemptId;\n }\n throw new AdyenCheckoutError('NETWORK_ERROR', 'Analytics: Attempt ID request was successfully but no ID was returned');\n });\n\n return memoizedPromise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","memoizedPromise","options","errorLevel","loadingContext","path","errorMessage","event","telemetryEvent","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","httpPost","then","conversion","checkoutAttemptId","AdyenCheckoutError"],"mappings":"wFAIO,MAAMA,EACT,uKAOEC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAA0C,KAE9C,MAAMC,EAAuB,CACzBC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,IACpCS,aAAcZ,GAGlB,OAAQa,IAEJ,GAAwB,OAApBN,EACA,OAAOA,EAGX,MAAMO,EAAiC,CACnCC,QAAS,SACTC,QAAS,MACTC,SAAU,MACVC,UAAWZ,EACXF,SACAe,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,SACxBZ,GAUP,OAPAN,EAAkBmB,EAAwClB,EAASM,GAAgBa,KAAKC,IACpF,GAAIA,GAAYC,kBACZ,OAAOD,EAAWC,kBAEtB,MAAM,IAAIC,EAAmB,gBAAiB,2EAG3CvB"}
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import v from"./Services/get-translations.js";import{defaultProps as A}from"./core.defaultProps.js";import{formatLocale as j,formatCustomTranslations as E}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";import{AnalyticsLogEvent as P}from"./Analytics/AnalyticsLogEvent.js";import M from"./Errors/CancelError.js";function T(t,o,s){return o in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}class x{static setBundleType(t){x.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then(t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this}).catch(t=>(this.options.onError&&this.options.onError(t),Promise.reject(t))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await v(this.cdnTranslationsUrl,x.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=j(this.options.locale),this.options.translations=E(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})})),this.session&&(o=this.session.submitDetails(t).catch(t=>(this.options.onError?.(t),Promise.reject(t)))),o?o.then(d).then(m).then(this.afterAdditionalDetails).then(t=>{u(t),this.options.onPaymentCompleted?.(t)}).catch(t=>{t instanceof M||(u(t),this.options.onPaymentFailed?.(t))}):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType,i=new P({type:g,subType:t.type,message:`${s} action was handled by the SDK`,component:s});this.modules.analytics.sendAnalytics(i);const n={...this.getCorePropsForComponent(),...o};return e(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return{...n(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:x.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}constructor(t){T(this,"session",void 0),T(this,"paymentMethodsResponse",void 0),T(this,"modules",void 0),T(this,"options",void 0),T(this,"analyticsContext",void 0),T(this,"loadingContext",void 0),T(this,"cdnImagesUrl",void 0),T(this,"cdnTranslationsUrl",void 0),T(this,"components",[]),T(this,"afterAdditionalDetails",t=>{if(this.options.afterAdditionalDetails&&t?.action){const o=this.createFromAction(t.action);return this.options.afterAdditionalDetails(o),Promise.reject(new M("Handled by afterAdditionalDetails"))}return Promise.resolve(t)}),T(this,"update",(t={})=>(this.setOptions(t),this.initialize().then(()=>(this.components.forEach(o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)}),this)))),T(this,"remove",t=>(this.components=this.components.filter(o=>o._id!==t._id),t.unmount(),this)),T(this,"setOptions",t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}}),a(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...A,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const n=this.options.clientKey?.substring(0,4);if(("test"===n||"live"===n)&&!this.loadingContext.includes(n))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${n} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===n&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=x.metadata)}}T(x,"metadata",{version:"6.20.0",bundleType:"esm"}),T(x,"registry",p);export{x as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import v from"./Services/get-translations.js";import{defaultProps as A}from"./core.defaultProps.js";import{formatLocale as j,formatCustomTranslations as E}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";import{AnalyticsLogEvent as P}from"./Analytics/AnalyticsLogEvent.js";import M from"./Errors/CancelError.js";function T(t,o,s){return o in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}class R{static setBundleType(t){R.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then(t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this}).catch(t=>(this.options.onError&&this.options.onError(t),Promise.reject(t))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await v(this.cdnTranslationsUrl,R.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=j(this.options.locale),this.options.translations=E(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})})),this.session&&(o=this.session.submitDetails(t).catch(t=>(this.options.onError?.(t),Promise.reject(t)))),o?o.then(d).then(m).then(this.afterAdditionalDetails).then(t=>{u(t),this.options.onPaymentCompleted?.(t)}).catch(t=>{t instanceof M||(u(t),this.options.onPaymentFailed?.(t))}):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType,i=new P({type:g,subType:t.type,message:`${s} action was handled by the SDK`,component:s});this.modules.analytics.sendAnalytics(i);const n={...this.getCorePropsForComponent(),...o};return e(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return{...n(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,bundleType:R.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}constructor(t){T(this,"session",void 0),T(this,"paymentMethodsResponse",void 0),T(this,"modules",void 0),T(this,"options",void 0),T(this,"analyticsContext",void 0),T(this,"loadingContext",void 0),T(this,"cdnImagesUrl",void 0),T(this,"cdnTranslationsUrl",void 0),T(this,"components",[]),T(this,"afterAdditionalDetails",t=>{if(this.options.afterAdditionalDetails&&t?.action){const o=this.createFromAction(t.action);return this.options.afterAdditionalDetails(o),Promise.reject(new M("Handled by afterAdditionalDetails"))}return Promise.resolve(t)}),T(this,"update",(t={})=>(this.setOptions(t),this.initialize().then(()=>(this.components.forEach(o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)}),this)))),T(this,"remove",t=>(this.components=this.components.filter(o=>o._id!==t._id),t.unmount(),this)),T(this,"setOptions",t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}}),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...A,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const n=this.options.clientKey?.substring(0,4);if(("test"===n||"live"===n)&&!this.loadingContext.includes(n))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${n} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===n&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=R.metadata)}}T(R,"metadata",{version:"6.22.0",bundleType:"esm"}),T(R,"registry",p);export{R as default};
2
2
  //# sourceMappingURL=core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { DEFAULT_LOCALE } from '../language/constants';\nimport getTranslations from './Services/get-translations';\nimport { defaultProps } from './core.defaultProps';\nimport { formatCustomTranslations, formatLocale } from '../language/utils';\nimport { resolveEnvironments } from './Environment';\n\nimport type { AnalyticsModule, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from './types';\nimport type { Translations } from '../language/types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\nimport { AnalyticsLogEvent } from './Analytics/AnalyticsLogEvent';\nimport CancelError from './Errors/CancelError';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: Readonly<{\n risk: RiskModule;\n analytics: AnalyticsModule;\n resources: Resources;\n i18n: Language;\n srPanel: SRPanel;\n }>;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata = {\n version: process.env.VERSION,\n bundleType: process.env.BUNDLE_TYPE\n };\n\n public static registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `The value you are passing as your \"clientKey\" looks like an originKey (${this.options.clientKey?.substring(0, 12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n await this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private async fetchLocaleTranslations(): Promise<Translations> {\n try {\n return await getTranslations(this.cdnTranslationsUrl, Core.metadata.version, this.options.locale);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.options.onError?.(error);\n else this.options.onError?.(new AdyenCheckoutError('ERROR', 'Failed to fetch translation', { cause: error }));\n }\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n this.options.locale = formatLocale(this.options.locale);\n this.options.translations = formatCustomTranslations(this.options.translations);\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.afterAdditionalDetails)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n return;\n }\n\n cleanupFinalResult(e as PaymentResponseData);\n this.options.onPaymentFailed?.(e as PaymentResponseData);\n });\n }\n\n private readonly afterAdditionalDetails = (response: PaymentResponseData): Promise<PaymentResponseData | Error> => {\n /**\n * After the user is redirected back, a request to `/details` or `/paymentDetails` will be made.\n * Typically, the response will not include an action object, except for the case of `paybybank_pix` payment method.\n * In terms of `paybybank_pix`, the action UIElement will be created and passed to the `afterAdditionalDetails` callback, allowing it to be mounted on the page.\n */\n if (this.options.afterAdditionalDetails && response?.action) {\n const actionEle = this.createFromAction(response.action);\n this.options.afterAdditionalDetails(actionEle);\n return Promise.reject(new CancelError('Handled by afterAdditionalDetails'));\n }\n return Promise.resolve(response);\n };\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n const event = new AnalyticsLogEvent({\n type: ANALYTICS_ACTION_STR,\n subType: action.type,\n message: `${component} action was handled by the SDK`,\n component\n });\n this.modules.analytics.sendAnalytics(event);\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...options,\n ...(this.session && { session: this.session })\n };\n component.update(newProps);\n });\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private async createCoreModules(): Promise<void> {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n const translations = await this.fetchLocaleTranslations();\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n loadingContext: this.loadingContext,\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n amount: this.options.amount,\n bundleType: Core.metadata.bundleType\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n translations,\n customTranslations: this.options.translations\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","fetchLocaleTranslations","getTranslations","cdnTranslationsUrl","version","AdyenCheckoutError","cause","paymentMethodsConfiguration","console","warn","IMPLEMENTATION_ERROR","DEFAULT_LOCALE","formatLocale","translations","formatCustomTranslations","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","afterAdditionalDetails","response","cleanupFinalResult","onPaymentCompleted","e","CancelError","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","event","AnalyticsLogEvent","ANALYTICS_ACTION_STR","subType","message","modules","analytics","sendAnalytics","props","getCorePropsForComponent","getComponentForAction","handleCreateError","processGlobalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","storeElementReference","element","components","push","paymentMethod","errorMessage","name","JSON","stringify","paymentMethodsResponse","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","analyticsContext","clientKey","resources","Resources","Language","customTranslations","srPanel","SRPanel","srConfig","constructor","_define_property","actionEle","update","forEach","newProps","remove","filter","c","_id","unmount","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","environment","_environmentUrls","Session","clientKeyType","substring","includes","api","debug","exposeLibraryMetadata","window"],"mappings":"s9CA6BA,MAAMA,EA0BF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,EACpB,CAEOG,YAAAA,CAAaC,GAChB,OAAOH,EAASE,aAAaC,EACjC,CAuCA,gBAAaC,GAIT,aAHMC,KAAKC,iBACXD,KAAKE,kCACCF,KAAKG,oBACJH,IACX,CAEA,oBAAcC,GACV,OAA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M,QAAQ2F,WAAW6B,UAAU,EAAG,GAC3D,IAAuB,SAAlBD,GAA8C,SAAlBA,KAA8B7H,KAAK6E,eAAekD,SAASF,GACxF,MAAM,IAAIhG,EACN,uBACA,0BAA0BgG,2BAAuC7H,KAAKM,QAAQqH,kBAAkBK,KAAOhI,KAAKM,QAAQoH,2BAGtG,SAAlBG,GACA7F,QAAQiG,MACJ,0EAA0EjI,KAAKM,QAAQ2F,WAAW6B,UAAU,EAAG,oQAInH9H,KAAKM,QAAQ4H,wBACbC,OAAO,iBAAsB/I,EAAKG,SAE1C,EA9DAmH,EAnBEtH,EAmBqBG,WAAW,CAC9BqC,QAAS,SACTpC,WAAY,QAGhBkH,EAxBEtH,EAwBYO,WAAWA"}
1
+ {"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { DEFAULT_LOCALE } from '../language/constants';\nimport getTranslations from './Services/get-translations';\nimport { defaultProps } from './core.defaultProps';\nimport { formatCustomTranslations, formatLocale } from '../language/utils';\nimport { resolveEnvironments } from './Environment';\n\nimport type { AnalyticsModule, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from './types';\nimport type { Translations } from '../language/types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\nimport { AnalyticsLogEvent } from './Analytics/AnalyticsLogEvent';\nimport CancelError from './Errors/CancelError';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: Readonly<{\n risk: RiskModule;\n analytics: AnalyticsModule;\n resources: Resources;\n i18n: Language;\n srPanel: SRPanel;\n }>;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata = {\n version: process.env.VERSION,\n bundleType: process.env.BUNDLE_TYPE\n };\n\n public static registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `The value you are passing as your \"clientKey\" looks like an originKey (${this.options.clientKey?.substring(0, 12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n await this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private async fetchLocaleTranslations(): Promise<Translations> {\n try {\n return await getTranslations(this.cdnTranslationsUrl, Core.metadata.version, this.options.locale);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.options.onError?.(error);\n else this.options.onError?.(new AdyenCheckoutError('ERROR', 'Failed to fetch translation', { cause: error }));\n }\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n this.options.locale = formatLocale(this.options.locale);\n this.options.translations = formatCustomTranslations(this.options.translations);\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.afterAdditionalDetails)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n return;\n }\n\n cleanupFinalResult(e as PaymentResponseData);\n this.options.onPaymentFailed?.(e as PaymentResponseData);\n });\n }\n\n private readonly afterAdditionalDetails = (response: PaymentResponseData): Promise<PaymentResponseData | Error> => {\n /**\n * After the user is redirected back, a request to `/details` or `/paymentDetails` will be made.\n * Typically, the response will not include an action object, except for the case of `paybybank_pix` payment method.\n * In terms of `paybybank_pix`, the action UIElement will be created and passed to the `afterAdditionalDetails` callback, allowing it to be mounted on the page.\n */\n if (this.options.afterAdditionalDetails && response?.action) {\n const actionEle = this.createFromAction(response.action);\n this.options.afterAdditionalDetails(actionEle);\n return Promise.reject(new CancelError('Handled by afterAdditionalDetails'));\n }\n return Promise.resolve(response);\n };\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n const event = new AnalyticsLogEvent({\n type: ANALYTICS_ACTION_STR,\n subType: action.type,\n message: `${component} action was handled by the SDK`,\n component\n });\n this.modules.analytics.sendAnalytics(event);\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...options,\n ...(this.session && { session: this.session })\n };\n component.update(newProps);\n });\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private async createCoreModules(): Promise<void> {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n const translations = await this.fetchLocaleTranslations();\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n bundleType: Core.metadata.bundleType\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n translations,\n customTranslations: this.options.translations\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","fetchLocaleTranslations","getTranslations","cdnTranslationsUrl","version","AdyenCheckoutError","cause","paymentMethodsConfiguration","console","warn","IMPLEMENTATION_ERROR","DEFAULT_LOCALE","formatLocale","translations","formatCustomTranslations","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","afterAdditionalDetails","response","cleanupFinalResult","onPaymentCompleted","e","CancelError","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","event","AnalyticsLogEvent","ANALYTICS_ACTION_STR","subType","message","modules","analytics","sendAnalytics","props","getCorePropsForComponent","getComponentForAction","handleCreateError","processGlobalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","storeElementReference","element","components","push","paymentMethod","errorMessage","name","JSON","stringify","paymentMethodsResponse","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","analyticsContext","clientKey","resources","Resources","Language","customTranslations","srPanel","SRPanel","srConfig","constructor","_define_property","actionEle","update","forEach","newProps","remove","filter","c","_id","unmount","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","environment","_environmentUrls","Session","clientKeyType","substring","includes","api","debug","exposeLibraryMetadata","window"],"mappings":"s9CA6BA,MAAMA,EA0BF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,EACpB,CAEOG,YAAAA,CAAaC,GAChB,OAAOH,EAASE,aAAaC,EACjC,CAuCA,gBAAaC,GAIT,aAHMC,KAAKC,iBACXD,KAAKE,kCACCF,KAAKG,oBACJH,IACX,CAEA,oBAAcC,GACV,OAAID,KAAKI,QACEJ,KAAKI,QACPC,aAAaL,KAAKM,SAClBC,KAAKC,IACF,MAAMC,OAAEA,EAAMC,cAAEA,EAAaC,YAAEA,EAAWC,eAAEA,KAAmBC,GAASL,EAWxE,OATAR,KAAKc,WAAW,IACTD,EACHJ,OAAQT,KAAKM,QAA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jI,KAAKM,QAAQ2F,WAAW6B,UAAU,EAAG,oQAInH9H,KAAKM,QAAQ4H,wBACbC,OAAO,iBAAsB/I,EAAKG,SAE1C,EA9DAmH,EAnBEtH,EAmBqBG,WAAW,CAC9BqC,QAAS,SACTpC,WAAY,QAGhBkH,EAxBEtH,EAwBYO,WAAWA"}
@@ -36,7 +36,7 @@ type OnAddressLookupType = (value: string, actions: {
36
36
  resolve: (value: Array<AddressLookupItem>) => void;
37
37
  reject: (reason?: any) => void;
38
38
  }) => Promise<void>;
39
- type OnAddressSelectedType = (value: string, actions: {
39
+ type OnAddressSelectedType = (value: AddressLookupItem, actions: {
40
40
  resolve: (value: AddressLookupItem) => void;
41
41
  reject: (reason?: any) => void;
42
42
  }) => Promise<void>;
@@ -681,7 +681,7 @@ interface PayButtonProps extends ButtonProps {
681
681
  */
682
682
  classNameModifiers?: string[];
683
683
  label?: string;
684
- amount: PaymentAmountExtended;
684
+ amount?: PaymentAmountExtended;
685
685
  secondaryAmount?: PaymentAmountExtended;
686
686
  status?: string;
687
687
  disabled?: boolean;
@@ -2143,7 +2143,20 @@ declare class BillDeskWalletElement extends IssuerListContainer {
2143
2143
  formatProps(props: any): any;
2144
2144
  }
2145
2145
 
2146
+ type AchForm = {
2147
+ selectedAccountType: string;
2148
+ ownerName: string;
2149
+ routingNumber: string;
2150
+ accountNumber: string;
2151
+ accountNumberVerification: string;
2152
+ };
2153
+ type AchFormPrefillData = Partial<Pick<AchForm, 'ownerName'>>;
2154
+
2146
2155
  interface AchConfiguration extends UIElementProps {
2156
+ /**
2157
+ * Pre-fill ACH form with shopper data
2158
+ */
2159
+ data?: AchFormPrefillData;
2147
2160
  /**
2148
2161
  * Adds placeholder text to the input fields
2149
2162
  */
@@ -3488,6 +3501,12 @@ interface SegmentedControlOption<T> {
3488
3501
  htmlProps?: {};
3489
3502
  }
3490
3503
 
3504
+ type Mandate = {
3505
+ amount: string;
3506
+ frequency: 'monthly' | 'weekly' | 'adhoc';
3507
+ amountRule: 'max' | 'exact';
3508
+ };
3509
+
3491
3510
  type UpiType = TxVariants.upi_qr | TxVariants.upi_intent | TxVariants.upi_collect;
3492
3511
  type UpiMode = 'vpa' | 'qrCode' | 'intent';
3493
3512
  type App = {
@@ -3504,6 +3523,7 @@ type UpiPaymentData = {
3504
3523
  };
3505
3524
  interface UPIConfiguration extends UIElementProps {
3506
3525
  defaultMode?: UpiMode;
3526
+ mandate?: Mandate;
3507
3527
  apps?: Array<App>;
3508
3528
  /**
3509
3529
  * Redirect url for upi intent apps
@@ -3517,6 +3537,10 @@ interface UPIConfiguration extends UIElementProps {
3517
3537
  paymentData?: string;
3518
3538
  qrCodeData?: string;
3519
3539
  brandLogo?: string;
3540
+ /**
3541
+ * The duration in minutes before the await/QR code expires.
3542
+ */
3543
+ countdownTime?: number;
3520
3544
  }
3521
3545
 
3522
3546
  declare enum PayToIdentifierEnum {
@@ -5253,13 +5277,11 @@ interface IssuerListProps extends BaseEnrollmentProps {
5253
5277
  interface PaymentProps extends IPayByBankPixAwait {
5254
5278
  enrollmentId?: string;
5255
5279
  initiationId?: string;
5256
- receiver: string;
5257
5280
  amount: {
5258
5281
  value: number;
5259
5282
  currency: string;
5260
5283
  };
5261
5284
  txVariant: string;
5262
- issuer: string;
5263
5285
  onPay: () => void;
5264
5286
  onAuthorize: (authorizationOptions: string) => void;
5265
5287
  setComponentRef?: (ref: any) => void;
@@ -5778,11 +5800,12 @@ interface AnalyticsOptions {
5778
5800
  analyticsData?: AnalyticsData;
5779
5801
  }
5780
5802
  type AnalyticsInitialEvent = {
5781
- containerWidth: number;
5782
- component: string;
5783
- flavor: string;
5803
+ containerWidth?: number;
5804
+ component?: string;
5805
+ flavor?: string;
5784
5806
  paymentMethods?: any[];
5785
5807
  sessionId?: string;
5808
+ checkoutStage?: 'precheckout' | 'checkout';
5786
5809
  };
5787
5810
  interface AnalyticsObject {
5788
5811
  timestamp: string;
@@ -6175,7 +6198,7 @@ declare abstract class UIElement<P extends UIElementProps = UIElementProps> exte
6175
6198
  */
6176
6199
  setStatus(status: UIElementStatus, props?: any): this;
6177
6200
  protected onChange(): void;
6178
- protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent): Promise<any>;
6201
+ protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent): Promise<void>;
6179
6202
  /**
6180
6203
  * A function for all UIElements, or BaseElement, to use to create an analytics action for when it's been:
6181
6204
  * - mounted,
@@ -6593,7 +6616,8 @@ interface ActionHandledReturnObject {
6593
6616
  originalAction?: PaymentAction;
6594
6617
  }
6595
6618
  interface AnalyticsModule {
6596
- setUp: (a: AnalyticsInitialEvent) => Promise<any>;
6619
+ setUp: (setupProps?: AnalyticsInitialEvent) => Promise<void>;
6620
+ flush(): void;
6597
6621
  getCheckoutAttemptId: () => string;
6598
6622
  getEventsQueue: () => EventsQueueModule;
6599
6623
  getEnabled: () => boolean;