@adyen/adyen-web 6.5.1 → 6.6.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 (230) hide show
  1. package/dist/cjs/adyen.css +2 -2
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +68 -30
  6. package/dist/es/adyen.css +2 -2
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  9. package/dist/es/components/Ach/components/AchInput/defaultProps.js +1 -1
  10. package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  11. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  12. package/dist/es/components/Boleto/Boleto.js.map +1 -1
  13. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  14. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  15. package/dist/es/components/Card/Card.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/types.js +1 -1
  19. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  20. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  21. package/dist/es/components/CashAppPay/services/types.js +1 -1
  22. package/dist/es/components/CashAppPay/services/types.js.map +1 -1
  23. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  24. package/dist/es/components/Donation/components/CampaignContent.js +1 -1
  25. package/dist/es/components/Donation/components/CampaignContent.js.map +1 -1
  26. package/dist/es/components/Donation/components/CampaignInfo.js +2 -0
  27. package/dist/es/components/Donation/components/CampaignInfo.js.map +1 -0
  28. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  29. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  30. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  31. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  32. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  33. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  34. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  35. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  36. package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
  37. package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
  38. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  39. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  40. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  41. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  42. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  43. package/dist/es/components/OnlineBankingCZ/index.js +1 -1
  44. package/dist/es/components/OnlineBankingCZ/index.js.map +1 -1
  45. package/dist/es/components/OnlineBankingSK/index.js +1 -1
  46. package/dist/es/components/OnlineBankingSK/index.js.map +1 -1
  47. package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
  48. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  49. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  50. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  51. package/dist/es/components/Redirect/Redirect.js +1 -1
  52. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  53. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  54. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  55. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  56. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  57. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  58. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  59. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  60. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  61. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  62. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  63. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  64. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  65. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  66. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  67. package/dist/es/components/Twint/Twint.js.map +1 -1
  68. package/dist/es/components/UPI/UPI.js.map +1 -1
  69. package/dist/es/components/internal/Address/components/CountryField.js +1 -1
  70. package/dist/es/components/internal/Address/components/CountryField.js.map +1 -1
  71. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  72. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  73. package/dist/es/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  74. package/dist/es/components/internal/Address/components/StateField.js +1 -1
  75. package/dist/es/components/internal/Address/components/StateField.js.map +1 -1
  76. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  77. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  78. package/dist/es/components/internal/Button/Button.js.map +1 -1
  79. package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  80. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  81. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  82. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  83. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  84. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  85. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  86. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  87. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  88. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  89. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  90. package/dist/es/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  91. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  92. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  93. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  94. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  95. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  96. package/dist/es/components/tx-variants.js +1 -1
  97. package/dist/es/components/tx-variants.js.map +1 -1
  98. package/dist/es/core/Analytics/Analytics.js +1 -1
  99. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  100. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  101. package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
  102. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
  103. package/dist/es/core/Analytics/constants.js +1 -1
  104. package/dist/es/core/Analytics/constants.js.map +1 -1
  105. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  106. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  107. package/dist/es/core/Errors/constants.js +1 -1
  108. package/dist/es/core/Errors/constants.js.map +1 -1
  109. package/dist/es/core/Errors/utils.js +1 -1
  110. package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
  111. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  112. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  113. package/dist/es/core/core.js +1 -1
  114. package/dist/es/index.d.ts +68 -30
  115. package/dist/es-legacy/adyen.css +2 -2
  116. package/dist/es-legacy/adyen.css.map +1 -1
  117. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  118. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +1 -1
  119. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  120. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  121. package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
  122. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  123. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  124. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  125. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  126. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  127. package/dist/es-legacy/components/Card/components/CardInput/types.js +1 -1
  128. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  129. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  130. package/dist/es-legacy/components/CashAppPay/services/types.js +1 -1
  131. package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  133. package/dist/es-legacy/components/Donation/components/CampaignContent.js +1 -1
  134. package/dist/es-legacy/components/Donation/components/CampaignContent.js.map +1 -1
  135. package/dist/es-legacy/components/Donation/components/CampaignInfo.js +2 -0
  136. package/dist/es-legacy/components/Donation/components/CampaignInfo.js.map +1 -0
  137. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  138. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  139. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  140. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  141. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  142. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  143. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  144. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  145. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  146. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  147. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  148. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  149. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  150. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  151. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  152. package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
  153. package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
  154. package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
  155. package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
  156. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  157. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  158. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  159. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  160. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  161. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  162. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  163. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  164. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  165. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  166. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  167. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  168. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  169. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  170. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  171. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  172. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  173. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  174. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  175. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  176. package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
  177. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  178. package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
  179. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  180. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  181. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  182. package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  183. package/dist/es-legacy/components/internal/Address/components/StateField.js +1 -1
  184. package/dist/es-legacy/components/internal/Address/components/StateField.js.map +1 -1
  185. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  186. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  187. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  188. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  189. package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  190. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  191. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  192. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  193. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  194. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  195. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  196. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  197. package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
  198. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  199. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  200. package/dist/es-legacy/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  201. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  202. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  203. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  204. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  205. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  206. package/dist/es-legacy/components/tx-variants.js +1 -1
  207. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  208. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  209. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  210. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  211. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
  212. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
  213. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  214. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  215. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  216. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  217. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  218. package/dist/es-legacy/core/Errors/constants.js +1 -1
  219. package/dist/es-legacy/core/Errors/constants.js.map +1 -1
  220. package/dist/es-legacy/core/Errors/utils.js +1 -1
  221. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  222. package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  223. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  224. package/dist/es-legacy/core/core.js +1 -1
  225. package/package.json +12 -12
  226. package/styles/adyen.css +2 -2
  227. package/dist/es/components/Donation/components/CampaignContainer.js +0 -2
  228. package/dist/es/components/Donation/components/CampaignContainer.js.map +0 -1
  229. package/dist/es-legacy/components/Donation/components/CampaignContainer.js +0 -2
  230. package/dist/es-legacy/components/Donation/components/CampaignContainer.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: any;\n public static defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise() {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then(resolveObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch(rejectObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAUA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,sBAAqB,GAErE,CAEAM,iBAAAA,GAEIP,KAAKQ,mBAAqBC,EAAeC,EAAwBV,KAAKJ,uBAAwBe,GAC9FX,KAAKQ,mBAAmBI,QACnBC,MAAKC,IACFT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,sBAAsBF,EAAAA,IAEpCG,OAAMC,IACHb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,mBAAmBD,EAAAA,GAE1C,CAEAE,oBAAAA,GACQpB,KAAKQ,oBAAoBR,KAAKQ,mBAAmBa,SACrDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,iBAAEA,EAAgBC,gBAAEA,EAAeC,aAAEA,IAAgBC,qBAAEA,IAC1D,OACIC,EAACC,MAAAA,CAAIC,UAAU,2CACV7B,KAAKG,MAAM2B,aAAeH,EAACI,QAC5BJ,EAACC,MAAAA,CAAII,MAAO,CAAEC,QAAS,SACnBN,EAACO,EAAAA,CACGC,KAAM1C,EACN2C,SAAU,KACNZ,IAAkB,CAAEa,cAAe,kBAAmBC,kBAAmB,GAAGC,+BAAyC,IAG7HZ,EAACa,EAAAA,CACGL,KAAM,oBACNM,OAAQlB,EACRmB,OAAQjD,EACRkD,UAAW,oBACXC,WAAYlB,EACZD,aAAcA,KAKlC,CApEAoB,WAAAA,CAAY1C,GACR2C,MAAM3C,GAPV4C,EAAA/C,KAAQC,6BAAR,GACA8C,EAAA/C,KAAQQ,0BAAR,GAWI,MAAMwC,qBAAEA,EAAoBC,6BAAEA,GAAiCjD,KAAKG,MAE9D+C,EAAUC,KAAKC,UAAU,CAC3BJ,uBACAC,iCAEEvB,EAAuB2B,EAAgBH,GAC7ClD,KAAKsD,MAAQ,CAAE5B,uBACnB,EAlBAqB,EAHErD,EAGY6D,eAAe,CACzBzB,aAAa"}
1
+ {"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: any;\n public static defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise() {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then(resolveObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch(rejectObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAUA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAIzBC,KAAK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EAGY6D,eAAe,CACzBzB,aAAa"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as i,prepareFingerPrintData as n}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as d,TIMEOUT as l,THREEDS2_ERROR as m,THREEDS2_FULL as h,THREEDS2_NUM as c,THREEDS2_FINGERPRINT as S}from"../../constants.js";import{Analytics3DS2Errors as D,ANALYTICS_NETWORK_ERROR as u,ANALYTICS_API_ERROR as g,Analytics3DS2Events as f}from"../../../../core/Analytics/constants.js";function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class I extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{threeDSMethodURL:t,threeDSMethodNotificationURL:r,postMessageDomain:o,threeDSServerTransID:s}=this.state.fingerPrintData;if(!a(t,e))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:D.TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const i=a(r,e),n=a(o,e),d=s?.length;if(!i||!n||!d)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:D.TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.indexOf(d)>-1?D.ACTION_IS_MISSING_TOKEN:D.TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},(()=>{const r=(this.props.isMDFlow?s:i)(this.props.dataKey,e,this.props.paymentData);let o;const n=t||e;if(n.errorCode){const e={code:n.errorCode===l?D.THREEDS2_TIMEOUT:n.errorCode,errorType:n.errorCode===l?u:g};o={type:m,message:n.message,...e},this.props.onSubmitAnalytics(o)}let a;switch(e?.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o={type:h,message:`${c} fingerprinting has completed`,subtype:f.FINGERPRINT_COMPLETED,result:a},this.props.onSubmitAnalytics(o),this.props.onComplete(r)}))}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,{onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${S}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e,...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):null}constructor(e){super(e),C(this,"onFormSubmit",(e=>{this.props.onSubmitAnalytics({type:h,message:e,subtype:f.FINGERPRINT_DATA_SENT})}));const{token:t,notificationURL:r}=this.props;if(t){const e=n({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:d}},console.debug(`${p}: ${d}`)}}C(I,"type","scheme"),C(I,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{I as default};
1
+ import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as i,prepareFingerPrintData as n}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as d,TIMEOUT as l,THREEDS2_ERROR as m,THREEDS2_FULL as h,THREEDS2_NUM as c,THREEDS2_FINGERPRINT as S}from"../../constants.js";import{Analytics3DS2Errors as D,ANALYTICS_ERROR_TYPE as u,Analytics3DS2Events as g}from"../../../../core/Analytics/constants.js";function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class C extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{threeDSMethodURL:t,threeDSMethodNotificationURL:r,postMessageDomain:o,threeDSServerTransID:s}=this.state.fingerPrintData;if(!a(t,e))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:D.TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const i=a(r,e),n=a(o,e),d=s?.length;if(!i||!n||!d)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:D.TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.indexOf(d)>-1?D.ACTION_IS_MISSING_TOKEN:D.TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},(()=>{const r=(this.props.isMDFlow?s:i)(this.props.dataKey,e,this.props.paymentData);let o;const n=t||e;if(n.errorCode){const e={code:n.errorCode===l?D.THREEDS2_TIMEOUT:n.errorCode,errorType:n.errorCode===l?u.network:u.apiError};o={type:m,message:n.message,...e},this.props.onSubmitAnalytics(o)}let a;switch(e?.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o={type:h,message:`${c} fingerprinting has completed`,subtype:g.FINGERPRINT_COMPLETED,result:a},this.props.onSubmitAnalytics(o),this.props.onComplete(r)}))}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,{onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${S}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e,...s,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit}):null}constructor(e){super(e),f(this,"onFormSubmit",(e=>{this.props.onSubmitAnalytics({type:h,message:e,subtype:g.FINGERPRINT_DATA_SENT})}));const{token:t,notificationURL:r}=this.props;if(t){const e=n({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:d}},console.debug(`${p}: ${d}`)}}f(C,"type","scheme"),f(C,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{C as default};
2
2
  //# sourceMappingURL=PrepareFingerprint3DS2.js.map
@@ -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 { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_API_ERROR, ANALYTICS_NETWORK_ERROR, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\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 this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\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 analyticsObject: SendAnalyticsObject;\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_NETWORK_ERROR : ANALYTICS_API_ERROR\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 analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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 analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_NETWORK_ERROR","ANALYTICS_API_ERROR","type","THREEDS2_ERROR","onSubmitAnalytics","result","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","prepareFinger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O,CACP,MAAM7E,EAAiD+E,EAAuB,CAAEF,QAAOC,oBAEvFhF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEgF,SAAS,EAAOnD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA2C,EADEhF,EACYyD,OAAO,UAErBuB,EAHEhF,EAGYuF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACTzC,YAAa,GACbqB,aAAa,EACbzB,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 { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\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 this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\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 analyticsObject: SendAnalyticsObject;\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 analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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 analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","type","THREEDS2_ERROR","onSubmitAnalytics","result","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":"0wBAmBA,MAAMA,UAA+BC,EAuCjCC,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,UAAW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AAepC,OAAEA,EAAM3B,gBAAEA,IAC9B,MAAe,0BAAX2B,EAEIqC,EAACC,EAAAA,CACGC,sBAAuBC,IACnBrE,KAAKc,kBAAkBuD,EAAYZ,OAAM,EAE7Ca,mBAAoBD,IAIhB,MAAME,EAAiC,CACnCvD,UAAWqD,EAAYrD,UACvBG,QAAS,GAAGqD,MAAyBH,EAAYrD,aAGrDhB,KAAKc,kBAAkBuD,EAAYZ,OAAQc,IAE/CN,YAAaA,KACT/D,EACJuE,gBAAiBzE,KAAKI,MAAMqE,gBAC5BC,aAAc1E,KAAK0E,eAKxB,IACX,CAtOAC,WAAAA,CAAYvE,GACRwE,MAAMxE,GAmBVyE,EAAOH,KAAAA,gBAAgBI,IACnB9E,KAAKI,MAAMoD,kBAAkB,CACzBF,KAAMI,EACNvC,QAAS2D,EACTlB,QAASC,EAAoBkB,uBACjC,IAtBA,MAAMC,MAAEA,EAAKC,gBAAEA,GAAoBjF,KAAKI,MAExC,GAAI4E,EAAO,CACP,MAAM9E,EAAiDgF,EAAuB,CAAEF,QAAOC,oBAEvFjF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEiF,SAAS,EAAOpD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA4C,EADEjF,EACY0D,OAAO,UAErBuB,EAHEjF,EAGYwF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT1C,YAAa,GACbsB,aAAa,EACb1B,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2Form.js","sources":["../../../../../../src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\ninterface ThreeDS2FormProps {\n name: string;\n action: string;\n target: string;\n inputName: string;\n inputValue: string;\n onFormSubmit: (msg: string) => void;\n}\n\nexport default class ThreeDS2Form extends Component<ThreeDS2FormProps> {\n protected formEl;\n\n componentDidMount() {\n this.formEl.submit();\n this.props.onFormSubmit(`${this.props.inputName} sent`);\n }\n\n render({ name, action, target, inputName, inputValue }) {\n return (\n <form\n ref={ref => {\n this.formEl = ref;\n }}\n method=\"POST\"\n className={classNames(['adyen-checkout__threeds2__form', `adyen-checkout__threeds2__form--${name}`])}\n name={name}\n action={action}\n target={target}\n style={{ display: 'none' }}\n >\n <input name={inputName} value={inputValue} />\n </form>\n );\n }\n}\n"],"names":["ThreeDS2Form","Component","componentDidMount","this","formEl","submit","props","onFormSubmit","inputName","render","name","action","target","inputValue","h","form","ref","method","className","classNames","style","display","input","value"],"mappings":"kJAYe,MAAMA,UAAqBC,EAGtCC,iBAAAA,GACIC,KAAKC,OAAOC,SACZF,KAAKG,MAAMC,aAAa,GAAGJ,KAAKG,MAAME,iBAC1C,CAEAC,MAAAA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,OAAEA,EAAMJ,UAAEA,EAASK,WAAEA,IACtC,OACIC,EAACC,OAAAA,CACGC,IAAKA,IACDb,KAAKC,OAASY,CAAAA,EAElBC,OAAO,OACPC,UAAWC,EAAW,CAAC,iCAAkC,mCAAmCT,MAC5FA,KAAMA,EACNC,OAAQA,EACRC,OAAQA,EACRQ,MAAO,CAAEC,QAAS,SAElBP,EAACQ,QAAAA,CAAMZ,KAAMF,EAAWe,MAAOV,IAG3C,gDAvBA,KAAUT,cAAVD"}
1
+ {"version":3,"file":"ThreeDS2Form.js","sources":["../../../../../../src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\ninterface ThreeDS2FormProps {\n name: string;\n action: string;\n target: string;\n inputName: string;\n inputValue: string;\n onFormSubmit: (msg: string) => void;\n}\n\nexport default class ThreeDS2Form extends Component<ThreeDS2FormProps> {\n protected formEl;\n\n componentDidMount() {\n this.formEl.submit();\n this.props.onFormSubmit(`${this.props.inputName} sent`);\n }\n\n render({ name, action, target, inputName, inputValue }) {\n return (\n <form\n ref={ref => {\n this.formEl = ref;\n }}\n method=\"POST\"\n className={classNames(['adyen-checkout__threeds2__form', `adyen-checkout__threeds2__form--${name}`])}\n name={name}\n action={action}\n target={target}\n style={{ display: 'none' }}\n >\n <input name={inputName} value={inputValue} />\n </form>\n );\n }\n}\n"],"names":["ThreeDS2Form","Component","componentDidMount","this","formEl","submit","props","onFormSubmit","inputName","render","name","action","target","inputValue","h","form","ref","method","className","classNames","style","display","input","value","super","args"],"mappings":"kJAYe,MAAMA,UAAqBC,EAGtCC,iBAAAA,GACIC,KAAKC,OAAOC,SACZF,KAAKG,MAAMC,aAAa,GAAGJ,KAAKG,MAAME,iBAC1C,CAEAC,MAAAA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,OAAEA,EAAMJ,UAAEA,EAASK,WAAEA,IACtC,OACIC,EAACC,OAAAA,CACGC,IAAKA,IACDb,KAAKC,OAASY,CAAAA,EAElBC,OAAO,OACPC,UAAWC,EAAW,CAAC,iCAAkC,mCAAmCT,MAC5FA,KAAMA,EACNC,OAAQA,EACRC,OAAQA,EACRQ,MAAO,CAAEC,QAAS,SAElBP,EAACQ,QAAAA,CAAMZ,KAAMF,EAAWe,MAAOV,IAG3C,6BAvBAW,SAAAC,UAAA,KAAUrB,cAAVD"}
@@ -1 +1 @@
1
- {"version":3,"file":"Twint.js","sources":["../../../../src/components/Twint/Twint.tsx"],"sourcesContent":["import RedirectElement from '../Redirect';\nimport PayButton, { payAmountLabel } from '../internal/PayButton';\nimport { h } from 'preact';\nimport { TxVariants } from '../tx-variants';\n\nclass TwintElement extends RedirectElement {\n public static type = TxVariants.twint;\n\n public static defaultProps = {\n type: TwintElement.type,\n name: 'Twint'\n };\n /**\n * Get the element displayable name\n */\n get displayName(): string {\n const { i18n, name, isStoredPaymentMethod } = this.props;\n return isStoredPaymentMethod ? `${name} ${i18n.get('twint.saved')}` : name || this.constructor['type'];\n }\n\n public payButtonLabel() {\n const { i18n, amount, isStoredPaymentMethod, name } = this.props;\n if (isStoredPaymentMethod) return payAmountLabel(i18n, amount);\n return `${i18n.get('continueTo')} ${name}`;\n }\n\n /**\n * Overrides RedirectElement default payButton behaviour to use label\n * @param props - props\n */\n public payButton = props => {\n return <PayButton {...props} label={this.payButtonLabel()} onClick={this.submit} />;\n };\n}\n\nexport default TwintElement;\n"],"names":["TwintElement","RedirectElement","displayName","i18n","name","isStoredPaymentMethod","this","props","get","constructor","payButtonLabel","amount","payAmountLabel","_define_property","payButton","h","PayButton","label","onClick","submit","type","TxVariants","twint","defaultProps"],"mappings":"qYAKA,MAAMA,UAAqBC,EAUvB,eAAIC,GACA,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,sBAAEA,GAA0BC,KAAKC,MACnD,OAAOF,EAAwB,GAAGD,KAAQD,EAAKK,IAAI,iBAAmBJ,GAAQE,KAAKG,YAAmB,IAC1G,CAEOC,cAAAA,GACH,MAAMP,KAAEA,EAAIQ,OAAEA,EAAMN,sBAAEA,EAAqBD,KAAEA,GAASE,KAAKC,MAC3D,OAAIF,EAA8BO,EAAeT,EAAMQ,GAChD,GAAGR,EAAKK,IAAI,iBAAiBJ,GACxC,+BAMAS,EAAAP,KAAOQ,aAAYP,GACRQ,EAACC,EAAAA,IAAcT,EAAOU,MAAOX,KAAKI,iBAAkBQ,QAASZ,KAAKa,YAzB7EN,EADEb,EACYoB,OAAOC,EAAWC,OAEhCT,EAHEb,EAGYuB,eAAe,CACzBH,KAAMpB,EAAaoB,KACnBhB,KAAM"}
1
+ {"version":3,"file":"Twint.js","sources":["../../../../src/components/Twint/Twint.tsx"],"sourcesContent":["import RedirectElement from '../Redirect';\nimport PayButton, { payAmountLabel } from '../internal/PayButton';\nimport { h } from 'preact';\nimport { TxVariants } from '../tx-variants';\n\nclass TwintElement extends RedirectElement {\n public static type = TxVariants.twint;\n\n public static defaultProps = {\n type: TwintElement.type,\n name: 'Twint'\n };\n /**\n * Get the element displayable name\n */\n get displayName(): string {\n const { i18n, name, isStoredPaymentMethod } = this.props;\n return isStoredPaymentMethod ? `${name} ${i18n.get('twint.saved')}` : name || this.constructor['type'];\n }\n\n public payButtonLabel() {\n const { i18n, amount, isStoredPaymentMethod, name } = this.props;\n if (isStoredPaymentMethod) return payAmountLabel(i18n, amount);\n return `${i18n.get('continueTo')} ${name}`;\n }\n\n /**\n * Overrides RedirectElement default payButton behaviour to use label\n * @param props - props\n */\n public payButton = props => {\n return <PayButton {...props} label={this.payButtonLabel()} onClick={this.submit} />;\n };\n}\n\nexport default TwintElement;\n"],"names":["TwintElement","RedirectElement","displayName","i18n","name","isStoredPaymentMethod","this","props","get","constructor","payButtonLabel","amount","payAmountLabel","super","args","_define_property","payButton","h","PayButton","label","onClick","submit","type","TxVariants","twint","defaultProps"],"mappings":"qYAKA,MAAMA,UAAqBC,EAUvB,eAAIC,GACA,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,sBAAEA,GAA0BC,KAAKC,MACnD,OAAOF,EAAwB,GAAGD,KAAQD,EAAKK,IAAI,iBAAmBJ,GAAQE,KAAKG,YAAmB,IAC1G,CAEOC,cAAAA,GACH,MAAMP,KAAEA,EAAIQ,OAAEA,EAAMN,sBAAEA,EAAqBD,KAAEA,GAASE,KAAKC,MAC3D,OAAIF,EAA8BO,EAAeT,EAAMQ,GAChD,GAAGR,EAAKK,IAAI,iBAAiBJ,GACxC,mBAEAS,SAAAC,GAIAC,EAAAT,KAAOU,aAAYT,GACRU,EAACC,EAAAA,IAAcX,EAAOY,MAAOb,KAAKI,iBAAkBU,QAASd,KAAKe,YAzB7EN,EADEf,EACYsB,OAAOC,EAAWC,OAEhCT,EAHEf,EAGYyB,eAAe,CACzBH,KAAMtB,EAAasB,KACnBlB,KAAM"}
@@ -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,KAAIC,IAAQ,IAAKA,EAAKJ,KAAMC,EAAWI,eAA2BV,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,GAE1D,MAAO,CACHC,cAAe,IACPL,KAAKM,aAAe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AUnC,KAAKoC,SACfC,aAAcrC,KAAKqC,aACnBvD,KAAMkB,KAAKtB,MAAMI,KACjBD,YAAamB,KAAKtB,MAAMG,YACxByD,cAAetC,KAAKtB,MAAM4D,gBAI9C,CAEOC,MAAAA,GACH,MAAM/C,KAAEA,EAAImB,IAAEA,EAAGC,kBAAEA,GAAsBZ,KAAKtB,MAC9C,OACImC,EAAC2B,EAAAA,CAAalD,KAAMU,KAAKtB,MAAMY,KAAMmD,eAAgBzC,KAAKtB,MAAM+D,eAAgBC,UAAW1C,KAAK0C,WAC5F7B,EAAC8B,EAAAA,CAAgBC,QAAS5C,KAAKtB,MAAMmE,QAAQD,SAAU5C,KAAKU,cAAclB,EAAMmB,EAAKC,IAGjG,CA5HAkC,WAAAA,CAAYC,EAAiBrE,GACzBE,MAAMmE,EAAUrE,GAHpBsE,EAAAhD,KAAQQ,oBAAR,GA2DAwC,EAAAhD,KAAQqC,gBAAgBY,IACpBjD,KAAKQ,aAAeyC,CAAAA,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 { 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,KAAIC,IAAQ,IAAKA,EAAKJ,KAAMC,EAAWI,eAA2BV,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,GAE1D,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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mD,eAAgBzC,KAAKtB,MAAM+D,eAAgBC,UAAW1C,KAAK0C,WAC5F7B,EAAC8B,EAAAA,CAAgBC,QAAS5C,KAAKtB,MAAMmE,QAAQD,SAAU5C,KAAKU,cAAclB,EAAMmB,EAAKC,IAGjG,CA5HAkC,WAAAA,CAAYC,EAAiBrE,GACzBE,MAAMmE,EAAUrE,GAHpBsE,EAAAhD,KAAQQ,oBAAR,GA2DAwC,EAAQX,KAAAA,gBAAgBY,IACpBjD,KAAKQ,aAAeyC,CAAAA,IAxDpBjD,KAAKQ,aAAeR,KAAKtB,MAAMG,WACnC,EARAmE,EADEzE,EACYiB,OAAOC,EAAWyD,KAChCF,EAFEzE,EAEY4E,aAAa,CAAC1D,EAAWyD,IAAKzD,EAAWgB,OAAQhB,EAAWC,YAAaD,EAAWI"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as o,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import t from"../../FormFields/Field/Field.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Services/get-dataset.js";import n from"../../FormFields/Select/Select.js";function l(l){const{allowedCountries:i=[],classNameModifiers:c=[],errorMessage:m,onDropdownChange:d,value:u}=l,{i18n:p,loadingContext:f}=a(),[g,h]=o([]),[y,j]=o(!1),[C,F]=o(l.readOnly);return r((()=>{s("countries",f,p.locale).then((e=>{const o=((e,o)=>{const r=e=>({...e,name:e.name,selectedOptionName:e.name});return o.length?e.filter((e=>o.includes(e.id))).map(r):e.map(r)})(e,i);h(o||[]),F(1===o.length||C),j(!0)})).catch((e=>{console.error(e),h([]),j(!0)}))}),[]),y?e(t,{name:"country",label:p.get("country"),errorMessage:m,classNameModifiers:c,isValid:!!u,showValidIcon:!1,i18n:p,readOnly:C&&!!u},e(n,{onChange:d,name:"country",selectedValue:u,items:g,readonly:C&&!!u})):null}export{l as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as r,useLayoutEffect as o}from"../../../../external/preact/hooks/dist/hooks.js";import t from"../../FormFields/Field/Field.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Services/get-dataset.js";import n from"../../FormFields/Select/Select.js";function l(l){const{allowedCountries:i=[],classNameModifiers:c=[],errorMessage:m,onDropdownChange:d,value:u,required:p}=l,{i18n:f,loadingContext:g}=a(),[h,y]=r([]),[j,C]=r(!1),[F,x]=r(l.readOnly);return o((()=>{s("countries",g,f.locale).then((e=>{const r=((e,r)=>{const o=e=>({...e,name:e.name,selectedOptionName:e.name});return r.length?e.filter((e=>r.includes(e.id))).map(o):e.map(o)})(e,i);y(r||[]),x(1===r.length||F),C(!0)})).catch((e=>{console.error(e),y([]),C(!0)}))}),[]),j?e(t,{name:"country",label:f.get("country"),errorMessage:m,classNameModifiers:c,isValid:!!u,showValidIcon:!1,i18n:f,readOnly:F&&!!u},e(n,{onChange:d,name:"country",selectedValue:u,items:h,readonly:F&&!!u,required:p})):null}export{l as default};
2
2
  //# sourceMappingURL=CountryField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select onChange={onDropdownChange} name={'country'} selectedValue={value} items={countries} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["CountryField","props","allowedCountries","classNameModifiers","errorMessage","onDropdownChange","value","i18n","loadingContext","useCoreContext","countries","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","applyMapper","country","name","selectedOptionName","length","filter","includes","id","map","formatCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAoBe,SAASA,EAAaC,GACjC,MAAMC,iBAAEA,EAAmB,GAAEC,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,GAAUL,GAC5FM,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAWC,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAASX,EAAMc,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaV,EAAgBD,EAAKY,QACxCC,MAAKC,IACF,MAAMC,EAtBE,EAACZ,EAAoCR,KACzD,MACMqB,EAAeC,IACV,IACAA,EACHC,KAAMD,EAAQC,KACdC,mBAAoBF,EAAQC,OAGpC,OAAOvB,EAAiByB,OAASjB,EAAUkB,QARtBJ,GAA8BtB,EAAiB2B,SAASL,EAAQM,MAQtBC,IAAIR,GAAeb,EAAUqB,IAAIR,EAAAA,EAa/DS,CAAgBX,EAAUnB,GAC/CS,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAaK,QAAgBZ,GACzCD,GAAU,EAAA,IAEbmB,OAAMC,IACHC,QAAQD,MAAMA,GACdvB,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDuB,EAACC,EAAAA,CACGZ,KAAM,UACNa,MAAO/B,EAAKgC,IAAI,WAChBnC,aAAcA,EACdD,mBAAoBA,EACpBqC,UAAWlC,EACXmC,eAAe,EACflC,KAAMA,EACNQ,SAAUA,KAAcT,GAExB8B,EAACM,EAAAA,CAAOC,SAAUtC,EAAkBoB,KAAM,UAAWmB,cAAetC,EAAOuC,MAAOnC,EAAWoC,SAAU/B,KAAcT,KAbzG,IAgBxB"}
1
+ {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value, required } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select\n onChange={onDropdownChange}\n name={'country'}\n selectedValue={value}\n items={countries}\n readonly={readOnly && !!value}\n required={required}\n />\n </Field>\n );\n}\n"],"names":["CountryField","props","allowedCountries","classNameModifiers","errorMessage","onDropdownChange","value","required","i18n","loadingContext","useCoreContext","countries","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","applyMapper","country","name","selectedOptionName","length","filter","includes","id","map","formatCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAoBe,SAASA,EAAaC,GACjC,MAAMC,iBAAEA,EAAmB,GAAEC,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,EAAKC,SAAEA,GAAaN,GACtGO,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAWC,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAASZ,EAAMe,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaV,EAAgBD,EAAKY,QACxCC,MAAKC,IACF,MAAMC,EAtBE,EAACZ,EAAoCT,KACzD,MACMsB,EAAeC,IACV,IACAA,EACHC,KAAMD,EAAQC,KACdC,mBAAoBF,EAAQC,OAGpC,OAAOxB,EAAiB0B,OAASjB,EAAUkB,QARtBJ,GAA8BvB,EAAiB4B,SAASL,EAAQM,MAQtBC,IAAIR,GAAeb,EAAUqB,IAAIR,EAAAA,EAa/DS,CAAgBX,EAAUpB,GAC/CU,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAaK,QAAgBZ,GACzCD,GAAU,EAAA,IAEbmB,OAAMC,IACHC,QAAQD,MAAMA,GACdvB,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDuB,EAACC,EAAAA,CACGZ,KAAM,UACNa,MAAO/B,EAAKgC,IAAI,WAChBpC,aAAcA,EACdD,mBAAoBA,EACpBsC,UAAWnC,EACXoC,eAAe,EACflC,KAAMA,EACNQ,SAAUA,KAAcV,GAExB+B,EAACM,EAAAA,CACGC,SAAUvC,EACVqB,KAAM,UACNmB,cAAevC,EACfwC,MAAOnC,EACPoC,SAAU/B,KAAcV,EACxBC,SAAUA,KAnBF,IAuBxB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import t from"./CountryField.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import a from"../../FormFields/InputText.js";function i(i){const{i18n:n}=s(),{classNameModifiers:l=[],data:d,errors:c,valid:u,fieldName:m,onInput:f,onBlur:p,trimOnBlur:g,maxLength:F,disabled:C}=i,M=d[m],y=d.country,b=i.specifications.countryHasOptionalField(y,m),j=i.specifications.getKeyForField(m,y),w=b?` ${n.get("field.title.optional")}`:"",h=`${n.get(j)}${w}`,v=function(e,r,o,t){if("object"==typeof e[r]?.errorMessage){const{translationKey:t,translationObject:s}=e[r].errorMessage;return o.get(t,s)}return o.get(e[r]?.errorMessage,{values:{label:t.toLowerCase()}})||!!e[r]}(c,m,n,h);switch(m){case"country":return e(t,{allowedCountries:i.allowedCountries,classNameModifiers:l,label:h,errorMessage:v,onDropdownChange:i.onDropdownChange,value:M});case"stateOrProvince":return e(o,{classNameModifiers:l,label:h,errorMessage:v,onDropdownChange:i.onDropdownChange,selectedCountry:y,specifications:i.specifications,value:M});default:return e(r,{label:h,classNameModifiers:l,errorMessage:v,isValid:u[m],name:m,i18n:n,onFocus:e=>i.onFieldFocusAnalytics(m,e),onBlur:e=>i.onFieldBlurAnalytics(m,e)},e(a,{name:m,classNameModifiers:l,value:M,onInput:f,onBlur:p,maxlength:F,trimOnBlur:g,disabled:C,required:!b}))}}export{i as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import t from"./CountryField.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import s from"../../FormFields/InputText.js";function a(a){const{i18n:n}=i(),{classNameModifiers:l=[],data:d,errors:c,valid:u,fieldName:m,onInput:f,onBlur:p,trimOnBlur:g,maxLength:F,disabled:C}=a,M=d[m],y=d.country,b=a.specifications.countryHasOptionalField(y,m),j=a.specifications.getKeyForField(m,y),w=b?` ${n.get("field.title.optional")}`:"",h=`${n.get(j)}${w}`,v=function(e,r,o,t){if("object"==typeof e[r]?.errorMessage){const{translationKey:t,translationObject:i}=e[r].errorMessage;return o.get(t,i)}return o.get(e[r]?.errorMessage,{values:{label:t.toLowerCase()}})||!!e[r]}(c,m,n,h);switch(m){case"country":return e(t,{allowedCountries:a.allowedCountries,classNameModifiers:l,label:h,errorMessage:v,onDropdownChange:a.onDropdownChange,value:M,required:!b});case"stateOrProvince":return e(o,{classNameModifiers:l,label:h,errorMessage:v,onDropdownChange:a.onDropdownChange,selectedCountry:y,specifications:a.specifications,value:M,required:!b});default:return e(r,{label:h,classNameModifiers:l,errorMessage:v,isValid:u[m],name:m,i18n:n,onFocus:e=>a.onFieldFocusAnalytics(m,e),onBlur:e=>a.onFieldBlurAnalytics(m,e)},e(s,{name:m,classNameModifiers:l,value:M,onInput:f,onBlur:p,maxlength:F,trimOnBlur:g,disabled:C,required:!b}))}}export{a as default};
2
2
  //# sourceMappingURL=FieldContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction FieldContainer(props: FieldContainerProps) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName);\n const labelKey: string = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n switch (fieldName) {\n case 'country':\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n />\n );\n case 'stateOrProvince':\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n />\n );\n default:\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n />\n </Field>\n );\n }\n}\n\nexport default FieldContainer;\n"],"names":["FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","fieldName","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength","required"],"mappings":"iTAyBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,GAAaZ,EAEhHa,EAAgBT,EAAKG,GACrBO,EAA0BV,EAAKW,QAC/BC,EAAsBhB,EAAMiB,eAAeC,wBAAwBJ,EAAiBP,GACpFY,EAAmBnB,EAAMiB,eAAeG,eAAeb,EAAWO,GAClEO,EAAgBL,EAAa,IAAIf,EAAKqB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGtB,EAAKqB,IAAIH,KAAYE,IAChCG,EA1BV,SAAyBnB,EAA2BE,EAAmBN,EAAgBsB,GACnF,GAA+C,iBAApClB,EAAOE,IAAYiB,aAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBrB,EAAOE,GAAWiB,aAChE,OAAOvB,EAAKqB,IAAIG,EAAgBC,EACpC,CAGA,OADiBzB,EAAKqB,IAAIjB,EAAOE,IAAYiB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DvB,EAAOE,EAChC,CAkByBsB,CAAgBxB,EAAQE,EAAWN,EAAMsB,GAE9D,OAAQhB,GACJ,IAAK,UACD,OACIuB,EAACC,EAAAA,CACGC,iBAAkBhC,EAAMgC,iBACxB7B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBpB,MAAOA,IAGnB,IAAK,kBACD,OACIiB,EAACI,EAAAA,CACG/B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBnB,gBAAiBA,EACjBG,eAAgBjB,EAAMiB,eACtBJ,MAAOA,IAGnB,QACI,OACIiB,EAACK,EAAAA,CACGZ,MAAOA,EACPpB,mBAAoBA,EACpBqB,aAAcA,EACdY,QAAS9B,EAAMC,GACf8B,KAAM9B,EACNN,KAAMA,EACNqC,QAASC,GAAKvC,EAAMwC,sBAAsBjC,EAAWgC,GACrD9B,OAAQ8B,GAAKvC,EAAMyC,qBAAqBlC,EAAWgC,IAEnDT,EAACY,EAAAA,CACGL,KAAM9B,EACNJ,mBAAoBA,EACpBU,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRkC,UAAWhC,EACXD,WAAYA,EACZE,SAAUA,EACVgC,UAAW5B,KAKnC"}
1
+ {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction FieldContainer(props: FieldContainerProps) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName);\n const labelKey: string = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n switch (fieldName) {\n case 'country':\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n required={!isOptional}\n />\n );\n case 'stateOrProvince':\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n required={!isOptional}\n />\n );\n default:\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n />\n </Field>\n );\n }\n}\n\nexport default FieldContainer;\n"],"names":["FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","fieldName","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","required","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength"],"mappings":"iTAyBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,GAAaZ,EAEhHa,EAAgBT,EAAKG,GACrBO,EAA0BV,EAAKW,QAC/BC,EAAsBhB,EAAMiB,eAAeC,wBAAwBJ,EAAiBP,GACpFY,EAAmBnB,EAAMiB,eAAeG,eAAeb,EAAWO,GAClEO,EAAgBL,EAAa,IAAIf,EAAKqB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGtB,EAAKqB,IAAIH,KAAYE,IAChCG,EA1BV,SAAyBnB,EAA2BE,EAAmBN,EAAgBsB,GACnF,GAA+C,iBAApClB,EAAOE,IAAYiB,aAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBrB,EAAOE,GAAWiB,aAChE,OAAOvB,EAAKqB,IAAIG,EAAgBC,EACpC,CAGA,OADiBzB,EAAKqB,IAAIjB,EAAOE,IAAYiB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DvB,EAAOE,EAChC,CAkByBsB,CAAgBxB,EAAQE,EAAWN,EAAMsB,GAE9D,OAAQhB,GACJ,IAAK,UACD,OACIuB,EAACC,EAAAA,CACGC,iBAAkBhC,EAAMgC,iBACxB7B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBpB,MAAOA,EACPqB,UAAWlB,IAGvB,IAAK,kBACD,OACIc,EAACK,EAAAA,CACGhC,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBnB,gBAAiBA,EACjBG,eAAgBjB,EAAMiB,eACtBJ,MAAOA,EACPqB,UAAWlB,IAGvB,QACI,OACIc,EAACM,EAAAA,CACGb,MAAOA,EACPpB,mBAAoBA,EACpBqB,aAAcA,EACda,QAAS/B,EAAMC,GACf+B,KAAM/B,EACNN,KAAMA,EACNsC,QAASC,GAAKxC,EAAMyC,sBAAsBlC,EAAWiC,GACrD/B,OAAQ+B,GAAKxC,EAAM0C,qBAAqBnC,EAAWiC,IAEnDV,EAACa,EAAAA,CACGL,KAAM/B,EACNJ,mBAAoBA,EACpBU,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRmC,UAAWjC,EACXD,WAAYA,EACZE,SAAUA,EACVsB,UAAWlB,KAKnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyAddress.js","sources":["../../../../../../src/components/internal/Address/components/ReadOnlyAddress.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport Fieldset from '../../FormFields/Fieldset';\nimport { ReadOnlyAddressProps } from '../types';\nimport { FALLBACK_VALUE } from '../constants';\n\nconst FullName = ({ firstName, lastName }) => {\n return (\n <Fragment>\n {firstName && `${firstName} `}\n {lastName && `${lastName}`}\n <br />\n </Fragment>\n );\n};\n\nconst ReadOnlyAddress = ({ data, label }: ReadOnlyAddressProps) => {\n const { street, houseNumberOrName, city, postalCode, stateOrProvince, country, firstName, lastName } = data;\n const hasName = firstName || lastName;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label} readonly>\n <Fragment>\n {hasName && <FullName firstName={firstName} lastName={lastName}></FullName>}\n {!!street && street}\n {houseNumberOrName && `, ${houseNumberOrName},`}\n <br />\n {postalCode && `${postalCode}`}\n {city && `, ${city}`}\n {stateOrProvince && stateOrProvince !== FALLBACK_VALUE && `, ${stateOrProvince}`}\n {country && `, ${country} `}\n </Fragment>\n </Fieldset>\n );\n};\n\nexport default ReadOnlyAddress;\n"],"names":["FullName","firstName","lastName","h","Fragment","br","ReadOnlyAddress","data","label","street","houseNumberOrName","city","postalCode","stateOrProvince","country","Fieldset","classNameModifiers","readonly","FALLBACK_VALUE"],"mappings":"+LAKA,MAAMA,EAAW,EAAGC,YAAWC,cAEvBC,EAACC,EAAAA,KACIH,GAAa,GAAGA,KAChBC,GAAY,GAAGA,IAChBC,EAACE,KAAAA,OAKPC,EAAkB,EAAGC,OAAMC,YAC7B,MAAMC,OAAEA,EAAMC,kBAAEA,EAAiBC,KAAEA,EAAIC,WAAEA,EAAUC,gBAAEA,EAAeC,QAAEA,EAAOb,UAAEA,EAASC,SAAEA,GAAaK,EAGvG,OACIJ,EAACY,EAAAA,CAASC,mBAAoB,CAACR,GAAQA,MAAOA,EAAOS,UAAAA,GACjDd,EAACC,EAAAA,MAJOH,GAAaC,IAKLC,EAACH,EAAAA,CAASC,UAAWA,EAAWC,SAAUA,MACnDO,GAAUA,EACZC,GAAqB,KAAKA,KAC3BP,EAACE,KACAO,MAAAA,GAAc,GAAGA,IACjBD,GAAQ,KAAKA,IACbE,GAAmBA,IAAoBK,GAAkB,KAAKL,IAC9DC,GAAW,KAAKA,MAAU"}
1
+ {"version":3,"file":"ReadOnlyAddress.js","sources":["../../../../../../src/components/internal/Address/components/ReadOnlyAddress.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport Fieldset from '../../FormFields/Fieldset';\nimport { ReadOnlyAddressProps } from '../types';\nimport { FALLBACK_VALUE } from '../constants';\n\nconst FullName = ({ firstName, lastName }) => {\n return (\n <Fragment>\n {firstName && `${firstName} `}\n {lastName && `${lastName}`}\n <br />\n </Fragment>\n );\n};\n\nconst ReadOnlyAddress = ({ data, label }: ReadOnlyAddressProps) => {\n const { street, houseNumberOrName, city, postalCode, stateOrProvince, country, firstName, lastName } = data;\n const hasName = firstName || lastName;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label} readonly>\n <Fragment>\n {hasName && <FullName firstName={firstName} lastName={lastName}></FullName>}\n {!!street && street}\n {houseNumberOrName && `, ${houseNumberOrName},`}\n <br />\n {postalCode && `${postalCode}`}\n {city && `, ${city}`}\n {stateOrProvince && stateOrProvince !== FALLBACK_VALUE && `, ${stateOrProvince}`}\n {country && `, ${country} `}\n </Fragment>\n </Fieldset>\n );\n};\n\nexport default ReadOnlyAddress;\n"],"names":["FullName","firstName","lastName","h","Fragment","br","ReadOnlyAddress","data","label","street","houseNumberOrName","city","postalCode","stateOrProvince","country","Fieldset","classNameModifiers","readonly","FALLBACK_VALUE"],"mappings":"+LAKA,MAAMA,EAAW,EAAGC,YAAWC,cAEvBC,EAACC,EAAAA,KACIH,GAAa,GAAGA,KAChBC,GAAY,GAAGA,IAChBC,EAACE,KAAAA,OAKPC,EAAkB,EAAGC,OAAMC,YAC7B,MAAMC,OAAEA,EAAMC,kBAAEA,EAAiBC,KAAEA,EAAIC,WAAEA,EAAUC,gBAAEA,EAAeC,QAAEA,EAAOb,UAAEA,EAASC,SAAEA,GAAaK,EAGvG,OACIJ,EAACY,EAAAA,CAASC,mBAAoB,CAACR,GAAQA,MAAOA,EAAOS,UAAAA,GACjDd,EAACC,EAAAA,MAJOH,GAAaC,IAKLC,EAACH,EAAAA,CAASC,UAAWA,EAAWC,SAAUA,MACnDO,GAAUA,EACZC,GAAqB,KAAKA,KAC3BP,EAACE,KAAAA,MACAO,GAAc,GAAGA,IACjBD,GAAQ,KAAKA,IACbE,GAAmBA,IAAoBK,GAAkB,KAAKL,IAC9DC,GAAW,KAAKA,MAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import a from"../../../../core/Services/get-dataset.js";import n from"../../FormFields/Select/Select.js";function i(i){const{classNameModifiers:l,label:c,onDropdownChange:d,readOnly:m,selectedCountry:f,specifications:p,value:u}=i,{i18n:h,loadingContext:g}=s(),[j,v]=t([]),[y,C]=t(!1);return r((()=>{if(!f||!p.countryHasDataset(f))return v([]),void C(!0);a(`states/${f}`,g,h.locale).then((e=>{const t=e&&e.length?e:[];v(t),C(!0)})).catch((()=>{v([]),C(!0)}))}),[f]),y&&j.length?e(o,{label:c,classNameModifiers:l,errorMessage:i.errorMessage,isValid:!!u,showValidIcon:!1,name:"stateOrProvince",i18n:h,readOnly:m&&!!u},e(n,{name:"stateOrProvince",onChange:d,selectedValue:u,items:j,readonly:m&&!!u})):null}export{i as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as r,useLayoutEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import a from"../../../../core/Services/get-dataset.js";import i from"../../FormFields/Select/Select.js";function n(n){const{classNameModifiers:l,label:c,onDropdownChange:d,readOnly:m,selectedCountry:f,specifications:u,value:p,required:h}=n,{i18n:g,loadingContext:j}=s(),[v,y]=r([]),[C,F]=r(!1);return t((()=>{if(!f||!u.countryHasDataset(f))return y([]),void F(!0);a(`states/${f}`,j,g.locale).then((e=>{const r=e&&e.length?e:[];y(r),F(!0)})).catch((()=>{y([]),F(!0)}))}),[f]),C&&v.length?e(o,{label:c,classNameModifiers:l,errorMessage:n.errorMessage,isValid:!!p,showValidIcon:!1,name:"stateOrProvince",i18n:g,readOnly:m&&!!p},e(i,{name:"stateOrProvince",onChange:d,selectedValue:p,items:v,required:h,readonly:m&&!!p})):null}export{n as default};
2
2
  //# sourceMappingURL=StateField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateField.js","sources":["../../../../../../src/components/internal/Address/components/StateField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useLayoutEffect } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { StateFieldItem, StateFieldProps } from '../types';\nimport Select from '../../FormFields/Select';\n\nexport default function StateField(props: StateFieldProps) {\n const { classNameModifiers, label, onDropdownChange, readOnly, selectedCountry, specifications, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [states, setStates] = useState<StateFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n\n useLayoutEffect(() => {\n if (!selectedCountry || !specifications.countryHasDataset(selectedCountry)) {\n setStates([]);\n setLoaded(true);\n return;\n }\n\n getDataset(`states/${selectedCountry}`, loadingContext, i18n.locale)\n .then(response => {\n const newStates = response && response.length ? response : [];\n setStates(newStates);\n setLoaded(true);\n })\n .catch(() => {\n setStates([]);\n setLoaded(true);\n });\n }, [selectedCountry]);\n\n if (!loaded || !states.length) return null;\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={props.errorMessage}\n isValid={!!value}\n showValidIcon={false}\n name={'stateOrProvince'}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select name={'stateOrProvince'} onChange={onDropdownChange} selectedValue={value} items={states} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["StateField","props","classNameModifiers","label","onDropdownChange","readOnly","selectedCountry","specifications","value","i18n","loadingContext","useCoreContext","states","setStates","useState","loaded","setLoaded","useLayoutEffect","countryHasDataset","getDataset","locale","then","response","newStates","length","catch","h","Field","errorMessage","isValid","showValidIcon","name","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAQe,SAASA,EAAWC,GAC/B,MAAMC,mBAAEA,EAAkBC,MAAEA,EAAKC,iBAAEA,EAAgBC,SAAEA,EAAQC,gBAAEA,EAAeC,eAAEA,EAAcC,MAAEA,GAAUP,GACpGQ,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAQC,GAAaC,EAA2B,KAChDC,EAAQC,GAAaF,GAAkB,GAqB9C,OAnBAG,GAAgB,KACZ,IAAKX,IAAoBC,EAAeW,kBAAkBZ,GAGtD,OAFAO,EAAU,SACVG,GAAU,GAIdG,EAAW,UAAUb,IAAmBI,EAAgBD,EAAKW,QACxDC,MAAKC,IACF,MAAMC,EAAYD,GAAYA,EAASE,OAASF,EAAW,GAC3DT,EAAUU,GACVP,GAAU,EAAA,IAEbS,OAAM,KACHZ,EAAU,IACVG,GAAU,EAAA,GACd,GACL,CAACV,IAECS,GAAWH,EAAOY,OAGnBE,EAACC,EAAAA,CACGxB,MAAOA,EACPD,mBAAoBA,EACpB0B,aAAc3B,EAAM2B,aACpBC,UAAWrB,EACXsB,eAAe,EACfC,KAAM,kBACNtB,KAAMA,EACNJ,SAAUA,KAAcG,GAExBkB,EAACM,EAAAA,CAAOD,KAAM,kBAAmBE,SAAU7B,EAAkB8B,cAAe1B,EAAO2B,MAAOvB,EAAQwB,SAAU/B,KAAcG,KAb5F,IAgB1C"}
1
+ {"version":3,"file":"StateField.js","sources":["../../../../../../src/components/internal/Address/components/StateField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useLayoutEffect } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { StateFieldItem, StateFieldProps } from '../types';\nimport Select from '../../FormFields/Select';\n\nexport default function StateField(props: StateFieldProps) {\n const { classNameModifiers, label, onDropdownChange, readOnly, selectedCountry, specifications, value, required } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [states, setStates] = useState<StateFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n\n useLayoutEffect(() => {\n if (!selectedCountry || !specifications.countryHasDataset(selectedCountry)) {\n setStates([]);\n setLoaded(true);\n return;\n }\n\n getDataset(`states/${selectedCountry}`, loadingContext, i18n.locale)\n .then(response => {\n const newStates = response && response.length ? response : [];\n setStates(newStates);\n setLoaded(true);\n })\n .catch(() => {\n setStates([]);\n setLoaded(true);\n });\n }, [selectedCountry]);\n\n if (!loaded || !states.length) return null;\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={props.errorMessage}\n isValid={!!value}\n showValidIcon={false}\n name={'stateOrProvince'}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select\n name={'stateOrProvince'}\n onChange={onDropdownChange}\n selectedValue={value}\n items={states}\n required={required}\n readonly={readOnly && !!value}\n />\n </Field>\n );\n}\n"],"names":["StateField","props","classNameModifiers","label","onDropdownChange","readOnly","selectedCountry","specifications","value","required","i18n","loadingContext","useCoreContext","states","setStates","useState","loaded","setLoaded","useLayoutEffect","countryHasDataset","getDataset","locale","then","response","newStates","length","catch","h","Field","errorMessage","isValid","showValidIcon","name","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAQe,SAASA,EAAWC,GAC/B,MAAMC,mBAAEA,EAAkBC,MAAEA,EAAKC,iBAAEA,EAAgBC,SAAEA,EAAQC,gBAAEA,EAAeC,eAAEA,EAAcC,MAAEA,EAAKC,SAAEA,GAAaR,GAC9GS,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAQC,GAAaC,EAA2B,KAChDC,EAAQC,GAAaF,GAAkB,GAqB9C,OAnBAG,GAAgB,KACZ,IAAKZ,IAAoBC,EAAeY,kBAAkBb,GAGtD,OAFAQ,EAAU,SACVG,GAAU,GAIdG,EAAW,UAAUd,IAAmBK,EAAgBD,EAAKW,QACxDC,MAAKC,IACF,MAAMC,EAAYD,GAAYA,EAASE,OAASF,EAAW,GAC3DT,EAAUU,GACVP,GAAU,EAAA,IAEbS,OAAM,KACHZ,EAAU,IACVG,GAAU,EAAA,GACd,GACL,CAACX,IAECU,GAAWH,EAAOY,OAGnBE,EAACC,EAAAA,CACGzB,MAAOA,EACPD,mBAAoBA,EACpB2B,aAAc5B,EAAM4B,aACpBC,UAAWtB,EACXuB,eAAe,EACfC,KAAM,kBACNtB,KAAMA,EACNL,SAAUA,KAAcG,GAExBmB,EAACM,EAAAA,CACGD,KAAM,kBACNE,SAAU9B,EACV+B,cAAe3B,EACf4B,MAAOvB,EACPJ,SAAUA,EACV4B,SAAUhC,KAAcG,KAnBE,IAuB1C"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import s from"../../../utils/uuid.js";import r from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as o,ANALYTICS_RENDERED_STR as n}from"../../../core/Analytics/constants.js";import{on as i,off as a}from"../../../utils/listenerUtils.js";function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class p{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=e(this.props,"modules.risk.data"),s=e(this.props,"modules.analytics.getCheckoutAttemptId")?.()??o,r=this.state.order||this.props.order,n=this.formatData();if(n.paymentMethod&&s&&(n.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&n.billingAddress){const{firstName:t,lastName:e,...s}=n.billingAddress;n.billingAddress={...s}}return{...t&&{riskData:{clientData:t}},...r&&{order:{orderData:r.orderData,pspReference:r.pspReference}},...n,clientStateDataIndicator:!0}}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const s="string"==typeof e?document.querySelector(e):e;if(!s)throw new Error("Component could not mount. Root node was not found.");const r=!this._node;return this._node&&this.unmount(),this._node=s,i(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,s),r&&this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:s&&s.offsetWidth,component:this.props.isDropin?"dropin":this.constructor.analyticsType??this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:n})})),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return a(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){h(this,"_id",`${this.constructor.type}-${s()}`),h(this,"core",void 0),h(this,"props",void 0),h(this,"state",{}),h(this,"_component",void 0),h(this,"_node",null);const o=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!o)throw new r("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e),this.handleKeyPress=this.handleKeyPress.bind(this)}}h(p,"defaultProps",{});export{p as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import s from"../../../utils/uuid.js";import r from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as o,ANALYTICS_RENDERED_STR as i}from"../../../core/Analytics/constants.js";import{on as n,off as a}from"../../../utils/listenerUtils.js";function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class p{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=e(this.props,"modules.risk.data"),s=e(this.props,"modules.analytics.getCheckoutAttemptId")?.()??o,r=this.state.order||this.props.order,i=this.formatData();if(i.paymentMethod&&s&&(i.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&i.billingAddress){const{firstName:t,lastName:e,...s}=i.billingAddress;i.billingAddress={...s}}return{...t&&{riskData:{clientData:t}},...r&&{order:{orderData:r.orderData,pspReference:r.pspReference}},...i,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const s="string"==typeof e?document.querySelector(e):e;if(!s)throw new Error("Component could not mount. Root node was not found.");const r=!this._node;return this._node&&this.unmount(),this._node=s,n(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,s),r&&this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:s&&s.offsetWidth,component:this.props.isDropin?"dropin":this.constructor.analyticsType??this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:i})})),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return a(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){h(this,"_id",`${this.constructor.type}-${s()}`),h(this,"core",void 0),h(this,"props",void 0),h(this,"state",{}),h(this,"_component",void 0),h(this,"_node",null);const o=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!o)throw new r("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e),this.handleKeyPress=this.handleKeyPress.bind(this)}}h(p,"defaultProps",{});export{p as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","clientData","getProp","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","type","billingAddress","firstName","lastName","rest","riskData","orderData","pspReference","clientStateDataIndicator","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIs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AAmB,6DAIvEH,KAAKuD,KAAOC,EACZxD,KAAKF,kBAAkBG,GAEvBD,KAAKS,eAAiBT,KAAKS,eAAewD,KAAKjE,KACnD,EAhBAyD,EAVW5D,EAUMqE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","clientData","getProp","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","type","billingAddress","firstName","lastName","rest","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"0eAuBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAA2B,gBAAKJ,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAG,GACI,MAAO,EACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfZ,KAAKa,MAAQ,IAAKb,KAAKa,SAAUD,EACrC,CAMA,QAAWE,GACP,MAAMC,EAAaC,EAAQhB,KAAKC,MAAO,qBACjCgB,EAAoBD,EAAQhB,KAAKC,MAAO,yCAApBe,MAAqEE,EACzFC,EAAQnB,KAAKa,MAAMM,OAASnB,KAAKC,MAAMkB,MACvCC,EAAgBpB,KAAKI,aAS3B,GAPIgB,EAAcC,eAAiBJ,IAC/BG,EAAcC,cAAcJ,kBAAoBA,GAM5B,YAApBjB,KAAKC,MAAMqB,MAAsBF,EAAcG,eAAgB,CAC/D,MAAMC,UAAEA,EAASC,SAAEA,KAAaC,GAASN,EAAcG,eACvDH,EAAcG,eAAiB,IAAKG,EACxC,CAEA,MAAO,IACCX,GAAc,CAAEY,SAAU,CAAEZ,kBAC5BI,GAAS,CAAEA,MAAO,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AG3D,KAAKG,YAAmB,QAAIyD,OACrDF,EAAA1D,KAAgBwD,YAAhB,GAEAE,EAAA1D,KAAOC,aAAP,GACAyD,EAAA1D,KAAOa,QAAa,CAAA,GACpB6C,EAAA1D,KAAO2C,kBAAP,GAEAe,EAAA1D,KAAUwC,QAAqB,MAK3B,MAAMqB,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuCjE,KAAKG,YAAmB,6DAIvEH,KAAKwD,KAAOC,EACZzD,KAAKF,kBAAkBG,GAEvBD,KAAKS,eAAiBT,KAAKS,eAAeyD,KAAKlE,KACnD,EAhBA0D,EAVW7D,EAUMsE,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './Button.scss';\nimport { ButtonProps, ButtonState } from './types';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self',\n onClick: () => {}\n };\n\n public onClick = e => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n public onKeyDown = (event: KeyboardEvent) => {\n this.props.onKeyDown?.(event);\n };\n\n render({ classNameModifiers = [], disabled, href, icon, inline, label, status, variant }, { completed }) {\n const { i18n } = useCoreContext();\n\n const buttonIcon = icon ? <img className=\"adyen-checkout__button__icon\" src={icon} alt=\"\" aria-hidden=\"true\" /> : '';\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant !== 'primary' ? [variant] : []),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n <span className={'adyen-checkout__button__text--sr-only'}>{i18n.get('loading')}</span>\n </span>\n ),\n redirect: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a className={buttonClasses} href={href} disabled={disabled} target={this.props.target} rel={this.props.rel}>\n {buttonText}\n </a>\n );\n }\n\n return (\n <button className={buttonClasses} type=\"button\" disabled={disabled} onClick={this.onClick} onKeyDown={this.onKeyDown}>\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","inline","label","status","variant","completed","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","get","redirect","default","buttonText","a","target","this","props","rel","button","type","onClick","onKeyDown","children","_define_property","e","preventDefault","complete","delay","setState","setTimeout","event","defaultProps"],"mappings":"gXAOA,MAAMA,UAAeC,EA8BjBC,MAAAA,EAAOC,mBAAEA,EAAqB,GAAEC,SAAEA,EAAQC,KAAEA,EAAIC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,IAAWC,UAAEA,IACxF,MAAMC,KAAEA,GAASC,IAEXC,EAAaR,EAAOS,EAACC,MAAAA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AW,KACPd,KAAKa,SAAS,CAAEvC,WAAW,GAAM,GAClCsC,EAAAA,IAGPJ,EAAAR,KAAOM,aAAaS,IAChBf,KAAKC,MAAMK,YAAYS,EAAAA,KA1B3BP,EADE7C,EACYqD,eAAe,CACzB5C,OAAQ,UACRC,QAAS,UACTN,UAAU,EACVI,MAAO,GACPD,QAAQ,EACR6B,OAAQ,QACRM,QAAS"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './Button.scss';\nimport { ButtonProps, ButtonState } from './types';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self',\n onClick: () => {}\n };\n\n public onClick = e => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n public onKeyDown = (event: KeyboardEvent) => {\n this.props.onKeyDown?.(event);\n };\n\n render({ classNameModifiers = [], disabled, href, icon, inline, label, status, variant }, { completed }) {\n const { i18n } = useCoreContext();\n\n const buttonIcon = icon ? <img className=\"adyen-checkout__button__icon\" src={icon} alt=\"\" aria-hidden=\"true\" /> : '';\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant !== 'primary' ? [variant] : []),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n <span className={'adyen-checkout__button__text--sr-only'}>{i18n.get('loading')}</span>\n </span>\n ),\n redirect: (\n <span className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a className={buttonClasses} href={href} disabled={disabled} target={this.props.target} rel={this.props.rel}>\n {buttonText}\n </a>\n );\n }\n\n return (\n <button className={buttonClasses} type=\"button\" disabled={disabled} onClick={this.onClick} onKeyDown={this.onKeyDown}>\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","inline","label","status","variant","completed","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","get","redirect","default","buttonText","a","target","this","props","rel","button","type","onClick","onKeyDown","children","super","args","_define_property","e","preventDefault","complete","delay","setState","setTimeout","event","defaultProps"],"mappings":"gXAOA,MAAMA,UAAeC,EA8BjBC,MAAAA,EAAOC,mBAAEA,EAAqB,GAAEC,SAAEA,EAAQC,KAAEA,EAAIC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,IAAWC,UAAEA,IACxF,MAAMC,KAAEA,GAASC,IAEXC,EAAaR,EAAOS,EAACC,MAAAA,CAAIC,UAAU,+BAA+BC,IAAKZ,EAAMa,IAAI,GAAGC,cAAY,SAAY,GAE5GC,EAAY,IACXlB,KACa,YAAZO,EAAwB,CAACA,GAAW,MACpCH,EAAS,CAAC,UAAY,MACtBI,EAAY,CAAC,aAAe,MACjB,YAAXF,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEa,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,KAAIC,GAA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 +1 @@
1
- {"version":3,"file":"TimeoutError.js","sources":["../../../../../../src/components/internal/ClickToPay/errors/TimeoutError.ts"],"sourcesContent":["interface TimeoutErrorProps {\n source: string;\n scheme: string;\n isTimeoutTriggeredBySchemeSdk: boolean;\n}\n\nclass TimeoutError extends Error {\n public scheme: string;\n public source: string;\n public isTimeoutTriggeredBySchemeSdk: boolean;\n\n /** Currently populated only by Visa SDK if available */\n public correlationId?: string;\n\n constructor(options: TimeoutErrorProps) {\n super(`ClickToPayService - Timeout during ${options.source}() of the scheme '${options.scheme}'`);\n\n this.name = 'TimeoutError';\n this.source = options.source;\n this.scheme = options.scheme;\n this.isTimeoutTriggeredBySchemeSdk = options.isTimeoutTriggeredBySchemeSdk;\n }\n\n public setCorrelationId(correlationId: string): void {\n this.correlationId = correlationId;\n }\n\n public toString() {\n return this.message;\n }\n}\n\nexport default TimeoutError;\n"],"names":["TimeoutError","Error","setCorrelationId","correlationId","this","toString","message","constructor","options","super","source","scheme","_define_property","isTimeoutTriggeredBySchemeSdk","name"],"mappings":"wHAMA,MAAMA,UAAqBC,MAiBhBC,gBAAAA,CAAiBC,GACpBC,KAAKD,cAAgBA,CACzB,CAEOE,QAAAA,GACH,OAAOD,KAAKE,OAChB,CAfAC,WAAAA,CAAYC,GACRC,MAAM,sCAAsCD,EAAQE,2BAA2BF,EAAQG,WAR3FC,EAAAR,KAAOO,cAAP,GACAC,EAAAR,KAAOM,cAAP,GACAE,EAAAR,KAAOS,qCAAP,GAGAD,EAAOT,KAAAA,qBAAP,GAKIC,KAAKU,KAAO,eACZV,KAAKM,OAASF,EAAQE,OACtBN,KAAKO,OAASH,EAAQG,OACtBP,KAAKS,8BAAgCL,EAAQK,6BACjD"}
1
+ {"version":3,"file":"TimeoutError.js","sources":["../../../../../../src/components/internal/ClickToPay/errors/TimeoutError.ts"],"sourcesContent":["interface TimeoutErrorProps {\n source: string;\n scheme: string;\n isTimeoutTriggeredBySchemeSdk: boolean;\n}\n\nclass TimeoutError extends Error {\n public scheme: string;\n public source: string;\n public isTimeoutTriggeredBySchemeSdk: boolean;\n\n /** Currently populated only by Visa SDK if available */\n public correlationId?: string;\n\n constructor(options: TimeoutErrorProps) {\n super(`ClickToPayService - Timeout during ${options.source}() of the scheme '${options.scheme}'`);\n\n this.name = 'TimeoutError';\n this.source = options.source;\n this.scheme = options.scheme;\n this.isTimeoutTriggeredBySchemeSdk = options.isTimeoutTriggeredBySchemeSdk;\n }\n\n public setCorrelationId(correlationId: string): void {\n this.correlationId = correlationId;\n }\n\n public toString() {\n return this.message;\n }\n}\n\nexport default TimeoutError;\n"],"names":["TimeoutError","Error","setCorrelationId","correlationId","this","toString","message","constructor","options","super","source","scheme","_define_property","isTimeoutTriggeredBySchemeSdk","name"],"mappings":"wHAMA,MAAMA,UAAqBC,MAiBhBC,gBAAAA,CAAiBC,GACpBC,KAAKD,cAAgBA,CACzB,CAEOE,QAAAA,GACH,OAAOD,KAAKE,OAChB,CAfAC,WAAAA,CAAYC,GACRC,MAAM,sCAAsCD,EAAQE,2BAA2BF,EAAQG,WAR3FC,EAAOD,KAAAA,cAAP,GACAC,EAAOF,KAAAA,cAAP,GACAE,EAAAR,KAAOS,qCAAP,GAGAD,EAAAR,KAAOD,qBAAP,GAKIC,KAAKU,KAAO,eACZV,KAAKM,OAASF,EAAQE,OACtBN,KAAKO,OAASH,EAAQG,OACtBP,KAAKS,8BAAgCL,EAAQK,6BACjD"}
@@ -1,2 +1,2 @@
1
- import{CTP_IFRAME_NAME as e,createCheckoutPayloadBasedOnScheme as i,createShopperCardsList as t}from"./utils.js";import s from"./sdks/SrciError.js";import{SchemeNames as o}from"./sdks/utils.js";import n from"../../../../utils/uuid.js";import r from"../../../../core/Errors/AdyenCheckoutError.js";import{isRejected as a,isFulfilled as d}from"../../../../utils/promise-util.js";import h from"../errors/TimeoutError.js";import{executeWithTimeout as c}from"./execute-with-timeout.js";function l(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}var m;!function(e){e.Idle="Idle",e.Loading="Loading",e.ShopperIdentified="ShopperIdentified",e.OneTimePassword="OneTimePassword",e.Ready="Ready",e.Login="Login",e.NotAvailable="NotAvailable"}(m||(m={}));class S{get shopperAccountFound(){return["Ready","ShopperIdentified"].includes(this.state)}get schemes(){return this.sdkLoader.schemes}updateStoreCookiesConsent(e){this.storeCookies=e}async initialize(){this.setState("Loading");try{this.sdks=await this.sdkLoader.load(this.environment),await this.initiateSdks();const{recognized:e=!1,idTokens:i=null}=await this.verifyIfShopperIsRecognized();if(e)return await this.getShopperProfile(i),void this.setState("Ready");if(!this.shopperIdentity)return void this.setState("NotAvailable");const{isEnrolled:t}=await this.verifyIfShopperIsEnrolled(this.shopperIdentity);if(t)return void this.setState("ShopperIdentified");this.setState("NotAvailable")}catch(e){e instanceof s&&"REQUEST_TIMEOUT"===e?.reason||e instanceof h?this.handleTimeout(e):e instanceof s?console.warn(`Error at ClickToPayService # init: ${e.toString()}`):console.warn(e),this.setState("NotAvailable")}}subscribeOnStateChange(e){this.stateSubscriber=e}async startIdentityValidation(){if(!this.validationSchemeSdk)throw Error("startIdentityValidation: No ValidationSDK set for the validation process");try{const{maskedValidationChannel:e}=await this.validationSchemeSdk.initiateIdentityValidation();this.identityValidationData={maskedShopperContact:e.replace(/\*/g,"•"),selectedNetwork:o[this.validationSchemeSdk.schemeName]},this.setState("OneTimePassword")}catch(e){throw this.validationSchemeSdk=null,e}}async finishIdentityValidation(e){if(!this.validationSchemeSdk)throw Error("finishIdentityValidation: No ValidationSDK set for the validation process");const i=await this.validationSchemeSdk.completeIdentityValidation(e);await this.getShopperProfile([i.idToken]),this.setState("Ready"),this.validationSchemeSdk=null}async checkout(t){if(!t)throw Error("ClickToPayService # checkout: Missing card data");const s=this.sdks.find((e=>e.schemeName===t.scheme)),o=await s.checkout({srcDigitalCardId:t.srcDigitalCardId,srcCorrelationId:t.srcCorrelationId,...t.isDcfPopupEmbedded&&{windowRef:window.frames[e]},...this.storeCookies&&{complianceSettings:{complianceResources:[{complianceType:"REMEMBER_ME",uri:""}]}}});if("COMPLETE"!==o.dcfActionCode)throw new r("ERROR",`Checkout through Scheme DCF did not complete. DCF Action code received: ${o.dcfActionCode}`);return i(t,o,this.environment)}async logout(){if(!this.sdks)throw new r("ERROR","ClickToPayService is not initialized");try{const e=this.sdks.map((e=>e.unbindAppInstance()));await Promise.all(e)}catch(e){e instanceof s?console.warn(`Error at ClickToPayService # logout: ${e.toString()}`):console.warn(e)}this.shopperCards=null,this.identityValidationData=null,this.validationSchemeSdk=null,this.setState("Login")}verifyIfShopperIsEnrolled(e){const{shopperEmail:i}=e;return new Promise(((e,t)=>{const s=this.sdks.map((s=>c((()=>s.identityLookup({identityValue:i,type:"email"})),5e3,new h({source:"identityLookup",scheme:s.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((i=>{i.consumerPresent&&!this.validationSchemeSdk&&(this.setSdkForPerformingShopperIdentityValidation(s),e({isEnrolled:!0}))})).catch((e=>{t(e)}))));Promise.allSettled(s).then((()=>{e({isEnrolled:!1})}))}))}setState(e){this.state=e,this.stateSubscriber?.(this.state)}setSdkForPerformingShopperIdentityValidation(e){this.validationSchemeSdk=e}handleTimeout(e){const i=e instanceof s?new h({source:e.source,scheme:e.scheme,isTimeoutTriggeredBySchemeSdk:!0}):e;"visa"===i.scheme&&(i.setCorrelationId(window.VISA_SDK?.correlationId),window.VISA_SDK?.correlationId?window.VISA_SDK?.buildClientProfile?.():window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId)),this.onTimeout?.(i)}async getShopperProfile(e){return new Promise(((i,s)=>{const o=this.sdks.map((i=>i.getSrcProfile(e)));Promise.allSettled(o).then((e=>{e.every(a)&&s(e[0].reason);const o=e.map(((e,i)=>d(e)&&{...e.value,scheme:this.sdks[i].schemeName})).filter((e=>!!e));this.shopperCards=t(o),i()}))}))}verifyIfShopperIsRecognized(){return new Promise(((e,i)=>{const t=this.sdks.map((t=>c((()=>t.isRecognized()),5e3,new h({source:"isRecognized",scheme:t.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((i=>{i.recognized&&e(i)})).catch((e=>{i(e)}))));Promise.allSettled(t).then((()=>{e({recognized:!1})}))}))}initiateSdks(){const e=this.sdks.map((e=>{const i=this.schemesConfig[e.schemeName];return c((()=>e.init(i,this.srciTransactionId)),5e3,new h({source:"init",scheme:e.schemeName,isTimeoutTriggeredBySchemeSdk:!1}))}));return Promise.all(e)}constructor(e,i,t,s,o){l(this,"sdkLoader",void 0),l(this,"schemesConfig",void 0),l(this,"shopperIdentity",void 0),l(this,"environment",void 0),l(this,"onTimeout",void 0),l(this,"srciTransactionId",n()),l(this,"sdks",void 0),l(this,"validationSchemeSdk",null),l(this,"stateSubscriber",void 0),l(this,"state","Idle"),l(this,"shopperCards",null),l(this,"identityValidationData",null),l(this,"storeCookies",!1),this.sdkLoader=i,this.schemesConfig=e,this.shopperIdentity=s,this.environment=t,this.onTimeout=o}}export{m as CtpState,S as default};
1
+ import{CTP_IFRAME_NAME as e,createCheckoutPayloadBasedOnScheme as i,createShopperCardsList as t}from"./utils.js";import s from"./sdks/SrciError.js";import{SchemeNames as o}from"./sdks/utils.js";import r from"../../../../utils/uuid.js";import n from"../../../../core/Errors/AdyenCheckoutError.js";import{isRejected as a,isFulfilled as d}from"../../../../utils/promise-util.js";import h from"../errors/TimeoutError.js";import{executeWithTimeout as c}from"./execute-with-timeout.js";function l(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}var m=function(e){return e.Idle="Idle",e.Loading="Loading",e.ShopperIdentified="ShopperIdentified",e.OneTimePassword="OneTimePassword",e.Ready="Ready",e.Login="Login",e.NotAvailable="NotAvailable",e}({});class S{get shopperAccountFound(){return["Ready","ShopperIdentified"].includes(this.state)}get schemes(){return this.sdkLoader.schemes}updateStoreCookiesConsent(e){this.storeCookies=e}async initialize(){this.setState("Loading");try{this.sdks=await this.sdkLoader.load(this.environment),await this.initiateSdks();const{recognized:e=!1,idTokens:i=null}=await this.verifyIfShopperIsRecognized();if(e)return await this.getShopperProfile(i),void this.setState("Ready");if(!this.shopperIdentity)return void this.setState("NotAvailable");const{isEnrolled:t}=await this.verifyIfShopperIsEnrolled(this.shopperIdentity);if(t)return void this.setState("ShopperIdentified");this.setState("NotAvailable")}catch(e){e instanceof s&&"REQUEST_TIMEOUT"===e?.reason||e instanceof h?this.handleTimeout(e):e instanceof s?console.warn(`Error at ClickToPayService # init: ${e.toString()}`):console.warn(e),this.setState("NotAvailable")}}subscribeOnStateChange(e){this.stateSubscriber=e}async startIdentityValidation(){if(!this.validationSchemeSdk)throw Error("startIdentityValidation: No ValidationSDK set for the validation process");try{const{maskedValidationChannel:e}=await this.validationSchemeSdk.initiateIdentityValidation();this.identityValidationData={maskedShopperContact:e.replace(/\*/g,"•"),selectedNetwork:o[this.validationSchemeSdk.schemeName]},this.setState("OneTimePassword")}catch(e){throw this.validationSchemeSdk=null,e}}async finishIdentityValidation(e){if(!this.validationSchemeSdk)throw Error("finishIdentityValidation: No ValidationSDK set for the validation process");const i=await this.validationSchemeSdk.completeIdentityValidation(e);await this.getShopperProfile([i.idToken]),this.setState("Ready"),this.validationSchemeSdk=null}async checkout(t){if(!t)throw Error("ClickToPayService # checkout: Missing card data");const s=this.sdks.find((e=>e.schemeName===t.scheme)),o=await s.checkout({srcDigitalCardId:t.srcDigitalCardId,srcCorrelationId:t.srcCorrelationId,...t.isDcfPopupEmbedded&&{windowRef:window.frames[e]},...this.storeCookies&&{complianceSettings:{complianceResources:[{complianceType:"REMEMBER_ME",uri:""}]}}});if("COMPLETE"!==o.dcfActionCode)throw new n("ERROR",`Checkout through Scheme DCF did not complete. DCF Action code received: ${o.dcfActionCode}`);return i(t,o,this.environment)}async logout(){if(!this.sdks)throw new n("ERROR","ClickToPayService is not initialized");try{const e=this.sdks.map((e=>e.unbindAppInstance()));await Promise.all(e)}catch(e){e instanceof s?console.warn(`Error at ClickToPayService # logout: ${e.toString()}`):console.warn(e)}this.shopperCards=null,this.identityValidationData=null,this.validationSchemeSdk=null,this.setState("Login")}verifyIfShopperIsEnrolled(e){const{shopperEmail:i}=e;return new Promise(((e,t)=>{const s=this.sdks.map((s=>c((()=>s.identityLookup({identityValue:i,type:"email"})),5e3,new h({source:"identityLookup",scheme:s.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((i=>{i.consumerPresent&&!this.validationSchemeSdk&&(this.setSdkForPerformingShopperIdentityValidation(s),e({isEnrolled:!0}))})).catch((e=>{t(e)}))));Promise.allSettled(s).then((()=>{e({isEnrolled:!1})}))}))}setState(e){this.state=e,this.stateSubscriber?.(this.state)}setSdkForPerformingShopperIdentityValidation(e){this.validationSchemeSdk=e}handleTimeout(e){const i=e instanceof s?new h({source:e.source,scheme:e.scheme,isTimeoutTriggeredBySchemeSdk:!0}):e;"visa"===i.scheme&&(i.setCorrelationId(window.VISA_SDK?.correlationId),window.VISA_SDK?.correlationId?window.VISA_SDK?.buildClientProfile?.():window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId)),this.onTimeout?.(i)}async getShopperProfile(e){return new Promise(((i,s)=>{const o=this.sdks.map((i=>i.getSrcProfile(e)));Promise.allSettled(o).then((e=>{e.every(a)&&s(e[0].reason);const o=e.map(((e,i)=>d(e)&&{...e.value,scheme:this.sdks[i].schemeName})).filter((e=>!!e));this.shopperCards=t(o),i()}))}))}verifyIfShopperIsRecognized(){return new Promise(((e,i)=>{const t=this.sdks.map((t=>c((()=>t.isRecognized()),5e3,new h({source:"isRecognized",scheme:t.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((i=>{i.recognized&&e(i)})).catch((e=>{i(e)}))));Promise.allSettled(t).then((()=>{e({recognized:!1})}))}))}initiateSdks(){const e=this.sdks.map((e=>{const i=this.schemesConfig[e.schemeName];return c((()=>e.init(i,this.srciTransactionId)),5e3,new h({source:"init",scheme:e.schemeName,isTimeoutTriggeredBySchemeSdk:!1}))}));return Promise.all(e)}constructor(e,i,t,s,o){l(this,"sdkLoader",void 0),l(this,"schemesConfig",void 0),l(this,"shopperIdentity",void 0),l(this,"environment",void 0),l(this,"onTimeout",void 0),l(this,"srciTransactionId",r()),l(this,"sdks",void 0),l(this,"validationSchemeSdk",null),l(this,"stateSubscriber",void 0),l(this,"state","Idle"),l(this,"shopperCards",null),l(this,"identityValidationData",null),l(this,"storeCookies",!1),this.sdkLoader=i,this.schemesConfig=e,this.shopperIdentity=s,this.environment=t,this.onTimeout=o}}export{m as CtpState,S as default};
2
2
  //# sourceMappingURL=ClickToPayService.js.map