@adyen/adyen-web 6.19.0 → 6.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/adyen.css +10 -11
  3. package/dist/cjs/adyen.css.map +1 -1
  4. package/dist/cjs/index.cjs +2 -2
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.cts +43 -65
  7. package/dist/es/adyen.css +10 -11
  8. package/dist/es/adyen.css.map +1 -1
  9. package/dist/es/components/Ach/Ach.js +1 -1
  10. package/dist/es/components/Ach/Ach.js.map +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  12. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  13. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  14. package/dist/es/components/Card/Card.js +1 -1
  15. package/dist/es/components/Card/Card.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  19. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  20. package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
  21. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  22. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  23. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  24. package/dist/es/components/Dropin/Dropin.js +1 -1
  25. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  26. package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  27. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  28. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  29. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  30. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  31. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  32. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  33. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  34. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  35. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  36. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  37. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  38. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  39. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  40. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  41. package/dist/es/components/UPI/UPI.js +1 -1
  42. package/dist/es/components/UPI/UPI.js.map +1 -1
  43. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  44. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  45. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  46. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  47. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  48. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  49. package/dist/es/components/UPI/constants.js +2 -0
  50. package/dist/es/components/UPI/constants.js.map +1 -0
  51. package/dist/es/components/internal/Address/Address.js.map +1 -1
  52. package/dist/es/components/internal/Alert/Alert.js +1 -1
  53. package/dist/es/components/internal/Alert/Alert.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  56. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  57. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  58. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  59. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  60. package/dist/es/components/internal/PayButton/PayButton.js +1 -1
  61. package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
  62. package/dist/es/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  65. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  69. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  70. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  71. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  72. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  73. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  74. package/dist/es/core/Analytics/utils.js.map +1 -1
  75. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  76. package/dist/es/core/Errors/utils.js.map +1 -1
  77. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  78. package/dist/es/core/core.js +1 -1
  79. package/dist/es/core/core.registry.js.map +1 -1
  80. package/dist/es/core/utils.js.map +1 -1
  81. package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
  82. package/dist/es/external/preact/dist/preact.js.map +1 -1
  83. package/dist/es/index.d.ts +43 -65
  84. package/dist/es/language/utils.js.map +1 -1
  85. package/dist/es/utils/clipboard.js.map +1 -1
  86. package/dist/es/utils/setFocus.js.map +1 -1
  87. package/dist/es/utils/useForm/reducer.js.map +1 -1
  88. package/dist/es-legacy/adyen.css +10 -11
  89. package/dist/es-legacy/adyen.css.map +1 -1
  90. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  91. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  92. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  93. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  94. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  95. package/dist/es-legacy/components/Card/Card.js +1 -1
  96. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  97. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  98. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  99. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  100. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  101. package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
  102. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  103. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  104. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  105. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  106. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  107. package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  108. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  109. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  110. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  111. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  112. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  113. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  114. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  115. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  116. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  117. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  118. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  119. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  120. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  121. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  122. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  123. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  124. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  125. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  126. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  127. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  128. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  129. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  130. package/dist/es-legacy/components/UPI/constants.js +2 -0
  131. package/dist/es-legacy/components/UPI/constants.js.map +1 -0
  132. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  133. package/dist/es-legacy/components/internal/Alert/Alert.js +1 -1
  134. package/dist/es-legacy/components/internal/Alert/Alert.js.map +1 -1
  135. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  136. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  137. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  138. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  139. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  140. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  141. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  142. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  143. package/dist/es-legacy/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  144. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  145. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  146. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  147. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  148. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  149. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  150. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  151. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  152. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  153. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  154. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  155. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  156. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  157. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  158. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  159. package/dist/es-legacy/core/core.js +1 -1
  160. package/dist/es-legacy/core/core.registry.js.map +1 -1
  161. package/dist/es-legacy/core/utils.js.map +1 -1
  162. package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
  163. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  164. package/dist/es-legacy/language/utils.js.map +1 -1
  165. package/dist/es-legacy/utils/clipboard.js.map +1 -1
  166. package/dist/es-legacy/utils/setFocus.js.map +1 -1
  167. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  168. package/package.json +159 -159
  169. package/styles/adyen.css +10 -11
  170. package/dist/es/components/UPI/components/UPIComponent/constants.js +0 -2
  171. package/dist/es/components/UPI/components/UPIComponent/constants.js.map +0 -1
  172. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  173. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
  174. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js +0 -2
  175. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js.map +0 -1
  176. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  177. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n <div className=\"adyen-checkout-issuer-list-introduction-text-container\">\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.title')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content1')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content2')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAGlBP,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,+CAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,kDAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,mDAK9B"}
1
+ {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAK9B"}
@@ -1,2 +1,2 @@
1
- import{useState as t,useEffect as o}from"../../../../external/preact/hooks/dist/hooks.js";import e from"../../../../utils/get-issuer-image.js";import{useCoreContext as r}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Context/useImage.js";const i=({issuers:i,txVariant:n})=>{const{loadingContext:a}=r(),m=s(),[c,f]=t(i);return o(()=>{if(i?.length>0){const t=e({loadingContext:a},n,m);f(i.map(o=>({...o,icon:t(o.id)})))}},[i,n]),c};export{i as useIssuerWithLogo};
1
+ import{useState as t,useEffect as o}from"../../../../external/preact/hooks/dist/hooks.js";import e from"../../../../utils/get-issuer-image.js";import{useCoreContext as r}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Context/useImage.js";const i=({issuers:i=[],txVariant:n})=>{const{loadingContext:a}=r(),m=s(),[c,f]=t(i);return o(()=>{if(i?.length>0){const t=e({loadingContext:a},n,m);f(i.map(o=>({...o,icon:t(o.id)})))}},[i,n]),c};export{i as useIssuerWithLogo};
2
2
  //# sourceMappingURL=useIssuerWithLogo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers, txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","icon","id"],"mappings":"mRAUaA,EAAoB,EAAGC,UAASC,gBACzC,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,GAAIT,GAASU,OAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,QACLA,EACHC,KAAMJ,EAAcG,EAAKE,OAGrC,GACD,CAAChB,EAASC,IAENK"}
1
+ {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers = [], txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","icon","id"],"mappings":"6QAUO,MAAMA,EAAoB,EAAGC,UAAU,GAAIC,gBAC9C,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,GAAIT,GAASU,OAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,QACLA,EACHC,KAAMJ,EAAcG,EAAKE,OAGrC,GACD,CAAChB,EAASC,IAENK"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useRef as n,useCallback as o,useEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import l from"../../../internal/Voucher/Voucher.js";import s from"../../../../core/Context/useImage.js";import p from"../../../internal/PayButton/PayButton.js";import m from"./getAuthorizationStatus.js";import u from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:y,countdownTime:b,receiver:d,amount:f,txVariant:x,issuer:g,setComponentRef:h,enrollmentId:k,initiationId:w,clientKey:j,onAuthorize:v,onError:C}){const{i18n:P,loadingContext:I}=i(),B=s(),[E,F]=a("ready"),[S,z]=a(null),A=[{name:"open-finance",alt:P.get("paybybankpix.await.logoAlt.openFinance"),src:`${B({parentFolder:`${x}/`})("open-finance")}`}],D=[{label:P.get("paybybankpix.payment.receiver.label"),value:d},{label:P.get("paybybankpix.payment.paymentDate.label"),value:P.date((new Date).toString())},{label:P.get("paybybankpix.payment.paymentMethod.label"),value:"Pix Open Finance"}],T=n({setStatus:F}),K=o(async()=>{if(S)return;const e=await m({enrollmentId:k,initiationId:w,clientKey:j,loadingContext:I});return e.authorizationOptions&&z(e.authorizationOptions),e},[S,k,w,j,I]);return r(()=>{h(T.current)},[h]),r(()=>{S&&v(S)},[S]),"await"===y?e(u,{logos:A,type:x,countdownTime:b,clientKey:j,onError:C,awaitText:P.get("paybybankpix.await.fetchDetails"),pollStatus:K}):e(t,null,e(l,{issuerImageUrl:B({imageFolder:`${x}/`})(g),paymentMethodType:x,amount:P.amount(f.value,f.currency),voucherDetails:D}),e(p,{classNameModifiers:["standalone"],label:P.get("paybybankpix.storedPayment.payButton.label"),status:E,amount:f,onClick:c}))}export{c as default};
1
+ import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useState as e,useRef as n,useCallback as o,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import s from"../../../internal/PayButton/PayButton.js";import l from"./getAuthorizationStatus.js";import p from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:m,countdownTime:u,amount:f,txVariant:y,setComponentRef:d,enrollmentId:x,initiationId:b,clientKey:g,onAuthorize:k,onError:w}){const{i18n:C,loadingContext:h}=i(),j=r(),[P,B]=e("ready"),[E,I]=e(null),z=[{name:"open-finance",alt:C.get("paybybankpix.await.logoAlt.openFinance"),src:`${j({parentFolder:`${y}/`})("open-finance")}`}],A=n({setStatus:B}),S=o(async()=>{if(E)return;const t=await l({enrollmentId:x,initiationId:b,clientKey:g,loadingContext:h});return t.authorizationOptions&&I(t.authorizationOptions),t},[E,x,b,g,h]);return a(()=>{d(A.current)},[d]),a(()=>{E&&k(E)},[E]),"await"===m?t(p,{logos:z,type:y,countdownTime:u,clientKey:g,onError:w,awaitText:C.get("paybybankpix.await.fetchDetails"),pollStatus:S}):t(s,{classNameModifiers:["standalone"],label:C.get("paybybankpix.redirectBtn.label"),status:P,amount:f,onClick:c})}export{c as default};
2
2
  //# sourceMappingURL=StoredPayment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport PaymentDetails from '../../../internal/Voucher';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n receiver,\n amount,\n txVariant,\n issuer,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n const details = [\n { label: i18n.get('paybybankpix.payment.receiver.label'), value: receiver },\n { label: i18n.get('paybybankpix.payment.paymentDate.label'), value: i18n.date(new Date().toString()) },\n { label: i18n.get('paybybankpix.payment.paymentMethod.label'), value: 'Pix Open Finance' }\n ];\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <Fragment>\n <PaymentDetails\n issuerImageUrl={getImage({ imageFolder: `${txVariant}/` })(issuer)}\n paymentMethodType={txVariant}\n amount={i18n.amount(amount.value, amount.currency)}\n voucherDetails={details}\n ></PaymentDetails>\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.storedPayment.payButton.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n </Fragment>\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","receiver","amount","txVariant","issuer","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","details","label","value","date","Date","toString","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","Fragment","PaymentDetails","issuerImageUrl","imageFolder","paymentMethodType","currency","voucherDetails","PayButton","classNameModifiers","onClick"],"mappings":"kiBAWA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,SACbA,EAAQC,OACRA,EAAMC,UACNA,EAASC,OACTA,EAAMC,gBACNA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGvB,MAA5BW,CAA4C,oBAGtDa,EAAU,CACZ,CAAEC,MAAOjB,EAAKa,IAAI,uCAAwCK,MAAO5B,GACjE,CAAE2B,MAAOjB,EAAKa,IAAI,0CAA2CK,MAAOlB,EAAKmB,MAAK,IAAIC,MAAOC,aACzF,CAAEJ,MAAOjB,EAAKa,IAAI,4CAA6CK,MAAO,qBAEpEI,EAAOC,EAAO,CAChBjB,cAGEkB,EAAaC,EAAYC,UAC3B,GAAIlB,EAAsB,OAE1B,MAAMmB,QAAiBC,EAAuB,CAAEjC,eAAcC,eAAcC,YAAWI,mBAKvF,OAJI0B,EAASnB,sBACTC,EAAwBkB,EAASnB,sBAG9BmB,GACR,CAACnB,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVA4B,EAAU,KACNnC,EAAgB4B,EAAKQ,UACtB,CAACpC,IAEJmC,EAAU,KACFrB,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATpB,EACH2C,EAACC,EAAAA,CACGtB,MAAOA,EACPtB,KAAMI,EACNH,cAAeA,EACfQ,UAAWA,EACXE,QAASA,EACTkC,UAAWjC,EAAKa,IAAI,mCACpBW,WAAYA,IAGhBO,EAACG,OACGH,EAACI,EAAAA,CACGC,eAAgBjC,EAAS,CAAEkC,YAAa,GAAG7C,MAA3BW,CAA2CV,GAC3D6C,kBAAmB9C,EACnBD,OAAQS,EAAKT,OAAOA,EAAO2B,MAAO3B,EAAOgD,UACzCC,eAAgBxB,IAEpBe,EAACU,EAAAA,CACGC,mBAzDY,CAAC,cA0DbzB,MAAOjB,EAAKa,IAAI,8CAChBR,OAAQA,EACRd,OAAQA,EACRoD,QAASxD,IAIzB"}
