@adyen/adyen-web 6.24.0 → 6.25.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 (76) hide show
  1. package/dist/cjs/adyen.css +13 -12
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +215 -4
  6. package/dist/es/adyen.css +13 -12
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/ANCV.js +1 -1
  9. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  10. package/dist/es/components/Blik/Blik.js +1 -1
  11. package/dist/es/components/Blik/Blik.js.map +1 -1
  12. package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  13. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  14. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  15. package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
  16. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  17. package/dist/es/components/MBWay/MBWay.js +1 -1
  18. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  19. package/dist/es/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js.map +1 -1
  20. package/dist/es/components/PayTo/PayTo.js +1 -1
  21. package/dist/es/components/PayTo/PayTo.js.map +1 -1
  22. package/dist/es/components/Pix/Pix.js +1 -1
  23. package/dist/es/components/Pix/Pix.js.map +1 -1
  24. package/dist/es/components/PreAuthorizedDebitCanada/components/SettlementInfo.js +1 -1
  25. package/dist/es/components/PreAuthorizedDebitCanada/components/SettlementInfo.js.map +1 -1
  26. package/dist/es/components/UPI/UPI.js +1 -1
  27. package/dist/es/components/UPI/UPI.js.map +1 -1
  28. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  29. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  30. package/dist/es/components/internal/Await/Await.js +1 -1
  31. package/dist/es/components/internal/Await/Await.js.map +1 -1
  32. package/dist/es/components/internal/Button/Button.js.map +1 -1
  33. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  34. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  35. package/dist/es/components/internal/QRLoader/components/QRCountdown.js +1 -1
  36. package/dist/es/components/internal/QRLoader/components/QRCountdown.js.map +1 -1
  37. package/dist/es/components/internal/QRLoader/components/QRFinalState.js +2 -0
  38. package/dist/es/components/internal/QRLoader/components/QRFinalState.js.map +1 -0
  39. package/dist/es/core/config.js +1 -1
  40. package/dist/es/index.d.ts +215 -4
  41. package/dist/es-legacy/adyen.css +13 -12
  42. package/dist/es-legacy/adyen.css.map +1 -1
  43. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  44. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  45. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  46. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  47. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  48. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  49. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  50. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  51. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  52. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  53. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  54. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js.map +1 -1
  55. package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
  56. package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
  57. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  58. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  59. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/SettlementInfo.js +1 -1
  60. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/SettlementInfo.js.map +1 -1
  61. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  62. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  63. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  64. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  65. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  66. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  67. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  68. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  69. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  70. package/dist/es-legacy/components/internal/QRLoader/components/QRCountdown.js +1 -1
  71. package/dist/es-legacy/components/internal/QRLoader/components/QRCountdown.js.map +1 -1
  72. package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js +2 -0
  73. package/dist/es-legacy/components/internal/QRLoader/components/QRFinalState.js.map +1 -0
  74. package/dist/es-legacy/core/config.js +1 -1
  75. package/package.json +3 -3
  76. package/styles/adyen.css +13 -12
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\nimport { getIntentOption, getQrOption, getVpaOption } from './constants';\n\n/**\n * For mobile:\n * We should show upi_collect and upi_intent depending on if `apps` are returned in /paymentMethods response.\n * If there is no apps, hide segmented controls.\n * The upi_collect should always be on the second tab.\n * Never show QR code.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration): UPIConfiguration {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: ['qrCode', 'vpa'].includes(props?.defaultMode) ? props.defaultMode : 'qrCode',\n apps: [], // For desktop, ignore the apps\n segmentedControlOptions: [getQrOption(props.i18n), getVpaOption(props.i18n)]\n };\n }\n\n const { i18n, apps = [] } = props;\n const hasIntentApps = apps.length > 0;\n if (hasIntentApps) {\n // Mobile with UPI apps\n const allowedModes: UpiMode[] = ['intent', 'vpa'];\n const defaultMode = allowedModes.includes(props.defaultMode) ? props.defaultMode : 'intent';\n return {\n ...super.formatProps(props),\n defaultMode,\n apps,\n segmentedControlOptions: [getIntentOption(i18n), getVpaOption(i18n)]\n };\n }\n\n // Mobile, but no UPI apps\n return {\n ...super.formatProps(props),\n defaultMode: 'vpa', // Only VPA is possible\n apps: [],\n segmentedControlOptions: []\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return TxVariants.upi_intent;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={this.props.countdownTime ?? 5}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime ?? 5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n amount={this.props.amount}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n segmentedControlOptions={this.props.segmentedControlOptions}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n amount={this.props.amount}\n mandate={this.props.mandate}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","includes","apps","segmentedControlOptions","getQrOption","i18n","getVpaOption","length","getIntentOption","isValid","this","state","formatData","virtualPaymentAddress","app","data","paymentMethod","type","paymentType","TxVariants","upi_collect","upi_intent","id","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","isAutoPay","mandate","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","get","countdownTime","onActionHandled","showAmount","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","amount","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"05BAyBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAa,CAAC,SAAU,OAAOC,SAASJ,GAAOG,aAAeH,EAAMG,YAAc,SAClFE,KAAM,GACNC,wBAAyB,CAACC,EAAYP,EAAMQ,MAAOC,EAAaT,EAAMQ,QAI9E,MAAMA,KAAEA,EAAIH,KAAEA,EAAO,IAAOL,EAE5B,GADsBK,EAAKK,OAAS,EACjB,CAEf,MACMP,EAD0B,CAAC,SAAU,OACVC,SAASJ,EAAMG,aAAeH,EAAMG,YAAc,SACnF,MAAO,IACAD,MAAMH,YAAYC,GACrBG,cACAE,OACAC,wBAAyB,CAACK,EAAgBH,GAAOC,EAAaD,IAEtE,CAGA,MAAO,IACAN,MAAMH,YAAYC,GACrBG,YAAa,MACbE,KAAM,GACNC,wBAAyB,GAEjC,CAEA,WAAWM,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,sBAAEA,EAAqBC,IAAEA,GAAQJ,KAAKC,MAAMI,MAAQ,CAA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b,MAAMwD,SAG/B,QACI,OACItB,EAACuB,EAAAA,CACGrB,IAAMA,IACFvB,KAAKwB,aAAeD,GAExBsB,UAAW7C,KAAK6C,UAChBC,SAAU9C,KAAK+C,SACfC,aAAchD,KAAKgD,aACnBxD,KAAMQ,KAAKb,MAAMK,KACjBC,wBAAyBO,KAAKb,MAAMM,wBACpCH,YAAaU,KAAKb,MAAMG,YACxB2D,cAAejD,KAAKb,MAAM8D,cAC1BN,OAAQ3C,KAAKb,MAAMwD,OACnBvB,QAASpB,KAAKb,MAAMiC,UAIxC,CAEO8B,MAAAA,GACH,MAAM3C,KAAEA,EAAIU,IAAEA,EAAGC,kBAAEA,GAAsBlB,KAAKb,MAC9C,OACIkC,EAAC8B,EAAAA,CAAaxD,KAAMK,KAAKb,MAAMQ,KAAMyD,eAAgBpD,KAAKb,MAAMiE,eAAgBC,UAAWrD,KAAKqD,WAC5FhC,EAACiC,EAAAA,CAAgBC,QAASvD,KAAKb,MAAMqE,QAAQD,SAAUvD,KAAKgB,cAAcT,EAAMU,EAAKC,IAGjG,CA3IA,WAAAuC,CAAYC,EAAiBvE,GACzBE,MAAMqE,EAAUvE,GAHpBwE,EAAA3D,KAAQc,oBAAR,GAkEA6C,EAAA3D,KAAQgD,eAAgBY,IACpB5D,KAAKc,aAAe8C,IA/DpB5D,KAAKc,aAAed,KAAKb,MAAMG,WACnC,EARAqE,EADE3E,EACYuB,OAAOE,EAAWoD,KAChCF,EAFE3E,EAEY8E,aAAa,CAACrD,EAAWoD,IAAKpD,EAAWM,OAAQN,EAAWC,YAAaD,EAAWE"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\nimport { getIntentOption, getQrOption, getVpaOption } from './constants';\n\n/**\n * For mobile:\n * We should show upi_collect and upi_intent depending on if `apps` are returned in /paymentMethods response.\n * If there is no apps, hide segmented controls.\n * The upi_collect should always be on the second tab.\n * Never show QR code.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration): UPIConfiguration {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: ['qrCode', 'vpa'].includes(props?.defaultMode) ? props.defaultMode : 'qrCode',\n apps: [], // For desktop, ignore the apps\n segmentedControlOptions: [getQrOption(props.i18n), getVpaOption(props.i18n)]\n };\n }\n\n const { i18n, apps = [] } = props;\n const hasIntentApps = apps.length > 0;\n if (hasIntentApps) {\n // Mobile with UPI apps\n const allowedModes: UpiMode[] = ['intent', 'vpa'];\n const defaultMode = allowedModes.includes(props.defaultMode) ? props.defaultMode : 'intent';\n return {\n ...super.formatProps(props),\n defaultMode,\n apps,\n segmentedControlOptions: [getIntentOption(i18n), getVpaOption(i18n)]\n };\n }\n\n // Mobile, but no UPI apps\n return {\n ...super.formatProps(props),\n defaultMode: 'vpa', // Only VPA is possible\n apps: [],\n segmentedControlOptions: []\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return TxVariants.upi_intent;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={this.props.countdownTime ?? 5}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime ?? 5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n amount={this.props.amount}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n segmentedControlOptions={this.props.segmentedControlOptions}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n amount={this.props.amount}\n mandate={this.props.mandate}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","includes","apps","segmentedControlOptions","getQrOption","i18n","getVpaOption","length","getIntentOption","isValid","this","state","formatData","virtualPaymentAddress","app","data","paymentMethod","type","paymentType","TxVariants","upi_collect","upi_intent","id","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","isAutoPay","mandate","h","QRLoader","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","get","countdownTime","onActionHandled","showAmount","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","amount","UPIComponent","ref","componentRef","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"05BAyBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAa,CAAC,SAAU,OAAOC,SAASJ,GAAOG,aAAeH,EAAMG,YAAc,SAClFE,KAAM,GACNC,wBAAyB,CAACC,EAAYP,EAAMQ,MAAOC,EAAaT,EAAMQ,QAI9E,MAAMA,KAAEA,EAAIH,KAAEA,EAAO,IAAOL,EAE5B,GADsBK,EAAKK,OAAS,EACjB,CAEf,MACMP,EAD0B,CAAC,SAAU,OACVC,SAASJ,EAAMG,aAAeH,EAAMG,YAAc,SACnF,MAAO,IACAD,MAAMH,YAAYC,GACrBG,cACAE,OACAC,wBAAyB,CAACK,EAAgBH,GAAOC,EAAaD,IAEtE,CAGA,MAAO,IACAN,MAAMH,YAAYC,GACrBG,YAAa,MACbE,KAAM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AI,6BAC/BF,WAAY3B,KAAK2B,WACjBF,UAAWzB,KAAK0B,KAChBe,OAAQzC,KAAKb,MAAMsD,SAG/B,QACI,OACIpB,EAACqB,EAAAA,CACGC,IAAMA,IACF3C,KAAK4C,aAAeD,GAExBE,UAAW7C,KAAK6C,UAChBC,SAAU9C,KAAK+C,SACfC,aAAchD,KAAKgD,aACnBxD,KAAMQ,KAAKb,MAAMK,KACjBC,wBAAyBO,KAAKb,MAAMM,wBACpCH,YAAaU,KAAKb,MAAMG,YACxB2D,cAAejD,KAAKb,MAAM8D,cAC1BR,OAAQzC,KAAKb,MAAMsD,OACnBrB,QAASpB,KAAKb,MAAMiC,UAIxC,CAEO8B,MAAAA,GACH,MAAM3C,KAAEA,EAAIU,IAAEA,EAAGC,kBAAEA,GAAsBlB,KAAKb,MAC9C,OACIkC,EAAC8B,EAAAA,CAAaxD,KAAMK,KAAKb,MAAMQ,KAAMyD,eAAgBpD,KAAKb,MAAMiE,eAAgBC,UAAWrD,KAAKqD,WAC5FhC,EAACiC,EAAAA,CAAgBC,QAASvD,KAAKb,MAAMqE,QAAQD,SAAUvD,KAAKgB,cAAcT,EAAMU,EAAKC,IAGjG,CArIA,WAAAuC,CAAYC,EAAiBvE,GACzBE,MAAMqE,EAAUvE,GAHpBwE,EAAA3D,KAAQc,oBAAR,GAkEA6C,EAAA3D,KAAQgD,eAAgBY,IACpB5D,KAAKc,aAAe8C,IA/DpB5D,KAAKc,aAAed,KAAKb,MAAMG,WACnC,EARAqE,EADE3E,EACYuB,OAAOE,EAAWoD,KAChCF,EAFE3E,EAEY8E,aAAa,CAACrD,EAAWoD,IAAKpD,EAAWM,OAAQN,EAAWC,YAAaD,EAAWE"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import{CoreProvider as o}from"../../../core/Context/CoreProvider.js";import"../../../external/preact/hooks/dist/hooks.js";import"../../../core/Errors/AdyenCheckoutError.js";import"../../../core/Errors/SRPanelContext.js";import"../../internal/Button/Button.js";import r from"../../internal/QRLoader/QRLoader.js";import"../../internal/QRLoader/QRLoaderDetailsProvider.js";import s from"../../internal/RedirectButton/RedirectButton.js";import n from"../../../core/Errors/SRPanelProvider.js";class i extends e{formatData(){return{paymentMethod:{type:this.type,...this.state.data}}}get isValid(){return!0}renderQRCode(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{srPanel:this.props.modules.srPanel},t(r,{ref:t=>{this.componentRef=t},...this.props,delay:this.props.delay,countdownTime:this.props.countdownTime,instructions:this.props.instructions,type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,onActionHandled:this.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics})))}render(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{showPayButton:this.props.showPayButton,name:this.displayName,onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})):null}}var a,p,l;l={qrCodeImage:"",amount:null,paymentData:null,onError:()=>{}},(p="defaultProps")in(a=i)?Object.defineProperty(a,p,{value:l,enumerable:!0,configurable:!0,writable:!0}):a[p]=l;export{i as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as o}from"../../internal/UIElement/UIElement.js";import{CoreProvider as r}from"../../../core/Context/CoreProvider.js";import"../../../external/preact/hooks/dist/hooks.js";import"../../../core/Errors/AdyenCheckoutError.js";import"../../../core/Errors/SRPanelContext.js";import"../../internal/Button/Button.js";import e from"../../internal/QRLoader/QRLoader.js";import"../../internal/QRLoader/QRLoaderDetailsProvider.js";import s from"../../internal/RedirectButton/RedirectButton.js";import n from"../../../core/Errors/SRPanelProvider.js";class i extends o{formatData(){return{paymentMethod:{type:this.type,...this.state.data}}}get isValid(){return!0}renderQRCode(){return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{srPanel:this.props.modules.srPanel},t(e,{...this.props,delay:this.props.delay,countdownTime:this.props.countdownTime,instructions:this.props.instructions,type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,onActionHandled:this.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics})))}render(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{showPayButton:this.props.showPayButton,name:this.displayName,onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})):null}}var a,p,l;l={qrCodeImage:"",amount:null,paymentData:null,onError:()=>{}},(p="defaultProps")in(a=i)?Object.defineProperty(a,p,{value:l,enumerable:!0,configurable:!0,writable:!0}):a[p]=l;export{i as default};
2
2
  //# sourceMappingURL=QRLoaderContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport QRLoader from '../../internal/QRLoader';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n delay={this.props.delay}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n onActionHandled={this.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n render() {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </CoreProvider>\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","type","this","state","data","isValid","renderQRCode","h","CoreProvider","i18n","props","loadingContext","resources","SRPanelProvider","srPanel","modules","QRLoader","ref","componentRef","delay","countdownTime","instructions","constructor","brandLogo","icon","onComplete","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","render","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","qrCodeImage","amount","onError","defaultProps"],"mappings":"knBAQA,MAAMA,UAAmFC,EASrFC,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKD,QACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAACM,EAAAA,CAAgBC,QAASZ,KAAKQ,MAAMK,QAAQD,SACzCP,EAACS,EAAAA,CACGC,IAAKA,IACDf,KAAKgB,aAAeD,MAEpBf,KAAKQ,MACTS,MAAOjB,KAAKQ,MAAMS,MAClBC,cAAelB,KAAKQ,MAAMU,cAC1BC,aAAcnB,KAAKQ,MAAMW,aACzBpB,KAAMC,KAAKoB,YAAY,KACvBC,UAAWrB,KAAKQ,MAAMa,WAAarB,KAAKsB,KACxCC,WAAYvB,KAAKuB,WACjBC,gBAAiBxB,KAAKwB,gBACtBC,UAAWzB,KAAK0B,YAChBC,kBAAmB3B,KAAK4B,mBAK5C,CAEAC,MAAAA,GACI,OAAI7B,KAAKQ,MAAMsB,YACJ9B,KAAKI,eAGZJ,KAAKQ,MAAMuB,cAEP1B,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAAC2B,EAAAA,CACGD,cAAe/B,KAAKQ,MAAMuB,cAC1BE,KAAMjC,KAAK0B,YACXQ,SAAUlC,KAAKmC,OACfC,UAAWpC,KAAKoC,UAChBrB,IAAKA,IACDf,KAAKgB,aAAeD,MAOjC,IACX,cAnEgC,CAC5BsB,YAAa,GACbC,OAAQ,KACRR,YAAa,KACbS,QAAS,WAJIC,oBAFf7C"}
1
+ {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport QRLoader from '../../internal/QRLoader';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <QRLoader\n {...this.props}\n delay={this.props.delay}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n onActionHandled={this.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n render() {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </CoreProvider>\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","type","this","state","data","isValid","renderQRCode","h","CoreProvider","i18n","props","loadingContext","resources","SRPanelProvider","srPanel","modules","QRLoader","delay","countdownTime","instructions","constructor","brandLogo","icon","onComplete","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","render","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","ref","componentRef","qrCodeImage","amount","onError","defaultProps"],"mappings":"knBAQA,MAAMA,UAAmFC,EASrFC,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKD,QACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAACM,EAAAA,CAAgBC,QAASZ,KAAKQ,MAAMK,QAAQD,SACzCP,EAACS,EAAAA,IACOd,KAAKQ,MACTO,MAAOf,KAAKQ,MAAMO,MAClBC,cAAehB,KAAKQ,MAAMQ,cAC1BC,aAAcjB,KAAKQ,MAAMS,aACzBlB,KAAMC,KAAKkB,YAAY,KACvBC,UAAWnB,KAAKQ,MAAMW,WAAanB,KAAKoB,KACxCC,WAAYrB,KAAKqB,WACjBC,gBAAiBtB,KAAKsB,gBACtBC,UAAWvB,KAAKwB,YAChBC,kBAAmBzB,KAAK0B,mBAK5C,CAEAC,MAAAA,GACI,OAAI3B,KAAKQ,MAAMoB,YACJ5B,KAAKI,eAGZJ,KAAKQ,MAAMqB,cAEPxB,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAACyB,EAAAA,CACGD,cAAe7B,KAAKQ,MAAMqB,cAC1BE,KAAM/B,KAAKwB,YACXQ,SAAUhC,KAAKiC,OACfC,UAAWlC,KAAKkC,UAChBC,IAAKA,IACDnC,KAAKoC,aAAeD,MAOjC,IACX,cAhEgC,CAC5BE,YAAa,GACbC,OAAQ,KACRV,YAAa,KACbW,QAAS,WAJIC,oBAFf7C"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as t,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import r from"../../../core/Services/payment-status.js";import{processResponse as n}from"../../../core/ProcessResponse/process-response.js";import s from"../Spinner/Spinner.js";import i from"../Countdown/index.js";import c from"../Button/Button.js";import{useCoreContext as l}from"../../../core/Context/CoreProvider.js";import u from"../../../core/Errors/AdyenCheckoutError.js";import d from"../ContentSeparator/ContentSeparator.js";import m from"../../../core/Context/useImage.js";function _(_){const{i18n:p,loadingContext:y}=l(),h=m(),[w,k]=t(!1),[f,g]=t(!1),[v,N]=t(!0),[C,T]=t(!1),[b,x]=t(_.delay),[R,j]=t(100),[E,S]=t(0),[A,D]=t(!1),[I,L]=t(null),{amount:P}=_,M=e=>{if(e.props.payload){k(!0);const t={data:{details:{payload:e.props.payload},paymentData:_.paymentData}};return _.onComplete(t,this)}g(!0),_.onError(new u("ERROR","successful result, but no payload in response"))},O=e=>{if(g(!0),e.props.payload){const t={data:{details:{payload:e.props.payload},paymentData:_.paymentData}};return _.onComplete(t,this)}_.onError(new u("ERROR","error result with no payload in response"))},$=async()=>{const{paymentData:e,clientKey:t,throttleInterval:a,pollStatus:o}=_,s=o??(()=>r(e,t,y,a));return C||(_.onActionHandled?.({componentType:_.type,actionDescription:"polling-started"}),T(!0)),s().then(n).catch(({message:e,...t})=>({type:"network-error",props:{...e&&{message:p.get(e)},...t}})).then(e=>{switch(e.type){case"success":M(e);break;case"error":O(e);break;default:N(!1)}})},z=e=>{window.location.assign(e)};a(()=>{_.shouldRedirectAutomatically&&_.url&&z(_.url)},[_.shouldRedirectAutomatically,_.url]),a(()=>($(),()=>{clearTimeout(I)}),[]),a(()=>{if(f)return clearTimeout(I);if(w)return clearTimeout(I);if(!v){const e=async()=>{await $();const e=E+b;S(e),e>=_.throttleTime&&!A&&(x(_.throttleInterval),D(!0))};L(setTimeout(()=>{e()},b))}},[v,f,w,E]);const B=(t,a)=>e("div",{className:"adyen-checkout__await adyen-checkout__await--result"},e("img",{className:"adyen-checkout__await__icon adyen-checkout__await__icon--result",src:h({imageFolder:"components/"})(t),alt:p.get(a)}),e("div",{className:"adyen-checkout__await__subtitle adyen-checkout__await__subtitle--result"},p.get(a)));if(f)return B("error","error.subtitle.payment");if(w)return B("success","creditCard.success");if(v)return e("div",{className:"adyen-checkout__await"},_.brandLogo&&e("img",{src:_.brandLogo,alt:_.type,className:"adyen-checkout__await__brand-logo"}),e(s,{inline:!1,size:"large"}));const F=p.get("wechatpay.timetopay").split("%@");return e("div",{className:o("adyen-checkout__await",`adyen-checkout__await--${_.type}`,_.classNameModifiers.map(e=>`adyen-checkout__await--${e}`))},_.brandLogo&&e("img",{src:_.brandLogo,alt:_.type,className:"adyen-checkout__await__brand-logo"}),!(!_.showAmount||null===P?.value||!P?.currency)&&e("div",{className:"adyen-checkout__await__amount"},p.amount(P.value,P.currency)),null!=_.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},_.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(s,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},_.awaitText)),_.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${R}%`}})),e("div",{className:"adyen-checkout__await__countdown"},F[0]," ",e(i,{minutesFromNow:_.countdownTime,onTick:e=>{j(e.percentage)},onCompleted:()=>{g(!0),clearTimeout(I),_.onError(new u("ERROR","Payment Expired"))}})," ",F[1])),_.url&&!_.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(c,{classNameModifiers:["await"],onClick:()=>z(_.url),label:p.get("openApp")})),_.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof _.instructions?p.get(_.instructions):_.instructions?.()),_.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},_.endSlot()))}_.defaultProps={countdownTime:15,onError:()=>{},onComplete:()=>{},delay:2e3,throttleTime:6e4,throttleInterval:1e4,showCountdownTimer:!0,classNameModifiers:[],url:null};export{_ as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as t,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import r from"../../../core/Services/payment-status.js";import{processResponse as n}from"../../../core/ProcessResponse/process-response.js";import s from"../Spinner/Spinner.js";import i from"../Countdown/index.js";import c from"../Button/Button.js";import{useCoreContext as l}from"../../../core/Context/CoreProvider.js";import u from"../../../core/Errors/AdyenCheckoutError.js";import d from"../ContentSeparator/ContentSeparator.js";import m from"../../../core/Context/useImage.js";function _(_){const{i18n:p,loadingContext:y}=l(),w=m(),[h,k]=t(!1),[f,g]=t(!1),[N,v]=t(!0),[C,T]=t(!1),[b,x]=t(_.delay),[R,j]=t(100),[E,S]=t(0),[A,D]=t(!1),[I,L]=t(null),{amount:P}=_,M=async()=>{const{paymentData:e,clientKey:t,throttleInterval:a,pollStatus:o}=_,s=o??(()=>r(e,t,y,a));return C||(_.onActionHandled?.({componentType:_.type,actionDescription:"polling-started"}),T(!0)),s().then(n).catch(({message:e,...t})=>({type:"network-error",props:{...e&&{message:p.get(e)},...t}})).then(e=>{switch(e.type){case"success":(e=>{if(e.props.payload){k(!0);const t={data:{details:{payload:e.props.payload},paymentData:_.paymentData}};return _.onComplete(t)}g(!0),_.onError(new u("ERROR","successful result, but no payload in response"))})(e);break;case"error":(e=>{if(g(!0),e.props.payload){const t={data:{details:{payload:e.props.payload},paymentData:_.paymentData}};return _.onComplete(t)}_.onError(new u("ERROR","error result with no payload in response"))})(e);break;default:v(!1)}})},O=e=>{window.location.assign(e)};a(()=>{_.shouldRedirectAutomatically&&_.url&&O(_.url)},[_.shouldRedirectAutomatically,_.url]),a(()=>(M(),()=>{clearTimeout(I)}),[]),a(()=>{if(f)return clearTimeout(I);if(h)return clearTimeout(I);if(!N){const e=async()=>{await M();const e=E+b;S(e),e>=_.throttleTime&&!A&&(x(_.throttleInterval),D(!0))};L(setTimeout(()=>{e()},b))}},[N,f,h,E]);const $=(t,a)=>e("div",{className:"adyen-checkout__await adyen-checkout__await--result"},e("img",{className:"adyen-checkout__await__icon adyen-checkout__await__icon--result",src:w({imageFolder:"components/"})(t),alt:p.get(a)}),e("p",{className:"adyen-checkout__await__subtitle adyen-checkout__await__subtitle--result"},p.get(a)));if(f)return $("error","error.subtitle.payment");if(h)return $("success","creditCard.success");if(N)return e("div",{className:"adyen-checkout__await"},_.brandLogo&&e("img",{src:_.brandLogo,alt:_.type,className:"adyen-checkout__await__brand-logo"}),e(s,{inline:!1,size:"large"}));const z=p.get("wechatpay.timetopay").split("%@");return e("div",{className:o("adyen-checkout__await",`adyen-checkout__await--${_.type}`,_.classNameModifiers.map(e=>`adyen-checkout__await--${e}`))},_.brandLogo&&e("img",{src:_.brandLogo,alt:_.type,className:"adyen-checkout__await__brand-logo"}),!(!_.showAmount||null===P?.value||!P?.currency)&&e("div",{className:"adyen-checkout__await__amount"},p.amount(P.value,P.currency)),null!=_.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},_.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(s,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},_.awaitText)),_.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${R}%`}})),e("div",{className:"adyen-checkout__await__countdown"},z[0]," ",e(i,{minutesFromNow:_.countdownTime,onTick:e=>{j(e.percentage)},onCompleted:()=>{g(!0),clearTimeout(I),_.onError(new u("ERROR","Payment Expired"))}})," ",z[1])),_.url&&!_.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(c,{classNameModifiers:["await"],onClick:()=>O(_.url),label:p.get("openApp")})),_.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof _.instructions?p.get(_.instructions):_.instructions?.()),_.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},_.endSlot()))}_.defaultProps={countdownTime:15,onError:()=>{},onComplete:()=>{},delay:2e3,throttleTime:6e4,throttleInterval:1e4,showCountdownTimer:!0,classNameModifiers:[],url:null};export{_ as default};
2
2
  //# sourceMappingURL=Await.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport classnames from 'classnames';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport Spinner from '../../internal/Spinner';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { AwaitComponentProps, StatusObject } from './types';\nimport './Await.scss';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport ContentSeparator from '../ContentSeparator';\nimport useImage from '../../../core/Context/useImage';\n\nfunction Await(props: AwaitComponentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [completed, setCompleted] = useState(false);\n const [expired, setExpired] = useState(false);\n const [loading, setLoading] = useState(true);\n const [hasCalledActionHandled, setHasCalledActionHandled] = useState(false);\n const [delay, setDelay] = useState(props.delay);\n const [percentage, setPercentage] = useState(100);\n const [timePassed, setTimePassed] = useState(0);\n const [hasAdjustedTime, setHasAdjustedTime] = useState(false);\n const [storedTimeout, setStoredTimeout] = useState(null);\n const { amount } = props;\n\n const onTimeUp = (): void => {\n setExpired(true);\n clearTimeout(storedTimeout);\n props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n const onTick = (time): void => {\n setPercentage(time.percentage);\n };\n\n const onComplete = (status: StatusObject): void => {\n // Only make details call if we have a payload\n if (status.props.payload) {\n setCompleted(true);\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n // Send success response to onAdditionalDetails\n return props.onComplete(state, this);\n }\n\n // Show error state & call merchant defined error callback if we do not have a payload\n setExpired(true);\n props.onError(new AdyenCheckoutError('ERROR', 'successful result, but no payload in response'));\n };\n\n const onError = (status: StatusObject): void => {\n setExpired(true);\n\n // Only make details call if we have a payload\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n // Send error response to onAdditionalDetails\n return props.onComplete(state, this);\n }\n\n // Call merchant defined error callback if we do not have a payload\n props.onError(new AdyenCheckoutError('ERROR', 'error result with no payload in response'));\n };\n\n const checkStatus = async (): Promise<void> => {\n const { paymentData, clientKey, throttleInterval, pollStatus } = props;\n\n // If there's a custom pollStatus function, call it.\n // Otherwise, call the default one.\n const pollStatusFunction = pollStatus ?? (() => checkPaymentStatus(paymentData, clientKey, loadingContext, throttleInterval));\n\n if (!hasCalledActionHandled) {\n props.onActionHandled?.({ componentType: props.type, actionDescription: 'polling-started' });\n setHasCalledActionHandled(true);\n }\n\n return pollStatusFunction()\n .then(processResponse)\n .catch(({ message, ...response }) => ({\n type: 'network-error',\n props: {\n ...(message && { message: i18n.get(message) }),\n ...response\n }\n }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n onComplete(status);\n break;\n\n case 'error':\n onError(status);\n break;\n\n default:\n setLoading(false);\n }\n });\n };\n\n const redirectToApp = (url): void => {\n window.location.assign(url);\n };\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n useEffect(() => {\n void checkStatus();\n return (): void => {\n clearTimeout(storedTimeout);\n };\n }, []);\n\n useEffect(() => {\n if (expired) return clearTimeout(storedTimeout);\n\n if (completed) return clearTimeout(storedTimeout);\n\n if (!loading) {\n // Retry until getting a complete response from the server OR it times out\n // Changes setTimeout time to new value (throttleInterval) after a certain amount of time (throttleTime) has passed\n const statusInterval = async (): Promise<void> => {\n await checkStatus();\n\n const actualTimePassed = timePassed + delay;\n // timePassed is the value that is the main \"engine\" that drives this useEffect/polling\n setTimePassed(actualTimePassed);\n\n if (actualTimePassed >= props.throttleTime && !hasAdjustedTime) {\n setDelay(props.throttleInterval);\n setHasAdjustedTime(true);\n }\n };\n\n // Create (another) interval to poll for a result\n setStoredTimeout(setTimeout(() => void statusInterval(), delay));\n }\n }, [loading, expired, completed, timePassed]);\n\n const finalState = (image, message) => (\n <div className=\"adyen-checkout__await adyen-checkout__await--result\">\n <img\n className=\"adyen-checkout__await__icon adyen-checkout__await__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={i18n.get(message)}\n />\n <div className=\"adyen-checkout__await__subtitle adyen-checkout__await__subtitle--result\">{i18n.get(message)}</div>\n </div>\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__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n delay: 2000,\n throttleTime: 60000,\n throttleInterval: 10000,\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n\nexport default Await;\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","getImage","useImage","completed","setCompleted","useState","expired","setExpired","loading","setLoading","hasCalledActionHandled","setHasCalledActionHandled","delay","setDelay","percentage","setPercentage","timePassed","setTimePassed","hasAdjustedTime","setHasAdjustedTime","storedTimeout","setStoredTimeout","amount","onComplete","status","payload","state","data","details","paymentData","this","onError","AdyenCheckoutError","checkStatus","async","clientKey","throttleInterval","pollStatus","pollStatusFunction","checkPaymentStatus","onActionHandled","componentType","type","actionDescription","then","processResponse","catch","message","response","get","redirectToApp","url","window","location","assign","useEffect","shouldRedirectAutomatically","clearTimeout","statusInterval","actualTimePassed","throttleTime","setTimeout","finalState","image","h","div","className","img","src","imageFolder","alt","brandLogo","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","awaitText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onTick","time","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps"],"mappings":"2qBAgBA,SAASA,EAAMC,GACX,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAWC,GAAgBC,GAAS,IACpCC,EAASC,GAAcF,GAAS,IAChCG,EAASC,GAAcJ,GAAS,IAChCK,EAAwBC,G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mD,IAAIpD,EAAMuG,cAAgBvG,EAAMuG,kBAItFvG,EAAMwG,SAAWrC,EAACC,MAAAA,CAAIC,UAAU,mCAAmCrE,EAAMwG,WAGtF,CAEAzG,EAAM0G,aAAe,CACjBV,cAAe,GACf7D,QAAS,OACTR,WAAY,OACZX,MAAO,IACPgD,aAAc,IACdxB,iBAAkB,IAClBkD,oBAAoB,EACpBR,mBAAoB,GACpB3B,IAAK"}
1
+ {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport classnames from 'classnames';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\nimport Spinner from '../../internal/Spinner';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { AwaitComponentProps, StatusObject } from './types';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport ContentSeparator from '../ContentSeparator';\nimport useImage from '../../../core/Context/useImage';\nimport { CountdownTime } from '../Countdown/types';\nimport './Await.scss';\n\nfunction Await(props: AwaitComponentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [completed, setCompleted] = useState(false);\n const [expired, setExpired] = useState(false);\n const [loading, setLoading] = useState(true);\n const [hasCalledActionHandled, setHasCalledActionHandled] = useState(false);\n const [delay, setDelay] = useState(props.delay);\n const [percentage, setPercentage] = useState(100);\n const [timePassed, setTimePassed] = useState(0);\n const [hasAdjustedTime, setHasAdjustedTime] = useState(false);\n const [storedTimeout, setStoredTimeout] = useState<NodeJS.Timeout | number | null>(null);\n const { amount } = props;\n\n const onTimeUp = (): void => {\n setExpired(true);\n clearTimeout(storedTimeout);\n props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n const onTick = (time: CountdownTime): void => {\n setPercentage(time.percentage);\n };\n\n const onComplete = (status: StatusObject): void => {\n // Only make details call if we have a payload\n if (status.props.payload) {\n setCompleted(true);\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n // Send success response to onAdditionalDetails\n return props.onComplete(state);\n }\n\n // Show error state & call merchant defined error callback if we do not have a payload\n setExpired(true);\n props.onError(new AdyenCheckoutError('ERROR', 'successful result, but no payload in response'));\n };\n\n const onError = (status: StatusObject): void => {\n setExpired(true);\n\n // Only make details call if we have a payload\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n // Send error response to onAdditionalDetails\n return props.onComplete(state);\n }\n\n // Call merchant defined error callback if we do not have a payload\n props.onError(new AdyenCheckoutError('ERROR', 'error result with no payload in response'));\n };\n\n const checkStatus = async (): Promise<void> => {\n const { paymentData, clientKey, throttleInterval, pollStatus } = props;\n\n // If there's a custom pollStatus function, call it.\n // Otherwise, call the default one.\n const pollStatusFunction = pollStatus ?? (() => checkPaymentStatus(paymentData, clientKey, loadingContext, throttleInterval));\n\n if (!hasCalledActionHandled) {\n props.onActionHandled?.({ componentType: props.type, actionDescription: 'polling-started' });\n setHasCalledActionHandled(true);\n }\n\n return pollStatusFunction()\n .then(processResponse)\n .catch(({ message, ...response }) => ({\n type: 'network-error',\n props: {\n ...(message && { message: i18n.get(message) }),\n ...response\n }\n }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n onComplete(status);\n break;\n\n case 'error':\n onError(status);\n break;\n\n default:\n setLoading(false);\n }\n });\n };\n\n const redirectToApp = (url: string): void => {\n window.location.assign(url);\n };\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n useEffect(() => {\n void checkStatus();\n return (): void => {\n clearTimeout(storedTimeout);\n };\n }, []);\n\n useEffect(() => {\n if (expired) return clearTimeout(storedTimeout);\n\n if (completed) return clearTimeout(storedTimeout);\n\n if (!loading) {\n // Retry until getting a complete response from the server OR it times out\n // Changes setTimeout time to new value (throttleInterval) after a certain amount of time (throttleTime) has passed\n const statusInterval = async (): Promise<void> => {\n await checkStatus();\n\n const actualTimePassed = timePassed + delay;\n // timePassed is the value that is the main \"engine\" that drives this useEffect/polling\n setTimePassed(actualTimePassed);\n\n if (actualTimePassed >= props.throttleTime && !hasAdjustedTime) {\n setDelay(props.throttleInterval);\n setHasAdjustedTime(true);\n }\n };\n\n // Create (another) interval to poll for a result\n setStoredTimeout(setTimeout(() => void statusInterval(), delay));\n }\n }, [loading, expired, completed, timePassed]);\n\n const finalState = (image: string, message: string) => (\n <div className=\"adyen-checkout__await adyen-checkout__await--result\">\n <img\n className=\"adyen-checkout__await__icon adyen-checkout__await__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={i18n.get(message)}\n />\n <p className=\"adyen-checkout__await__subtitle adyen-checkout__await__subtitle--result\">{i18n.get(message)}</p>\n </div>\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__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n delay: 2000,\n throttleTime: 60000,\n throttleInterval: 10000,\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n\nexport default Await;\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","getImage","useImage","completed","setCompleted","useState","expired","setExpired","loading","setLoading","hasCalledActionHandled","setHasCalledActionHandled","delay","setDelay","percentage","setPercentage","timePassed","setTimePassed","hasAdjustedTime","setHasAdjustedTime","storedTimeout","setStoredTimeout","amount","checkStatus","async","paymentData","clientKey","throttleInterval","pollStatus","pollStatusFunction","checkPaymentStatus","onActionHandled","componentType","type","actionDescription","then","processResponse","catch","message","response","get","status","payload","state","data","details","onComplete","onError","AdyenCheckoutError","redirectToApp","url","window","location","assign","useEffect","shouldRedirectAutomatically","clearTimeout","statusInterval","actualTimePassed","throttleTime","setTimeout","finalState","image","h","div","className","img","src","imageFolder","alt","p","brandLogo","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","awaitText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onTick","time","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps"],"mappings":"2qBAgBA,SAASA,EAAMC,GACX,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAWC,GAAgBC,GAAS,IACpCC,EAASC,GAAcF,GAAS,IAChCG,EAASC,GAAcJ,GAAS,IAChCK,EAAwBC,GAA6BN,GAAS,IAC9DO,EAAOC,GAAYR,EAASR,EAAMe,QAClCE,EAAYC,GAAiBV,EAAS,MACtCW,EAAYC,GAAiBZ,EAAS,IACtCa,EAAiBC,GAAsBd,GAAS,IAChDe,EAAeC,GAAoBhB,EAAyC,OAC7EiB,OAAEA,GAAWzB,EAkDb0B,EAAcC,UAChB,MAAMC,YAAEA,EAAWC,UAAEA,EAASC,iBAAEA,EAAgBC,WAAEA,GAAe/B,EAI3DgC,EAAqBD,QAAqBE,EAAmBL,EAAaC,EAAW3B,EAAgB4B,IAO3G,OALKjB,IACDb,EAAMkC,kBAAkB,CAAEC,cAAenC,EAAMoC,KAAMC,kBAAmB,oBACxEvB,GAA0B,IAGvBkB,IACFM,KAAKC,GACLC,MAAM,EAAGC,aAAYC,MAAU,CAC5BN,KAAM,gBACNpC,MAAO,IACCyC,GAAW,CAAEA,QAASxC,EAAK0C,IAAIF,OAChCC,MAGVJ,KAAMM,IACH,OAAQA,EAAOR,MACX,IAAK,UA7DF,CAACQ,IAEhB,GAAIA,EAAO5C,MAAM6C,QAAS,CACtBtC,GAAa,GACb,MAAMuC,EAAQ,CACVC,KAAM,CACFC,QAAS,CAAEH,QAASD,EAAO5C,MAAM6C,SACjCjB,YAAa5B,EAAM4B,cA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LpDC,IACZ/E,EAAc+E,EAAKhF,aAwL6DiF,YA/LnE,KACbxF,GAAW,GACXiD,aAAapC,GACbvB,EAAMkD,QAAQ,IAAIC,EAAmB,QAAS,uBA4L2D,IAClF2B,EAAgB,KAKlC9E,EAAMqD,MAAQrD,EAAM0D,6BACjBQ,EAACC,MAAAA,CAAIC,UAAU,mCACXF,EAACiC,QACDjC,EAACkC,EAAAA,CAAOnB,mBAAoB,CAAC,SAAUoB,QAAS,IAAMjD,EAAcpD,EAAMqD,KAAMiD,MAAOrG,EAAK0C,IAAI,cAIvG3C,EAAMuG,cACHrC,EAACC,MAAAA,CAAIC,UAAU,uCACoB,iBAAvBpE,EAAMuG,aAA4BtG,EAAK0C,IAAI3C,EAAMuG,cAAgBvG,EAAMuG,kBAItFvG,EAAMwG,SAAWtC,EAACC,MAAAA,CAAIC,UAAU,mCAAmCpE,EAAMwG,WAGtF,CAEAzG,EAAM0G,aAAe,CACjBV,cAAe,GACf7C,QAAS,OACTD,WAAY,OACZlC,MAAO,IACP+C,aAAc,IACdhC,iBAAkB,IAClB2D,oBAAoB,EACpBR,mBAAoB,GACpB5B,IAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './Button.scss';\nimport { ButtonProps, ButtonState } from './types';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n render() {\n const {\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaDescribedBy,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant !== 'primary' ? [variant] : []),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n <span className={'adyen-checkout__button__text--sr-only'}>{i18n.get('loading')}</span>\n </span>\n ),\n redirect: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a className={buttonClasses} href={href} disabled={disabled} target={this.props.target} rel={this.props.rel}>\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaDescribedBy","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","get","redirect","default","buttonText","a","target","rel","button","ref","type","onClick","aria-label","aria-describedby","children","super","args","_define_property","e","preventDefault","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAyBjBC,MAAAA,GACI,MAAMC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,gBACTA,EAAeC,OACfA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFrB,GAAwBD,EACpBuB,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,UAAajB,GAAwBD,EAAQA,EAC7D2B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXhC,KACa,YAAZU,EAAwB,CAACA,GAAW,MACpCL,EAAS,CAAC,UAAY,MACtBgB,EAAY,CAAC,aAAe,MACjB,YAAXZ,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEwB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,E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ACVK,MAAO,GACPD,QAAQ,EACR0C,OAAQ"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n render() {\n const {\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaDescribedBy,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant !== 'primary' ? [variant] : []),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n <span className={'adyen-checkout__button__text--sr-only'}>{i18n.get('loading')}</span>\n </span>\n ),\n redirect: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a className={buttonClasses} href={href} disabled={disabled} target={this.props.target} rel={this.props.rel}>\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaDescribedBy","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","get","redirect","default","buttonText","a","target","rel","button","ref","type","onClick","aria-label","aria-describedby","children","super","args","_define_property","e","preventDefault","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAyBjBC,MAAAA,GACI,MAAMC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,gBACTA,EAAeC,OACfA,EAAMC,Q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KAAKiC,QACdC,aAAY9C,EACZ+C,mBAAkB9C,EAClBK,aAAcA,EACdC,aAAcA,EACdG,UAAWA,EACXF,QAASA,EACTC,OAAQA,EACRE,WAAYA,GAEX2B,EACW,YAAXpC,GAAmC,aAAXA,GAAyBU,KAAKC,MAAMmC,SAGzE,mBA3HJC,SAAAC,GAUIC,EAAAvC,KAAOiC,UAAWO,IACdA,EAAEC,iBAEGzC,KAAKC,MAAMnB,UACZkB,KAAKC,MAAMgC,UAAUO,EAAG,CAAEE,SAAU1C,KAAK0C,aAIjDH,EAAAvC,KAAO0C,WAAW,CAACC,EAAQ,OACvB3C,KAAK4C,SAAS,CAAE1C,WAAW,IAC3B2C,WAAW,KACP7C,KAAK4C,SAAS,CAAE1C,WAAW,KAC5ByC,MArBPJ,EADE7D,EACYoE,eAAe,CACzBxD,OAAQ,UACRC,QAAS,UACTT,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR0C,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Button/Button.js";import r from"../Spinner/Spinner.js";import s from"../../../core/Services/payment-status.js";import{processResponse as a}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as i}from"../../../utils/clipboard.js";import n from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import c from"../ContentSeparator/ContentSeparator.js";import d from"../../../core/Context/useImage.js";import{useA11yReporter as l}from"../../../core/Errors/useA11yReporter.js";import m from"../../../utils/useAutoFocus.js";import{ANALYTICS_QR_CODE_DOWNLOAD as u,ANALYTICS_DOWNLOAD_STR as h}from"../../../core/Analytics/constants.js";import{AnalyticsInfoEvent as y}from"../../../core/Analytics/AnalyticsInfoEvent.js";import _ from"./components/QRDetails.js";import{QRLoaderDetailsProvider as f}from"./QRLoaderDetailsProvider.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class k extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout(async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))},t)}render({amount:t,showAmount:s,url:a,brandLogo:n,brandName:g,countdownTime:k,type:q,onActionHandled:b},{expired:C,completed:T,loading:v}){const{i18n:w,loadingContext:I}=p(),j=d(),N=this.props.qrCodeData?`${I}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,S=(t,o)=>{const r=w.get(o);return l(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:j({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(C)return S("error","error.subtitle.payment");if(T)return S("success","creditCard.success");if(v)return e("div",{className:"adyen-checkout__qr-loader"},n&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:g,src:n,className:"adyen-checkout__qr-loader__brand-logo"})),e(r,null));const x=m(),D=this.props.classNameModifiers.map(t=>`adyen-checkout__qr-loader--${t}`);return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${q} ${D.join(" ")}`},n&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:n,alt:g,className:"adyen-checkout__qr-loader__brand-logo"})),s&&t&&null!==t.value&&!!t.currency&&e("h1",{className:"adyen-checkout__qr-loader__payment_amount"},w.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("p",{className:"adyen-checkout__qr-loader__subtitle"},w.get(this.props.redirectIntroduction)),e(o,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:w.get(this.props.buttonLabel)}),e(c,null)),e("p",{ref:x,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?w.get(this.props.introduction):this.props.introduction?.()),e(f,{qrCodeImage:N,qrCodeData:this.props.qrCodeData,percentage:this.state.percentage,timeToPay:this.props.timeToPay,copyBtn:this.props.copyBtn,instructions:this.props.instructions,countdownTime:k,onTick:t=>this.onTick(t),onQRCodeLoad:()=>{b?.({componentType:this.props.type,actionDescription:"qr-code-loaded"})},onTimeUp:()=>this.onTimeUp(),handleCopy:t=>{i(this.props.qrCodeData);const e=new y({type:h,target:u});this.props.onSubmitAnalytics(e),t()}},this.props.children?this.props.children:e(_,null)))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",t=>{window.location.assign(t)}),g(this,"statusInterval",(t=0)=>{if(this.state.expired||this.state.completed)return;this.setState(e=>({timePassed:e.timePassed+this.props.delay+t}));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)}),g(this,"onTick",t=>{this.setState({percentage:t.percentage})}),g(this,"onTimeUp",()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new n("ERROR","Payment Expired"))}),g(this,"onComplete",t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}),g(this,"onError",t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new n("ERROR","error result with no payload in response");return this.props.onError(e)}),g(this,"checkStatus",()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return s(t,e,o,r).then(a).catch(t=>({type:"network-error",props:t})).then(t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t})}),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(k,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp",showAmount:!0});export{k as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as t,useRef as o,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import a from"../Button/Button.js";import n from"../Spinner/Spinner.js";import s from"../../../core/Services/payment-status.js";import{processResponse as c}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as i}from"../../../utils/clipboard.js";import l from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as d}from"../../../core/Context/CoreProvider.js";import m from"../ContentSeparator/ContentSeparator.js";import p from"../../../utils/useAutoFocus.js";import{ANALYTICS_QR_CODE_DOWNLOAD as u,ANALYTICS_DOWNLOAD_STR as y}from"../../../core/Analytics/constants.js";import{AnalyticsInfoEvent as _}from"../../../core/Analytics/AnalyticsInfoEvent.js";import h from"./components/QRDetails.js";import{QRLoaderDetailsProvider as f}from"./QRLoaderDetailsProvider.js";import{QRFinalState as g}from"./components/QRFinalState.js";function q(q){const{i18n:k,loadingContext:C}=d(),[b,w]=t(!1),[v,j]=t(q.delay),[N,T]=t(!1),[D,R]=t(!0),[E,I]=t(100),[A,P]=t(0),S=o(null),x=async()=>{const{paymentData:e,clientKey:t,throttledInterval:o}=q;return s(e,t,C,o).then(c).catch(e=>({type:"network-error",props:e})).then(e=>{switch(e.type){case"success":(e=>{w(!0),R(!1);const t={data:{details:{payload:e.props.payload},paymentData:q.paymentData}};q.onComplete(t)})(e);break;case"error":(e=>{if(T(!0),R(!1),e.props.payload){const t={data:{details:{payload:e.props.payload},paymentData:q.paymentData}};q.onComplete(t)}const t=new l("ERROR","error result with no payload in response");q.onError(t)})(e);break;default:R(!1)}})};r(()=>{x()},[]),r(()=>{if(N||b||D)return;let e=v;return S.current=setTimeout(()=>{(async()=>{const t=performance.now();await x();const o=performance.now(),r=Math.round(o-t),a=A+r+e;P(a),a>=q.throttleTime&&e!==q.throttledInterval&&(j(q.throttledInterval),e=q.throttledInterval)})()},e),()=>{clearTimeout(S.current)}},[N,b,D,v,q.throttleTime,A]);const{amount:$,showAmount:L,url:B,brandLogo:M,brandName:Q,countdownTime:K,type:F,onActionHandled:O}=q,H=q.qrCodeData?`${C}utility/v1/barcode.png?type=qrCode&data=${q.qrCodeData}&clientKey=${q.clientKey}`:q.qrCodeImage,U=p();if(N)return e(g,{image:"error",message:k.get("error.subtitle.payment")});if(b)return e(g,{image:"success",message:k.get("creditCard.success")});if(D)return e("div",{className:"adyen-checkout__qr-loader"},M&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:Q,src:M,className:"adyen-checkout__qr-loader__brand-logo"})),e(n,null));const z=q.classNameModifiers.map(e=>`adyen-checkout__qr-loader--${e}`);return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${F} ${z.join(" ")}`},M&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:M,alt:Q,className:"adyen-checkout__qr-loader__brand-logo"})),L&&$&&null!==$.value&&!!$.currency&&e("h1",{className:"adyen-checkout__qr-loader__payment_amount"},k.amount($.value,$.currency)),B&&e("div",{className:"adyen-checkout__qr-loader__app-link"},q.redirectIntroduction&&e("p",{className:"adyen-checkout__qr-loader__subtitle"},k.get(q.redirectIntroduction)),e(a,{classNameModifiers:["qr-loader"],onClick:()=>(e=>{window.location.assign(e)})(B),label:k.get(q.buttonLabel)}),e(m,null)),e("p",{ref:U,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof q.introduction?k.get(q.introduction):q.introduction?.()),e(f,{qrCodeImage:H,qrCodeData:q.qrCodeData,percentage:E,timeToPay:q.timeToPay,copyBtn:q.copyBtn,instructions:q.instructions,countdownTime:K,onTick:e=>(e=>{I(e.percentage)})(e),onQRCodeLoad:()=>{O?.({componentType:q.type,actionDescription:"qr-code-loaded"})},onTimeUp:()=>(T(!0),void q.onError(new l("ERROR","Payment Expired"))),handleCopy:e=>{i(q.qrCodeData);const t=new _({type:y,target:u});q.onSubmitAnalytics(t),e()}},q.children?q.children:e(h,null)))}q.defaultProps={delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp",showAmount:!0};export{q as default};
2
2
  //# sourceMappingURL=QRLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\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 { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\nimport { CountdownTime } from '../Countdown/types';\nimport QRDetails from './components/QRDetails';\nimport { QRLoaderDetailsProvider } from './QRLoaderDetailsProvider';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId: NodeJS.Timeout | number | undefined;\n\n constructor(props: QRLoaderProps) {\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: CountdownTime): 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 handleCopy = (complete: () => void) => {\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\n const onQrCodeLoad = () => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n };\n\n const finalState = (image: string, message: string) => {\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 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 <h1 className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</h1>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <p className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</p>\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 <p 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 </p>\n\n <QRLoaderDetailsProvider\n qrCodeImage={qrCodeImage}\n qrCodeData={this.props.qrCodeData}\n percentage={this.state.percentage}\n timeToPay={this.props.timeToPay}\n copyBtn={this.props.copyBtn}\n instructions={this.props.instructions}\n countdownTime={countdownTime}\n onTick={(time: CountdownTime) => this.onTick(time)}\n onQRCodeLoad={onQrCodeLoad}\n onTimeUp={() => this.onTimeUp()}\n handleCopy={handleCopy}\n >\n {this.props.children ? this.props.children : <QRDetails />}\n </QRLoaderDetailsProvider>\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","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","h1","redirectIntroduction","p","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","QRLoaderDetailsProvider","percentage","state","timeToPay","copyBtn","instructions","onTick","time","onQRCodeLoad","componentType","actionDescription","onTimeUp","handleCopy","complete","copyToClipboard","event","AnalyticsInfoEvent","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","onSubmitAnalytics","children","QRDetails","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mnCAwBA,MAAMA,UAAiBC,EA+BnBC,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,WAAEA,EAAUC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC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MAE3E,OAAOkF,EAAmBF,EAAa9E,EAAWP,EAAgB8E,GAC7DU,KAAKC,GACLC,MAAMC,IAAAA,CAAejG,KAAM,gBAAiBW,MAAOsF,KACnDH,KAAM7E,IACH,OAAQA,EAAOjB,MACX,IAAK,UACDvB,KAAK8G,WAAWtE,GAChB,MACJ,IAAK,QACDxC,KAAK4G,QAAQpE,GACb,MACJ,QACIxC,KAAKsG,SAAS,CAAE3E,SAAS,IAEjC,OAAOa,MAzHfxC,KAAK0E,MAAQ,CACT+C,aAAc,UACd/F,WAAW,EACXpB,MAAO4B,EAAM5B,MACbmB,SAAS,EACTE,SAAS,EACT8C,WAAY,IACZ+B,WAAY,EAEpB,EAEAP,EAjBEpG,EAiBY6H,eAAe,CACzBpH,MAAO,IACPgB,cAAe,GACfsF,QAAS,OACTE,WAAY,OACZJ,aAAc,IACdpD,mBAAoB,GACpBqD,kBAAmB,IACnBpC,aAAc,uBACdI,UAAW,sBACXR,YAAa,UACbjD,YAAY"}
1
+ {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef } from 'preact/hooks';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\nimport { QRLoaderProps } 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 useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\nimport { CountdownTime } from '../Countdown/types';\nimport QRDetails from './components/QRDetails';\nimport { QRLoaderDetailsProvider } from './QRLoaderDetailsProvider';\nimport { QRFinalState } from './components/QRFinalState';\nimport './QRLoader.scss';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nfunction QRLoader(props: QRLoaderProps) {\n const { i18n, loadingContext } = useCoreContext();\n const [completed, setCompleted] = useState(false);\n const [delay, setDelay] = useState(props.delay);\n const [expired, setExpired] = useState(false);\n const [loading, setLoading] = useState(true);\n const [percentage, setPercentage] = useState(100);\n const [timePassed, setTimePassed] = useState(0);\n const timeoutRef = useRef<NodeJS.Timeout | number | null>(null);\n\n const redirectToApp = (url: string | URL): void => {\n window.location.assign(url);\n };\n\n const onTick = (time: CountdownTime): void => {\n setPercentage(time.percentage);\n };\n\n const onTimeUp = (): void => {\n setExpired(true);\n props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n const onComplete = (status: StatusObject): void => {\n setCompleted(true);\n setLoading(false);\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n\n props.onComplete(state);\n };\n\n const onError = (status: StatusObject): void => {\n setExpired(true);\n setLoading(false);\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: props.paymentData\n }\n };\n props.onComplete(state);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n props.onError(error);\n };\n\n const checkStatus = async (): Promise<void> => {\n const { paymentData, clientKey, throttledInterval } = 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 onComplete(status);\n break;\n case 'error':\n onError(status);\n break;\n default:\n setLoading(false);\n }\n });\n };\n\n useEffect(() => {\n void checkStatus();\n }, []);\n\n useEffect(() => {\n if (expired || completed || loading) {\n return;\n }\n\n let currentDelay = delay;\n\n const statusInterval = async (): Promise<void> => {\n const start = performance.now();\n await checkStatus();\n const end = performance.now();\n const responseTime = Math.round(end - start);\n\n const actualTimePassed = timePassed + responseTime + currentDelay;\n setTimePassed(actualTimePassed);\n\n if (actualTimePassed >= props.throttleTime && currentDelay !== props.throttledInterval) {\n setDelay(props.throttledInterval);\n currentDelay = props.throttledInterval;\n }\n };\n\n timeoutRef.current = setTimeout(() => {\n void statusInterval();\n }, currentDelay);\n\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, [expired, completed, loading, delay, props.throttleTime, timePassed]);\n\n const { amount, showAmount, url, brandLogo, brandName, countdownTime, type, onActionHandled } = props;\n\n const qrCodeImage = props.qrCodeData ? `${loadingContext}${QRCODE_URL}${props.qrCodeData}&clientKey=${props.clientKey}` : props.qrCodeImage;\n\n const handleCopy = (complete: () => void) => {\n void copyToClipboard(props.qrCodeData);\n\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n props.onSubmitAnalytics(event);\n complete();\n };\n\n const onQrCodeLoad = () => {\n onActionHandled?.({\n componentType: props.type,\n actionDescription: 'qr-code-loaded'\n });\n };\n\n const qrSubtitleRef = useAutoFocus();\n\n if (expired) {\n return <QRFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <QRFinalState image=\"success\" message={i18n.get('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 classnames = 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 <h1 className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</h1>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {props.redirectIntroduction && <p className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(props.redirectIntroduction)}</p>}\n <Button classNameModifiers={['qr-loader']} onClick={() => redirectToApp(url)} label={i18n.get(props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <p ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof props.introduction === 'string' ? i18n.get(props.introduction) : props.introduction?.()}\n </p>\n\n <QRLoaderDetailsProvider\n qrCodeImage={qrCodeImage}\n qrCodeData={props.qrCodeData}\n percentage={percentage}\n timeToPay={props.timeToPay}\n copyBtn={props.copyBtn}\n instructions={props.instructions}\n countdownTime={countdownTime}\n onTick={(time: CountdownTime) => onTick(time)}\n onQRCodeLoad={onQrCodeLoad}\n onTimeUp={() => onTimeUp()}\n handleCopy={handleCopy}\n >\n {props.children ? props.children : <QRDetails />}\n </QRLoaderDetailsProvider>\n </div>\n );\n}\n\nQRLoader.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\nexport default QRLoader;\n"],"names":["QRLoader","props","i18n","loadingContext","useCoreContext","completed","setCompleted","useState","delay","setDelay","expired","setExpired","loading","setLoading","percentage","setPercentage","timePassed","setTimePassed","timeoutRef","useRef","checkStatus","async","paymentData","clientKey","throttledInterval","checkPaymentStatus","then","processResponse","catch","response","type","status","state","data","details","payload","onComplete","error","AdyenCheckoutError","onError","useEffect","currentDelay","current","setTimeout","start","performance","now","end","responseTime","Math","round","actualTimePassed","throttleTime","statusInterval","clearTimeout","amount","showAmount","url","brandLogo","brandName","countdownTime","onActionHandled","qrCodeImage","qrCodeData","qrSubtitleRef","useAutoFocus","h","QRFinalState","image","message","get","div","className","img","alt","src","Spinner","classnames","classNameModifiers","map","m","join","value","currency","h1","redirectIntroduction","p","Button","onClick","window","location","assign","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","QRLoaderDetailsProvider","timeToPay","copyBtn","instructions","onTick","time","onQRCodeLoad","componentType","actionDescription","onTimeUp","handleCopy","complete","copyToClipboard","event","AnalyticsInfoEvent","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","onSubmitAnalytics","children","QRDetails","defaultProps"],"mappings":"ghCAuBA,SAASA,EAASC,GACd,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAWC,GAAgBC,GAAS,IACpCC,EAAOC,GAAYF,EAASN,EAAMO,QAClCE,EAASC,GAAcJ,GAAS,IAChCK,EAASC,GAAcN,GAAS,IAChCO,EAAYC,GAAiBR,EAAS,MACtCS,EAAYC,GAAiBV,EAAS,GACvCW,EAAaC,EAAuC,MA+CpDC,EAAcC,UAChB,MAAMC,YAAEA,EAAWC,UAAEA,EAASC,kBAAEA,GAAsBvB,EAEtD,OAAOwB,EAAmBH,EAAaC,EAAWpB,EAAgBqB,GAC7DE,KAAKC,GACLC,MAAMC,IAAAA,CAAeC,KAAM,gBAAiB7B,MAAO4B,KACnDH,KAAMK,IACH,OAAQA,EAAOD,MACX,IAAK,UAxCF,CAACC,IAChBzB,GAAa,GACbO,GAAW,GAEX,MAAMmB,EAAQ,CACVC,KAAM,CACFC,QAAS,CAAEC,QAASJ,EAAO9B,MAAMkC,SACjCb,YAAarB,EAAMqB,cAI3BrB,EAAMmC,WAAWJ,IA8BDI,CAAWL,GACX,MACJ,IAAK,QA7BL,CAACA,IAIb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sByF,CAAOC,GACxCC,aAlES,KACjB5C,IAAkB,CACd6C,cAAezG,EAAM6B,KACrB6E,kBAAmB,oBAgEfC,SAAU,KA7KlBjG,GAAW,QACXV,EAAMsC,QAAQ,IAAID,EAAmB,QAAS,qBA6KtCuE,WA/EQC,IACXC,EAAgB9G,EAAM8D,YAE3B,MAAMiD,EAAQ,IAAIC,EAAmB,CACjCnF,KAAMoF,EACNC,OAAQC,IAEZnH,EAAMoH,kBAAkBL,GACxBF,MAyES7G,EAAMqH,SAAWrH,EAAMqH,SAAWpD,EAACqD,EAAAA,OAIpD,CAEAvH,EAASwH,aAAe,CACpBhH,MAAO,IACPoD,cAAe,GACfrB,QAAS,OACTH,WAAY,OACZgB,aAAc,IACd0B,mBAAoB,GACpBtD,kBAAmB,IACnB0E,aAAc,uBACdE,UAAW,sBACXN,YAAa,UACbtC,YAAY"}
@@ -1,2 +1,2 @@
1
- import{createElement as o}from"../../../../external/preact/dist/preact.js";import e from"../../Countdown/index.js";import{useCoreContext as t}from"../../../../core/Context/CoreProvider.js";const n=({countdownTime:n,timeToPay:r,onTick:i,onCompleted:a})=>{const{i18n:m}=t(),c=m.get(r).split("%@");return o("span",{"aria-live":"polite",className:"adyen-checkout__qr-loader__countdown"},c[0]," ",o(e,{minutesFromNow:n,onTick:i,onCompleted:a})," ",c[1])};export{n as default};
1
+ import{createElement as o}from"../../../../external/preact/dist/preact.js";import e from"../../Countdown/index.js";import{useCoreContext as t}from"../../../../core/Context/CoreProvider.js";const n=({countdownTime:n,timeToPay:r,onTick:m,onCompleted:a})=>{const{i18n:c}=t(),i=c.get(r).split("%@");return o("span",{className:"adyen-checkout__qr-loader__countdown"},i[0]," ",o(e,{minutesFromNow:n,onTick:m,onCompleted:a})," ",i[1])};export{n as default};
2
2
  //# sourceMappingURL=QRCountdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRCountdown.js","sources":["../../../../../../src/components/internal/QRLoader/components/QRCountdown.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Countdown from '../../Countdown';\nimport { QRCountdownProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\nconst QRCountdown = ({ countdownTime, timeToPay, onTick, onCompleted }: QRCountdownProps) => {\n const { i18n } = useCoreContext();\n\n const timeToPayString = i18n.get(timeToPay).split('%@');\n\n return (\n <span aria-live=\"polite\" className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={onTick} onCompleted={onCompleted} />\n &nbsp;{timeToPayString[1]}\n </span>\n );\n};\nexport default QRCountdown;\n"],"names":["QRCountdown","countdownTime","timeToPay","onTick","onCompleted","i18n","useCoreContext","timeToPayString","get","split","h","span","aria-live","className","Countdown","minutesFromNow"],"mappings":"6LAKA,MAAMA,EAAc,EAAGC,gBAAeC,YAAWC,SAAQC,kBACrD,MAAMC,KAAEA,GAASC,IAEXC,EAAkBF,EAAKG,IAAIN,GAAWO,MAAM,MAElD,OACIC,EAACC,OAAAA,CAAKC,YAAU,SAASC,UAAU,wCAC9BN,EAAgB,GAAG,IACpBG,EAACI,EAAAA,CAAUC,eAAgBd,EAAeE,OAAQA,EAAQC,YAAaA,IAAe,IAC/EG,EAAgB"}
1
+ {"version":3,"file":"QRCountdown.js","sources":["../../../../../../src/components/internal/QRLoader/components/QRCountdown.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Countdown from '../../Countdown';\nimport { QRCountdownProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\nconst QRCountdown = ({ countdownTime, timeToPay, onTick, onCompleted }: QRCountdownProps) => {\n const { i18n } = useCoreContext();\n\n const timeToPayString = i18n.get(timeToPay).split('%@');\n\n return (\n <span className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={onTick} onCompleted={onCompleted} />\n &nbsp;{timeToPayString[1]}\n </span>\n );\n};\nexport default QRCountdown;\n"],"names":["QRCountdown","countdownTime","timeToPay","onTick","onCompleted","i18n","useCoreContext","timeToPayString","get","split","h","span","className","Countdown","minutesFromNow"],"mappings":"6LAKA,MAAMA,EAAc,EAAGC,gBAAeC,YAAWC,SAAQC,kBACrD,MAAMC,KAAEA,GAASC,IAEXC,EAAkBF,EAAKG,IAAIN,GAAWO,MAAM,MAElD,OACIC,EAACC,OAAAA,CAAKC,UAAU,wCACXL,EAAgB,GAAG,IACpBG,EAACG,EAAAA,CAAUC,eAAgBb,EAAeE,OAAQA,EAAQC,YAAaA,IAAe,IAC/EG,EAAgB"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../../../core/Context/useImage.js";import{useA11yReporter as o}from"../../../../core/Errors/useA11yReporter.js";const t=({image:t,message:a})=>{const c=r();return o(a),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:c({imageFolder:"components/"})(t),alt:a}),e("p",{className:"adyen-checkout__qr-loader__subtitle"},a))};export{t as QRFinalState};
2
+ //# sourceMappingURL=QRFinalState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRFinalState.js","sources":["../../../../../../src/components/internal/QRLoader/components/QRFinalState.tsx"],"sourcesContent":["import { h } from 'preact';\nimport useImage from '../../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../../core/Errors/useA11yReporter';\n\nexport const QRFinalState = ({ image, message }: { image: string; message: string }) => {\n const getImage = useImage();\n\n useA11yReporter(message);\n\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={message}\n />\n <p className=\"adyen-checkout__qr-loader__subtitle\">{message}</p>\n </div>\n );\n};\n"],"names":["QRFinalState","image","message","getImage","useImage","useA11yReporter","h","div","className","img","src","imageFolder","alt","p"],"mappings":"kNAIaA,EAAe,EAAGC,QAAOC,cAClC,MAAMC,EAAWC,IAIjB,OAFAC,EAAgBH,GAGZI,EAACC,MAAAA,CAAIC,UAAU,+DACXF,EAACG,MAAAA,CACGD,UAAU,0EACVE,IAAKP,EAAS,CAAEQ,YAAa,eAAxBR,CAAyCF,GAC9CW,IAAKV,IAETI,EAACO,IAAAA,CAAEL,UAAU,uCAAuCN"}
@@ -1,2 +1,2 @@
1
- const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",n="6.24.0",o="esm",t=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],r=6e4;export{r as DEFAULT_HTTP_TIMEOUT,e as FALLBACK_CONTEXT,t as GENERIC_OPTIONS,o as LIBRARY_BUNDLE_TYPE,n as LIBRARY_VERSION};
1
+ const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",n="6.25.0",o="esm",t=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],r=6e4;export{r as DEFAULT_HTTP_TIMEOUT,e as FALLBACK_CONTEXT,t as GENERIC_OPTIONS,o as LIBRARY_BUNDLE_TYPE,n as LIBRARY_VERSION};
2
2
  //# sourceMappingURL=config.js.map