@adyen/adyen-web 6.40.2 → 6.41.1

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 (99) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +35 -25
  4. package/dist/es/components/ANCV/ANCV.js +1 -1
  5. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  6. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  7. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  8. package/dist/es/components/Card/Card.js +1 -1
  9. package/dist/es/components/Card/Card.js.map +1 -1
  10. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  11. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  12. package/dist/es/components/Dropin/Dropin.js +1 -1
  13. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  14. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  15. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  16. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  17. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  18. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  19. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  20. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  21. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  22. package/dist/es/components/Giftcard/components/GiftcardPinField.js +1 -1
  23. package/dist/es/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  24. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  25. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  26. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  27. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  28. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  29. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  30. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  31. package/dist/es/components/internal/Address/validate.formats.js +1 -1
  32. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  33. package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
  34. package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
  35. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  36. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  37. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  38. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  39. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  40. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  41. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  42. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  43. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  44. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  45. package/dist/es/core/config.js +1 -1
  46. package/dist/es/index.d.ts +35 -25
  47. package/dist/es/utils/commonUtils.js +1 -1
  48. package/dist/es/utils/commonUtils.js.map +1 -1
  49. package/dist/es/utils/promiseTimeout.js.map +1 -1
  50. package/dist/es/utils/validator-utils.js +1 -1
  51. package/dist/es/utils/validator-utils.js.map +1 -1
  52. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  53. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  54. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  55. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  56. package/dist/es-legacy/components/Card/Card.js +1 -1
  57. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  58. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  59. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  60. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  61. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  62. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  63. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  64. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  65. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  66. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  67. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  68. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  69. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  70. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js +1 -1
  71. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  72. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  73. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  74. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  75. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  76. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  77. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  78. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  79. package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
  80. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  81. package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
  82. package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
  83. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  84. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  85. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  86. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  87. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  88. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  89. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  90. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  91. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  92. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  93. package/dist/es-legacy/core/config.js +1 -1
  94. package/dist/es-legacy/utils/commonUtils.js +1 -1
  95. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  96. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  97. package/dist/es-legacy/utils/validator-utils.js +1 -1
  98. package/dist/es-legacy/utils/validator-utils.js.map +1 -1
  99. package/package.json +19 -19