1
+ {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n amount,\n txVariant,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.redirectBtn.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","amount","txVariant","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","PayButton","classNameModifiers","label","onClick"],"mappings":"geAUA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,OACbA,EAAMC,UACNA,EAASC,gBACTA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGtB,MAA5BU,CAA4C,oBAItDa,EAAOC,EAAO,CAChBX,cAGEY,EAAaC,EAAYC,UAC3B,GAAIZ,EAAsB,OAE1B,MAAMa,QAAiBC,EAAuB,CAAE3B,eAAcC,eAAcC,YAAWI,mBAKvF,OAJIoB,EAASb,sBACTC,EAAwBY,EAASb,sBAG9Ba,GACR,CAACb,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVAsB,EAAU,KACN7B,EAAgBsB,EAAKQ,UACtB,CAAC9B,IAEJ6B,EAAU,KACFf,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATlB,EACHmC,EAACC,EAAAA,CACGhB,MAAOA,EACPpB,KAAMG,EACNF,cAAeA,EACfM,UAAWA,EACXE,QAASA,EACT4B,UAAW3B,EAAKa,IAAI,mCACpBK,WAAYA,IAGhBO,EAACG,EAAAA,CACGC,mBA9CgB,CAAC,cA+CjBC,MAAO9B,EAAKa,IAAI,kCAChBR,OAAQA,EACRb,OAAQA,EACRuC,QAAS1C,GAGrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"2DAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,EAAmC,IAAKC,GAErCC,OAAOC,KAAKF,GAAOG,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQN,EAAMK,GAIpB,OAHa,UAATA,GAAoBE,EAA4BC,SAASF,MACzDF,EAAIC,GAAQC,GAETF,GACR"}
1
+ {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"2DAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,EAAmC,IAAKC,GAErCC,OAAOC,KAAKF,GAAOG,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQN,EAAMK,GAIpB,OAHa,UAATA,GAAoBE,EAA4BC,SAASF,MACzDF,EAAIC,GAAQC,GAETF,GACR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FastlaneSDK.js","sources":["../../../../src/components/PayPalFastlane/FastlaneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport requestFastlaneToken from './services/request-fastlane-token';\nimport { convertAdyenLocaleToFastlaneLocale } from './utils/convert-locale';\nimport Script from '../../utils/Script';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport type {\n FastlanePaymentMethodConfiguration,\n FastlaneWindowInstance,\n FastlaneAuthenticatedCustomerResult,\n FastlaneShippingAddressSelectorResult,\n FastlaneSDKConfiguration,\n FastlaneConsentRenderState\n} from './types';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly locale: string;\n private readonly forceConsentDetails: boolean;\n\n private fastlaneSdk?: FastlaneWindowInstance;\n private latestShopperDetails?: { email: string; customerId: string };\n private fastlaneSessionId?: string;\n\n constructor(configuration: FastlaneSDKConfiguration) {\n if (!configuration?.environment) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'environment' property is required\");\n if (!configuration?.clientKey) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'clientKey' property is required\");\n\n if (configuration.forceConsentDetails && configuration.environment.includes('live'))\n console.warn(\"Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment\");\n\n const { apiUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.locale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n return this;\n }\n\n /**\n * Triggers the authentication for Fastlane using shopper's email.\n * If shopper is recognized, the OTP flow is initialized.\n *\n * @param email\n */\n public async authenticate(email: string): Promise<FastlaneAuthenticatedCustomerResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'authenticate(): Fastlane SDK is not initialized');\n }\n\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n return this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n } else {\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n }\n }\n\n /**\n * Creates the Adyen Component configuration based on the Fastlane authentication result.\n *\n * In case the shopper authenticated successfully, it returns config to be used in the Fastlane component\n * Otherwise, it returns the configuration to be used in the Card component\n *\n * @param authResult\n */\n public async getComponentConfiguration(authResult: FastlaneAuthenticatedCustomerResult): Promise<FastlanePaymentMethodConfiguration> {\n if (!authResult) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'FastlaneSDK: you must pass the authentication result to get the component configuration'\n );\n }\n\n if (authResult.authenticationState === 'succeeded') {\n const hasCard = !!authResult.profileData?.card;\n\n if (!hasCard) {\n throw new AdyenCheckoutError('ERROR', 'getComponentConfiguration(): There is no card associated with the authenticated profile');\n }\n\n return {\n paymentType: 'fastlane',\n configuration: {\n fastlaneSessionId: this.fastlaneSessionId,\n email: this.latestShopperDetails.email,\n tokenId: authResult.profileData.card.id,\n lastFour: authResult.profileData.card.paymentSource.card.lastDigits,\n brand: authResult.profileData.card.paymentSource.card.brand.toLowerCase()\n }\n };\n } else {\n const consentDetails = await this.fetchConsentDetails();\n return {\n paymentType: 'card',\n configuration: {\n ...(consentDetails && {\n fastlaneConfiguration: {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n }\n })\n }\n };\n }\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n return this.fastlaneSdk.profile.showShippingAddressSelector();\n }\n\n /**\n * Render the \"Fastlane by PayPal\" logo in the specified HTML container\n */\n public async mountWatermark(container: HTMLElement | string, options = { includeAdditionalInfo: true }): Promise<void> {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n }\n\n private requestClientToken(): Promise<FastlaneTokenData> {\n return requestFastlaneToken(this.checkoutShopperURL, this.clientKey);\n }\n\n private async fetchSdk(clientToken: string, clientId: string): Promise<void> {\n const url = `https://www.paypal.com/sdk/js?client-id=${clientId}&components=buttons,fastlane`;\n const script = new Script(url, 'body', {}, { sdkClientToken: clientToken });\n\n await script.load();\n }\n\n /**\n * Fetch the fastlane session ID used internally by PayPal for Network Token Usage event\n * This ID is not critical for the payment processing part\n *\n * @private\n */\n private async fetchSessionIdAsync(): Promise<void> {\n try {\n const { sessionId } = await this.fastlaneSdk.identity.getSession();\n this.fastlaneSessionId = sessionId;\n } catch (error) {\n console.warn('Fastlane SDK: Failed to fetch session ID', error);\n }\n }\n\n /**\n * Fetch object containing that details that will be used to display the sign-up UI\n * inside the card component\n * @private\n */\n private async fetchConsentDetails(): Promise<FastlaneConsentRenderState> {\n try {\n const consentComponent = await this.fastlaneSdk.ConsentComponent();\n return await consentComponent.getRenderState();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'fetchConsentDetails(): failed to fetch consent details', { cause: error });\n }\n }\n\n private async initializeFastlaneInstance(): Promise<void> {\n try {\n this.fastlaneSdk = await window.paypal.Fastlane({\n intendedExperience: 'externalProcessorCustomConsent',\n ...(this.forceConsentDetails && {\n metadata: {\n geoLocOverride: 'US'\n }\n })\n });\n this.fastlaneSdk.setLocale(this.locale);\n\n void this.fetchSessionIdAsync();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor', {\n cause: error\n });\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","tokenData","this","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","authenticate","email","fastlaneSdk","AdyenCheckoutError","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","triggerAuthenticationFlow","authenticationState","profileData","undefined","getComponentConfiguration","authResult","card","paymentType","configuration","fastlaneSessionId","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fetchConsentDetails","fastlaneConfiguration","showShippingAddressSelector","profile","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","script","Script","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","error","console","warn","consentComponent","ConsentComponent","getRenderState","cause","window","paypal","Fastlane","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","locale","constructor","_define_property","environment","includes","apiUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale"],"mappings":"maAeA,MAAMA,EA4BF,gBAAaC,GACT,MAAMC,QAAkBC,KAAKC,qBAG7B,aAFMD,KAAKE,SAASH,EAAUI,MAAOJ,EAAUK,gBACzCJ,KAAKK,6BACJL,IACX,CAQA,kBAAaM,CAAaC,GACtB,IAAKP,KAAKQ,YACN,MAAM,IAAIC,EAAmB,uBAAwB,mDAGzD,MAAMC,kBAAEA,SAA4BV,KAAKQ,YAAYG,SAASC,sBAAsBL,GAEpF,OAAIG,GACAV,KAAKa,qBAAuB,CAAEN,QAAOO,WAAYJ,GAC1CV,KAAKQ,YAAYG,SAASI,0BAA0BL,IAEpD,CACHM,oBAAqB,YACrBC,iBAAaC,EAGzB,CAUA,+BAAaC,CAA0BC,GACnC,IAAKA,EACD,MAAM,IAAIX,EACN,uBACA,2FAIR,GAAuC,cAAnCW,EAAWJ,oBAAqC,CAGhD,MAFkBI,EAAWH,aAAaI,KAGtC,MAAM,IAAIZ,EAAmB,QAAS,2FAG1C,MAAO,CACHa,YAAa,WACbC,cAAe,CACXC,kBAAmBxB,KAAKwB,kBACxBjB,MAAOP,KAAKa,qBAAqBN,MACjCkB,QAASL,EAAWH,YAAYI,KAAKK,GACrCC,SAAUP,EAAWH,YAAYI,KAAKO,cAAcP,KAAKQ,WACzDC,MAAOV,EAAWH,YAAYI,KAAKO,cAAcP,KAAKS,MAAMC,gBAGjE,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iB4C,0BAAjB,GACA2B,EAAAvE,KAAiBqE,cAAjB,GACAE,EAAAvE,KAAiBiE,2BAAjB,GAEAM,EAAAvE,KAAQQ,mBAAR,GACA+D,EAAAvE,KAAQa,4BAAR,GACA0D,EAAAvE,KAAQwB,yBAAR,IAGSD,GAAeiD,YAAa,MAAM,IAAI/D,EAAmB,uBAAwB,mDACtF,IAAKc,GAAesB,UAAW,MAAM,IAAIpC,EAAmB,uBAAwB,iDAEhFc,EAAc0C,qBAAuB1C,EAAciD,YAAYC,SAAS,SACxElB,QAAQC,KAAK,gFAEjB,MAAMkB,OAAEA,GAAWC,EAAoBpD,EAAciD,aAErDxE,KAAK4C,mBAAqB8B,EAC1B1E,KAAK6C,UAAYtB,EAAcsB,UAC/B7C,KAAKiE,oBAAsB1C,EAAc0C,sBAAuB,EAChEjE,KAAKqE,OAASO,EAAmCrD,EAAc8C,QAAU,QAC7E"}
1
+ {"version":3,"file":"FastlaneSDK.js","sources":["../../../../src/components/PayPalFastlane/FastlaneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport requestFastlaneToken from './services/request-fastlane-token';\nimport { convertAdyenLocaleToFastlaneLocale } from './utils/convert-locale';\nimport Script from '../../utils/Script';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport type {\n FastlanePaymentMethodConfiguration,\n FastlaneWindowInstance,\n FastlaneAuthenticatedCustomerResult,\n FastlaneShippingAddressSelectorResult,\n FastlaneSDKConfiguration,\n FastlaneConsentRenderState\n} from './types';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly locale: string;\n private readonly forceConsentDetails: boolean;\n\n private fastlaneSdk?: FastlaneWindowInstance;\n private latestShopperDetails?: { email: string; customerId: string };\n private fastlaneSessionId?: string;\n\n constructor(configuration: FastlaneSDKConfiguration) {\n if (!configuration?.environment) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'environment' property is required\");\n if (!configuration?.clientKey) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'clientKey' property is required\");\n\n if (configuration.forceConsentDetails && configuration.environment.includes('live'))\n console.warn(\"Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment\");\n\n const { apiUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.locale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n return this;\n }\n\n /**\n * Triggers the authentication for Fastlane using shopper's email.\n * If shopper is recognized, the OTP flow is initialized.\n *\n * @param email\n */\n public async authenticate(email: string): Promise<FastlaneAuthenticatedCustomerResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'authenticate(): Fastlane SDK is not initialized');\n }\n\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n return this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n } else {\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n }\n }\n\n /**\n * Creates the Adyen Component configuration based on the Fastlane authentication result.\n *\n * In case the shopper authenticated successfully, it returns config to be used in the Fastlane component\n * Otherwise, it returns the configuration to be used in the Card component\n *\n * @param authResult\n */\n public async getComponentConfiguration(authResult: FastlaneAuthenticatedCustomerResult): Promise<FastlanePaymentMethodConfiguration> {\n if (!authResult) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'FastlaneSDK: you must pass the authentication result to get the component configuration'\n );\n }\n\n if (authResult.authenticationState === 'succeeded') {\n const hasCard = !!authResult.profileData?.card;\n\n if (!hasCard) {\n throw new AdyenCheckoutError('ERROR', 'getComponentConfiguration(): There is no card associated with the authenticated profile');\n }\n\n return {\n paymentType: 'fastlane',\n configuration: {\n fastlaneSessionId: this.fastlaneSessionId,\n email: this.latestShopperDetails.email,\n tokenId: authResult.profileData.card.id,\n lastFour: authResult.profileData.card.paymentSource.card.lastDigits,\n brand: authResult.profileData.card.paymentSource.card.brand.toLowerCase()\n }\n };\n } else {\n const consentDetails = await this.fetchConsentDetails();\n return {\n paymentType: 'card',\n configuration: {\n ...(consentDetails && {\n fastlaneConfiguration: {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n }\n })\n }\n };\n }\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n return this.fastlaneSdk.profile.showShippingAddressSelector();\n }\n\n /**\n * Render the \"Fastlane by PayPal\" logo in the specified HTML container\n */\n public async mountWatermark(container: HTMLElement | string, options = { includeAdditionalInfo: true }): Promise<void> {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n }\n\n private requestClientToken(): Promise<FastlaneTokenData> {\n return requestFastlaneToken(this.checkoutShopperURL, this.clientKey);\n }\n\n private async fetchSdk(clientToken: string, clientId: string): Promise<void> {\n const url = `https://www.paypal.com/sdk/js?client-id=${clientId}&components=buttons,fastlane`;\n const script = new Script(url, 'body', {}, { sdkClientToken: clientToken });\n\n await script.load();\n }\n\n /**\n * Fetch the fastlane session ID used internally by PayPal for Network Token Usage event\n * This ID is not critical for the payment processing part\n *\n * @private\n */\n private async fetchSessionIdAsync(): Promise<void> {\n try {\n const { sessionId } = await this.fastlaneSdk.identity.getSession();\n this.fastlaneSessionId = sessionId;\n } catch (error) {\n console.warn('Fastlane SDK: Failed to fetch session ID', error);\n }\n }\n\n /**\n * Fetch object containing that details that will be used to display the sign-up UI\n * inside the card component\n * @private\n */\n private async fetchConsentDetails(): Promise<FastlaneConsentRenderState> {\n try {\n const consentComponent = await this.fastlaneSdk.ConsentComponent();\n return await consentComponent.getRenderState();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'fetchConsentDetails(): failed to fetch consent details', { cause: error });\n }\n }\n\n private async initializeFastlaneInstance(): Promise<void> {\n try {\n this.fastlaneSdk = await window.paypal.Fastlane({\n intendedExperience: 'externalProcessorCustomConsent',\n ...(this.forceConsentDetails && {\n metadata: {\n geoLocOverride: 'US'\n }\n })\n });\n this.fastlaneSdk.setLocale(this.locale);\n\n void this.fetchSessionIdAsync();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor', {\n cause: error\n });\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","tokenData","this","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","authenticate","email","fastlaneSdk","AdyenCheckoutError","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","triggerAuthenticationFlow","authenticationState","profileData","undefined","getComponentConfiguration","authResult","card","paymentType","configuration","fastlaneSessionId","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fetchConsentDetails","fastlaneConfiguration","showShippingAddressSelector","profile","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","script","Script","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","error","console","warn","consentComponent","ConsentComponent","getRenderState","cause","window","paypal","Fastlane","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","locale","constructor","_define_property","environment","includes","apiUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale"],"mappings":"maAeA,MAAMA,EA4BF,gBAAaC,GACT,MAAMC,QAAkBC,KAAKC,qBAG7B,aAFMD,KAAKE,SAASH,EAAUI,MAAOJ,EAAUK,gBACzCJ,KAAKK,6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EjE,KAAKqE,OAASO,EAAmCrD,EAAc8C,QAAU,QAC7E"}
@@ -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, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } 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_FULL, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static 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: challengeData as 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 type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.CHALLENGE_DATA_SENT\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__?.indexOf('localhost:8080') > -1) ||\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: `${Analytics3DS2Errors.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 code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${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 this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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 =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${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 code: errorCode,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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 /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AnalyticsEvent;\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' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\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 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 type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subType: Analytics3DS2Events.CHALLENGE_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 code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","code","errorType","ANALYTICS_ERROR_TYPE","apiError","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","network","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"unCAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,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,KAAKI,MAAMqF,gBAC5BC,aAAc1F,KAAK0F,eAKL,UAAtB1F,KAAKC,MAAMiC,OAEP2C,EAACc,MAAAA,CAAIC,UAAU,4CACXf,EAACgB,EAAAA,CACGD,UAAU,mEACVE,IAAKnB,EAAS,CACVoB,YAAa,eADZpB,CAEF,SACHqB,IAAK,KAETnB,EAACc,MAAAA,CAAIC,UAAU,gCACV5F,KAAKC,MAAMW,UAAYZ,KAAKC,MAAMW,UAAYZ,KAAKI,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAtVA,WAAAiF,CAAY7F,GAGR,GAFA8F,MAAM9F,GAoBV+F,EAAAnG,KAAO0F,eAAgBU,IACnB,MAAMnF,EAAQ,IAAIyC,EAAkB,CAChCC,KAAMC,EACNrC,QAAS6E,EACTtC,QAASC,EAAoBsC,sBAGjCrG,KAAKI,MAAMqB,kBAAkBR,KAzBzBjB,KAAKI,MAAMkG,MAAO,CAClB,MAAMpG,EAA6CqG,EAAqB,CACpED,MAAOtG,KAAKI,MAAMkG,MAClBE,KAAMxG,KAAKI,MAAMqG,qBAAuBzG,KAAKI,MAAMoG,OAGvDxG,KAAKC,MAAQ,CACTiC,OAAQ,OACRhC,cAAeA,QAInBF,KAAKC,MAAQ,CAAEC,cAAe,CAAEwG,SAAS,EAAOtE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA4D,EADEvG,EACY+G,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTtB,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, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } 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_FULL, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static 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: challengeData as 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 type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.CHALLENGE_DATA_SENT\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__?.indexOf('localhost:8080') > -1) ||\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: `${Analytics3DS2Errors.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 code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${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 this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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 =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${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 code: errorCode,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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 /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AnalyticsEvent;\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' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\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 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 type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subType: Analytics3DS2Events.CHALLENGE_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 code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\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","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","code","errorType","ANALYTICS_ERROR_TYPE","apiError","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","network","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"unCAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,GAAWT,KAAKC,MAAMC,cAI9B,IAHuBQ,EAAeD,EAAQN,GAGzB,CAEjBH,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAoBC,4BAA4Bd,KAAKI,MAAMW,KAAKC,IAAI,oBAEtF,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,KAAMN,EAAoBC,wBAC1BM,UAAWC,EAAqBC,SAChCC,QAAS,GAAGC,wDAKhB,OAHAxB,KAAKI,MAAMqB,kBAAkBR,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GAFA8F,MAAM9F,GAoBV+F,EAAAnG,KAAO0F,eAAgBU,IACnB,MAAMnF,EAAQ,IAAIyC,EAAkB,CAChCC,KAAMC,EACNrC,QAAS6E,EACTtC,QAASC,EAAoBsC,sBAGjCrG,KAAKI,MAAMqB,kBAAkBR,KAzBzBjB,KAAKI,MAAMkG,MAAO,CAClB,MAAMpG,EAA6CqG,EAAqB,CACpED,MAAOtG,KAAKI,MAAMkG,MAClBE,KAAMxG,KAAKI,MAAMqG,qBAAuBzG,KAAKI,MAAMoG,OAGvDxG,KAAKC,MAAQ,CACTiC,OAAQ,OACRhC,cAAeA,EAEvB,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAEwG,SAAS,EAAOtE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA4D,EADEvG,EACY+G,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTtB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\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__?.indexOf('localhost:8080') > -1) ||\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 fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\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\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error 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 ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\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?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW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EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
1
+ {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\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__?.indexOf('localhost:8080') > -1) ||\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 fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\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\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error 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 ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\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?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBU,6BAC/BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORtB,KAAK4B,SAAS,CAAEC,OAAQ,yBAE5B,KAAO,CAGH,MAAMC,EAAmB9B,KAAMC,MAAMC,gBAAgC6B,MAE/Df,E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IhB,MAAME,EAAiC,CACnCxD,UAAWsD,EAAYtD,UACvBG,QAAS,GAAGsD,MAAyBH,EAAYtD,aAGrDhB,KAAKc,kBAAkBwD,EAAYd,OAAQgB,IAE/CN,YAAaA,KACThE,EACJwE,gBAAiB1E,KAAKI,MAAMsE,gBAC5BC,aAAc3E,KAAK2E,eAKxB,IACX,CAxOA,WAAAC,CAAYxE,GACRyE,MAAMzE,GAmBV0E,EAAA9E,KAAO2E,eAAgBI,IACnB,MAAMnC,EAAQ,IAAIa,EAAkB,CAChCC,KAAMC,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,wBAGjChF,KAAKI,MAAMmD,kBAAkBX,KAxB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBlF,KAAKI,MAExC,GAAI6E,EAAO,CACP,MAAM/E,EAAiDiF,EAAuB,CAAEF,QAAOC,oBAEvFlF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,EAEzB,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEkF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADElF,EACY8D,OAAO,UAErBoB,EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import n from"../internal/Await/Await.js";import i from"../internal/QRLoader/QRLoader.js";import s from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import a from"../../utils/isMobile.js";function d(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class l extends e{formatProps(t){if(!a())return{...super.formatProps(t),defaultMode:t?.defaultMode??"qrCode",apps:[]};const e=t.apps?.length>0,o=e?"intent":"vpa",r=[o,"qrCode"],n={id:"vpa",name:t.i18n.get("upi.collect.dropdown.label"),type:p.upi_collect},i=e?[...t.apps.map(t=>({...t,type:p.upi_intent})),n]:[];return{...super.formatProps(t),defaultMode:r.includes(t?.defaultMode)?t.defaultMode:o,apps:i}}get isValid(){return this.state.isValid}formatData(){const{virtualPaymentAddress:t,app:e}=this.state.data||{};return{paymentMethod:{...this.paymentType&&{type:this.paymentType},...this.paymentType===p.upi_collect&&t&&{virtualPaymentAddress:t},...this.paymentType===p.upi_intent&&e?.id&&{appId:e.id}}}}get paymentType(){return"qrCode"===this.selectedMode?p.upi_qr:"vpa"===this.selectedMode?p.upi_collect:this.state.data?.app?.type}renderContent(e,r,s){switch(e){case"qrCode":return t(i,{ref:t=>{this.componentRef=t},...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:p.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:5,onActionHandled:this.onActionHandled});case"await":return t(n,{ref:t=>{this.componentRef=t},url:r,type:s,showCountdownTimer:!0,shouldRedirectAutomatically:!0,countdownTime:5,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon});default:return t(o,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,onUpdateMode:this.onUpdateMode,apps:this.props.apps,defaultMode:this.props.defaultMode,showPayButton:this.props.showPayButton})}}render(){const{type:e,url:o,paymentMethodType:n}=this.props;return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{srPanel:this.props.modules.srPanel},this.renderContent(e,o,n)))}constructor(t,e){super(t,e),d(this,"selectedMode",void 0),d(this,"onUpdateMode",t=>{this.selectedMode=t}),this.selectedMode=this.props.defaultMode}}d(l,"type",p.upi),d(l,"txVariants",[p.upi,p.upi_qr,p.upi_collect,p.upi_intent]);export{l as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as n}from"../../core/Context/CoreProvider.js";import r from"../internal/Await/Await.js";import s from"../internal/QRLoader/QRLoader.js";import i from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import a from"../../utils/isMobile.js";import{getQrOption as d,getVpaOption as l,getIntentOption as u}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class h extends e{formatProps(t){if(!a())return{...super.formatProps(t),defaultMode:["qrCode","vpa"].includes(t?.defaultMode)?t.defaultMode:"qrCode",apps:[],segmentedControlOptions:[d(t.i18n),l(t.i18n)]};const{i18n:e,apps:o=[]}=t;if(o.length>0){const n=["intent","vpa"].includes(t.defaultMode)?t.defaultMode:"intent";return{...super.formatProps(t),defaultMode:n,apps:o,segmentedControlOptions:[u(e),l(e)]}}return{...super.formatProps(t),defaultMode:"vpa",apps:[],segmentedControlOptions:[]}}get isValid(){return this.state.isValid}formatData(){const{virtualPaymentAddress:t,app:e}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===p.upi_collect&&t&&{virtualPaymentAddress:t},...this.paymentType===p.upi_intent&&e?.id&&{appId:e.id}}}}get paymentType(){return"qrCode"===this.selectedMode?p.upi_qr:"vpa"===this.selectedMode?p.upi_collect:p.upi_intent}renderContent(e,n,i){switch(e){case"qrCode":return t(s,{ref:t=>{this.componentRef=t},...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:p.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:5,onActionHandled:this.onActionHandled});case"await":return t(r,{ref:t=>{this.componentRef=t},url:n,type:i,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!0,countdownTime:5,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon,amount:this.props.amount});default:return t(o,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,onUpdateMode:this.onUpdateMode,apps:this.props.apps,segmentedControlOptions:this.props.segmentedControlOptions,defaultMode:this.props.defaultMode,showPayButton:this.props.showPayButton})}}render(){const{type:e,url:o,paymentMethodType:r}=this.props;return t(n,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},this.renderContent(e,o,r)))}constructor(t,e){super(t,e),m(this,"selectedMode",void 0),m(this,"onUpdateMode",t=>{this.selectedMode=t}),this.selectedMode=this.props.defaultMode}}m(h,"type",p.upi),m(h,"txVariants",[p.upi,p.upi_qr,p.upi_collect,p.upi_intent]);export{h as default};
2
2
  //# sourceMappingURL=UPI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"2lBAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAaH,GAAOG,aAAe,SAEnCC,KAAM,IAId,MAAMC,EAAgBL,EAAMI,MAAME,OAAS,EACrCC,EAAsBF,EAAgB,SAAW,MACjDG,EAAe,CAACD,EAAqB,UACrCE,EAAqB,CACvBC,GAAI,MACJC,KAAMX,EAAMY,KAAKC,IAAI,8BACrBC,KAAMC,EAAWC,aAEfZ,EAAOC,EAAgB,IAAIL,EAAMI,KAAKa,IAAIC,QAAaA,EAAKJ,KAAMC,EAAWI,cAA2BV,GAAiB,GAC/H,MAAO,IACAP,MAAMH,YAAYC,GACrBG,YAAaK,EAAaY,SAASpB,GAAOG,aAAeH,EAAMG,YAAcI,EAC7EH,OAER,CAEA,WAAWiB,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,sBAAEA,EAAqBP,IAAEA,GAAQI,KAAKC,MAAMG,MAAQ,CAAA,EAE1D,MAAO,CACHC,cAAe,IACPL,KAAKM,aAAe,CAAEd,KAAMQ,KAAKM,gBACjCN,KAAKM,cAAgBb,EAAWC,aAAeS,GAAyB,CAAEA,4BAC1EH,KAAKM,cAAgBb,EAAWI,YAAcD,GAAKR,IAAM,CAAEmB,MAAOX,EAAIR,KAGtF,CAEA,eAAIkB,GACA,MAA0B,WAAtBN,KAAKQ,aACEf,EAAWgB,OAEI,QAAtBT,KAAKQ,aACEf,EAAWC,YAEfM,KAAKC,MAAMG,MAAMR,KAA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MAAM+D,eAAgBC,UAAW1C,KAAK0C,WAC5F7B,EAAC8B,EAAAA,CAAgBC,QAAS5C,KAAKtB,MAAMmE,QAAQD,SAAU5C,KAAKU,cAAclB,EAAMmB,EAAKC,IAGjG,CA5HA,WAAAkC,CAAYC,EAAiBrE,GACzBE,MAAMmE,EAAUrE,GAHpBsE,EAAAhD,KAAQQ,oBAAR,GA2DAwC,EAAAhD,KAAQqC,eAAgBY,IACpBjD,KAAKQ,aAAeyC,IAxDpBjD,KAAKQ,aAAeR,KAAKtB,MAAMG,WACnC,EARAmE,EADEzE,EACYiB,OAAOC,EAAWyD,KAChCF,EAFEzE,EAEY4E,aAAa,CAAC1D,EAAWyD,IAAKzD,EAAWgB,OAAQhB,EAAWC,YAAaD,EAAWI"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\nimport { getIntentOption, getQrOption, getVpaOption } from './constants';\n\n/**\n * For mobile:\n * We should show upi_collect and upi_intent depending on if `apps` are returned in /paymentMethods response.\n * If there is no apps, hide segmented controls.\n * The upi_collect should always be on the second tab.\n * Never show QR code.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration): UPIConfiguration {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: ['qrCode', 'vpa'].includes(props?.defaultMode) ? props.defaultMode : 'qrCode',\n apps: [], // For desktop, ignore the apps\n segmentedControlOptions: [getQrOption(props.i18n), getVpaOption(props.i18n)]\n };\n }\n\n const { i18n, apps = [] } = props;\n const hasIntentApps = apps.length > 0;\n if (hasIntentApps) {\n // Mobile with UPI apps\n const allowedModes: UpiMode[] = ['intent', 'vpa'];\n const defaultMode = allowedModes.includes(props.defaultMode) ? props.defaultMode : 'intent';\n return {\n ...super.formatProps(props),\n defaultMode,\n apps,\n segmentedControlOptions: [getIntentOption(i18n), getVpaOption(i18n)]\n };\n }\n\n // Mobile, but no UPI apps\n return {\n ...super.formatProps(props),\n defaultMode: 'vpa', // Only VPA is possible\n apps: [],\n segmentedControlOptions: []\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return TxVariants.upi_intent;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n amount={this.props.amount}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n segmentedControlOptions={this.props.segmentedControlOptions}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","includes","apps","segmentedControlOptions","getQrOption","i18n","getVpaOption","length","getIntentOption","isValid","this","state","formatData","virtualPaymentAddress","app","data","paymentMethod","type","paymentType","TxVariants","upi_collect","upi_intent","id","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","get","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","showAmount","clientKey","paymentData","onError","messageText","awaitText","amount","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"+qBAyBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAa,CAAC,SAAU,OAAOC,SAASJ,GAAOG,aAAeH,EAAMG,YAAc,SAClFE,KAAM,GACNC,wBAAyB,CAACC,EAAYP,EAAMQ,MAAOC,EAAaT,EAAMQ,QAI9E,MAAMA,KAAEA,EAAIH,KAAEA,EAAO,IAAOL,EAE5B,GADsBK,EAAKK,OAAS,EACjB,CAEf,MACMP,EAD0B,CAAC,SAAU,OACVC,SAASJ,EAAMG,aAAeH,EAAMG,YAAc,SACnF,MAAO,IACAD,MAAMH,YAAYC,GACrBG,cACAE,OACAC,wBAAyB,CAACK,EAAgBH,GAAOC,EAAaD,IAEtE,CAGA,MAAO,IACAN,MAAMH,YAAYC,GACrBG,YAAa,MACbE,KAAM,GACNC,wBAAyB,GAEjC,CAEA,WAAWM,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,sBAAEA,EAAqBC,IAAEA,GAAQJ,KAAKC,MAAMI,MAAQ,CAAA,EAE1D,MAAO,CACHC,cAAe,CACXC,KAAMP,KAAKQ,eACPR,KAAKQ,cAAgBC,EAAWC,aAAeP,GAAyB,CAAEA,4BAC1EH,KAAKQ,cAAgBC,EAAWE,YAAcP,GAAKQ,IAAM,CAAEC,MAAOT,EAAIQ,KAGtF,CAEA,eAAIJ,GACA,MAA0B,WAAtBR,KAAKc,aACEL,EAAWM,OAEI,QAAtBf,KAAKc,aACEL,EAAWC,YAEfD,EAAWE,UACtB,CAMQK,aAAAA,CAAcT,EAAcU,EAAaC,GAC7C,OAAQX,GACJ,IAAK,SACD,OACIY,EAACC,EAAAA,CACGC,IAAKA,IACDrB,KAAKsB,aAAeD,M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Kb,MAAMmE,QAAQD,SAAUrD,KAAKgB,cAAcT,EAAMU,EAAKC,IAGjG,CAtIA,WAAAqC,CAAYC,EAAiBrE,GACzBE,MAAMmE,EAAUrE,GAHpBsE,EAAAzD,KAAQc,oBAAR,GAkEA2C,EAAAzD,KAAQ8C,eAAgBY,IACpB1D,KAAKc,aAAe4C,IA/DpB1D,KAAKc,aAAed,KAAKb,MAAMG,WACnC,EARAmE,EADEzE,EACYuB,OAAOE,EAAWkD,KAChCF,EAFEzE,EAEY4E,aAAa,CAACnD,EAAWkD,IAAKlD,EAAWM,OAAQN,EAAWC,YAAaD,EAAWE"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as o,useEffect as n}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../VpaInput/VpaInput.js";import i from"../../../../core/Context/useImage.js";import s from"./useUpiSegmentedControlOptions.js";import{A11Y as l}from"./constants.js";import d from"../../../internal/SegmentedControl/SegmentedControl.js";import p from"../../../internal/ContentSeparator/ContentSeparator.js";import u from"../UPIIntentAppList/UPIIntentAppList.js";import{useCoreContext as m}from"../../../../core/Context/CoreProvider.js";function c({defaultMode:c,onChange:g,onUpdateMode:I,payButton:C,showPayButton:b,apps:f=[]}){const{i18n:h}=m(),y=i(),[v,A]=a("ready"),[S,j]=a("qrCode"===c),[V,N]=a(c),[P,k]=a(""),[x,q]=a(null),[B,E]=a(null),[T,U]=a(null),[M,Q]=a(null),R=s(f,V);this.setStatus=e=>{A(e)},this.showValidation=()=>{x?.validateInput()};const w=o(e=>{q(e)},[]),F=o(e=>{N(e),I(e)},[I]),H=o(e=>{e?.id!==B?.id&&(E(e),j(!0))},[B]),L=o(({data:{virtualPaymentAddress:e},errors:t,valid:a,isValid:o})=>{k(e),Q(t),U(a),j(o)},[]);return n(()=>{g("qrCode"!==V?{data:{...P&&{virtualPaymentAddress:P},...B&&{app:B}},errors:M,valid:T,isValid:S}:{data:{},valid:{},errors:{},isValid:!0})},[P,B,M,T,S,V]),e(t,null,e("p",{className:"adyen-checkout_upi-mode-selection-text"},h.get("upi.modeSelection")),e(d,{onChange:F,selectedValue:V,disabled:"loading"===v,classNameModifiers:["upi-margin-bottom"],options:R}),e(p,{label:h.get("upi.completePayment")}),"intent"===V&&e("div",{id:l.AreaId.INTENT,"aria-labelledby":l.ButtonId.INTENT,className:"adyen-checkout-upi-area-intent",role:"region"},e(u,{disabled:"loading"===v,apps:f,selectedAppId:B?.id,onAppSelect:H,onVpaInputChange:L,onSetInputHandlers:w}),b&&C({label:h.get("continue"),status:v,disabled:null==B})),"vpa"===V&&e("div",{id:l.AreaId.VPA,"aria-labelledby":l.ButtonId.VPA,className:"adyen-checkout-upi-area-vpa",role:"region"},e(r,{disabled:"loading"===v,onChange:g,onSetInputHandlers:w}),b&&C({label:h.get("continue"),status:v})),"qrCode"===V&&e("div",{id:l.AreaId.QR,"aria-labelledby":l.ButtonId.QR,className:"adyen-checkout-upi-area-qr-code",role:"region"},b&&C({label:h.get("generateQRCode"),icon:y({imageFolder:"components/"})("qr"),status:v})))}export{c as default};
1
+ import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as o,useEffect as n}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../VpaInput/VpaInput.js";import r from"../../../../core/Context/useImage.js";import{A11Y as s}from"../../constants.js";import l from"../../../internal/SegmentedControl/SegmentedControl.js";import d from"../UPIIntentAppList/UPIIntentAppList.js";import{useCoreContext as p}from"../../../../core/Context/CoreProvider.js";import c from"../../../internal/Alert/Alert.js";function u({defaultMode:u,onChange:m,onUpdateMode:g=()=>{},payButton:I,showPayButton:b,apps:h=[],segmentedControlOptions:f=[]}){const{i18n:y}=p(),C=r(),[A,N]=a("ready"),[k,j]=a(u),[v,S]=a(null),[V,q]=a(null),[x,P]=a("qrCode"===u);this.setStatus=e=>{N(e)},this.showValidation=()=>{v?.validateInput(),"intent"===k&&M()};const B=o(e=>{S(e)},[]),E=o(e=>{j(e),g(e)},[g]),T=o(e=>{e?.id!==V?.id&&(q(e),P(!0),N("ready"))},[V]),M=o(()=>{V?(N("ready"),P(!0)):(N("error"),P(!1))},[V]);return n(()=>{m("qrCode"!==k?{data:{...V&&{app:V}},isValid:x}:{data:{},valid:{},errors:{},isValid:!0})},[V,x,k,m]),e(t,null,f.length>0&&e("p",{className:"adyen-checkout_upi-mode-selection-text"},y.get("upi.modeSelection")),e(l,{onChange:E,selectedValue:k,disabled:"loading"===A,classNameModifiers:["upi-margin-bottom"],options:f}),"intent"===k&&e("div",{id:s.AreaId.INTENT,"aria-labelledby":s.ButtonId.INTENT,className:"adyen-checkout-upi-area-intent",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.intent.instruction")),"error"===A&&e(c,{icon:"cross"},y.get("upi.error.noAppSelected")),e(d,{disabled:"loading"===A,apps:h,selectedAppId:V?.id,onAppSelect:T}),b&&I({label:y.get("continue"),status:A})),"vpa"===k&&e("div",{id:s.AreaId.VPA,"aria-labelledby":s.ButtonId.VPA,className:"adyen-checkout-upi-area-vpa",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.collect.instruction")),e(i,{disabled:"loading"===A,onChange:m,onSetInputHandlers:B}),b&&I({label:y.get("continue"),status:A})),"qrCode"===k&&e("div",{id:s.AreaId.QR,"aria-labelledby":s.ButtonId.QR,className:"adyen-checkout-upi-area-qr-code",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.qrCode.instruction")),b&&I({label:y.get("generateQRCode"),icon:C({imageFolder:"components/"})("qr"),status:A})))}export{u as default};
2
2
  //# sourceMappingURL=UPIComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h, RefObject } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport { PayButtonFunctionProps, UIElementStatus } from '../../../types';\nimport VpaInput, { VpaInputHandlers } from '../VpaInput/VpaInput';\nimport { App, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport useUpiSegmentedControlOptions from './useUpiSegmentedControlOptions';\nimport { A11Y } from './constants';\nimport './UPIComponent.scss';\nimport SegmentedControl from '../../../internal/SegmentedControl';\nimport ContentSeparator from '../../../internal/ContentSeparator';\nimport UPIIntentAppList from '../UPIIntentAppList';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\ntype UpiData = { app?: App; virtualPaymentAddress?: string };\n\ntype OnChangeProps = { data: UpiData; valid; errors; isValid: boolean };\n\ninterface UPIComponentProps {\n defaultMode: UpiMode;\n showPayButton: boolean;\n apps?: Array<App>;\n\n ref?(ref: RefObject<typeof UPIComponent>): void;\n\n payButton?(props: PayButtonFunctionProps): h.JSX.Element;\n\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n\n onUpdateMode?(mode: UpiMode): void;\n}\n\nexport default function UPIComponent({ defaultMode, onChange, onUpdateMode, payButton, showPayButton, apps = [] }: UPIComponentProps): h.JSX.Element {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const [isValid, setIsValid] = useState<boolean>(defaultMode === 'qrCode');\n const [mode, setMode] = useState<UpiMode>(defaultMode);\n const [vpa, setVpa] = useState<string>('');\n const [vpaInputHandlers, setVpaInputHandlers] = useState<VpaInputHandlers>(null);\n const [selectedApp, setSelectedApp] = useState<App>(null);\n const [valid, setValid] = useState(null);\n const [errors, setErrors] = useState(null);\n const segmentedControlOptions = useUpiSegmentedControlOptions(apps, mode);\n\n this.setStatus = (status: UIElementStatus) => {\n setStatus(status);\n };\n\n this.showValidation = () => {\n vpaInputHandlers?.validateInput();\n };\n\n const onSetVpaInputHandlers = useCallback((handlers: VpaInputHandlers) => {\n setVpaInputHandlers(handlers);\n }, []);\n\n const onChangeUpiMode = useCallback(\n (newMode: UpiMode) => {\n setMode(newMode);\n onUpdateMode(newMode);\n },\n [onUpdateMode]\n );\n\n const handleAppSelect = useCallback(\n (app: App) => {\n if (app?.id === selectedApp?.id) return;\n\n setSelectedApp(app);\n setIsValid(true);\n },\n [selectedApp]\n );\n\n const handleVpaInputChange = useCallback(({ data: { virtualPaymentAddress }, errors, valid, isValid }: OnChangeProps) => {\n setVpa(virtualPaymentAddress);\n setErrors(errors);\n setValid(valid);\n setIsValid(isValid);\n }, []);\n\n useEffect(() => {\n if (mode !== 'qrCode') {\n onChange({\n data: { ...(vpa && { virtualPaymentAddress: vpa }), ...(selectedApp && { app: selectedApp }) },\n errors,\n valid,\n isValid\n });\n } else {\n /**\n * When selecting QR code mode, we need to clear the state data and trigger the 'onChange'.\n */\n onChange({ data: {}, valid: {}, errors: {}, isValid: true });\n }\n }, [vpa, selectedApp, errors, valid, isValid, mode]);\n\n return (\n <Fragment>\n <p className=\"adyen-checkout_upi-mode-selection-text\">{i18n.get('upi.modeSelection')}</p>\n <SegmentedControl\n onChange={onChangeUpiMode}\n selectedValue={mode}\n disabled={status === 'loading'}\n classNameModifiers={['upi-margin-bottom']}\n options={segmentedControlOptions}\n />\n <ContentSeparator label={i18n.get('upi.completePayment')} />\n {mode === 'intent' && (\n <div id={A11Y.AreaId.INTENT} aria-labelledby={A11Y.ButtonId.INTENT} className=\"adyen-checkout-upi-area-intent\" role=\"region\">\n <UPIIntentAppList\n disabled={status === 'loading'}\n apps={apps}\n selectedAppId={selectedApp?.id}\n onAppSelect={handleAppSelect}\n onVpaInputChange={handleVpaInputChange}\n onSetInputHandlers={onSetVpaInputHandlers}\n />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status,\n disabled: selectedApp == null\n })}\n </div>\n )}\n {mode === 'vpa' && (\n <div id={A11Y.AreaId.VPA} aria-labelledby={A11Y.ButtonId.VPA} className=\"adyen-checkout-upi-area-vpa\" role=\"region\">\n <VpaInput disabled={status === 'loading'} onChange={onChange} onSetInputHandlers={onSetVpaInputHandlers} />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </div>\n )}\n {mode === 'qrCode' && (\n <div id={A11Y.AreaId.QR} aria-labelledby={A11Y.ButtonId.QR} className=\"adyen-checkout-upi-area-qr-code\" role=\"region\">\n {showPayButton &&\n payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status\n })}\n </div>\n )}\n </Fragment>\n );\n}\n"],"names":["UPIComponent","defaultMode","onChange","onUpdateMode","payButton","showPayButton","apps","i18n","useCoreContext","getImage","useImage","status","setStatus","useState","isValid","setIsValid","mode","setMode","vpa","setVpa","vpaInputHandlers","setVpaInputHandlers","selectedApp","setSelectedApp","valid","setValid","errors","setErrors","segmentedControlOptions","useUpiSegmentedControlOptions","this","showValidation","validateInput","onSetVpaInputHandlers","useCallback","handlers","onChangeUpiMode","newMode","handleAppSelect","app","id","handleVpaInputChange","data","virtualPaymentAddress","useEffect","h","Fragment","p","className","get","SegmentedControl","selectedValue","disabled","classNameModifiers","options","ContentSeparator","label","div","A11Y","AreaId","INTENT","aria-labelledby","ButtonId","role","UPIIntentAppList","selectedAppId","onAppSelect","onVpaInputChange","onSetInputHandlers","VPA","VpaInput","QR","icon","imageFolder"],"mappings":"ooBAgCe,SAASA,GAAaC,YAAEA,EAAWC,SAAEA,EAAQC,aAAEA,EAAYC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAO,KACzG,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACVC,EAAQC,GAAaC,EAA0B,UAC/CC,EAASC,GAAcF,EAAkC,WAAhBZ,IACzCe,EAAMC,GAAWJ,EAAkBZ,IACnCiB,EAAKC,GAAUN,EAAiB,KAChCO,EAAkBC,GAAuBR,EAA2B,OACpES,EAAaC,GAAkBV,EAAc,OAC7CW,EAAOC,GAAYZ,EAAS,OAC5Ba,EAAQC,GAAad,EAAS,MAC/Be,EAA0BC,EAA8BvB,EAAMU,GAEpEc,KAAKlB,UAAaD,IACdC,EA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AyB,MAAf9B,KAIhB,QAATN,GACG6B,EAACY,MAAAA,CAAIjB,GAAIkB,EAAKC,OAAOU,IAAKR,kBAAiBH,EAAKI,SAASO,IAAKrB,UAAU,8BAA8Be,KAAK,UACvGlB,EAACyB,EAAAA,CAASlB,SAAqB,YAAXzC,EAAsBT,SAAUA,EAAUkE,mBAAoBnC,IAEjF5B,GACGD,EAAU,CACNoD,MAAOjD,EAAK0C,IAAI,YAChBtC,YAIN,WAATK,GACG6B,EAACY,MAAAA,CAAIjB,GAAIkB,EAAKC,OAAOY,GAAIV,kBAAiBH,EAAKI,SAASS,GAAIvB,UAAU,kCAAkCe,KAAK,UACxG1D,GACGD,EAAU,CACNoD,MAAOjD,EAAK0C,IAAI,kBAChBuB,KAAM/D,EAAS,CAAEgE,YAAa,eAAxBhE,CAAyC,MAC/CE,YAM5B"}