@@ -1 +1 @@
1
- {"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { Order, OrderStatus } from '../../../../types';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: (order) => void;\n brandLogoConfiguration: any;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div\n className=\"adyen-checkout__payment-method__header__title\"\n role=\"group\"\n id={`order-payment-method-${orderPaymentMethod.type}-${index}`}\n aria-label={\n orderPaymentMethod.lastFour\n ? i18n.get('order.paymentMethod.description', {\n values: {\n name: orderPaymentMethod.name ?? orderPaymentMethod.type,\n lastFour: orderPaymentMethod.lastFour.toString().split('').join(' ')\n }\n })\n : undefined\n }\n >\n <PaymentMethodIcon\n alt={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <Button\n inline\n variant=\"link\"\n id={`order-payment-method-remove-${orderPaymentMethod.type}-${index}`}\n ariaLabelledBy={\n orderPaymentMethod.lastFour\n ? `order-payment-method-${orderPaymentMethod.type}-${index} order-payment-method-remove-${orderPaymentMethod.type}-${index}`\n : undefined\n }\n label={i18n.get('storedPaymentMethod.disable.button')}\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n onClick={() => {\n onOrderCancel({ order });\n }}\n />\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</span>\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </span>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <p className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </p>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","role","id","aria-label","lastFour","get","values","name","toString","split","join","undefined","PaymentMethodIcon","alt","src","label","Button","inline","variant","ariaLabelledBy","onKeyPress","stopPropagationForActionKeys","onKeyDown","onClick","span","amount","value","currency","remainingAmount","p","strong"],"mappings":"yYAgBO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BAOxDF,IAAAA,EANb,MAAMG,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,SAA2B,QAA3BA,EAAAA,EAAaW,0BAAbX,SAAAA,EAA6BY,IAAI,CAACC,EAAoBC,KAWfD,IAAAA,SAVpCN,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CACGE,UAAU,gDACVQ,KAAK,QACLC,GAAI,wBAAwBN,EAAmBI,QAAQH,IACvDM,aACIP,EAAmBQ,SACblB,EAAKmB,IAAI,kCAAmC,CACxCC,OAAQ,CACJC,aAAMX,EAAAA,EAAmBW,YAAnBX,IAAAA,EAAAA,EAA2BA,EAAmBI,KACpDI,SAAUR,EAAmBQ,SAASI,WAAWC,MAAM,IAAIC,KAAK,aAGxEC,GAGVrB,EAACsB,EAAAA,CACGC,IAAKjB,EAAmBW,KACxBP,KAAMJ,EAAmBI,KACzBc,IAAK7B,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QAEzFJ,EAAmBmB,MAAQ,GAAGnB,EAAmBmB,QAAU,QAAQnB,EAAmBQ,YAG1FpB,GACGM,EAAC0B,EAAAA,CACGC,QAAAA,EACAC,QAAQ,OACRhB,GAAI,+BAA+BN,EAAmBI,QAAQH,IAC9DsB,eACIvB,EAAmBQ,SACb,wBAAwBR,EAAmBI,QAAQH,iCAAqCD,EAAmBI,QAAQH,SACnHc,EAEVI,MAAO7B,EAAKmB,IAAI,sCAChBe,WAAYC,EACZC,UAAWD,EACXE,QAAS,KACLvC,EAAc,CAAEF,cAKhCQ,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACkC,OAAAA,CAAK/B,UAAU,gEAAgEP,EAAKmB,IAAI,oBACzFf,EAACkC,OAAAA,CAAK/B,UAAU,gEACXP,EAAKuC,OAAO7B,EAAmB6B,OAAOC,MAAO9B,EAAmB6B,OAAOE,iBAQ/F5C,EAAY6C,iBACTtC,EAACuC,IAAAA,CAAEpC,UAAU,0CACRP,EAAKmB,IAAI,0BAA2B,IACrCf,EAACwC,cAAQ5C,EAAKuC,OAAO1C,EAAY6C,gBAAgBF,MAAO3C,EAAY6C,gBAAgBD"}
1
+ {"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { BrandConfiguration, onOrderCancelInternalCallback, Order, OrderStatus } from '../../../../types';\nimport { stopPropagationForActionKeys } from '../../../internal/Button/stopPropagationForActionKeys';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: onOrderCancelInternalCallback;\n brandLogoConfiguration: BrandConfiguration;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: Readonly<OrderPaymentMethodsProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div\n className=\"adyen-checkout__payment-method__header__title\"\n role=\"group\"\n id={`order-payment-method-${orderPaymentMethod.type}-${index}`}\n aria-label={\n orderPaymentMethod.lastFour\n ? i18n.get('order.paymentMethod.description', {\n values: {\n name: orderPaymentMethod.name ?? orderPaymentMethod.type,\n lastFour: orderPaymentMethod.lastFour.toString().split('').join(' ')\n }\n })\n : undefined\n }\n >\n <PaymentMethodIcon\n alt={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <Button\n inline\n variant=\"link\"\n id={`order-payment-method-remove-${orderPaymentMethod.type}-${index}`}\n ariaLabelledBy={\n orderPaymentMethod.lastFour\n ? `order-payment-method-${orderPaymentMethod.type}-${index} order-payment-method-remove-${orderPaymentMethod.type}-${index}`\n : undefined\n }\n label={i18n.get('storedPaymentMethod.disable.button')}\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n onClick={() => {\n onOrderCancel({ order });\n }}\n />\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</span>\n <span className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </span>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <p className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </p>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","role","id","aria-label","lastFour","get","values","name","toString","split","join","undefined","PaymentMethodIcon","alt","src","label","Button","inline","variant","ariaLabelledBy","onKeyPress","stopPropagationForActionKeys","onKeyDown","onClick","span","amount","value","currency","remainingAmount","p","strong"],"mappings":"yYAgBO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BAOxDF,IAAAA,EANb,MAAMG,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,SAA2B,QAA3BA,EAAAA,EAAaW,0BAAbX,SAAAA,EAA6BY,IAAI,CAACC,EAAoBC,KAWfD,IAAAA,SAVpCN,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CACGE,UAAU,gDACVQ,KAAK,QACLC,GAAI,wBAAwBN,EAAmBI,QAAQH,IACvDM,aACIP,EAAmBQ,SACblB,EAAKmB,IAAI,kCAAmC,CACxCC,OAAQ,CACJC,aAAMX,EAAAA,EAAmBW,YAAnBX,IAAAA,EAAAA,EAA2BA,EAAmBI,KACpDI,SAAUR,EAAmBQ,SAASI,WAAWC,MAAM,IAAIC,KAAK,aAGxEC,GAGVrB,EAACsB,EAAAA,CACGC,IAAKjB,EAAmBW,KACxBP,KAAMJ,EAAmBI,KACzBc,IAAK7B,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QAEzFJ,EAAmBmB,MAAQ,GAAGnB,EAAmBmB,QAAU,QAAQnB,EAAmBQ,YAG1FpB,GACGM,EAAC0B,EAAAA,CACGC,QAAAA,EACAC,QAAQ,OACRhB,GAAI,+BAA+BN,EAAmBI,QAAQH,IAC9DsB,eACIvB,EAAmBQ,SACb,wBAAwBR,EAAmBI,QAAQH,iCAAqCD,EAAmBI,QAAQH,SACnHc,EAEVI,MAAO7B,EAAKmB,IAAI,sCAChBe,WAAYC,EACZC,UAAWD,EACXE,QAAS,KACLvC,EAAc,CAAEF,cAKhCQ,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACkC,OAAAA,CAAK/B,UAAU,gEAAgEP,EAAKmB,IAAI,oBACzFf,EAACkC,OAAAA,CAAK/B,UAAU,gEACXP,EAAKuC,OAAO7B,EAAmB6B,OAAOC,MAAO9B,EAAmB6B,OAAOE,iBAQ/F5C,EAAY6C,iBACTtC,EAACuC,IAAAA,CAAEpC,UAAU,0CACRP,EAAKmB,IAAI,0BAA2B,IACrCf,EAACwC,cAAQ5C,EAAKuC,OAAO1C,EAAY6C,gBAAgBF,MAAO3C,EAAY6C,gBAAgBD"}
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentMethodList.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport UIElement from '../../../internal/UIElement/UIElement';\nimport { Order, OrderStatus } from '../../../../types/global-types';\nimport OrderPaymentMethods from './OrderPaymentMethods';\nimport { InstantPaymentMethods } from './InstantPaymentMethods';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useBrandLogoConfiguration } from './useBrandLogoConfiguration';\nimport PaymentMethodsContainer, { PaymentMethodsContainerProps } from './PaymentMethodsContainer';\nimport { useEffect } from 'preact/hooks';\n\ninterface PaymentMethodListProps extends Omit<PaymentMethodsContainerProps, 'label' | 'classNameModifiers'> {\n instantPaymentMethods?: UIElement[];\n storedPaymentMethods?: UIElement[];\n openFirstStoredPaymentMethod?: boolean;\n openFirstPaymentMethod?: boolean;\n openPaymentMethod?: {\n type: string;\n };\n order?: Order;\n orderStatus?: OrderStatus;\n onOrderCancel?: (order) => void;\n}\n\nconst PaymentMethodList = ({\n paymentMethods,\n instantPaymentMethods,\n storedPaymentMethods,\n openFirstStoredPaymentMethod,\n openFirstPaymentMethod,\n openPaymentMethod,\n order,\n orderStatus = null,\n onOrderCancel,\n onSelect = () => {},\n ...rest\n}: Readonly<PaymentMethodListProps>) => {\n const { i18n } = useCoreContext();\n const brandLogoConfiguration = useBrandLogoConfiguration(paymentMethods);\n const hasInstantPaymentMethods = instantPaymentMethods?.length > 0;\n const hasStoredPaymentMethods = storedPaymentMethods?.length > 0;\n const pmListLabel = hasInstantPaymentMethods || hasStoredPaymentMethods ? i18n.get('paymentMethodsList.otherPayments.label') : '';\n\n useEffect(() => {\n if (openPaymentMethod?.type) {\n const paymentMethod = paymentMethods?.find(paymentMethod => paymentMethod.type === openPaymentMethod?.type);\n if (!paymentMethod) {\n console.warn(`Drop-in: payment method type \"${openPaymentMethod?.type}\" not found`);\n } else {\n onSelect(paymentMethod);\n return;\n }\n }\n\n // Open first PaymentMethodItem\n const firstStoredPayment = storedPaymentMethods?.[0];\n const firstNonStoredPayment = paymentMethods?.[0];\n\n if (firstStoredPayment || firstNonStoredPayment) {\n const shouldOpenFirstStored = openFirstStoredPaymentMethod && firstStoredPayment?.props?.oneClick === true;\n if (shouldOpenFirstStored) {\n onSelect(firstStoredPayment);\n return;\n }\n\n if (openFirstPaymentMethod) {\n onSelect(firstNonStoredPayment);\n }\n }\n }, [storedPaymentMethods, paymentMethods, openFirstStoredPaymentMethod, openFirstPaymentMethod, openPaymentMethod]);\n\n return (\n <Fragment>\n {orderStatus && (\n <OrderPaymentMethods\n order={order}\n orderStatus={orderStatus}\n onOrderCancel={onOrderCancel}\n brandLogoConfiguration={brandLogoConfiguration}\n />\n )}\n\n {hasInstantPaymentMethods && <InstantPaymentMethods paymentMethods={instantPaymentMethods} onSelect={onSelect} />}\n\n {hasStoredPaymentMethods && (\n <PaymentMethodsContainer\n {...rest}\n label={i18n.get('paymentMethodsList.storedPayments.label')}\n classNameModifiers={['storedPayments']}\n paymentMethods={storedPaymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n\n {!!paymentMethods.length && (\n <PaymentMethodsContainer\n {...rest}\n label={pmListLabel}\n classNameModifiers={['otherPayments']}\n paymentMethods={paymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n </Fragment>\n );\n};\n\nexport default PaymentMethodList;\n"],"names":["PaymentMethodList","_0","paymentMethods","instantPaymentMethods","storedPaymentMethods","openFirstStoredPaymentMethod","openFirstPaymentMethod","openPaymentMethod","order","orderStatus","onOrderCancel","onSelect","rest","i18n","useCoreContext","brandLogoConfiguration","useBrandLogoConfiguration","hasInstantPaymentMethods","length","hasStoredPaymentMethods","pmListLabel","get","useEffect","type","paymentMethod","find","console","warn","firstStoredPayment","firstNonStoredPayment","props","oneClick","h","Fragment","OrderPaymentMethods","InstantPaymentMethods","PaymentMethodsContainer","label","classNameModifiers"],"mappings":"04DAuBA,MAAMA,EAAoBC,QAACC,eACvBA,EAAcC,sBACdA,EAAqBC,qBACrBA,EAAoBC,6BACpBA,EAA4BC,uBAC5BA,EAAsBC,kBACtBA,EAAiBC,MACjBA,EAAKC,YACL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AAAA,EACOxB,GAAAA,CACJyB,MAAOjB,EACPkB,mBAAoB,CAAC,iBACrBpC,eAAgBA,EAChBS,SAAUA"}
1
+ {"version":3,"file":"PaymentMethodList.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport UIElement from '../../../internal/UIElement/UIElement';\nimport { Order, OrderStatus } from '../../../../types/global-types';\nimport OrderPaymentMethods from './OrderPaymentMethods';\nimport { InstantPaymentMethods } from './InstantPaymentMethods';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useBrandLogoConfiguration } from './useBrandLogoConfiguration';\nimport PaymentMethodsContainer, { PaymentMethodsContainerProps } from './PaymentMethodsContainer';\nimport { useEffect } from 'preact/hooks';\nimport { onOrderCancelInternalCallback } from '../../types';\n\ninterface PaymentMethodListProps extends Omit<PaymentMethodsContainerProps, 'label' | 'classNameModifiers'> {\n instantPaymentMethods?: UIElement[];\n storedPaymentMethods?: UIElement[];\n openFirstStoredPaymentMethod?: boolean;\n openFirstPaymentMethod?: boolean;\n openPaymentMethod?: {\n type: string;\n };\n order?: Order;\n orderStatus?: OrderStatus;\n onOrderCancel?: onOrderCancelInternalCallback;\n}\n\nconst PaymentMethodList = ({\n paymentMethods,\n instantPaymentMethods,\n storedPaymentMethods,\n openFirstStoredPaymentMethod,\n openFirstPaymentMethod,\n openPaymentMethod,\n order,\n orderStatus = null,\n onOrderCancel,\n onSelect = () => {},\n ...rest\n}: Readonly<PaymentMethodListProps>) => {\n const { i18n } = useCoreContext();\n const brandLogoConfiguration = useBrandLogoConfiguration(paymentMethods);\n const hasInstantPaymentMethods = instantPaymentMethods?.length > 0;\n const hasStoredPaymentMethods = storedPaymentMethods?.length > 0;\n const pmListLabel = hasInstantPaymentMethods || hasStoredPaymentMethods ? i18n.get('paymentMethodsList.otherPayments.label') : '';\n\n useEffect(() => {\n if (openPaymentMethod?.type) {\n const paymentMethod = paymentMethods?.find(paymentMethod => paymentMethod.type === openPaymentMethod?.type);\n if (!paymentMethod) {\n console.warn(`Drop-in: payment method type \"${openPaymentMethod?.type}\" not found`);\n } else {\n onSelect(paymentMethod);\n return;\n }\n }\n\n // Open first PaymentMethodItem\n const firstStoredPayment = storedPaymentMethods?.[0];\n const firstNonStoredPayment = paymentMethods?.[0];\n\n if (firstStoredPayment || firstNonStoredPayment) {\n const shouldOpenFirstStored = openFirstStoredPaymentMethod && firstStoredPayment?.props?.oneClick === true;\n if (shouldOpenFirstStored) {\n onSelect(firstStoredPayment);\n return;\n }\n\n if (openFirstPaymentMethod) {\n onSelect(firstNonStoredPayment);\n }\n }\n }, [storedPaymentMethods, paymentMethods, openFirstStoredPaymentMethod, openFirstPaymentMethod, openPaymentMethod]);\n\n return (\n <Fragment>\n {orderStatus && (\n <OrderPaymentMethods\n order={order}\n orderStatus={orderStatus}\n onOrderCancel={onOrderCancel}\n brandLogoConfiguration={brandLogoConfiguration}\n />\n )}\n\n {hasInstantPaymentMethods && <InstantPaymentMethods paymentMethods={instantPaymentMethods} onSelect={onSelect} />}\n\n {hasStoredPaymentMethods && (\n <PaymentMethodsContainer\n {...rest}\n label={i18n.get('paymentMethodsList.storedPayments.label')}\n classNameModifiers={['storedPayments']}\n paymentMethods={storedPaymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n\n {!!paymentMethods.length && (\n <PaymentMethodsContainer\n {...rest}\n label={pmListLabel}\n classNameModifiers={['otherPayments']}\n paymentMethods={paymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n </Fragment>\n );\n};\n\nexport default PaymentMethodList;\n"],"names":["PaymentMethodList","_0","paymentMethods","instantPaymentMethods","storedPaymentMethods","openFirstStoredPaymentMethod","openFirstPaymentMethod","openPaymentMethod","order","orderStatus","onOrderCancel","onSelect","rest","i18n","useCoreContext","brandLogoConfiguration","useBrandLogoConfiguration","hasInstantPaymentMethods","length","hasStoredPaymentMethods","pmListLabel","get","useEffect","type","paymentMethod","find","console","warn","firstStoredPayment","firstNonStoredPayment","props","oneClick","h","Fragment","OrderPaymentMethods","InstantPaymentMethods","PaymentMethodsContainer","label","classNameModifiers"],"mappings":"04DAwBA,MAAMA,EAAoBC,QAACC,eACvBA,EAAcC,sBACdA,EAAqBC,qBACrBA,EAAoBC,6BACpBA,EAA4BC,uBAC5BA,EAAsBC,kBACtBA,EAAiBC,MACjBA,EAAKC,YACLA,EAAc,KAAIC,cAClBA,EAAaC,SACbA,EAAW,QAEoBV,EAD5BW,EAAAA,EAAAA,EAAAA,gMAEH,MAAMC,KAAEA,GAASC,IACXC,EAAyBC,EAA0Bd,GACnDe,GAA2Bd,aAAAA,EAAAA,EAAuBe,QAAS,EAC3DC,GAA0Bf,aAAAA,EAAAA,EAAsBc,QAAS,EACzDE,EAAcH,GAA4BE,EAA0BN,EAAKQ,IAAI,0CAA4C,GA8B/H,OA5BAC,EAAU,KACN,GAAIf,aAAAA,EAAAA,EAAmBgB,KAAM,CACzB,MAAMC,EAAgBtB,aAAAA,EAAAA,EAAgBuB,KAAKD,GAAiBA,EAAcD,QAAShB,aAAAA,EAAAA,EAAmBgB,OACtG,GAAKC,EAID,YADAb,EAASa,GAFTE,QAAQC,KAAK,iCAAiCpB,aAAAA,EAAAA,EAAmBgB,kBAKzE,CAGA,MAAMK,EAAqBxB,aAAAA,EAAAA,EAAuB,GAC5CyB,EAAwB3B,aAAAA,EAAAA,EAAiB,GAE/C,GAAI0B,GAAsBC,EAAuB,CACiBD,IAAAA,EAC9D,GAD8BvB,IAAwE,KAAxCuB,SAAyB,QAAzBA,EAAAA,EAAoBE,aAApBF,IAAAA,SAAAA,EAA2BG,UAGrF,YADApB,EAASiB,GAITtB,GACAK,EAASkB,EAEjB,GACD,CAACzB,EAAsBF,EAAgBG,EAA8BC,EAAwBC,IAG5FyB,EAACC,EAAAA,KACIxB,GACGuB,EAACE,EAAAA,CACG1B,MAAOA,EACPC,YAAaA,EACbC,cAAeA,EACfK,uBAAwBA,IAI/BE,GAA4Be,EAACG,EAAAA,CAAsBjC,eAAgBC,EAAuBQ,SAAUA,IAEpGQ,GACGa,EAACI,EAAAA,EAAAA,EAAAA,CAAAA,EACOxB,GAAAA,CACJyB,MAAOxB,EAAKQ,IAAI,2CAChBiB,mBAAoB,CAAC,kBACrBpC,eAAgBE,EAChBO,SAAUA,OAIfT,EAAegB,QACdc,EAACI,EAAAA,EAAAA,EAAAA,CAAAA,EACOxB,GAAAA,CACJyB,MAAOjB,EACPkB,mBAAoB,CAAC,iBACrBpC,eAAgBA,EAChBS,SAAUA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodItem/PaymentMethodItem.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import{useMemo as a}from"../../../../external/preact/hooks/dist/hooks.js";import n from"../../../../utils/uuid.js";import s from"../../../../_virtual/index.js";function i({label:i,classNameModifiers:d=[],paymentMethods:m=[],activePaymentMethod:l=null,isLoading:r=!1,isDisablingPaymentMethod:c=!1,showRemovePaymentMethodButton:h,onDisableStoredPaymentMethod:y=()=>{},onSelect:p,showRadioButton:u}){const{i18n:M}=o(),_=a(()=>`select-${n()}`,[]),P=s(["adyen-checkout__payment-methods-list",{"adyen-checkout__payment-methods-list--loading":r},...d.map(e=>`adyen-checkout__payment-methods-list--${e}`)]),b=1===m.length;return e("div",{className:"adyen-checkout-payment-methods-container"},!!i&&e("label",{htmlFor:_,className:"adyen-checkout-payment-methods-list-label"},i),e("div",{id:_,className:P,role:b?void 0:"radiogroup","aria-label":b?void 0:M.get("paymentMethodsList.aria.label")},m.map((o,a,n)=>{const i=l&&l._id===o._id,d=l&&n[a+1]&&l._id===n[a+1]._id;return e(t,{className:s({"adyen-checkout__payment-method--next-selected":d}),standalone:b,paymentMethod:o,isSelected:i,isDisablingPaymentMethod:i&&c,isLoading:r,onSelect:p,key:o._id,showRemovePaymentMethodButton:h,showRadioButton:u,onDisableStoredPaymentMethod:y})})))}export{i as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodItem/PaymentMethodItem.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import{useMemo as a}from"../../../../external/preact/hooks/dist/hooks.js";import n from"../../../../utils/uuid.js";import s from"../../../../_virtual/index.js";function i({label:i,classNameModifiers:d=[],paymentMethods:m=[],activePaymentMethod:l=null,isLoading:r=!1,isDisablingPaymentMethod:c=!1,showRemovePaymentMethodButton:h,onDisableStoredPaymentMethod:y=()=>{},onSelect:p,showRadioButton:u}){const{i18n:M}=o(),_=a(()=>`select-${n()}`,[]),v=s(["adyen-checkout__payment-methods-list",{"adyen-checkout__payment-methods-list--loading":r},...d.map(e=>`adyen-checkout__payment-methods-list--${e}`)]),P=1===m.length;return e("div",{className:"adyen-checkout-payment-methods-container"},!!i&&e("label",{htmlFor:_,className:"adyen-checkout-payment-methods-list-label"},i),e("div",{id:_,className:v,role:P?void 0:"radiogroup","aria-label":P?void 0:M.get("paymentMethodsList.aria.label")},m.map((o,a,n)=>{const i=(null==l?void 0:l._id)===o._id,d=l&&n[a+1]&&l._id===n[a+1]._id;return e(t,{className:s({"adyen-checkout__payment-method--next-selected":d}),standalone:P,paymentMethod:o,isSelected:i,isDisablingPaymentMethod:i&&c,isLoading:r,onSelect:p,key:o._id,showRemovePaymentMethodButton:h,showRadioButton:u,onDisableStoredPaymentMethod:y})})))}export{i as default};
2
2
  //# sourceMappingURL=PaymentMethodsContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentMethodsContainer.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodItem from './PaymentMethodItem/PaymentMethodItem';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useMemo } from 'preact/hooks';\nimport uuid from '../../../../utils/uuid';\nimport classNames from 'classnames';\nimport UIElement from '../../../internal/UIElement';\n\nexport interface PaymentMethodsContainerProps {\n label?: string;\n classNameModifiers?: string[];\n paymentMethods: UIElement[];\n activePaymentMethod?: UIElement;\n showRemovePaymentMethodButton?: boolean;\n onSelect?: (paymentMethod: UIElement) => void;\n onDisableStoredPaymentMethod?: (storedPaymentMethod) => void;\n isDisablingPaymentMethod?: boolean;\n isLoading: boolean;\n showRadioButton?: boolean;\n}\n\nfunction PaymentMethodsContainer({\n label,\n classNameModifiers = [],\n paymentMethods = [],\n activePaymentMethod = null,\n isLoading = false,\n isDisablingPaymentMethod = false,\n showRemovePaymentMethodButton,\n onDisableStoredPaymentMethod = () => {},\n onSelect,\n showRadioButton\n}: Readonly<PaymentMethodsContainerProps>) {\n const { i18n } = useCoreContext();\n const selectListId: string = useMemo(() => `select-${uuid()}`, []);\n const paymentMethodListClassnames = classNames([\n 'adyen-checkout__payment-methods-list',\n { 'adyen-checkout__payment-methods-list--loading': isLoading },\n ...classNameModifiers.map(m => `adyen-checkout__payment-methods-list--${m}`)\n ]);\n\n const standalone = paymentMethods.length === 1;\n\n return (\n <div className=\"adyen-checkout-payment-methods-container\">\n {!!label && (\n <label htmlFor={selectListId} className=\"adyen-checkout-payment-methods-list-label\">\n {label}\n </label>\n )}\n <div\n id={selectListId}\n className={paymentMethodListClassnames}\n role={standalone ? undefined : 'radiogroup'}\n aria-label={standalone ? undefined : i18n.get('paymentMethodsList.aria.label')}\n >\n {paymentMethods.map((paymentMethod, index, paymentMethodsCollection) => {\n const isSelected = activePaymentMethod && activePaymentMethod._id === paymentMethod._id;\n const isNextOneSelected =\n activePaymentMethod &&\n paymentMethodsCollection[index + 1] &&\n activePaymentMethod._id === paymentMethodsCollection[index + 1]._id;\n\n return (\n <PaymentMethodItem\n className={classNames({ 'adyen-checkout__payment-method--next-selected': isNextOneSelected })}\n standalone={standalone}\n paymentMethod={paymentMethod}\n isSelected={isSelected}\n isDisablingPaymentMethod={isSelected && isDisablingPaymentMethod}\n isLoading={isLoading}\n onSelect={onSelect}\n key={paymentMethod._id}\n showRemovePaymentMethodButton={showRemovePaymentMethodButton}\n showRadioButton={showRadioButton}\n onDisableStoredPaymentMethod={onDisableStoredPaymentMethod}\n />\n );\n })}\n </div>\n </div>\n );\n}\n\nexport default PaymentMethodsContainer;\n"],"names":["PaymentMethodsContainer","label","classNameModifiers","paymentMethods","activePaymentMethod","isLoading","isDisablingPaymentMethod","showRemovePaymentMethodButton","onDisableStoredPaymentMethod","onSelect","showRadioButton","i18n","useCoreContext","selectListId","useMemo","uuid","paymentMethodListClassnames","classNames","map","m","standalone","length","h","div","className","htmlFor","id","role","undefined","aria-label","get","paymentMethod","index","paymentMethodsCollection","isSelected","_id","isNextOneSelected","PaymentMethodItem","key"],"mappings":"6WAqBA,SAASA,GAAwBC,MAC7BA,EAAKC,mBACLA,EAAqB,GAAEC,eACvBA,EAAiB,GAAEC,oBACnBA,EAAsB,KAAIC,UAC1BA,GAAY,EAAKC,yBACjBA,GAA2B,EAAKC,8BAChCA,EAA6BC,6BAC7BA,EAA+B,OAAQC,SACvCA,EAAQC,gBACRA,IAEA,MAAMC,KAAEA,GAASC,IACXC,EAAuBC,EAAQ,IAAM,UAAUC,MAAU,IACzDC,EAA8BC,EAAW,CAC3C,uCACA,CAAE,gDAAiDZ,MAChDH,EAAmBgB,IAAIC,GAAK,yCAAyCA,OAGtEC,EAAuC,IAA1BjB,EAAekB,OAElC,OACIC,EAACC,MAAAA,CAAIC,UAAU,8CACRvB,GACCqB,EAACrB,QAAAA,CAAMwB,QAASZ,EAAcW,UAAU,6CACnCvB,GAGTqB,EAACC,MAAAA,CACGG,GAAIb,EACJW,UAAWR,EACXW,KAAMP,OAAaQ,EAAY,aAC/BC,aAAYT,OAAaQ,EAAYjB,EAAKmB,IAAI,kCAE7C3B,EAAee,IAAI,CAACa,EAAeC,EAAOC,KACvC,MAAMC,EAAa9B,GAAuBA,EAAoB+B,MAAQJ,EAAcI,IAC9EC,EACFhC,GACA6B,EAAyBD,EAAQ,IACjC5B,EAAoB+B,MAAQF,EAAyBD,EAAQ,GAAGG,IAEpE,OACIb,EAACe,EAAAA,CACGb,UAAWP,EAAW,CAAE,gDAAiDmB,IACzEhB,WAAYA,EACZW,cAAeA,EACfG,WAAYA,EACZ5B,yBAA0B4B,GAAc5B,EACxCD,UAAWA,EACXI,SAAUA,EACV6B,IAAKP,EAAcI,IACnB5B,8BAA+BA,EAC/BG,gBAAiBA,EACjBF,6BAA8BA,OAO1D"}
1
+ {"version":3,"file":"PaymentMethodsContainer.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodItem from './PaymentMethodItem/PaymentMethodItem';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useMemo } from 'preact/hooks';\nimport uuid from '../../../../utils/uuid';\nimport classNames from 'classnames';\nimport UIElement from '../../../internal/UIElement';\n\nexport interface PaymentMethodsContainerProps {\n label?: string;\n classNameModifiers?: string[];\n paymentMethods: UIElement[];\n activePaymentMethod?: UIElement;\n showRemovePaymentMethodButton?: boolean;\n onSelect?: (paymentMethod: UIElement) => void;\n onDisableStoredPaymentMethod?: (storedPaymentMethod) => void;\n isDisablingPaymentMethod?: boolean;\n isLoading: boolean;\n showRadioButton?: boolean;\n}\n\nfunction PaymentMethodsContainer({\n label,\n classNameModifiers = [],\n paymentMethods = [],\n activePaymentMethod = null,\n isLoading = false,\n isDisablingPaymentMethod = false,\n showRemovePaymentMethodButton,\n onDisableStoredPaymentMethod = () => {},\n onSelect,\n showRadioButton\n}: Readonly<PaymentMethodsContainerProps>) {\n const { i18n } = useCoreContext();\n const selectListId: string = useMemo(() => `select-${uuid()}`, []);\n const paymentMethodListClassnames = classNames([\n 'adyen-checkout__payment-methods-list',\n { 'adyen-checkout__payment-methods-list--loading': isLoading },\n ...classNameModifiers.map(m => `adyen-checkout__payment-methods-list--${m}`)\n ]);\n\n const standalone = paymentMethods.length === 1;\n\n return (\n <div className=\"adyen-checkout-payment-methods-container\">\n {!!label && (\n <label htmlFor={selectListId} className=\"adyen-checkout-payment-methods-list-label\">\n {label}\n </label>\n )}\n <div\n id={selectListId}\n className={paymentMethodListClassnames}\n role={standalone ? undefined : 'radiogroup'}\n aria-label={standalone ? undefined : i18n.get('paymentMethodsList.aria.label')}\n >\n {paymentMethods.map((paymentMethod, index, paymentMethodsCollection) => {\n const isSelected: boolean = activePaymentMethod?._id === paymentMethod._id;\n const isNextOneSelected =\n activePaymentMethod &&\n paymentMethodsCollection[index + 1] &&\n activePaymentMethod._id === paymentMethodsCollection[index + 1]._id;\n\n return (\n <PaymentMethodItem\n className={classNames({ 'adyen-checkout__payment-method--next-selected': isNextOneSelected })}\n standalone={standalone}\n paymentMethod={paymentMethod}\n isSelected={isSelected}\n isDisablingPaymentMethod={isSelected && isDisablingPaymentMethod}\n isLoading={isLoading}\n onSelect={onSelect}\n key={paymentMethod._id}\n showRemovePaymentMethodButton={showRemovePaymentMethodButton}\n showRadioButton={showRadioButton}\n onDisableStoredPaymentMethod={onDisableStoredPaymentMethod}\n />\n );\n })}\n </div>\n </div>\n );\n}\n\nexport default PaymentMethodsContainer;\n"],"names":["PaymentMethodsContainer","label","classNameModifiers","paymentMethods","activePaymentMethod","isLoading","isDisablingPaymentMethod","showRemovePaymentMethodButton","onDisableStoredPaymentMethod","onSelect","showRadioButton","i18n","useCoreContext","selectListId","useMemo","uuid","paymentMethodListClassnames","classNames","map","m","standalone","length","h","div","className","htmlFor","id","role","undefined","aria-label","get","paymentMethod","index","paymentMethodsCollection","isSelected","_id","isNextOneSelected","PaymentMethodItem","key"],"mappings":"6WAqBA,SAASA,GAAwBC,MAC7BA,EAAKC,mBACLA,EAAqB,GAAEC,eACvBA,EAAiB,GAAEC,oBACnBA,EAAsB,KAAIC,UAC1BA,GAAY,EAAKC,yBACjBA,GAA2B,EAAKC,8BAChCA,EAA6BC,6BAC7BA,EAA+B,OAAQC,SACvCA,EAAQC,gBACRA,IAEA,MAAMC,KAAEA,GAASC,IACXC,EAAuBC,EAAQ,IAAM,UAAUC,MAAU,IACzDC,EAA8BC,EAAW,CAC3C,uCACA,CAAE,gDAAiDZ,MAChDH,EAAmBgB,IAAIC,GAAK,yCAAyCA,OAGtEC,EAAuC,IAA1BjB,EAAekB,OAElC,OACIC,EAACC,MAAAA,CAAIC,UAAU,8CACRvB,GACCqB,EAACrB,QAAAA,CAAMwB,QAASZ,EAAcW,UAAU,6CACnCvB,GAGTqB,EAACC,MAAAA,CACGG,GAAIb,EACJW,UAAWR,EACXW,KAAMP,OAAaQ,EAAY,aAC/BC,aAAYT,OAAaQ,EAAYjB,EAAKmB,IAAI,kCAE7C3B,EAAee,IAAI,CAACa,EAAeC,EAAOC,KACvC,MAAMC,GAAsB9B,aAAAA,EAAAA,EAAqB+B,OAAQJ,EAAcI,IACjEC,EACFhC,GACA6B,EAAyBD,EAAQ,IACjC5B,EAAoB+B,MAAQF,EAAyBD,EAAQ,GAAGG,IAEpE,OACIb,EAACe,EAAAA,CACGb,UAAWP,EAAW,CAAE,gDAAiDmB,IACzEhB,WAAYA,EACZW,cAAeA,EACfG,WAAYA,EACZ5B,yBAA0B4B,GAAc5B,EACxCD,UAAWA,EACXI,SAAUA,EACV6B,IAAKP,EAAcI,IACnB5B,8BAA+BA,EAC/BG,gBAAiBA,EACjBF,6BAA8BA,OAO1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"snCAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,OAAOC,EAAA,CAAA,EACAD,eAAAA,EAAOE,cACPF,EAEX,CAEAG,UAAAA,OAKiCC,EACEC,EAL/B,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKR,MAAMU,MAClBC,oBAAoC,QAAfP,EAAAI,KAAKI,MAAMC,YAAX,IAAAT,OAAA,EAAAA,EAAiBO,oBACtCG,sBAAsC,QAAfT,EAAAG,KAAKI,MAAMC,YAAX,IAAAR,OAAA,EAAAA,EAAiBS,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,M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,GAJAtD,KAAKmB,aAAakD,WAAW,CAAEhB,UAASC,qBACxCtD,KAAKmD,UAAU,UAGXnD,KAAKR,MAAMwC,cAAf,CAIA,IAAKhC,KAAKR,MAAM8E,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIxB,QAAc,CAACC,EAASC,KACnB7C,KAAKR,MAAM8E,wBAAwB1B,EAASC,KAGhDO,KAAK,IAAMpD,KAAKyB,kBAEhBuC,MAAM,OAbf,IA6BJvB,EAAAzC,KAAmBqC,YAAa7C,GACrBoC,EAAC2C,EAAc/E,KA5J1BiD,EADSpD,EACcU,OAAmByE,EAAWC,UAIrDhC,EALSpD,EAKiBqF,eAAe,CACrChE,oBAAqB,CAAA"}
1
+ {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"snCAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,OAAOC,EAAA,CAAA,EACAD,eAAAA,EAAOE,cACPF,EAEX,CAEAG,UAAAA,OAKiCC,EACEC,EAL/B,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKR,MAAMU,MAClBC,oBAAoC,QAAfP,EAAAI,KAAKI,MAAMC,YAAX,IAAAT,OAAA,EAAAA,EAAiBO,oBACtCG,sBAAsC,QAAfT,EAAAG,KAAKI,MAAMC,YAAX,IAAAR,OAAA,EAAAA,EAAiBS,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACO,IAAAC,EAAP,eAAOA,EAAAT,KAAKR,MAAMkB,oBAAoBV,KAAKR,MAAMU,cAA1C,IAAAO,SAAAA,EAAkDD,OAAQR,KAAKR,MAAMgB,MAAQR,KAAKW,UAAUC,UAAfZ,CAA0BA,KAAKR,MAAMU,MAC7H,CAEA,eAAIW,GACO,IAAAJ,EAAP,OAAuD,QAAhDA,EAAAT,KAAKR,MAAMkB,oBAAoBV,KAAKR,MAAMU,cAA1C,IAAAO,OAAA,EAAAA,EAAkDK,OAAQd,KAAKR,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EAAc/E,KA5J1BiD,EADSpD,EACcU,OAAmByE,EAAWC,UAIrDhC,EALSpD,EAKiBqF,eAAe,CACrChE,oBAAqB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, any>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, any> {\n const balanceCheckErrors: Record<string, any> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","hasEnoughBalance","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"k3CA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA0C,CAAA,EAMhD,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc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AAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK2C,wBAAwBhE,EACjC,IAGJ4D,OAAOe,iBAAiB,SAIpBC,EAHAvD,KAAK8C,SAAS,CAAEvD,cAAc,IAGtB,QAARgE,EAAAvD,KAAKC,eAALsD,GAAAA,EAAUD,mBAGdf,EAAAvC,KAAOD,kBAAmByD,IACtBxD,KAAK8C,SAAS,CAAEvD,aAAciE,OA1GlCjB,EAbEhE,EAaqBkF,eAAe,CAClCvB,aAAa,EACbwB,oBAAoB,EACpBlC,SAAU,OACVC,QAAS,OACT0B,OAAQ,OACRlB,sBAAuB0B"}
1
+ {"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, GiftCardValidationError>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","hasEnoughBalance","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"k3CA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA8D,CAAA,EAMpE,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc,aAAc,kBAAkBC,SAASD,EACnE,CA2BAE,MAAAA,CAAOC,GAAOC,eAAEA,EAAcC,QAAEA,EAAOC,iBAAEA,EAAgBC,aAAEA,EAAYC,kBAAEA,IACrE,MAAMC,KAAEA,GAASC,KACXC,OAAEA,GAAWC,IAGnBC,EAA4B,CACxBC,OAAQN,EACRD,eACAQ,gBAAiBC,KAAKD,gBACtBE,IAAKD,KAAKC,MAGd,MAAMC,GAAoBZ,aAAAA,EAAAA,EAAkBa,QAAQd,aAAAA,EAAAA,EAASc,OAAQb,EAAmBD,EAClFe,GAAmBF,eAAAA,EAAmBC,SAASR,aAAAA,EAAAA,EAAQQ,OAE7D,GAAID,GAAqBE,EACrB,OACIC,EAACC,EAAAA,CACGjB,QAASA,EACTC,iBAAkBA,EAClBiB,YAAapB,EAAMoB,YACnBvB,OAAQgB,KAAKQ,MAAMxB,OACnByB,iBAAkBtB,EAAMsB,iBACxBC,cAAeV,KAAKb,MAAMuB,cAC1BC,UAAWX,KAAKb,MAAMwB,YAKlC,MAAMC,EAAsBC,GACpBA,EAASf,OAAOgB,oBAA4BrB,EAAKsB,IAAIF,EAASf,OAAOgB,qBAIrEtB,EAAkBsB,oBACXrB,EAAKsB,IAAIvB,EAAkBsB,oBAAoBjC,cAGnD,KAGX,OACIwB,EAACW,MAAAA,CAAIC,UAAU,4BACY,UAAtBjB,KAAKQ,MAAMxB,QAAsBqB,EAACa,EAAAA,CAAMC,KAAM,SAAU1B,EAAKsB,IAAI,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O0B,cAAcsB,IACjBhD,KAAK8C,SAAS,CAAE1D,eAAgB4D,EAAEC,sBAEJ,IAAZD,EAAEE,MAEhBlD,KAAKb,MAAMsC,QAAQuB,GAEnBhD,KAAKb,MAAMgE,OAAOH,KAI1BT,OAAOa,aAAa,EAAG/D,UAASC,uBAC5BU,KAAK8C,SAAS,CAAEzD,UAASC,uBAsC7BiD,EAAAvC,KAAOqD,wBAAyB3E,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK2C,wBAAwBhE,EACjC,IAGJ4D,OAAOe,iBAAiB,SAIpBC,EAHAvD,KAAK8C,SAAS,CAAEvD,cAAc,IAGtB,QAARgE,EAAAvD,KAAKC,eAALsD,GAAAA,EAAUD,mBAGdf,EAAAvC,KAAOD,kBAAmByD,IACtBxD,KAAK8C,SAAS,CAAEvD,aAAciE,OA1GlCjB,EAbEhE,EAaqBkF,eAAe,CAClCvB,aAAa,EACbwB,oBAAoB,EACpBlC,SAAU,OACVC,QAAS,OACT0B,OAAQ,OACRlB,sBAAuB0B"}
@@ -1,2 +1,2 @@
1
- import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as o}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const c=({i18n:c,classNameModifiers:d,sfpState:a,focusedElement:i,setFocusOn:s,label:p=c.get("creditCard.pin.label")})=>n(t,{label:p,classNameModifiers:["pin",...d],errorMessage:a.errors.encryptedSecurityCode&&c.get(a.errors.encryptedSecurityCode),focused:"encryptedSecurityCode"===i,onFocusField:()=>s("encryptedSecurityCode"),dir:"ltr",name:"encryptedSecurityCode",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:o},n(e,{encryptedFieldType:"encryptedSecurityCode","data-info":'{"length":"3-10", "maskInterval": 0}',className:r({"adyen-checkout__input":!0,"adyen-checkout__input--large":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":a.errors.encryptedSecurityCode,"adyen-checkout__input--focus":"encryptedSecurityCode"===i})}));export{c as GiftcardPinField};
1
+ import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as o}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const c=({i18n:c,classNameModifiers:d,sfpState:i,focusedElement:a,setFocusOn:s,label:l=c.get("creditCard.pin.label")})=>{var p,u;return n(t,{label:l,classNameModifiers:["pin",...d],errorMessage:(null===(p=i.errors)||void 0===p?void 0:p.encryptedSecurityCode)&&c.get(i.errors.encryptedSecurityCode),focused:"encryptedSecurityCode"===a,onFocusField:()=>s("encryptedSecurityCode"),dir:"ltr",name:"encryptedSecurityCode",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:o},n(e,{encryptedFieldType:"encryptedSecurityCode","data-info":'{"length":"3-10", "maskInterval": 0}',className:r({"adyen-checkout__input":!0,"adyen-checkout__input--large":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":null===(u=i.errors)||void 0===u?void 0:u.encryptedSecurityCode,"adyen-checkout__input--focus":"encryptedSecurityCode"===a})}))};export{c as GiftcardPinField};
2
2
  //# sourceMappingURL=GiftcardPinField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GiftcardPinField.js","sources":["../../../../../src/components/Giftcard/components/GiftcardPinField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from './types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const GiftcardPinField = ({\n i18n,\n classNameModifiers,\n sfpState,\n focusedElement,\n setFocusOn,\n label = i18n.get('creditCard.pin.label')\n}: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={label}\n classNameModifiers={['pin', ...classNameModifiers]}\n errorMessage={sfpState.errors.encryptedSecurityCode && i18n.get(sfpState.errors.encryptedSecurityCode)}\n focused={focusedElement === 'encryptedSecurityCode'}\n onFocusField={() => setFocusOn('encryptedSecurityCode')}\n dir={'ltr'}\n name={'encryptedSecurityCode'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType=\"encryptedSecurityCode\"\n data-info='{\"length\":\"3-10\", \"maskInterval\": 0}'\n className={classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--large': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': sfpState.errors.encryptedSecurityCode,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedSecurityCode'\n })}\n />\n </Field>\n );\n};\n"],"names":["GiftcardPinField","i18n","classNameModifiers","sfpState","focusedElement","setFocusOn","label","get","h","Field","errorMessage","errors","encryptedSecurityCode","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","data-info","className","classNames"],"mappings":"sWAOaA,EAAmB,EAC5BC,OACAC,qBACAC,WACAC,iBACAC,aACAC,QAAQL,EAAKM,IAAI,2BAGbC,EAACC,EAAAA,CACGH,MAAOA,EACPJ,mBAAoB,CAAC,SAAUA,GAC/BQ,aAAcP,EAASQ,OAAOC,uBAAyBX,EAAKM,IAAIJ,EAASQ,OAAOC,uBAChFC,QAA4B,0BAAnBT,EACTU,aAAc,IAAMT,EAAW,yBAC/BU,IAAK,MACLC,KAAM,wBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1BZ,EAACa,EAAAA,CACGC,mBAAmB,wBACnBC,YAAU,uCACVC,UAAWC,EAAW,CAClB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,+BAAgCtB,EAASQ,OAAOC,sBAChD,+BAAmD,0BAAnBR"}
1
+ {"version":3,"file":"GiftcardPinField.js","sources":["../../../../../src/components/Giftcard/components/GiftcardPinField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from './types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const GiftcardPinField = ({\n i18n,\n classNameModifiers,\n sfpState,\n focusedElement,\n setFocusOn,\n label = i18n.get('creditCard.pin.label')\n}: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={label}\n classNameModifiers={['pin', ...classNameModifiers]}\n errorMessage={sfpState.errors?.encryptedSecurityCode && i18n.get(sfpState.errors.encryptedSecurityCode)}\n focused={focusedElement === 'encryptedSecurityCode'}\n onFocusField={() => setFocusOn('encryptedSecurityCode')}\n dir={'ltr'}\n name={'encryptedSecurityCode'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType=\"encryptedSecurityCode\"\n data-info='{\"length\":\"3-10\", \"maskInterval\": 0}'\n className={classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--large': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': sfpState.errors?.encryptedSecurityCode,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedSecurityCode'\n })}\n />\n </Field>\n );\n};\n"],"names":["GiftcardPinField","i18n","classNameModifiers","sfpState","focusedElement","setFocusOn","label","get","h","Field","errorMessage","errors","encryptedSecurityCode","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","data-info","className","classNames"],"mappings":"sWAOaA,EAAmB,EAC5BC,OACAC,qBACAC,WACAC,iBACAC,aACAC,QAAQL,EAAKM,IAAI,gCAMKJ,EAgB0BA,EApBhD,OACIK,EAACC,EAAAA,CACGH,MAAOA,EACPJ,mBAAoB,CAAC,SAAUA,GAC/BQ,sBAAcP,EAAAA,EAASQ,cAATR,IAAAA,OAAAA,EAAAA,EAAiBS,wBAAyBX,EAAKM,IAAIJ,EAASQ,OAAOC,uBACjFC,QAA4B,0BAAnBT,EACTU,aAAc,IAAMT,EAAW,yBAC/BU,IAAK,MACLC,KAAM,wBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1BZ,EAACa,EAAAA,CACGC,mBAAmB,wBACnBC,YAAU,uCACVC,UAAWC,EAAW,CAClB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,+BAA+C,QAAftB,EAAAA,EAASQ,cAATR,IAAAA,SAAAA,EAAiBS,sBACjD,+BAAmD,0BAAnBR"}
@@ -1,2 +1,2 @@
1
- import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as a}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as n}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const p=({i18n:p,sfpState:i,focusedElement:o,setFocusOn:c})=>a(t,{label:p.get("giftcard.expiryDate.label"),classNameModifiers:["expireDate","50"],errorMessage:i.errors.encryptedExpiryDate&&p.get(i.errors.encryptedExpiryDate),focused:"encryptedExpiryDate"===o,onFocusField:()=>c("encryptedExpiryDate"),dir:"ltr",name:"encryptedExpiryDate",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:n},a(e,{encryptedFieldType:"encryptedExpiryDate",className:r("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":i.errors.encryptedExpiryDate,"adyen-checkout__input--focus":"encryptedExpiryDate"===o,"adyen-checkout__input--valid":!!i.valid.encryptedExpiryMonth&&!!i.valid.encryptedExpiryYear})}));export{p as MealVoucherExpiryField};
1
+ import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as a}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const i=({i18n:i,sfpState:o,focusedElement:p,setFocusOn:d})=>{var c,l;return n(t,{label:i.get("giftcard.expiryDate.label"),classNameModifiers:["expireDate","50"],errorMessage:(null===(c=o.errors)||void 0===c?void 0:c.encryptedExpiryDate)&&i.get(o.errors.encryptedExpiryDate),focused:"encryptedExpiryDate"===p,onFocusField:()=>d("encryptedExpiryDate"),dir:"ltr",name:"encryptedExpiryDate",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:a},n(e,{encryptedFieldType:"encryptedExpiryDate",className:r("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":null===(l=o.errors)||void 0===l?void 0:l.encryptedExpiryDate,"adyen-checkout__input--focus":"encryptedExpiryDate"===p,"adyen-checkout__input--valid":!!o.valid.encryptedExpiryMonth&&!!o.valid.encryptedExpiryYear})}))};export{i as MealVoucherExpiryField};
2
2
  //# sourceMappingURL=MealVoucherExpiryField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MealVoucherExpiryField.js","sources":["../../../../../src/components/MealVoucherFR/components/MealVoucherExpiryField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from '../../Giftcard/components/types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const MealVoucherExpiryField = ({ i18n, sfpState, focusedElement, setFocusOn }: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={i18n.get('giftcard.expiryDate.label')}\n classNameModifiers={['expireDate', '50']}\n errorMessage={sfpState.errors.encryptedExpiryDate && i18n.get(sfpState.errors.encryptedExpiryDate)}\n focused={focusedElement === 'encryptedExpiryDate'}\n onFocusField={() => setFocusOn('encryptedExpiryDate')}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType={'encryptedExpiryDate'}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': sfpState.errors.encryptedExpiryDate,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedExpiryDate',\n 'adyen-checkout__input--valid': !!sfpState.valid.encryptedExpiryMonth && !!sfpState.valid.encryptedExpiryYear\n })}\n />\n </Field>\n );\n};\n"],"names":["MealVoucherExpiryField","i18n","sfpState","focusedElement","setFocusOn","h","Field","label","get","classNameModifiers","errorMessage","errors","encryptedExpiryDate","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","className","classNames","valid","encryptedExpiryMonth","encryptedExpiryYear"],"mappings":"gWAOO,MAAMA,EAAyB,EAAGC,OAAMC,WAAUC,iBAAgBC,gBAEjEC,EAACC,EAAAA,CACGC,MAAON,EAAKO,IAAI,6BAChBC,mBAAoB,CAAC,aAAc,MACnCC,aAAcR,EAASS,OAAOC,qBAAuBX,EAAKO,IAAIN,EAASS,OAAOC,qBAC9EC,QAA4B,wBAAnBV,EACTW,aAAc,IAAMV,EAAW,uBAC/BW,IAAK,MACLC,KAAM,sBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1Bf,EAACgB,EAAAA,CACGC,mBAAoB,sBACpBC,UAAWC,EAAW,wBAAyB,+BAAgC,wCAAyC,CACpH,+BAAgCtB,EAASS,OAAOC,oBAChD,+BAAmD,wBAAnBT,EAChC,iCAAkCD,EAASuB,MAAMC,wBAA0BxB,EAASuB,MAAME"}
1
+ {"version":3,"file":"MealVoucherExpiryField.js","sources":["../../../../../src/components/MealVoucherFR/components/MealVoucherExpiryField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from '../../Giftcard/components/types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const MealVoucherExpiryField = ({ i18n, sfpState, focusedElement, setFocusOn }: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={i18n.get('giftcard.expiryDate.label')}\n classNameModifiers={['expireDate', '50']}\n errorMessage={sfpState.errors?.encryptedExpiryDate && i18n.get(sfpState.errors.encryptedExpiryDate)}\n focused={focusedElement === 'encryptedExpiryDate'}\n onFocusField={() => setFocusOn('encryptedExpiryDate')}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType={'encryptedExpiryDate'}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': sfpState.errors?.encryptedExpiryDate,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedExpiryDate',\n 'adyen-checkout__input--valid': !!sfpState.valid.encryptedExpiryMonth && !!sfpState.valid.encryptedExpiryYear\n })}\n />\n </Field>\n );\n};\n"],"names":["MealVoucherExpiryField","i18n","sfpState","focusedElement","setFocusOn","h","Field","label","get","classNameModifiers","errorMessage","errors","encryptedExpiryDate","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","className","classNames","valid","encryptedExpiryMonth","encryptedExpiryYear"],"mappings":"gWAOO,MAAMA,EAAyB,EAAGC,OAAMC,WAAUC,iBAAgBC,qBAK/CF,EAY0BA,EAhBhD,OACIG,EAACC,EAAAA,CACGC,MAAON,EAAKO,IAAI,6BAChBC,mBAAoB,CAAC,aAAc,MACnCC,sBAAcR,EAAAA,EAASS,cAATT,IAAAA,OAAAA,EAAAA,EAAiBU,sBAAuBX,EAAKO,IAAIN,EAASS,OAAOC,qBAC/EC,QAA4B,wBAAnBV,EACTW,aAAc,IAAMV,EAAW,uBAC/BW,IAAK,MACLC,KAAM,sBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1Bf,EAACgB,EAAAA,CACGC,mBAAoB,sBACpBC,UAAWC,EAAW,wBAAyB,+BAAgC,wCAAyC,CACpH,+BAA+C,QAAftB,EAAAA,EAASS,cAATT,IAAAA,SAAAA,EAAiBU,oBACjD,+BAAmD,wBAAnBT,EAChC,iCAAkCD,EAASuB,MAAMC,wBAA0BxB,EAASuB,MAAME"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as s}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import r from"../../../internal/IFrame/Iframe.js";import a from"../../../internal/Spinner/Spinner.js";import n from"../Form/ThreeDS2Form.js";import i from"../../../../utils/get-process-message-handler.js";import{encodeBase64URL as o}from"../utils.js";import l from"../../../../utils/promiseTimeout.js";import{CHALLENGE_TIMEOUT as m,CHALLENGE_TIMEOUT_REJECT_OBJECT as c,THREEDS2_NUM as h}from"../../constants.js";function p(e,s,t){return s in e?Object.defineProperty(e,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[s]=t,e}const d="threeDSIframe";class g extends e{get3DS2ChallengePromise(){return new Promise((e,s)=>{this.processMessageHandler=i(this.props.postMessageDomain,e,s,"challengeResult"),window.addEventListener("message",this.processMessageHandler)})}componentDidMount(){this.challengePromise=l(m,this.get3DS2ChallengePromise(),c),this.challengePromise.promise.then(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onCompleteChallenge(e)}).catch(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onErrorChallenge(e)})}componentWillUnmount(){this.challengePromise&&this.challengePromise.cancel(),window.removeEventListener("message",this.processMessageHandler)}render({acsURL:e,cReqData:i,iframeSizeArr:o,onFormSubmit:l},{base64URLencodedData:m,status:c}){const[h,p]=o;return s("div",{className:t(["adyen-checkout__threeds2__challenge",`adyen-checkout__threeds2__challenge--${i.challengeWindowSize}`])},"iframeLoaded"!==c&&s(a,null),s(r,{name:d,width:h,height:p,callback:this.iframeCallback}),s(n,{name:"cReqForm",action:e,target:d,inputName:"creq",inputValue:m,onFormSubmit:l}))}constructor(e){super(e),p(this,"processMessageHandler",void 0),p(this,"challengePromise",void 0),p(this,"iframeCallback",()=>{var e,s;(this.setState({status:"iframeLoaded"}),"init"===this.state.status)&&(null===(e=(s=this.props).onActionHandled)||void 0===e||e.call(s,{componentType:"3DS2Challenge",actionDescription:`${h} challenge iframe loaded`}))});const s=JSON.stringify(this.props.cReqData),t=o(s);this.state={base64URLencodedData:t,status:"init"}}}export{g as default};
1
+ import{Component as e,createElement as s}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import r from"../../../internal/IFrame/Iframe.js";import a from"../../../internal/Spinner/Spinner.js";import n from"../Form/ThreeDS2Form.js";import i from"../../../../utils/get-process-message-handler.js";import{encodeBase64URL as o}from"../utils.js";import l from"../../../../utils/promiseTimeout.js";import{CHALLENGE_TIMEOUT as m,CHALLENGE_TIMEOUT_REJECT_OBJECT as c,THREEDS2_NUM as h}from"../../constants.js";function p(e,s,t){return s in e?Object.defineProperty(e,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[s]=t,e}const d="threeDSIframe";class g extends e{get3DS2ChallengePromise(){return new Promise((e,s)=>{this.processMessageHandler=i(this.props.postMessageDomain,e,s,"challengeResult"),window.addEventListener("message",this.processMessageHandler)})}componentDidMount(){this.challengePromise=l(m,this.get3DS2ChallengePromise(),c),this.challengePromise.promise.then(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onCompleteChallenge(e)}).catch(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onErrorChallenge(e)})}componentWillUnmount(){this.challengePromise&&this.challengePromise.cancel(),window.removeEventListener("message",this.processMessageHandler)}render({acsURL:e,cReqData:i,iframeSizeArr:o,onFormSubmit:l},{base64URLencodedData:m,status:c}){const[h,p]=o;return s("div",{className:t(["adyen-checkout__threeds2__challenge",`adyen-checkout__threeds2__challenge--${i.challengeWindowSize}`])},"iframeLoaded"!==c&&s(a,null),s(r,{name:d,width:h,height:p,callback:this.iframeCallback}),s(n,{name:"cReqForm",action:e,target:d,inputName:"creq",inputValue:null!=m?m:"",onFormSubmit:l}))}constructor(e){super(e),p(this,"processMessageHandler",void 0),p(this,"challengePromise",void 0),p(this,"iframeCallback",()=>{var e,s;(this.setState({status:"iframeLoaded"}),"init"===this.state.status)&&(null===(e=(s=this.props).onActionHandled)||void 0===e||e.call(s,{componentType:"3DS2Challenge",actionDescription:`${h} challenge iframe loaded`}))});const s=JSON.stringify(this.props.cReqData),t=o(s);this.state={base64URLencodedData:t,status:"init"}}}export{g as default};
2
2
  //# sourceMappingURL=DoChallenge3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler;\n private challengePromise: { cancel: () => void; promise: Promise<any> };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit }, { base64URLencodedData, status }) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe name={iframeName} width={width} height={height} callback={this.iframeCallback} />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","_this_props_onActionHandled","_this_props","setState","state","onActionHandled","call","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","encodeBase64URL"],"mappings":"2pBAYA,MAAMA,EAAa,gBAEnB,MAAMC,UAAwBC,EAwBlBC,uBAAAA,GACJ,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,mBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAAAA,GAEIP,KAAKQ,iBAAmBC,EAAeC,EAAmBV,KAAKJ,0BAA2Be,GAC1FX,KAAKQ,iBAAiBI,QACjBC,KAAMC,IACHT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,oBAAoBF,KAGlCG,MAAOC,IACJb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,iBAAiBD,IAExC,CAEAE,oBAAAA,GACQpB,KAAKQ,kBAAkBR,KAAKQ,iBAAiBa,SACjDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,OAAEA,EAAMC,SAAEA,EAAQC,cAAEA,EAAaC,aAAEA,IAAgBC,qBAAEA,EAAoBC,OAAEA,IAC9E,MAAOC,EAAOC,GAAUL,EAExB,OACIM,EAACC,MAAAA,CACGC,UAAWC,EAAW,CAClB,sCACA,wCAAwCV,EAASW,yBAGzC,iBAAXP,GAA6BG,EAACK,EAAAA,MAE/BL,EAACM,EAAAA,CAAOC,KAAM7C,EAAYoC,MAAOA,EAAOC,OAAQA,EAAQS,SAAUvC,KAAKwC,iBACvET,EAACU,EAAAA,CACGH,KAAM,WACNI,OAAQnB,EACRoB,OAAQlD,EACRmD,UAAW,OACXC,WAAYlB,EACZD,aAAcA,IAI9B,CA1EA,WAAAoB,CAAY3C,GACR4C,MAAM5C,GAJV6C,EAAAhD,KAAQC,6BAAR,GACA+C,EAAAhD,KAAQQ,wBAAR,GAaAwC,EAAAhD,KAAQwC,iBAAiB,SAKjBS,EAAAC,GAJJlD,KAAKmD,SAAS,CAAEvB,OAAQ,iBAGE,SAAtB5B,KAAKoD,MAAMxB,UACe,QAA1BqB,GAAAC,EAAAlD,KAAKG,OAAMkD,uBAAX,IAAAJ,GAAAA,EAAAK,KAAAJ,EAA6B,CAAEK,cAAe,gBAAiBC,kBAAmB,GAAGC,iCAVzF,MAAMC,EAAUC,KAAKC,UAAU5D,KAAKG,MAAMqB,UACpCG,EAAuBkC,EAAgBH,GAC7C1D,KAAKoD,MAAQ,CAAEzB,uBAAsBC,OAAQ,OACjD"}
1
+ {"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler: (event: Pick<MessageEvent, 'origin' | 'data'>) => string | boolean;\n private challengePromise: { promise: Promise<ThreeDS2FlowObject>; cancel: () => void };\n\n constructor(props: DoChallenge3DS2Props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit }: DoChallenge3DS2Props, { base64URLencodedData, status }: DoChallenge3DS2State) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe name={iframeName} width={width} height={height} callback={this.iframeCallback} />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData ?? ''}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","_this_props_onActionHandled","_this_props","setState","state","onActionHandled","call","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","enc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AC,GAJJlD,KAAKmD,SAAS,CAAEvB,OAAQ,iBAGE,SAAtB5B,KAAKoD,MAAMxB,UACe,QAA1BqB,GAAAC,EAAAlD,KAAKG,OAAMkD,uBAAX,IAAAJ,GAAAA,EAAAK,KAAAJ,EAA6B,CAAEK,cAAe,gBAAiBC,kBAAmB,GAAGC,iCAVzF,MAAMC,EAAUC,KAAKC,UAAU5D,KAAKG,MAAMqB,UACpCG,EAAuBkC,EAAgBH,GAC7C1D,KAAKoD,MAAQ,CAAEzB,uBAAsBC,OAAQ,OACjD"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as o,createChallengeResolveData as s,prepareChallengeData as n}from"../utils.js";import i from"../../../internal/Img/Img.js";import{hasOwnProperty as a}from"../../../../utils/hasOwnProperty.js";import l from"../../../../core/Context/useImage.js";import p,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as u,MISSING_TOKEN_IN_ACTION_MSG as h,THREEDS2_NUM as m,THREEDS2_CHALLENGE as g}from"../../constants.js";import{isValidHttpUrl as S}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as d,LogEventSubtype as D,LogEventType as f}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as y,AnalyticsErrorEvent as E,ErrorEventType as b}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function _(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){_(e,r,t[r])})}return e}function T(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}class C extends e{componentDidMount(){if(!o(this.state.challengeData)){var e,r;const t="test"===this.props.environment&&(null===(r=this.props._environmentUrls)||void 0===r||null===(e=r.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{acsURL:o}=this.state.challengeData;if(!S(o,t)){this.setError({errorInfo:`${y.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new E({component:this.props.type,code:y.THREEDS2_TOKEN_IS_MISSING_ACSURL,errorType:b.threeDS2,message:`${u}: Decoded token is missing a valid acsURL property`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: no valid acsURL")}const{acsTransID:s,messageVersion:n,threeDSServerTransID:i}=this.state.challengeData.cReqData;if(!s||!n||!i){this.setError({errorInfo:`${y.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new E({component:this.props.type,code:y.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:b.threeDS2,message:`${u}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(h)?y.THREEDS2_ACTION_IS_MISSING_TOKEN:y.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new E({component:this.props.type,code:r,errorType:b.threeDS2,message:`${u}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=s(this.props.dataKey,e.transStatus,this.props.paymentData);let o;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?y.THREEDS2_TIMEOUT:y.THREEDS2_NO_TRANSSTATUS,errorType:b.threeDS2};o=new E(O({component:this.props.type,message:n.message},e)),this.props.onSubmitAnalytics(o)}let i;switch(null==e?void 0:e.transStatus){case"Y":i="success";break;case"N":i="failed";break;case"U":i=r?"timeout":"cancelled"}(null==e?void 0:e.errorCode)&&(i="noTransStatus"),o=new d({component:this.props.type,type:f.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),this.props.onSubmitAnalytics(o),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new p(c,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:o}){const s=l();return"performingChallenge"===this.state.status?r(t,T(O({onCompleteChallenge:e=>{let r=null;if(a(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${u}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new E({component:this.props.type,code:y.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:b.threeDS2,message:`${u}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(a(e,"errorCode")){const r={errorCode:e.errorCode,message:`${g}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new p(c,`${u}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}}},o),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(i,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:s({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),_(this,"onFormSubmit",e=>{const r=new d({component:this.props.type,type:f.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:h}},console.debug(`${u}: ${h}`)}}_(C,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{C as default};
1
+ import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as o,createChallengeResolveData as s,prepareChallengeData as n}from"../utils.js";import i from"../../../internal/Img/Img.js";import{hasOwnProperty as a}from"../../../../utils/hasOwnProperty.js";import l from"../../../../core/Context/useImage.js";import p,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as h,MISSING_TOKEN_IN_ACTION_MSG as u,THREEDS2_NUM as m,THREEDS2_CHALLENGE as g}from"../../constants.js";import{isValidHttpUrl as S}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as d,LogEventSubtype as D,LogEventType as E}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as f,AnalyticsErrorEvent as y,ErrorEventType as _}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function b(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){b(e,r,t[r])})}return e}function T(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}class I extends e{componentDidMount(){if(!o(this.state.challengeData)){var e,r;const t="test"===this.props.environment&&(null===(r=this.props._environmentUrls)||void 0===r||null===(e=r.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{acsURL:o,postMessageDomain:s}=this.state.challengeData,n=S(o,t),i=S(s,t);if(!n||!i){const e=n?f.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL:f.THREEDS2_TOKEN_IS_MISSING_ACSURL,r=n?"threeDSNotificationURL":"acsURL";this.setError({errorInfo:`${e}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new y({component:this.props.type,code:e,errorType:_.threeDS2,message:`${h}: Decoded token is missing a valid ${r} property`});return this.props.onSubmitAnalytics(t),void console.debug(`### PrepareChallenge3DS2::exiting:: no valid ${r}.${i?"":` postMessageDomain=${s}`}`)}const{acsTransID:a,messageVersion:l,threeDSServerTransID:p}=this.state.challengeData.cReqData;if(!a||!l||!p){this.setError({errorInfo:`${f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new y({component:this.props.type,code:f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:_.threeDS2,message:`${h}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(u)?f.THREEDS2_ACTION_IS_MISSING_TOKEN:f.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new y({component:this.props.type,code:r,errorType:_.threeDS2,message:`${h}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=s(this.props.dataKey,e.transStatus,this.props.paymentData);let o;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?f.THREEDS2_TIMEOUT:f.THREEDS2_NO_TRANSSTATUS,errorType:_.threeDS2};o=new y(O({component:this.props.type,message:n.message},e)),this.props.onSubmitAnalytics(o)}let i;switch(null==e?void 0:e.transStatus){case"Y":i="success";break;case"N":i="failed";break;case"U":i=r?"timeout":"cancelled"}(null==e?void 0:e.errorCode)&&(i="noTransStatus"),o=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),this.props.onSubmitAnalytics(o),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new p(c,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:o}){const s=o,n=l();return"performingChallenge"===this.state.status?r(t,T(O({onCompleteChallenge:e=>{let r=null;if(a(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${h}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new y({component:this.props.type,code:f.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:_.threeDS2,message:`${h}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(a(e,"errorCode")){const r={errorCode:e.errorCode,message:`${g}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new p(c,`${h}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}}},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(i,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:n({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),b(this,"onFormSubmit",e=>{const r=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:u}},console.debug(`${h}: ${u}`)}}b(I,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{I as default};
2
2
  //# sourceMappingURL=PrepareChallenge3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","_object_spread","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"8sDAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,GAAWZ,KAAKC,MAAMC,cAI9B,IAHuBW,EAAeD,EAAQN,GAGzB,CAEjBN,KAAKc,SACD,CACIC,UAAW,GAAGC,EAAeC,qCAAqCjB,KAAKO,MAAMW,KAAKC,IAAI,oBAE1F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWtB,KAAKO,MAAMgB,KACtBC,KAAMR,EAAeC,iCACrBQ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,wDAKhB,OAHA7B,KAAKO,MAAMuB,kBAAkBV,QAE7BW,QAAQC,MAAM,sDAElB,CAEA,MAAMC,WAAEA,EAAUC,eAAEA,EAAcC,qBAAEA,GAA0BnC,KAAKC,MAAMC,cAAgCkC,SAGzG,IAAKH,IAAeC,IAAmBC,EAAs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KAAKO,MAAMgB,KACtBA,KAAMsC,EAAalC,SACnBmC,QAASC,EAAgBwC,qBACzB3E,QAAS0E,IAGbtG,KAAKO,MAAMuB,kBAAkBV,KA1BzBpB,KAAKO,MAAMiG,MAAO,CAClB,MAAMtG,EAA6CuG,EAAqB,CACpED,MAAOxG,KAAKO,MAAMiG,MAClBE,KAAM1G,KAAKO,MAAMoG,qBAAuB3G,KAAKO,MAAMmG,OAGvD1G,KAAKC,MAAQ,CACTsC,OAAQ,OACRrC,gBAER,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAE0G,SAAS,EAAOnE,MAAOE,IAEvDZ,QAAQC,MAAM,GAAGH,MAA6Bc,IAEtD,EAzBA0D,EADEzG,EACqBiH,eAAe,CAClC3C,WAAY,OACZG,QAAS,OACTgB,UAAU"}
1
+ {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL, postMessageDomain } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n\n // Only render component if we have a valid acsURL & postMessageDomain.\n // i.e. a url to load into the iframe, and the domain that we expect the iframe to be sending messages back from\n if (!hasValidAcsURL || !hasValidPostMessageDomain) {\n const errorCode = !hasValidAcsURL\n ? ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL\n : ErrorEventCode.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL;\n const missingProperty = !hasValidAcsURL ? 'acsURL' : 'threeDSNotificationURL';\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid ${missingProperty} property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n `### PrepareChallenge3DS2::exiting:: no valid ${missingProperty}.${!hasValidPostMessageDomain ? ` postMessageDomain=${postMessageDomain}` : ''}`\n );\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData: stateChallengeData }: PrepareChallenge3DS2State) {\n const challengeData = stateChallengeData as ChallengeData;\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","postMessageDomain","hasValidAcsURL","isValidHttpUrl","hasValidPostMessageDomain","errorCode","ErrorEventCode","THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL","THREEDS2_TOKEN_IS_MISSING_ACSURL","missingProperty","setError","errorInfo","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","_object_spread","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","stateChallengeData","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"8sDAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,EAAMC,kBAAEA,GAAsBb,KAAKC,MAAMC,cAC3CY,EAAiBC,EAAeH,EAAQN,GACxCU,EAA4BD,EAAeF,EAAmBP,GAIpE,IAAKQ,IAAmBE,EAA2B,CAC/C,MAAMC,EAAaH,EAEbI,EAAeC,2DADfD,EAAeE,iCAEfC,EAAmBP,EAA4B,yBAAX,SAG1Cd,KAAKsB,SACD,CACIC,UAAW,GAAGN,MAAcjB,KAAKO,MAAMiB,KAAKC,IAAI,oBAEpD,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAW5B,KAAKO,MAAMsB,KACtBC,KAAMb,EACNc,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,uCAA8Dd,eAO9E,OALArB,KAAKO,MAAM6B,kBAAkBV,QAE7BW,Q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