1
+ {"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h, RefObject } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport { PayButtonFunctionProps, UIElementStatus } from '../../../types';\nimport VpaInput, { VpaInputHandlers } from '../VpaInput/VpaInput';\nimport { App, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport { A11Y } from '../../constants';\nimport './UPIComponent.scss';\nimport SegmentedControl from '../../../internal/SegmentedControl';\nimport UPIIntentAppList from '../UPIIntentAppList';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Alert from '../../../internal/Alert';\nimport { SegmentedControlOption } from '../../../internal/SegmentedControl/SegmentedControl';\n\ntype UpiData = { app?: App; virtualPaymentAddress?: string };\n\ntype OnChangeProps = { data: UpiData; valid?: { [key: string]: boolean }; errors?: { [key: string]: any }; isValid: boolean };\n\ninterface UPIComponentProps {\n defaultMode: UpiMode;\n showPayButton: boolean;\n apps?: Array<App>;\n segmentedControlOptions?: Array<SegmentedControlOption<UpiMode>>;\n\n ref?(ref: RefObject<typeof UPIComponent>): void;\n\n payButton?(props: PayButtonFunctionProps): h.JSX.Element;\n\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n\n onUpdateMode?(mode: UpiMode): void;\n}\n\nexport default function UPIComponent({\n defaultMode,\n onChange,\n onUpdateMode = () => {},\n payButton,\n showPayButton,\n apps = [],\n segmentedControlOptions = []\n}: Readonly<UPIComponentProps>): h.JSX.Element {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const [mode, setMode] = useState<UpiMode>(defaultMode);\n const [vpaInputHandlers, setVpaInputHandlers] = useState<VpaInputHandlers>(null);\n const [selectedApp, setSelectedApp] = useState<App>(null);\n const [isValid, setIsValid] = useState<boolean>(defaultMode === 'qrCode');\n\n this.setStatus = (status: UIElementStatus) => {\n setStatus(status);\n };\n\n this.showValidation = () => {\n vpaInputHandlers?.validateInput();\n if (mode === 'intent') {\n validateIntentApp();\n }\n };\n\n const onSetVpaInputHandlers = useCallback((handlers: VpaInputHandlers) => {\n setVpaInputHandlers(handlers);\n }, []);\n\n const onChangeUpiMode = useCallback(\n (newMode: UpiMode) => {\n setMode(newMode);\n onUpdateMode(newMode);\n },\n [onUpdateMode]\n );\n\n const handleAppSelect = useCallback(\n (app: App) => {\n if (app?.id === selectedApp?.id) return;\n\n setSelectedApp(app);\n setIsValid(true);\n setStatus('ready');\n },\n [selectedApp]\n );\n\n const validateIntentApp = useCallback(() => {\n if (!selectedApp) {\n setStatus('error');\n setIsValid(false);\n } else {\n setStatus('ready');\n setIsValid(true);\n }\n }, [selectedApp]);\n\n useEffect(() => {\n if (mode !== 'qrCode') {\n onChange({\n data: { ...(selectedApp && { app: selectedApp }) },\n isValid\n });\n } else {\n /**\n * When selecting QR code mode, we need to clear the state data and trigger the 'onChange'.\n */\n onChange({ data: {}, valid: {}, errors: {}, isValid: true });\n }\n }, [selectedApp, isValid, mode, onChange]);\n\n return (\n <Fragment>\n {segmentedControlOptions.length > 0 && <p className=\"adyen-checkout_upi-mode-selection-text\">{i18n.get('upi.modeSelection')}</p>}\n <SegmentedControl\n onChange={onChangeUpiMode}\n selectedValue={mode}\n disabled={status === 'loading'}\n classNameModifiers={['upi-margin-bottom']}\n options={segmentedControlOptions}\n />\n\n {mode === 'intent' && (\n <div id={A11Y.AreaId.INTENT} aria-labelledby={A11Y.ButtonId.INTENT} className=\"adyen-checkout-upi-area-intent\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.intent.instruction')}</span>\n {status === 'error' && <Alert icon={'cross'}>{i18n.get('upi.error.noAppSelected')}</Alert>}\n <UPIIntentAppList disabled={status === 'loading'} apps={apps} selectedAppId={selectedApp?.id} onAppSelect={handleAppSelect} />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </div>\n )}\n {mode === 'vpa' && (\n <div id={A11Y.AreaId.VPA} aria-labelledby={A11Y.ButtonId.VPA} className=\"adyen-checkout-upi-area-vpa\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.collect.instruction')}</span>\n <VpaInput disabled={status === 'loading'} onChange={onChange} onSetInputHandlers={onSetVpaInputHandlers} />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </div>\n )}\n {mode === 'qrCode' && (\n <div id={A11Y.AreaId.QR} aria-labelledby={A11Y.ButtonId.QR} className=\"adyen-checkout-upi-area-qr-code\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.qrCode.instruction')}</span>\n {showPayButton &&\n payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status\n })}\n </div>\n )}\n </Fragment>\n );\n}\n"],"names":["UPIComponent","defaultMode","onChange","onUpdateMode","payButton","showPayButton","apps","segmentedControlOptions","i18n","useCoreContext","getImage","useImage","status","setStatus","useState","mode","setMode","vpaInputHandlers","setVpaInputHandlers","selectedApp","setSelectedApp","isValid","setIsValid","this","showValidation","validateInput","validateIntentApp","onSetVpaInputHandlers","useCallback","handlers","onChangeUpiMode","newMode","handleAppSelect","app","id","useEffect","data","valid","errors","h","Fragment","length","p","className","get","SegmentedControl","selectedValue","disabled","classNameModifiers","options","div","A11Y","AreaId","INTENT","aria-labelledby","ButtonId","role","span","Alert","icon","UPIIntentAppList","selectedAppId","onAppSelect","label","VPA","VpaInput","onSetInputHandlers","QR","imageFolder"],"mappings":"gkBAiCe,SAASA,GAAaC,YACjCA,EAAWC,SACXA,EAAQC,aACRA,EAAe,OAAQC,UACvBA,EAASC,cACTA,EAAaC,KACbA,EAAO,GAAEC,wBACTA,EAA0B,KAE1B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACVC,EAAQC,GAAaC,EAA0B,UAC/CC,EAAMC,GAAWF,EAAkBb,IACnCgB,EAAkBC,GAAuBJ,EAA2B,OACpEK,EAAaC,GAAkBN,EAAc,OAC7CO,EAASC,GAAcR,EAAkC,WAAhBb,GAEhDsB,KAAKV,UAAaD,IACdC,EAAUD,IAGdW,KAAKC,eAAiB,KAClBP,GAAkBQ,gBACL,WAATV,GACAW,KAIR,MAAMC,EAAwBC,EAAaC,IACvCX,EAAoBW,IACrB,IAEGC,EAAkBF,EACnBG,IACGf,EAAQe,GACR5B,EAAa4B,IAEjB,CAAC5B,IAGC6B,EAAkBJ,EACnBK,IACOA,GAAKC,KAAOf,GAAae,KAE7Bd,EAAea,GACfX,GAAW,GACXT,EAAU,WAEd,CAACM,IAGCO,EAAoBE,EAAY,KAC7BT,GAIDN,EAAU,SACVS,GAAW,KAJXT,EAAU,SACVS,GAAW,KAKhB,CAACH,IAgBJ,OAdAgB,EAAU,KAEFjC,EADS,WAATa,EACS,CACLqB,KAAM,IAAMjB,GAAe,CAAEc,IAAKd,IAClCE,WAMK,CAAEe,KAAM,CAAA,EAAIC,MAAO,CAAA,EAAIC,OAAQ,CAAA,EAAIjB,SAAS,KAE1D,CAACF,EAAaE,EAASN,EAAMb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CAAE0D,YAAa,eAAxB1D,CAAyC,MAC/CE,YAM5B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../Dropin/components/PaymentMethod/PaymentMethodIcon.js";import i from"../../../../internal/ExpandButton/ExpandButton.js";const p=({app:p,imgSrc:n,isSelected:c,onSelect:o=()=>{},children:d})=>{const m=`adyen-checkout-upi-app-item-button-${p.id}`,s=`adyen-checkout-upi-app-${p.id}`;return e("li",{className:t({"adyen-checkout-upi-app-item":!0,"adyen-checkout-upi-app-item--selected":c}),onClick:()=>(e=>{o(e)})(p)},e("div",{className:"adyen-checkout-upi-app-item-header"},e(i,{classNameModifiers:["upi-app-item"],buttonId:m,isSelected:c,expandContentId:s},e(a,{src:n,altDescription:p.name,type:p.id}),e("label",{className:"adyen-checkout-upi-app-item__label",htmlFor:m},p.name))),c&&d&&e("div",{className:"adyen-checkout-upi-app-item-details",id:s},d))};export{p as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../Dropin/components/PaymentMethod/PaymentMethodIcon.js";import p from"../../../../internal/ExpandButton/ExpandButton.js";const c=({app:c,imgSrc:n,isSelected:i,onSelect:o=()=>{}})=>{const m=`adyen-checkout-upi-app-item-button-${c.id}`,s=`adyen-checkout-upi-app-${c.id}`;return e("li",{className:t({"adyen-checkout-upi-app-item":!0,"adyen-checkout-upi-app-item--selected":i}),onClick:()=>(e=>{o(e)})(c)},e("div",{className:"adyen-checkout-upi-app-item-header"},e(p,{classNameModifiers:["upi-app-item"],buttonId:m,isSelected:i,expandContentId:s},e(a,{src:n,altDescription:c.name,type:c.id}),e("label",{className:"adyen-checkout-upi-app-item__label",htmlFor:m},c.name))),i&&e("span",{className:"adyen-checkout-checkmark"}))};export{c as default};
2
2
  //# sourceMappingURL=UPIIntentAppItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPIIntentAppItem.js","sources":["../../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport cx from 'classnames';\nimport { App } from '../../../types';\nimport PaymentMethodIcon from '../../../../Dropin/components/PaymentMethod/PaymentMethodIcon';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport './UPIIntentAppItem.scss';\n\ninterface UPIIntentAppItemProps {\n app: App;\n imgSrc: string;\n isSelected: boolean;\n onSelect?: Function;\n children?: ComponentChildren;\n}\n\nconst UPIIntentAppItem = ({ app, imgSrc, isSelected, onSelect = () => {}, children }: UPIIntentAppItemProps): h.JSX.Element => {\n const buttonId = `adyen-checkout-upi-app-item-button-${app.id}`;\n const containerId = `adyen-checkout-upi-app-${app.id}`;\n const handleAppSelected = (app: App) => {\n onSelect(app);\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <li\n className={cx({\n 'adyen-checkout-upi-app-item': true,\n 'adyen-checkout-upi-app-item--selected': isSelected\n })}\n onClick={() => handleAppSelected(app)}\n >\n <div className=\"adyen-checkout-upi-app-item-header\">\n <ExpandButton classNameModifiers={['upi-app-item']} buttonId={buttonId} isSelected={isSelected} expandContentId={containerId}>\n <PaymentMethodIcon src={imgSrc} altDescription={app.name} type={app.id}></PaymentMethodIcon>\n <label className=\"adyen-checkout-upi-app-item__label\" htmlFor={buttonId}>\n {app.name}\n </label>\n </ExpandButton>\n </div>\n {isSelected && children && (\n <div className=\"adyen-checkout-upi-app-item-details\" id={containerId}>\n {children}\n </div>\n )}\n </li>\n );\n};\n\nexport default UPIIntentAppItem;\n"],"names":["UPIIntentAppItem","app","imgSrc","isSelected","onSelect","children","buttonId","id","containerId","h","li","className","cx","onClick","handleAppSelected","div","ExpandButton","classNameModifiers","expandContentId","PaymentMethodIcon","src","altDescription","name","type","label","htmlFor"],"mappings":"+QAeA,MAAMA,EAAmB,EAAGC,MAAKC,SAAQC,aAAYC,WAAW,OAAUC,eACtE,MAAMC,EAAW,sCAAsCL,EAAIM,KACrDC,EAAc,0BAA0BP,EAAIM,KAKlD,OAEIE,EAACC,KAAAA,CACGC,UAAWC,EAAG,CACV,+BAA+B,EAC/B,wCAAyCT,IAE7CU,QAAS,IAXS,CAACZ,IACvBG,EAASH,IAUUa,CAAkBb,IAEjCQ,EAACM,MAAAA,CAAIJ,UAAU,sCACXF,EAACO,EAAAA,CAAaC,mBAAoB,CAAC,gBAAiBX,SAAUA,EAAUH,WAAYA,EAAYe,gBAAiBV,GAC7GC,EAACU,EAAAA,CAAkBC,IAAKlB,EAAQmB,eAAgBpB,EAAIqB,KAAMC,KAAMtB,EAAIM,KACpEE,EAACe,QAAAA,CAAMb,UAAU,qCAAqCc,QAASnB,GAC1DL,EAAIqB,QAIhBnB,GAAcE,GACXI,EAACM,MAAAA,CAAIJ,UAAU,sCAAsCJ,GAAIC,GACpDH"}
1
+ {"version":3,"file":"UPIIntentAppItem.js","sources":["../../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { App } from '../../../types';\nimport PaymentMethodIcon from '../../../../Dropin/components/PaymentMethod/PaymentMethodIcon';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport './UPIIntentAppItem.scss';\n\ninterface UPIIntentAppItemProps {\n app: App;\n imgSrc: string;\n isSelected: boolean;\n onSelect?: Function;\n}\n\nconst UPIIntentAppItem = ({ app, imgSrc, isSelected, onSelect = () => {} }: UPIIntentAppItemProps): h.JSX.Element => {\n const buttonId = `adyen-checkout-upi-app-item-button-${app.id}`;\n const containerId = `adyen-checkout-upi-app-${app.id}`;\n const handleAppSelected = (app: App) => {\n onSelect(app);\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <li\n className={cx({\n 'adyen-checkout-upi-app-item': true,\n 'adyen-checkout-upi-app-item--selected': isSelected\n })}\n onClick={() => handleAppSelected(app)}\n >\n <div className=\"adyen-checkout-upi-app-item-header\">\n <ExpandButton classNameModifiers={['upi-app-item']} buttonId={buttonId} isSelected={isSelected} expandContentId={containerId}>\n <PaymentMethodIcon src={imgSrc} altDescription={app.name} type={app.id}></PaymentMethodIcon>\n <label className=\"adyen-checkout-upi-app-item__label\" htmlFor={buttonId}>\n {app.name}\n </label>\n </ExpandButton>\n </div>\n {isSelected && <span className=\"adyen-checkout-checkmark\" />}\n </li>\n );\n};\n\nexport default UPIIntentAppItem;\n"],"names":["UPIIntentAppItem","app","imgSrc","isSelected","onSelect","buttonId","id","containerId","h","li","className","cx","onClick","handleAppSelected","div","ExpandButton","classNameModifiers","expandContentId","PaymentMethodIcon","src","altDescription","name","type","label","htmlFor","span"],"mappings":"+QAcA,MAAMA,EAAmB,EAAGC,MAAKC,SAAQC,aAAYC,WAAW,WAC5D,MAAMC,EAAW,sCAAsCJ,EAAIK,KACrDC,EAAc,0BAA0BN,EAAIK,KAKlD,OAEIE,EAACC,KAAAA,CACGC,UAAWC,EAAG,CACV,+BAA+B,EAC/B,wCAAyCR,IAE7CS,QAAS,IAXS,CAACX,IACvBG,EAASH,IAUUY,CAAkBZ,IAEjCO,EAACM,MAAAA,CAAIJ,UAAU,sCACXF,EAACO,EAAAA,CAAaC,mBAAoB,CAAC,gBAAiBX,SAAUA,EAAUF,WAAYA,EAAYc,gBAAiBV,GAC7GC,EAACU,EAAAA,CAAkBC,IAAKjB,EAAQkB,eAAgBnB,EAAIoB,KAAMC,KAAMrB,EAAIK,KACpEE,EAACe,QAAAA,CAAMb,UAAU,qCAAqCc,QAASnB,GAC1DJ,EAAIoB,QAIhBlB,GAAcK,EAACiB,OAAAA,CAAKf,UAAU"}