@adyen/adyen-web 6.0.0-alpha.8 → 6.0.0-beta.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 (169) hide show
  1. package/dist/cjs/adyen.css +65 -65
  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 +861 -1243
  6. package/dist/es/adyen.css +65 -65
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Ach/Ach.js +1 -1
  9. package/dist/es/components/Ach/Ach.js.map +1 -1
  10. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  11. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  12. package/dist/es/components/Blik/Blik.js +1 -1
  13. package/dist/es/components/Blik/Blik.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  15. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/handlers.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +2 -0
  18. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -0
  19. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  20. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  21. package/dist/es/components/Dropin/Dropin.js +1 -1
  22. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  23. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  24. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  26. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  27. package/dist/es/components/Dropin/elements/createElements.js.map +1 -1
  28. package/dist/es/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  29. package/dist/es/components/Dropin/elements/createStoredElements.js.map +1 -1
  30. package/dist/es/components/Dropin/elements/filters.js.map +1 -1
  31. package/dist/es/components/Giropay/Giropay.js +1 -1
  32. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  33. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  34. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  35. package/dist/es/components/Redirect/Redirect.js +1 -1
  36. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  37. package/dist/es/components/Trustly/Trustly.js +1 -1
  38. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  39. package/dist/es/components/WeChat/config.js +1 -1
  40. package/dist/es/components/WeChat/config.js.map +1 -1
  41. package/dist/es/components/components-name-map.js +1 -1
  42. package/dist/es/components/components-name-map.js.map +1 -1
  43. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  44. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  45. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  46. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  47. package/dist/es/components/index.js +1 -1
  48. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  49. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  50. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  51. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/services/utils.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/services/utils.js.map +1 -1
  56. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  57. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  58. package/dist/es/components/internal/RedirectButton/RedirectButton.js +1 -1
  59. package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  60. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  61. package/dist/es/components/tx-variants.js +1 -1
  62. package/dist/es/components/tx-variants.js.map +1 -1
  63. package/dist/es/core/AdyenCheckout.js.map +1 -1
  64. package/dist/es/core/Analytics/Analytics.js +1 -1
  65. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  66. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  67. package/dist/es/core/ProcessResponse/PaymentAction/PaymentAction.js.map +1 -1
  68. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  69. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  70. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  71. package/dist/es/core/Services/http.js +1 -1
  72. package/dist/es/core/Services/http.js.map +1 -1
  73. package/dist/es/core/Services/sessions/setup-session.js +1 -1
  74. package/dist/es/core/Services/sessions/setup-session.js.map +1 -1
  75. package/dist/es/core/core.js +1 -1
  76. package/dist/es/core/core.js.map +1 -1
  77. package/dist/es/core/core.registry.js.map +1 -1
  78. package/dist/es/external/preact/dist/preact.js +1 -1
  79. package/dist/es/external/preact/dist/preact.js.map +1 -1
  80. package/dist/es/index.d.ts +861 -1243
  81. package/dist/es/index.js +1 -1
  82. package/dist/es/language/constants.js +1 -1
  83. package/dist/es/language/constants.js.map +1 -1
  84. package/dist/es-legacy/adyen.css +65 -65
  85. package/dist/es-legacy/adyen.css.map +1 -1
  86. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  87. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  88. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  89. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  90. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  91. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  92. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  93. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  94. package/dist/es-legacy/components/Card/components/CardInput/handlers.js +1 -1
  95. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +2 -0
  96. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -0
  97. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  98. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  99. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  100. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  101. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  102. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  103. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  104. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  105. package/dist/es-legacy/components/Dropin/elements/createElements.js.map +1 -1
  106. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  107. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js.map +1 -1
  108. package/dist/es-legacy/components/Dropin/elements/filters.js.map +1 -1
  109. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  110. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  111. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  112. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  113. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  114. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  115. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  116. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  117. package/dist/es-legacy/components/WeChat/config.js +1 -1
  118. package/dist/es-legacy/components/WeChat/config.js.map +1 -1
  119. package/dist/es-legacy/components/components-name-map.js +1 -1
  120. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  121. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  122. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  123. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  124. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  125. package/dist/es-legacy/components/index.js +1 -1
  126. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  127. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  128. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  129. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  130. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js +1 -1
  131. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  132. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js +1 -1
  133. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js.map +1 -1
  134. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  135. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  136. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  137. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  138. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  139. package/dist/es-legacy/components/tx-variants.js +1 -1
  140. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  141. package/dist/es-legacy/core/AdyenCheckout.js.map +1 -1
  142. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  143. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  144. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  145. package/dist/es-legacy/core/ProcessResponse/PaymentAction/PaymentAction.js.map +1 -1
  146. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  147. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  148. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  149. package/dist/es-legacy/core/Services/http.js +1 -1
  150. package/dist/es-legacy/core/Services/http.js.map +1 -1
  151. package/dist/es-legacy/core/Services/sessions/setup-session.js +1 -1
  152. package/dist/es-legacy/core/Services/sessions/setup-session.js.map +1 -1
  153. package/dist/es-legacy/core/core.js +1 -1
  154. package/dist/es-legacy/core/core.js.map +1 -1
  155. package/dist/es-legacy/core/core.registry.js.map +1 -1
  156. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  157. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  158. package/dist/es-legacy/index.js +1 -1
  159. package/dist/es-legacy/language/constants.js +1 -1
  160. package/dist/es-legacy/language/constants.js.map +1 -1
  161. package/package.json +30 -30
  162. package/dist/es/components/Ideal/index.js +0 -2
  163. package/dist/es/components/Ideal/index.js.map +0 -1
  164. package/dist/es/core/Services/analytics/log-event.js +0 -2
  165. package/dist/es/core/Services/analytics/log-event.js.map +0 -1
  166. package/dist/es-legacy/components/Ideal/index.js +0 -2
  167. package/dist/es-legacy/components/Ideal/index.js.map +0 -1
  168. package/dist/es-legacy/core/Services/analytics/log-event.js +0 -2
  169. package/dist/es-legacy/core/Services/analytics/log-event.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { h } from 'preact';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport { Resources } from '../../../core/Context/Resources';\nimport { ANALYTICS_SUBMIT_STR } from '../../../core/Analytics/constants';\n\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport type { CoreConfiguration, ICore } from '../../../core/types';\nimport type { ComponentMethodsRef, IUIElement, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type {\n AdditionalDetailsStateData,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentResponse\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { NewableComponent } from '../../../core/core.registry';\n\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> implements IUIElement {\n protected componentRef: any;\n\n protected resources: Resources;\n\n public elementRef: UIElement;\n\n public static type = undefined;\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n const isStoredPaymentMethod = !!componentProps?.isStoredPaymentMethod;\n const paymentMethodsResponseProps = isStoredPaymentMethod\n ? {}\n : this.core.paymentMethodsResponse.find(componentProps?.type || this.constructor['type']);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodsResponseProps,\n ...componentProps\n };\n\n const isDropin = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropin), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n // Only called once, for UIElements (including Dropin), as they are being mounted\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n const sessionId = this.props.session?.id;\n\n return this.props.modules.analytics.setUp({\n ...setUpAnalyticsObj,\n ...(sessionId && { sessionId })\n });\n }\n\n /**\n * A function for all UIElements, or BaseElement, to use to create an analytics action for when it's been:\n * - mounted,\n * - a PM has been selected\n * - onSubmit has been called (as a result of the pay button being pressed)\n *\n * In some other cases e.g. 3DS2 components, this function is overridden to allow more specific analytics actions to be created\n */\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj: SendAnalyticsObject, uiElementProps?) {\n /** Work out what the component's \"type\" is:\n * - first check for a dedicated \"analyticsType\" (currently only applies to custom-cards)\n * - otherwise, distinguish cards from non-cards: cards will use their static type property, everything else will use props.type\n */\n try {\n let component = this.constructor['analyticsType'];\n if (!component) {\n component = this.constructor['type'] === 'scheme' || this.constructor['type'] === 'bcmc' ? this.constructor['type'] : this.props.type;\n }\n\n this.props.modules.analytics.sendAnalytics(component, analyticsObj, uiElementProps);\n } catch (error) {\n console.warn('Failed to submit the analytics event. Error:', error);\n }\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall().then(sanitizeResponse).then(verifyPaymentDidNotFail).then(this.handleResponse).catch(this.handleFailedResult);\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) =>\n this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject\n })\n )\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n // Call analytics endpoint\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXCdSC4ksw9CNDBAjOa+B88wRoj/rLTieuWh/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJvZZHvlDMXIlxhZcDoQvsMj/WwE6+nFJxBiC3oRzmvVn3AbkLQGtvwq16UUSfYbPzG9dXypJMtcrZAQYq2g/2+BSibCcmee9AXq/wij11BERrYmjbDt5NkkdUnDVgAB7pdqbnWX0A2sxBKeYtLSP2kxp+5LoU/Wty3fmcVA3VKVkHfgmIihkeL8lY++5hvHjnkzOE4tyx/sheiKS4zqoWE43TD6n8mpFskAzwMHq4G2o6vkXqvaKFEq7y/R2fVrCypenmRhkPASizpM265rKLU+L4E/C+LMHfN0LYKRMCrLr0gI2GAp+1PZLHgh0tCtiJC/zcJJtJs6sHNQxLUN+kxJuELUHOcuL3ivjG+mWteUnBENZu7KqOSZYetiWYRiyLOXDiBHqbxuQwTuO54L15VLkS/mYB20etibM1nn+fRmbo+1IJkCSalhwi5D7fSrpjbQTmAsOpJT1N8lC1MSNmAvAwG1kWL4JxYwXDKYyYASnsia2V5IjoiQUYwQUFBMTAzQ0E1MzdFQUVEODdDMjRERDUzOTA5QjgwQTc4QTkyM0UzODIzRDY4REFDQzk0Qj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Ts4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n if (this.props.onComplete) this.props.onComplete(state, this.elementRef);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsStateData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsStateData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session ? this.core.update({ order }) : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a session /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * @param rawResponse -\n */\n protected handleResponse(rawResponse: RawPaymentResponse): void {\n const response = sanitizeResponse(rawResponse);\n\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protect _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonFunctionProps) => {\n return <PayButton {...props} amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return reject(new Error('onPaymentMethodsRequest is not implemented'));\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","buildElementProps","componentProps","finalProps","_object_spread","showPayButton","this","core","getCorePropsForComponent","isStoredPaymentMethod","paymentMethodsResponse","find","type","constructor","isDropin","assertIsDropin","props","formatProps","getRegulatoryDefaults","options","countryCode","storeElementRefOnCore","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","setUpAnalytics","setUpAnalyticsObj","_this_props_session","sessionId","session","id","modules","analytics","setUp","submitAnalytics","analyticsObj","uiElementProps","component","sendAnalytics","error","console","warn","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","handleFailedResult","onSubmit","submitUsingAdvancedFlow","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","ANALYTICS_SUBMIT_STR","submitPayment","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","_object_spread_props","unmount","mount","_node","rawResponse","response","order","remainingAmount","value","handleOrder","handleSuccessResult","updateParent","update","icon","paymentMethodType","_this_props_icon","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","_this_core_paymentMethodsResponse","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","checkout","super","_define_property","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","onPaymentCompleted","setComponentRef","ref","payButton","h","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"yyCA6BO,MAAeA,UAA6DC,EAsC5DC,iBAAAA,CAAkBC,GACjC,MAMMC,EAAaC,EAAA,CACfC,eAAe,GAPKC,KAAKC,KAAKC,8BACFN,aAAAA,EAAAA,EAAgBO,uBAE1C,GACAH,KAAKC,KAAKG,uBAAuBC,MAAKT,eAAAA,EAAgBU,OAAQN,KAAKO,YAAmB,MAMrFX,GAGDY,EAAWC,EAAeT,MAEhCA,KAAKU,MAAQV,KAAKW,YAAYb,EAAA,CAAA,EACvBE,KAAKO,yBACLK,EAAsBZ,KAAKC,KAAKY,QAAQC,YAAaN,GACrDX,GAEX,CAEUkB,qBAAAA,CAAsBL,IACvBA,aAAAA,EAAAA,EAAOF,WACRR,KAAKC,KAAKe,sBAAsBhB,KAExC,CAEOiB,WAAAA,GACH,OAAOC,QAAQC,SACnB,CAEOC,QAAAA,CAASC,GACZrB,KAAKsB,MAAQxB,KAAKE,KAAKsB,MAAUD,GACjCrB,KAAKuB,UACT,CAEOC,cAAAA,GAEH,OADIxB,KAAKyB,cAAgBzB,KAAKyB,aAAaD,gBAAgBxB,KAAKyB,aAAaD,iBACtExB,IACX,CAEO0B,gBAAAA,CAAiBC,EAAyBjB,GAC7C,IAAAkB,EACA,OADe,QAAfA,EAAA5B,KAAK6B,sBAALD,GAAAA,EAAiBE,UAAUH,EAAQjB,GAC5BV,IACX,CAEO8B,SAAAA,CAAUH,EAAyBjB,GAClC,IAAAqB,EAGJ,eAHIA,EAAA/B,KAAKyB,oBAAL,IAAAM,OAAA,EAAAA,EAAmBD,YACnB9B,KAAKyB,aAAaK,UAAUH,EAAQjB,GAEjCV,IACX,CAEUuB,QAAAA,OACNS,EAAAC,EAAmB,QAAnBD,GAAAC,EAAAjC,KAAKU,OAAMa,gBAAX,IAAAS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2E,wBAAwBiE,KAAK5I,MACjEA,KAAK6D,eAAiB7D,KAAK6D,eAAe+E,KAAK5I,MAC/CA,KAAK0B,iBAAmB1B,KAAK0B,iBAAiBkH,KAAK5I,MACnDA,KAAKgD,gBAAkBhD,KAAKgD,gBAAgB4F,KAAK5I,MACjDA,KAAKyD,iBAAmBzD,KAAKyD,iBAAiBmF,KAAK5I,MACnDA,KAAK4E,0BAA4B5E,KAAK4E,0BAA0BgE,KAAK5I,MACrEA,KAAKoE,wBAA0BpE,KAAKoE,wBAAwBwE,KAAK5I,MAEjEA,KAAK6B,WAAcnB,GAASA,EAAMmB,YAAe7B,KACjDA,KAAKsG,UAAYtG,KAAKU,MAAMmC,QAAU7C,KAAKU,MAAMmC,QAAQyD,eAAYuC,EAErE7I,KAAKe,sBAAsBf,KAAKU,MACpC,EA7BA+G,EAPkBhI,EAOJa,YAAOuI,GAKrBpB,EAZkBhI,EAYJqJ,aAAuB"}
1
+ {"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { h } from 'preact';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport { Resources } from '../../../core/Context/Resources';\nimport { ANALYTICS_SUBMIT_STR } from '../../../core/Analytics/constants';\n\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from '../../../core/types';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type {\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentResponse\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { NewableComponent } from '../../../core/core.registry';\n\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n protected componentRef: any;\n\n protected resources: Resources;\n\n public elementRef: UIElement;\n\n public static type = undefined;\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n const isStoredPaymentMethod = !!componentProps?.isStoredPaymentMethod;\n const paymentMethodsResponseProps = isStoredPaymentMethod\n ? {}\n : this.core.paymentMethodsResponse.find(componentProps?.type || this.constructor['type']);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodsResponseProps,\n ...componentProps\n };\n\n const isDropin = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropin), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n // Only called once, for UIElements (including Dropin), as they are being mounted\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n const sessionId = this.props.session?.id;\n\n return this.props.modules.analytics.setUp({\n ...setUpAnalyticsObj,\n ...(sessionId && { sessionId })\n });\n }\n\n /**\n * A function for all UIElements, or BaseElement, to use to create an analytics action for when it's been:\n * - mounted,\n * - a PM has been selected\n * - onSubmit has been called (as a result of the pay button being pressed)\n *\n * In some other cases e.g. 3DS2 components, this function is overridden to allow more specific analytics actions to be created\n */\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj: SendAnalyticsObject, uiElementProps?) {\n /** Work out what the component's \"type\" is:\n * - first check for a dedicated \"analyticsType\" (currently only applies to custom-cards)\n * - otherwise, distinguish cards from non-cards: cards will use their static type property, everything else will use props.type\n */\n try {\n let component = this.constructor['analyticsType'];\n if (!component) {\n component = this.constructor['type'] === 'scheme' || this.constructor['type'] === 'bcmc' ? this.constructor['type'] : this.props.type;\n }\n\n this.props.modules.analytics.sendAnalytics(component, analyticsObj, uiElementProps);\n } catch (error) {\n console.warn('Failed to submit the analytics event. Error:', error);\n }\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall().then(sanitizeResponse).then(verifyPaymentDidNotFail).then(this.handleResponse).catch(this.handleFailedResult);\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) =>\n this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject\n })\n )\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n // Call analytics endpoint\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXC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t8L2X2tdzkMayCYHXRwKh13Xyleqxt4WoEZmhwTmB3p9d1F0SylWnjcC6o/DnshJ9mMW/8D3oWS30Z7BwRODqKGVahRD0YGRzwMbVnEe5JFRfNvJZdLGl35L9632DVmuFQ0lr/8WNL/NrAJNtI6PXrZMNiza0/omPwPfe5ZYuD1Jgq59TX4h9d+3fdkArcJYL7AdoMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n if (this.props.onComplete) this.props.onComplete(state, this.elementRef);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session ? this.core.update({ order }) : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a session /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * @param rawResponse -\n */\n protected handleResponse(rawResponse: RawPaymentResponse): void {\n const response = sanitizeResponse(rawResponse);\n\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protect _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonFunctionProps) => {\n return <PayButton {...props} amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return reject(new Error('onPaymentMethodsRequest is not implemented'));\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","buildElementProps","componentProps","finalProps","_object_spread","showPayButton","this","core","getCorePropsForComponent","isStoredPaymentMethod","paymentMethodsResponse","find","type","constructor","isDropin","assertIsDropin","props","formatProps","getRegulatoryDefaults","options","countryCode","storeElementRefOnCore","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","setUpAnalytics","setUpAnalyticsObj","_this_props_session","sessionId","session","id","modules","analytics","setUp","submitAnalytics","analyticsObj","uiElementProps","component","sendAnalytics","error","console","warn","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","handleFailedResult","onSubmit","submitUsingAdvancedFlow","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","ANALYTICS_SUBMIT_STR","submitPayment","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","_object_spread_props","unmount","mount","_node","rawResponse","response","order","remainingAmount","value","handleOrder","handleSuccessResult","updateParent","update","icon","paymentMethodType","_this_props_icon","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","_this_core_paymentMethodsResponse","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","checkout","super","_define_property","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","onPaymentCompleted","setComponentRef","ref","payButton","h","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"yyCA4BO,MAAeA,UAA6DC,EAsC5DC,iBAAAA,CAAkBC,GACjC,MAMMC,EAAaC,EAAA,CACfC,eAAe,GAPKC,KAAKC,KAAKC,8BACFN,aAAAA,EAAAA,EAAgBO,uBAE1C,GACAH,KAAKC,KAAKG,uBAAuBC,MAAKT,eAAAA,EAAgBU,OAAQN,KAAKO,YAAmB,MAMrFX,GAGDY,EAAWC,EAAeT,MAEhCA,KAAKU,MAAQV,KAAKW,Y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AMmC,QAAU7C,KAAKU,MAAMmC,QAAQyD,eAAYuC,EAErE7I,KAAKe,sBAAsBf,KAAKU,MACpC,EA7BA+G,EAPkBhI,EAOJa,YAAOuI,GAKrBpB,EAZkBhI,EAYJqJ,aAAuB"}
@@ -1,2 +1,2 @@
1
- var a;!function(a){a.address="address",a.bankTransfer_IBAN="bankTransfer_IBAN",a.donation="donation",a.personal_details="personal_details",a.dropin="dropin",a.bcmc="bcmc",a.card="card",a.scheme="scheme",a.storedCard="storedCard",a.customCard="customcard",a.threeDS2Challenge="threeDS2Challenge",a.threeDS2Fingerprint="threeDS2Fingerprint",a.threeDS2DeviceFingerprint="threeDS2DeviceFingerprint",a.ach="ach",a.directdebit_GB="directdebit_GB",a.sepadirectdebit="sepadirectdebit",a.affirm="affirm",a.afterpay="afterpay",a.afterpay_default="afterpay_default",a.afterpay_b2b="afterpay_b2b",a.atome="atome",a.facilypay_3x="facilypay_3x",a.facilypay_4x="facilypay_4x",a.facilypay_6x="facilypay_6x",a.facilypay_10x="facilypay_10x",a.facilypay_12x="facilypay_12x",a.ratepay="ratepay",a.ratepay_directdebit="ratepay_directdebit",a.riverty="riverty",a.amazonpay="amazonpay",a.applepay="applepay",a.cashapp="cashapp",a.clicktopay="clicktopay",a.googlepay="googlepay",a.paypal="paypal",a.paywithgoogle="paywithgoogle",a.boletobancario="boletobancario",a.boletobancario_itau="boletobancario_itau",a.boletobancario_santander="boletobancario_santander",a.primeiropay_boleto="primeiropay_boleto",a.doku="doku",a.doku_alfamart="doku_alfamart",a.doku_permata_lite_atm="doku_permata_lite_atm",a.doku_indomaret="doku_indomaret",a.doku_atm_mandiri_va="doku_atm_mandiri_va",a.doku_sinarmas_va="doku_sinarmas_va",a.doku_mandiri_va="doku_mandiri_va",a.doku_cimb_va="doku_cimb_va",a.doku_danamon_va="doku_danamon_va",a.doku_bri_va="doku_bri_va",a.doku_bni_va="doku_bni_va",a.doku_bca_va="doku_bca_va",a.doku_wallet="doku_wallet",a.oxxo="oxxo",a.billdesk_online="billdesk_online",a.billdesk_wallet="billdesk_wallet",a.dotpay="dotpay",a.eps="eps",a.ideal="ideal",a.molpay_ebanking_fpx_MY="molpay_ebanking_fpx_MY",a.molpay_ebanking_TH="molpay_ebanking_TH",a.molpay_ebanking_VN="molpay_ebanking_VN",a.onlineBanking_CZ="onlineBanking_CZ",a.onlinebanking_IN="onlinebanking_IN",a.onlineBanking_PL="onlineBanking_PL",a.onlineBanking_SK="onlineBanking_SK",a.paybybank="paybybank",a.payu_IN_cashcard="payu_IN_cashcard",a.payu_IN_nb="payu_IN_nb",a.wallet_IN="wallet_IN",a.dragonpay="dragonpay",a.dragonpay_ebanking="dragonpay_ebanking",a.dragonpay_otc_banking="dragonpay_otc_banking",a.dragonpay_otc_non_banking="dragonpay_otc_non_banking",a.dragonpay_otc_philippines="dragonpay_otc_philippines",a.econtext="econtext",a.econtext_atm="econtext_atm",a.econtext_online="econtext_online",a.econtext_seven_eleven="econtext_seven_eleven",a.econtext_stores="econtext_stores",a.giropay="giropay",a.multibanco="multibanco",a.redirect="redirect",a.twint="twint",a.vipps="vipps",a.trustly="trustly",a.klarna="klarna",a.klarna_account="klarna_account",a.klarna_paynow="klarna_paynow",a.bcmc_mobile="bcmc_mobile",a.bcmc_mobile_QR="bcmc_mobile_QR",a.pix="pix",a.swish="swish",a.wechatpay="wechatpay",a.wechatpayQR="wechatpayQR",a.promptpay="promptpay",a.paynow="paynow",a.duitnow="duitnow",a.blik="blik",a.mbway="mbway",a.upi="upi",a.upi_qr="upi_qr",a.upi_collect="upi_collect",a.giftcard="giftcard",a.mealVoucher_FR="mealVoucher_FR",a.mealVoucher_FR_natixis="mealVoucher_FR_natixis",a.mealVoucher_FR_sodexo="mealVoucher_FR_sodexo",a.mealVoucher_FR_groupeup="mealVoucher_FR_groupeup"}(a||(a={}));export{a as TxVariants};
1
+ var a;!function(a){a.address="address",a.bankTransfer_IBAN="bankTransfer_IBAN",a.donation="donation",a.personal_details="personal_details",a.dropin="dropin",a.bcmc="bcmc",a.card="card",a.scheme="scheme",a.storedCard="storedCard",a.customCard="customcard",a.threeDS2Challenge="threeDS2Challenge",a.threeDS2Fingerprint="threeDS2Fingerprint",a.threeDS2DeviceFingerprint="threeDS2DeviceFingerprint",a.ach="ach",a.directdebit_GB="directdebit_GB",a.sepadirectdebit="sepadirectdebit",a.affirm="affirm",a.afterpay="afterpay",a.afterpay_default="afterpay_default",a.afterpay_b2b="afterpay_b2b",a.atome="atome",a.facilypay_3x="facilypay_3x",a.facilypay_4x="facilypay_4x",a.facilypay_6x="facilypay_6x",a.facilypay_10x="facilypay_10x",a.facilypay_12x="facilypay_12x",a.ratepay="ratepay",a.ratepay_directdebit="ratepay_directdebit",a.riverty="riverty",a.amazonpay="amazonpay",a.applepay="applepay",a.cashapp="cashapp",a.clicktopay="clicktopay",a.googlepay="googlepay",a.paypal="paypal",a.paywithgoogle="paywithgoogle",a.boletobancario="boletobancario",a.boletobancario_itau="boletobancario_itau",a.boletobancario_santander="boletobancario_santander",a.primeiropay_boleto="primeiropay_boleto",a.doku="doku",a.doku_alfamart="doku_alfamart",a.doku_permata_lite_atm="doku_permata_lite_atm",a.doku_indomaret="doku_indomaret",a.doku_atm_mandiri_va="doku_atm_mandiri_va",a.doku_sinarmas_va="doku_sinarmas_va",a.doku_mandiri_va="doku_mandiri_va",a.doku_cimb_va="doku_cimb_va",a.doku_danamon_va="doku_danamon_va",a.doku_bri_va="doku_bri_va",a.doku_bni_va="doku_bni_va",a.doku_bca_va="doku_bca_va",a.doku_wallet="doku_wallet",a.oxxo="oxxo",a.billdesk_online="billdesk_online",a.billdesk_wallet="billdesk_wallet",a.dotpay="dotpay",a.eps="eps",a.molpay_ebanking_fpx_MY="molpay_ebanking_fpx_MY",a.molpay_ebanking_TH="molpay_ebanking_TH",a.molpay_ebanking_VN="molpay_ebanking_VN",a.onlineBanking_CZ="onlineBanking_CZ",a.onlinebanking_IN="onlinebanking_IN",a.onlineBanking_PL="onlineBanking_PL",a.onlineBanking_SK="onlineBanking_SK",a.paybybank="paybybank",a.payu_IN_cashcard="payu_IN_cashcard",a.payu_IN_nb="payu_IN_nb",a.wallet_IN="wallet_IN",a.dragonpay="dragonpay",a.dragonpay_ebanking="dragonpay_ebanking",a.dragonpay_otc_banking="dragonpay_otc_banking",a.dragonpay_otc_non_banking="dragonpay_otc_non_banking",a.dragonpay_otc_philippines="dragonpay_otc_philippines",a.econtext="econtext",a.econtext_atm="econtext_atm",a.econtext_online="econtext_online",a.econtext_seven_eleven="econtext_seven_eleven",a.econtext_stores="econtext_stores",a.giropay="giropay",a.multibanco="multibanco",a.redirect="redirect",a.twint="twint",a.vipps="vipps",a.trustly="trustly",a.klarna="klarna",a.klarna_account="klarna_account",a.klarna_paynow="klarna_paynow",a.bcmc_mobile="bcmc_mobile",a.bcmc_mobile_QR="bcmc_mobile_QR",a.pix="pix",a.swish="swish",a.wechatpay="wechatpay",a.wechatpayQR="wechatpayQR",a.promptpay="promptpay",a.paynow="paynow",a.duitnow="duitnow",a.blik="blik",a.mbway="mbway",a.ancv="ancv",a.upi="upi",a.upi_qr="upi_qr",a.upi_collect="upi_collect",a.giftcard="giftcard",a.mealVoucher_FR="mealVoucher_FR",a.mealVoucher_FR_natixis="mealVoucher_FR_natixis",a.mealVoucher_FR_sodexo="mealVoucher_FR_sodexo",a.mealVoucher_FR_groupeup="mealVoucher_FR_groupeup"}(a||(a={}));export{a as TxVariants};
2
2
  //# sourceMappingURL=tx-variants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx-variants.js","sources":["../../../src/components/tx-variants.ts"],"sourcesContent":["export enum TxVariants {\n /** internal */\n address = 'address',\n bankTransfer_IBAN = 'bankTransfer_IBAN',\n donation = 'donation',\n personal_details = 'personal_details',\n dropin = 'dropin',\n /** internal */\n\n /** Card */\n bcmc = 'bcmc',\n card = 'card',\n scheme = 'scheme',\n storedCard = 'storedCard',\n customCard = 'customcard',\n /** Card */\n\n /** ThreeDS */\n threeDS2Challenge = 'threeDS2Challenge',\n threeDS2Fingerprint = 'threeDS2Fingerprint',\n threeDS2DeviceFingerprint = 'threeDS2DeviceFingerprint',\n /** ThreeDS */\n\n /** Direct debit */\n ach = 'ach',\n directdebit_GB = 'directdebit_GB',\n sepadirectdebit = 'sepadirectdebit',\n /** Direct debit */\n\n /** Open Invoice */\n affirm = 'affirm',\n afterpay = 'afterpay',\n afterpay_default = 'afterpay_default',\n afterpay_b2b = 'afterpay_b2b',\n atome = 'atome',\n facilypay_3x = 'facilypay_3x',\n facilypay_4x = 'facilypay_4x',\n facilypay_6x = 'facilypay_6x',\n facilypay_10x = 'facilypay_10x',\n facilypay_12x = 'facilypay_12x',\n ratepay = 'ratepay',\n ratepay_directdebit = 'ratepay_directdebit',\n riverty = 'riverty',\n /** Open Invoice */\n\n /** Wallets */\n amazonpay = 'amazonpay',\n applepay = 'applepay',\n cashapp = 'cashapp',\n clicktopay = 'clicktopay',\n googlepay = 'googlepay',\n paypal = 'paypal',\n paywithgoogle = 'paywithgoogle',\n /** Wallets */\n\n /** Voucher */\n boletobancario = 'boletobancario',\n boletobancario_itau = 'boletobancario_itau',\n boletobancario_santander = 'boletobancario_santander',\n primeiropay_boleto = 'primeiropay_boleto',\n doku = 'doku',\n doku_alfamart = 'doku_alfamart',\n doku_permata_lite_atm = 'doku_permata_lite_atm',\n doku_indomaret = 'doku_indomaret',\n doku_atm_mandiri_va = 'doku_atm_mandiri_va',\n doku_sinarmas_va = 'doku_sinarmas_va',\n doku_mandiri_va = 'doku_mandiri_va',\n doku_cimb_va = 'doku_cimb_va',\n doku_danamon_va = 'doku_danamon_va',\n doku_bri_va = 'doku_bri_va',\n doku_bni_va = 'doku_bni_va',\n doku_bca_va = 'doku_bca_va',\n doku_wallet = 'doku_wallet',\n oxxo = 'oxxo',\n /** Voucher */\n\n /** issuerList */\n billdesk_online = 'billdesk_online',\n billdesk_wallet = 'billdesk_wallet',\n dotpay = 'dotpay',\n eps = 'eps',\n ideal = 'ideal',\n molpay_ebanking_fpx_MY = 'molpay_ebanking_fpx_MY',\n molpay_ebanking_TH = 'molpay_ebanking_TH',\n molpay_ebanking_VN = 'molpay_ebanking_VN',\n onlineBanking_CZ = 'onlineBanking_CZ',\n onlinebanking_IN = 'onlinebanking_IN',\n onlineBanking_PL = 'onlineBanking_PL',\n onlineBanking_SK = 'onlineBanking_SK',\n paybybank = 'paybybank',\n payu_IN_cashcard = 'payu_IN_cashcard',\n payu_IN_nb = 'payu_IN_nb',\n wallet_IN = 'wallet_IN',\n /** issuerList */\n\n /** Dragonpay */\n dragonpay = 'dragonpay',\n dragonpay_ebanking = 'dragonpay_ebanking',\n dragonpay_otc_banking = 'dragonpay_otc_banking',\n dragonpay_otc_non_banking = 'dragonpay_otc_non_banking',\n dragonpay_otc_philippines = 'dragonpay_otc_philippines',\n /** Dragonpay */\n\n /** Econtext */\n econtext = 'econtext',\n econtext_atm = 'econtext_atm',\n econtext_online = 'econtext_online',\n econtext_seven_eleven = 'econtext_seven_eleven',\n econtext_stores = 'econtext_stores',\n /** Econtext */\n\n /** Redirect */\n giropay = 'giropay',\n multibanco = 'multibanco',\n redirect = 'redirect',\n twint = 'twint',\n vipps = 'vipps',\n trustly = 'trustly',\n /** Redirect */\n\n /** Klarna */\n klarna = 'klarna',\n klarna_account = 'klarna_account',\n klarna_paynow = 'klarna_paynow',\n /** Klarna */\n\n /** QRLoader */\n bcmc_mobile = 'bcmc_mobile',\n bcmc_mobile_QR = 'bcmc_mobile_QR',\n pix = 'pix',\n swish = 'swish',\n wechatpay = 'wechatpay',\n wechatpayQR = 'wechatpayQR',\n promptpay = 'promptpay',\n paynow = 'paynow',\n duitnow = 'duitnow',\n /** QRLoader */\n\n /** Await */\n blik = 'blik',\n mbway = 'mbway',\n upi = 'upi', // also QR\n upi_qr = 'upi_qr', // also QR\n upi_collect = 'upi_collect', // also QR\n /** Await */\n\n /** Giftcard */\n giftcard = 'giftcard',\n mealVoucher_FR = 'mealVoucher_FR',\n mealVoucher_FR_natixis = 'mealVoucher_FR_natixis',\n mealVoucher_FR_sodexo = 'mealVoucher_FR_sodexo',\n mealVoucher_FR_groupeup = 'mealVoucher_FR_groupeup'\n /** Giftcard */\n}\n"],"names":["TxVariants"],"mappings":"OAAYA,SAAAA,GACKA,EAAA,QAAA,gIAQJA,EAAA,KAAA,2FAQGA,EAAA,kBAAA,wHAMKA,EAAA,IAAA,4EAMAA,EAAA,OAAA,iWAgBLA,EAAA,UAAA,0JAUAA,EAAA,eAAA,mlBAqBGA,EAAA,gBAAA,kfAmBDA,EAAA,UAAA,sNAQDA,EAAA,SAAA,iKAQAA,EAAA,QAAA,8GASFA,EAAA,OAAA,2EAMEA,EAAA,YAAA,8LAYHA,EAAA,KAAA,iFAQGA,EAAA,SAAA,mMAlJLA,CAAAA,IAAAA,EAAAA,CAAAA"}
1
+ {"version":3,"file":"tx-variants.js","sources":["../../../src/components/tx-variants.ts"],"sourcesContent":["export enum TxVariants {\n /** internal */\n address = 'address',\n bankTransfer_IBAN = 'bankTransfer_IBAN',\n donation = 'donation',\n personal_details = 'personal_details',\n dropin = 'dropin',\n /** internal */\n\n /** Card */\n bcmc = 'bcmc',\n card = 'card',\n scheme = 'scheme',\n storedCard = 'storedCard',\n customCard = 'customcard',\n /** Card */\n\n /** ThreeDS */\n threeDS2Challenge = 'threeDS2Challenge',\n threeDS2Fingerprint = 'threeDS2Fingerprint',\n threeDS2DeviceFingerprint = 'threeDS2DeviceFingerprint',\n /** ThreeDS */\n\n /** Direct debit */\n ach = 'ach',\n directdebit_GB = 'directdebit_GB',\n sepadirectdebit = 'sepadirectdebit',\n /** Direct debit */\n\n /** Open Invoice */\n affirm = 'affirm',\n afterpay = 'afterpay',\n afterpay_default = 'afterpay_default',\n afterpay_b2b = 'afterpay_b2b',\n atome = 'atome',\n facilypay_3x = 'facilypay_3x',\n facilypay_4x = 'facilypay_4x',\n facilypay_6x = 'facilypay_6x',\n facilypay_10x = 'facilypay_10x',\n facilypay_12x = 'facilypay_12x',\n ratepay = 'ratepay',\n ratepay_directdebit = 'ratepay_directdebit',\n riverty = 'riverty',\n /** Open Invoice */\n\n /** Wallets */\n amazonpay = 'amazonpay',\n applepay = 'applepay',\n cashapp = 'cashapp',\n clicktopay = 'clicktopay',\n googlepay = 'googlepay',\n paypal = 'paypal',\n paywithgoogle = 'paywithgoogle',\n /** Wallets */\n\n /** Voucher */\n boletobancario = 'boletobancario',\n boletobancario_itau = 'boletobancario_itau',\n boletobancario_santander = 'boletobancario_santander',\n primeiropay_boleto = 'primeiropay_boleto',\n doku = 'doku',\n doku_alfamart = 'doku_alfamart',\n doku_permata_lite_atm = 'doku_permata_lite_atm',\n doku_indomaret = 'doku_indomaret',\n doku_atm_mandiri_va = 'doku_atm_mandiri_va',\n doku_sinarmas_va = 'doku_sinarmas_va',\n doku_mandiri_va = 'doku_mandiri_va',\n doku_cimb_va = 'doku_cimb_va',\n doku_danamon_va = 'doku_danamon_va',\n doku_bri_va = 'doku_bri_va',\n doku_bni_va = 'doku_bni_va',\n doku_bca_va = 'doku_bca_va',\n doku_wallet = 'doku_wallet',\n oxxo = 'oxxo',\n /** Voucher */\n\n /** issuerList */\n billdesk_online = 'billdesk_online',\n billdesk_wallet = 'billdesk_wallet',\n dotpay = 'dotpay',\n eps = 'eps',\n molpay_ebanking_fpx_MY = 'molpay_ebanking_fpx_MY',\n molpay_ebanking_TH = 'molpay_ebanking_TH',\n molpay_ebanking_VN = 'molpay_ebanking_VN',\n onlineBanking_CZ = 'onlineBanking_CZ',\n onlinebanking_IN = 'onlinebanking_IN',\n onlineBanking_PL = 'onlineBanking_PL',\n onlineBanking_SK = 'onlineBanking_SK',\n paybybank = 'paybybank',\n payu_IN_cashcard = 'payu_IN_cashcard',\n payu_IN_nb = 'payu_IN_nb',\n wallet_IN = 'wallet_IN',\n /** issuerList */\n\n /** Dragonpay */\n dragonpay = 'dragonpay',\n dragonpay_ebanking = 'dragonpay_ebanking',\n dragonpay_otc_banking = 'dragonpay_otc_banking',\n dragonpay_otc_non_banking = 'dragonpay_otc_non_banking',\n dragonpay_otc_philippines = 'dragonpay_otc_philippines',\n /** Dragonpay */\n\n /** Econtext */\n econtext = 'econtext',\n econtext_atm = 'econtext_atm',\n econtext_online = 'econtext_online',\n econtext_seven_eleven = 'econtext_seven_eleven',\n econtext_stores = 'econtext_stores',\n /** Econtext */\n\n /** Redirect */\n giropay = 'giropay',\n multibanco = 'multibanco',\n redirect = 'redirect',\n twint = 'twint',\n vipps = 'vipps',\n trustly = 'trustly',\n /** Redirect */\n\n /** Klarna */\n klarna = 'klarna',\n klarna_account = 'klarna_account',\n klarna_paynow = 'klarna_paynow',\n /** Klarna */\n\n /** QRLoader */\n bcmc_mobile = 'bcmc_mobile',\n bcmc_mobile_QR = 'bcmc_mobile_QR',\n pix = 'pix',\n swish = 'swish',\n wechatpay = 'wechatpay',\n wechatpayQR = 'wechatpayQR',\n promptpay = 'promptpay',\n paynow = 'paynow',\n duitnow = 'duitnow',\n /** QRLoader */\n\n /** Await */\n blik = 'blik',\n mbway = 'mbway',\n ancv = 'ancv',\n upi = 'upi', // also QR\n upi_qr = 'upi_qr', // also QR\n upi_collect = 'upi_collect', // also QR\n /** Await */\n\n /** Giftcard */\n giftcard = 'giftcard',\n mealVoucher_FR = 'mealVoucher_FR',\n mealVoucher_FR_natixis = 'mealVoucher_FR_natixis',\n mealVoucher_FR_sodexo = 'mealVoucher_FR_sodexo',\n mealVoucher_FR_groupeup = 'mealVoucher_FR_groupeup'\n /** Giftcard */\n}\n"],"names":["TxVariants"],"mappings":"OAAYA,SAAAA,GACKA,EAAA,QAAA,gIAQJA,EAAA,KAAA,2FAQGA,EAAA,kBAAA,wHAMKA,EAAA,IAAA,4EAMAA,EAAA,OAAA,iWAgBLA,EAAA,UAAA,0JAUAA,EAAA,eAAA,mlBAqBGA,EAAA,gBAAA,keAkBDA,EAAA,UAAA,sNAQDA,EAAA,SAAA,iKAQAA,EAAA,QAAA,8GASFA,EAAA,OAAA,2EAMEA,EAAA,YAAA,8LAYHA,EAAA,KAAA,+FASGA,EAAA,SAAA,mMAlJLA,CAAAA,IAAAA,EAAAA,CAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AdyenCheckout.js","sources":["../../../src/core/AdyenCheckout.ts"],"sourcesContent":["import Core from './core';\nimport type { CoreConfiguration, ICore } from './types';\nimport type { IUIElement } from '../components/internal/UIElement/types';\n\nasync function AdyenCheckout(props: CoreConfiguration): Promise<Core> {\n const checkout = new Core(props);\n return await checkout.initialize();\n}\n\nAdyenCheckout.register = (...items: (new (checkout: ICore, props) => IUIElement)[]) => {\n Core.register(...items);\n};\n\n/**\n * Function used by the 'auto' package to insert its bundle type information in the Core.\n * We can't inject its bundle type when bundling with Rollup (as done with the other bundle types), since 'auto' uses ES-LEGACY bundle type under the hood.\n */\nAdyenCheckout.setBundleType = (type: string) => {\n Core.setBundleType(type);\n};\n\nexport { AdyenCheckout };\n"],"names":["async","AdyenCheckout","props","checkout","Core","initialize","register","items","setBundleType","type"],"mappings":"yBAIAA,eAAeC,EAAcC,GACzB,MAAMC,EAAW,IAAIC,EAAKF,GAC1B,aAAaC,EAASE,YAC1B,CAEAJ,EAAcK,SAAW,IAAIC,KACzBH,EAAKE,YAAYC,EAAAA,EAOrBN,EAAcO,cAAiBC,IAC3BL,EAAKI,cAAcC,EAAAA"}
1
+ {"version":3,"file":"AdyenCheckout.js","sources":["../../../src/core/AdyenCheckout.ts"],"sourcesContent":["import Core from './core';\nimport { UIElement } from '../types';\nimport type { CoreConfiguration, ICore } from './types';\n\nasync function AdyenCheckout(props: CoreConfiguration): Promise<Core> {\n const checkout = new Core(props);\n return await checkout.initialize();\n}\n\nAdyenCheckout.register = (...items: (new (checkout: ICore, props) => UIElement)[]) => {\n Core.register(...items);\n};\n\n/**\n * Function used by the 'auto' package to insert its bundle type information in the Core.\n * We can't inject its bundle type when bundling with Rollup (as done with the other bundle types), since 'auto' uses ES-LEGACY bundle type under the hood.\n */\nAdyenCheckout.setBundleType = (type: string) => {\n Core.setBundleType(type);\n};\n\nexport { AdyenCheckout };\n"],"names":["async","AdyenCheckout","props","checkout","Core","initialize","register","items","setBundleType","type"],"mappings":"yBAIAA,eAAeC,EAAcC,GACzB,MAAMC,EAAW,IAAIC,EAAKF,GAC1B,aAAaC,EAASE,YAC1B,CAEAJ,EAAcK,SAAW,IAAIC,KACzBH,EAAKE,YAAYC,EAAAA,EAOrBN,EAAcO,cAAiBC,IAC3BL,EAAKI,cAAcC,EAAAA"}
@@ -1,2 +1,2 @@
1
- import t from"../Services/analytics/log-event.js";import e from"../Services/analytics/collect-id.js";import n from"./EventsQueue.js";import{ANALYTICS_EVENT_INFO as a,ANALYTICS_INFO_TIMER_INTERVAL as l,ANALYTICS_EVENT_LOG as o,ANALYTICS_EVENT_ERROR as c,ANALYTICS_PATH as r}from"./constants.js";import{debounce as s}from"../../utils/debounce.js";import{processAnalyticsData as i,createAnalyticsObject as u}from"./utils.js";import{analyticsPreProcessor as y}from"./analyticsPreProcessor.js";function m(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),a.forEach((function(e){m(t,e,n[e])}))}return t}let f=null,p=!1,b=null;const g=({loadingContext:m,locale:g,clientKey:j,analytics:v,amount:h,analyticsContext:O,bundleType:P})=>{const w=d({},{enabled:!0,telemetry:!0,checkoutAttemptId:null,analyticsData:{}},v),x=t({loadingContext:m,locale:g}),A=e({analyticsContext:O,clientKey:j,locale:g,amount:h,analyticsPath:r,bundleType:P}),C=n({analyticsContext:O,clientKey:j,analyticsPath:r}),E=()=>f?C.run(f):Promise.resolve(null),k={setUp:async t=>{const{enabled:e,payload:n,telemetry:a}=w,l=i(w.analyticsData);if(!0===e){if(!0===a&&!f)try{const e=await A(d({},t,n&&d({},n),Object.keys(l).length&&d({},l)));f=e}catch(t){console.warn("Fetching checkoutAttemptId failed."+(t?` Error=${t}`:""))}p||(x(t),p=!0)}},getCheckoutAttemptId:()=>f,getEventsQueue:()=>C,createAnalyticsEvent:({event:t,data:e})=>{const n=u(d({event:t},e));return((t,e)=>{const n=t===a?t:`${t}s`;C.add(`${n}`,e),t===a&&(clearTimeout(b),b=setTimeout(E,l)),t!==o&&t!==c||(clearTimeout(b),s(E)())})(t,n),n},getEnabled:()=>w.enabled,sendAnalytics:null};return k.sendAnalytics=y(k),k};export{g as default};
1
+ import t from"../Services/analytics/collect-id.js";import e from"./EventsQueue.js";import{ANALYTICS_EVENT_INFO as n,ANALYTICS_INFO_TIMER_INTERVAL as a,ANALYTICS_EVENT_LOG as l,ANALYTICS_EVENT_ERROR as o,ANALYTICS_PATH as c}from"./constants.js";import{debounce as r}from"../../utils/debounce.js";import{processAnalyticsData as s,createAnalyticsObject as i}from"./utils.js";import{analyticsPreProcessor as u}from"./analyticsPreProcessor.js";function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function m(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),a.forEach((function(e){y(t,e,n[e])}))}return t}let d=null,f=null;const p=({locale:y,clientKey:p,analytics:b,amount:j,analyticsContext:g,bundleType:h})=>{const v=m({},{enabled:!0,checkoutAttemptId:null,analyticsData:{}},b),O=t({analyticsContext:g,clientKey:p,locale:y,amount:j,analyticsPath:c,bundleType:h}),P=e({analyticsContext:g,clientKey:p,analyticsPath:c}),w=()=>d?P.run(d):Promise.resolve(null),A={setUp:async t=>{const{enabled:e,payload:n}=v,a=s(v.analyticsData);if(!0===e&&!d)try{const e=await O(m({},t,n&&m({},n),Object.keys(a).length&&m({},a)));d=e}catch(t){console.warn("Fetching checkoutAttemptId failed."+(t?` Error=${t}`:""))}},getCheckoutAttemptId:()=>d,getEventsQueue:()=>P,createAnalyticsEvent:({event:t,data:e})=>{const c=i(m({event:t},e));return((t,e)=>{const c=t===n?t:`${t}s`;P.add(`${c}`,e),t===n&&(clearTimeout(f),f=setTimeout(w,a)),t!==l&&t!==o||(clearTimeout(f),r(w)())})(t,c),c},getEnabled:()=>v.enabled,sendAnalytics:null};return A.sendAnalytics=u(A),A};export{p as default};
2
2
  //# sourceMappingURL=Analytics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import LogEvent from '../Services/analytics/log-event';\nimport CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject, processAnalyticsData } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet hasLoggedPixel = false;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ loadingContext, locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n telemetry: true,\n checkoutAttemptId: null,\n analyticsData: {}\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const logEvent = LogEvent({ loadingContext, locale });\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(sendAnalyticsEvents, ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n /**\n * Make \"setup\" call, to pass containerWidth, buildType, channel etc, and receive a checkoutAttemptId in return\n * @param initialEvent -\n */\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { enabled, payload, telemetry } = props; // TODO what is payload, is it ever used?\n\n const analyticsData = processAnalyticsData(props.analyticsData);\n\n if (enabled === true) {\n if (telemetry === true && !capturedCheckoutAttemptId) {\n try {\n const checkoutAttemptId = await collectId({\n ...initialEvent,\n ...(payload && { ...payload }),\n ...(Object.keys(analyticsData).length && { ...analyticsData })\n });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n\n if (!hasLoggedPixel) {\n // Log pixel\n // TODO once we stop using the pixel we can stop requiring both \"enabled\" & \"telemetry\" config options.\n // And v6 will have a \"level: 'none\" | \"all\" | \"minimal\" config prop\n logEvent(initialEvent);\n hasLoggedPixel = true;\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject): AnalyticsObject => {\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n\n return aObj;\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = analyticsPreProcessor(anlModule);\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","hasLoggedPixel","sendEventsTimerId","Analytics","loadingContext","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","_object_spread","enabled","telemetry","checkoutAttemptId","analyticsData","logEvent","LogEvent","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","processAnalyticsData","Object","keys","length","e","console","warn","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","aObj","createAnalyticsObject","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"y6BAUA,IAAIA,EAA4B,KAC5BC,GAAiB,EACjBC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,iBAAgBC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzF,MAOMC,EAAQC,KAPO,CACjBC,SAAS,EACTC,WAAW,EACXC,kBAAmB,KACnBC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AAsBjC,GAEzCA,CAAAA"}
1
+ {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject, processAnalyticsData } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n checkoutAttemptId: null,\n analyticsData: {}\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(sendAnalyticsEvents, ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n /**\n * Make \"setup\" call, to pass containerWidth, buildType, channel etc, and receive a checkoutAttemptId in return\n * @param initialEvent -\n */\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { enabled, payload } = props; // TODO what is payload, is it ever used?\n\n const analyticsData = processAnalyticsData(props.analyticsData);\n\n if (enabled === true && !capturedCheckoutAttemptId) {\n try {\n const checkoutAttemptId = await collectId({\n ...initialEvent,\n ...(payload && { ...payload }),\n ...(Object.keys(analyticsData).length && { ...analyticsData })\n });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject): AnalyticsObject => {\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n\n return aObj;\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = analyticsPreProcessor(anlModule);\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","sendEventsTimerId","Analytics","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","_object_spread","enabled","checkoutAttemptId","analyticsData","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","processAnalyticsData","Object","keys","length","e","console","warn","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","aObj","createAnalyticsObject","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"u3BASA,IAAIA,EAA4B,KAC5BC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzE,MAMMC,EAAQC,KANO,CACjBC,SAAS,EACTC,kBAAmB,KACnBC,cAAe,CAAC,GAGgBR,GAE9BS,EAAYC,EAAU,CAAER,mBAAkBH,YAAWD,SAAQG,SAAQU,cAAeC,EAAgBT,eACpGU,EAAiCC,EAAY,CAAEZ,mBAAkBH,YAAWY,cAAeC,IAE3FG,EAAsB,IACpBpB,EACOkB,EAAYG,IAAIrB,GAEpBsB,QAAQC,QAAQ,MA8BrBC,EAA6B,CAK/BC,MAAOC,MAAOC,IACV,MAAMhB,QAAEA,EAAOiB,QAAEA,GAAYnB,EAEvBI,EAAgBgB,EAAqBpB,EAAMI,eAEjD,IAAgB,IAAZF,IAAqBX,EACrB,IACI,MAAMY,QAA0BE,EAAUJ,EAAA,CAAA,EACnCiB,EACCC,GAAWlB,EAAA,GAAKkB,GAChBE,OAAOC,KAAKlB,GAAemB,QAAUtB,EAAKG,CAAAA,EAAAA,KAElDb,EAA4BY,CAChC,CAAE,MAAOqB,GACLC,QAAQC,KAAK,sCAAqCF,EAAI,UAAUA,IAAM,IAC1E,CACJ,EAGJG,qBAAsB,IAAcpC,EAGpCqC,eAAgB,IAAMnB,EAEtBoB,qBAAsB,EAAGC,QAAOC,WAC5B,MAAMC,EAAwBC,EAAsBhC,EAAA,CAChD6B,SACGC,IAMP,MAjEkB,EAACG,EAAuBC,KAC9C,MAAMC,EAAYF,IAASG,EAAuBH,EAAO,GAAGA,KAC5DzB,EAAY6B,IAAI,GAAGF,IAAaD,GAO5BD,IAASG,IACTE,aAAa/C,GACbA,EAAoBgD,WAAW7B,EAAqB8B,IASpDP,IAASQ,GAAuBR,IAASS,IACzCJ,aAAa/C,GAEboD,EAASjC,EAATiC,GACJ,EAuCIC,CAAkBf,EAAOE,GAElBA,CAAAA,EAGXc,WAAY,IAAM9C,EAAME,QAExB6C,cAAe,MAKnB,OAFAhC,EAAUgC,cAAgBC,EAAsBjC,GAEzCA,CAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutSession.js","sources":["../../../../src/core/CheckoutSession/CheckoutSession.ts"],"sourcesContent":["import makePayment from '../Services/sessions/make-payment';\nimport submitDetails from '../Services/sessions/submit-details';\nimport setupSession from '../Services/sessions/setup-session';\nimport checkBalance from '../Services/sessions/check-balance';\nimport Storage from '../../utils/Storage';\nimport createOrder from '../Services/sessions/create-order';\nimport { sanitizeSession } from './utils';\nimport {\n CheckoutSession,\n CheckoutSessionBalanceResponse,\n CheckoutSessionDetailsResponse,\n CheckoutSessionOrdersResponse,\n CheckoutSessionPaymentResponse,\n CheckoutSessionSetupResponse,\n SessionConfiguration\n} from './types';\nimport cancelOrder from '../Services/sessions/cancel-order';\nimport { onOrderCancelData } from '../../components/Dropin/types';\nimport { AdditionalDetailsStateData } from '../../types/global-types';\n\nclass Session {\n private readonly session: CheckoutSession;\n private readonly storage: Storage<CheckoutSession>;\n public readonly clientKey: string;\n public readonly loadingContext: string;\n public configuration: SessionConfiguration;\n\n constructor(rawSession: Partial<CheckoutSession>, clientKey: string, loadingContext: string) {\n const session = sanitizeSession(rawSession) as CheckoutSession;\n\n if (!clientKey) throw new Error('No clientKey available');\n if (!loadingContext) throw new Error('No loadingContext available');\n\n this.storage = new Storage('session', 'localStorage');\n this.clientKey = clientKey;\n this.loadingContext = loadingContext;\n this.session = session;\n\n if (!this.session.sessionData) {\n this.session = this.getStoredSession();\n } else {\n this.storeSession();\n }\n }\n\n get shopperLocale() {\n return this.session.shopperLocale;\n }\n\n get id() {\n return this.session.id;\n }\n\n get data() {\n return this.session.sessionData;\n }\n\n /**\n * Updates the session.data with the latest data blob\n */\n private updateSessionData(latestData: string): void {\n this.session.sessionData = latestData;\n this.storeSession();\n }\n\n /**\n * Fetches data from a session\n */\n setupSession(options): Promise<CheckoutSessionSetupResponse> {\n return setupSession(this, options).then(response => {\n if (response.configuration) {\n this.configuration = { ...response.configuration };\n }\n\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits a session payment\n */\n submitPayment(data): Promise<CheckoutSessionPaymentResponse> {\n return makePayment(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits session payment additional details\n */\n submitDetails(data: AdditionalDetailsStateData['data']): Promise<CheckoutSessionDetailsResponse> {\n return submitDetails(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Checks the balance for a payment method\n */\n checkBalance(data): Promise<CheckoutSessionBalanceResponse> {\n return checkBalance(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Creates an order for the current session\n */\n createOrder(): Promise<CheckoutSessionOrdersResponse> {\n return createOrder(this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Cancels an order for the current session\n */\n cancelOrder(data: onOrderCancelData): Promise<CheckoutSessionOrdersResponse> {\n return cancelOrder(data.order, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Gets the stored session but only if the current id and the stored id match\n */\n getStoredSession(): CheckoutSession {\n const storedSession = this.storage.get();\n return this.id === storedSession?.id ? storedSession : this.session;\n }\n\n /**\n * Stores the session\n */\n storeSession(): void {\n this.storage.set({ id: this.session.id, sessionData: this.session.sessionData });\n }\n\n /**\n * Clears the stored session\n */\n removeStoredSession(): void {\n this.storage.remove();\n }\n}\n\nexport default Session;\n"],"names":["Session","shopperLocale","this","session","id","data","sessionData","updateSessionData","latestData","storeSession","setupSession","options","then","response","configuration","_object_spread","submitPayment","makePayment","submitDetails","checkBalance","createOrder","cancelOrder","order","getStoredSession","storedSession","storage","get","set","removeStoredSession","remove","constructor","rawSession","clientKey","loadingContext","_define_property","sanitizeSession","Error","Storage"],"mappings":"ugBAoBA,MAAMA,EAyBF,iBAAIC,GACA,OAAOC,KAAKC,QAAQF,aACxB,CAEA,MAAIG,GACA,OAAOF,KAAKC,QAAQC,EACxB,CAEA,QAAIC,GACA,OAAOH,KAAKC,QAAQG,WACxB,CAKQC,iBAAAA,CAAkBC,GACtBN,KAAKC,QAAQG,YAAcE,EAC3BN,KAAKO,cACT,CAKAC,YAAAA,CAAaC,GACT,OAAOD,EAAaR,KAAMS,GAASC,MAAKC,IAChCA,EAASC,gBACTZ,KAAKY,oVAAgBC,CAAA,CAAA,EAAKF,EAASC,gBAGnCD,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAG,aAAAA,CAAcX,GACV,OAAOY,EAAYZ,EAAMH,MAAMU,MAAKC,IAC5BA,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAK,aAAAA,CAAcb,GACV,OAAOa,EAAcb,EAAMH,MAAMU,MAAKC,IAC9BA,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAM,YAAAA,CAAad,GACT,OAAOc,EAAad,EAAMH,MAAMU,MAAKC,IAC7BA,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAO,WAAAA,GACI,OAAOA,EAAYlB,MAAMU,MAAKC,IACtBA,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAQ,WAAAA,CAAYhB,GACR,OAAOgB,EAAYhB,EAAKiB,MAAOpB,MAAMU,MAAKC,IAClCA,EAASP,aACTJ,KAAKK,kBAAkBM,EAASP,aAG7BO,IAEf,CAKAU,gBAAAA,GACI,MAAMC,EAAgBtB,KAAKuB,QAAQC,MACnC,OAAOxB,KAAKE,MAAOoB,aAAAA,EAAAA,EAAepB,IAAKoB,EAAgBtB,KAAKC,OAChE,CAKAM,YAAAA,GACIP,KAAKuB,QAAQE,IAAI,CAAEvB,GAAIF,KAAKC,QAAQC,GAAIE,YAAaJ,KAAKC,QAAQG,aACtE,CAKAsB,mBAAAA,GACI1B,KAAKuB,QAAQI,QACjB,CA5IAC,WAAAA,CAAYC,EAAsCC,EAAmBC,GANrEC,EAAAhC,KAAiBC,eAAjB,GACA+B,EAAAhC,KAAiBuB,eAAjB,GACAS,EAAAhC,KAAgB8B,iBAAhB,GACAE,EAAAhC,KAAgB+B,sBAAhB,GACAC,EAAAhC,KAAOY,qBAAP,GAGI,MAAMX,EAAUgC,EAAgBJ,GAEhC,IAAKC,EAAW,MAAM,IAAII,MAAM,0BAChC,IAAKH,EAAgB,MAAM,IAAIG,MAAM,+BAErClC,KAAKuB,QAAU,IAAIY,EAAQ,UAAW,gBACtCnC,KAAK8B,UAAYA,EACjB9B,KAAK+B,eAAiBA,EACtB/B,KAAKC,QAAUA,EAEVD,KAAKC,QAAQG,YAGdJ,KAAKO,eAFLP,KAAKC,QAAUD,KAAKqB,kBAI5B"}
1
+ {"version":3,"file":"CheckoutSession.js","sources":["../../../../src/core/CheckoutSession/CheckoutSession.ts"],"sourcesContent":["import makePayment from '../Services/sessions/make-payment';\nimport submitDetails from '../Services/sessions/submit-details';\nimport setupSession from '../Services/sessions/setup-session';\nimport checkBalance from '../Services/sessions/check-balance';\nimport Storage from '../../utils/Storage';\nimport createOrder from '../Services/sessions/create-order';\nimport { sanitizeSession } from './utils';\nimport {\n CheckoutSession,\n CheckoutSessionBalanceResponse,\n CheckoutSessionDetailsResponse,\n CheckoutSessionOrdersResponse,\n CheckoutSessionPaymentResponse,\n CheckoutSessionSetupResponse,\n SessionConfiguration\n} from './types';\nimport cancelOrder from '../Services/sessions/cancel-order';\nimport { onOrderCancelData } from '../../components/Dropin/types';\nimport type { AdditionalDetailsData } from '../types';\n\nclass Session {\n private readonly session: CheckoutSession;\n private readonly storage: Storage<CheckoutSession>;\n public readonly clientKey: string;\n public readonly loadingContext: string;\n public configuration: SessionConfiguration;\n\n constructor(rawSession: Partial<CheckoutSession>, clientKey: string, loadingContext: string) {\n const session = sanitizeSession(rawSession) as CheckoutSession;\n\n if (!clientKey) throw new Error('No clientKey available');\n if (!loadingContext) throw new Error('No loadingContext available');\n\n this.storage = new Storage('session', 'localStorage');\n this.clientKey = clientKey;\n this.loadingContext = loadingContext;\n this.session = session;\n\n if (!this.session.sessionData) {\n this.session = this.getStoredSession();\n } else {\n this.storeSession();\n }\n }\n\n get shopperLocale() {\n return this.session.shopperLocale;\n }\n\n get id() {\n return this.session.id;\n }\n\n get data() {\n return this.session.sessionData;\n }\n\n /**\n * Updates the session.data with the latest data blob\n */\n private updateSessionData(latestData: string): void {\n this.session.sessionData = latestData;\n this.storeSession();\n }\n\n /**\n * Fetches data from a session\n */\n setupSession(options): Promise<CheckoutSessionSetupResponse> {\n return setupSession(this, options).then(response => {\n if (response.configuration) {\n this.configuration = { ...response.configuration };\n }\n\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits a session payment\n */\n submitPayment(data): Promise<CheckoutSessionPaymentResponse> {\n return makePayment(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits session payment additional details\n */\n submitDetails(data: AdditionalDetailsData['data']): Promise<CheckoutSessionDetailsResponse> {\n return submitDetails(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Checks the balance for a payment method\n */\n checkBalance(data): Promise<CheckoutSessionBalanceResponse> {\n return checkBalance(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Creates an order for the current session\n */\n createOrder(): Promise<CheckoutSessionOrdersResponse> {\n return createOrder(this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Cancels an order for the current session\n */\n cancelOrder(data: onOrderCancelData): Promise<CheckoutSessionOrdersResponse> {\n return cancelOrder(data.order, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Gets the stored session but only if the current id and the stored id match\n */\n getStoredSession(): CheckoutSession {\n const storedSession = this.storage.get();\n return this.id === storedSession?.id ? storedSession : this.session;\n }\n\n /**\n * Stores the session\n */\n storeSession(): void {\n this.storage.set({ id: this.session.id, sessionData: this.session.sessionData });\n }\n\n /**\n * Clears the stored session\n */\n removeStoredSession(): void {\n this.storage.remove();\n }\n}\n\nexport default Session;\n"],"names":["Session","shopperLocale","this","session","id","data","sessionData","updateSessionData","latestData","storeSession","setupSession","options","then","response","configuration","_object_spread","submitPayment","makePayment","submitDetails","checkBalance","createOrder","cancelOrder","order","getStoredSession","storedSession","storage","get","set","removeStoredSession","remove","constructor","rawSession","clientKey","loadingContext","_define_property","sanitizeSession","Error","Storage"],"mappings":"ugBAoBA,MAAMA,EAyBF,iBAAIC,GACA,OAAOC,KAAKC,QAAQF,aACxB,CAEA,MAAIG,GACA,OAAOF,KAAKC,QAAQC,EACxB,CAEA,QAAIC,GACA,OAAOH,KAAKC,QAAQG,WACxB,CAKQC,iBAAAA,CAAkBC,GACtBN,KAAKC,QAAQG,YAAcE,EAC3BN,KAAKO,cACT,CAKAC,YAAAA,CAAaC,GACT,OAAOD,EAAaR,KAAMS,GAASC,M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MX,EAAUgC,EAAgBJ,GAEhC,IAAKC,EAAW,MAAM,IAAII,MAAM,0BAChC,IAAKH,EAAgB,MAAM,IAAIG,MAAM,+BAErClC,KAAKuB,QAAU,IAAIY,EAAQ,UAAW,gBACtCnC,KAAK8B,UAAYA,EACjB9B,KAAK+B,eAAiBA,EACtB/B,KAAKC,QAAUA,EAEVD,KAAKC,QAAQG,YAGdJ,KAAKO,eAFLP,KAAKC,QAAUD,KAAKqB,kBAI5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentAction.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/PaymentAction.ts"],"sourcesContent":["import actionTypes from './actionTypes';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\n// import type { IUIElement } from '../../../components/internal/UIElement/types';\nimport UIElement from '../../../components/internal/UIElement';\n\nexport function getComponentForAction(core: ICore, registry: IRegistry, action: PaymentAction, props = {}): UIElement {\n const nextAction = actionTypes[action.type];\n\n if (nextAction && typeof nextAction === 'function') {\n return nextAction(core, registry, action, props);\n }\n\n throw new Error('Invalid Action');\n}\n\nexport default getComponentForAction;\n"],"names":["getComponentForAction","core","registry","action","props","nextAction","actionTypes","type","Error"],"mappings":"gCAOO,SAASA,EAAsBC,EAAaC,EAAqBC,EAAuBC,EAAQ,CAAA,GACnG,MAAMC,EAAaC,EAAYH,EAAOI,MAEtC,GAAIF,GAAoC,mBAAfA,EACrB,OAAOA,EAAWJ,EAAMC,EAAUC,EAAQC,GAG9C,MAAM,IAAII,MAAM,iBACpB"}
1
+ {"version":3,"file":"PaymentAction.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/PaymentAction.ts"],"sourcesContent":["import actionTypes from './actionTypes';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\nimport UIElement from '../../../components/internal/UIElement';\n\nexport function getComponentForAction(core: ICore, registry: IRegistry, action: PaymentAction, props = {}): UIElement {\n const nextAction = actionTypes[action.type];\n\n if (nextAction && typeof nextAction === 'function') {\n return nextAction(core, registry, action, props);\n }\n\n throw new Error('Invalid Action');\n}\n\nexport default getComponentForAction;\n"],"names":["getComponentForAction","core","registry","action","props","nextAction","actionTypes","type","Error"],"mappings":"gCAMO,SAASA,EAAsBC,EAAaC,EAAqBC,EAAuBC,EAAQ,CAAA,GACnG,MAAMC,EAAaC,EAAYH,EAAOI,MAEtC,GAAIF,GAAoC,mBAAfA,EACrB,OAAOA,EAAWJ,EAAMC,EAAUC,EAAQC,GAG9C,MAAM,IAAII,MAAM,iBACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"actionTypes.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/actionTypes.ts"],"sourcesContent":["import { get3DS2FlowProps } from '../../../components/ThreeDS2/components/utils';\nimport uuid from '../../../utils/uuid';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\nimport type { IUIElement } from '../../../components/internal/UIElement/types';\n\nconst createComponent = (core: ICore, registry: IRegistry, componentType, props): IUIElement => {\n const Element = registry.getComponent(componentType);\n\n if (!Element) {\n throw Error(`Action Element of type ${componentType} not found in the registry`);\n }\n\n return new Element(core, { ...props, id: `${componentType}-${uuid()}` });\n};\n\nconst getActionHandler = statusType => {\n return (core: ICore, registry: IRegistry, action: PaymentAction, props) => {\n const config = {\n ...props,\n ...action,\n onComplete: props.onAdditionalDetails,\n onError: props.onError,\n statusType\n };\n\n return createComponent(core, registry, action.paymentMethodType, config);\n };\n};\n\nconst actionTypes = {\n redirect: (core: ICore, registry, action: PaymentAction, props) => {\n const config = {\n ...props,\n ...action,\n statusType: 'redirect'\n };\n\n return createComponent(core, registry, 'redirect', config);\n },\n\n threeDS2: (core: ICore, registry, action: PaymentAction, props) => {\n const componentType = action.subtype === 'fingerprint' ? 'threeDS2DeviceFingerprint' : 'threeDS2Challenge';\n\n const paymentData = action.subtype === 'fingerprint' || props.isMDFlow ? action.paymentData : action.authorisationToken;\n\n const config = {\n // Props common to both flows\n core: core,\n token: action.token,\n paymentData,\n onActionHandled: props.onActionHandled,\n onComplete: props.isMDFlow ? props.onComplete : props.onAdditionalDetails,\n onError: props.onError,\n isDropin: !!props.isDropin,\n loadingContext: props.loadingContext,\n clientKey: props.clientKey,\n paymentMethodType: props.paymentMethodType,\n challengeWindowSize: props.challengeWindowSize, // always pass challengeWindowSize in case it's been set directly in the handleAction config object\n isMDFlow: props.isMDFlow,\n modules: {\n analytics: props.modules?.analytics,\n resources: props.modules?.resources\n },\n\n // Props unique to a particular flow\n ...get3DS2FlowProps(action.subtype, props)\n };\n\n return createComponent(core, registry, componentType, config);\n },\n\n voucher: getActionHandler('custom'),\n qrCode: getActionHandler('custom'),\n await: getActionHandler('custom'),\n bankTransfer: getActionHandler('custom'),\n sdk: getActionHandler('custom')\n} as const;\n\nexport default actionTypes;\n"],"names":["createComponent","core","registry","componentType","props","Element","getComponent","Error","_object_spread_props","id","uuid","getActionHandler","statusType","action","config","onComplete","onAdditionalDetails","onError","paymentMethodType","actionTypes","redirect","threeDS2","subtype","paymentData","isMDFlow","authorisationToken","_object_spread","token","onActionHandled","isDropin","loadingContext","clientKey","challengeWindowSize","modules","analytics","resources","get3DS2FlowProps","voucher","qrCode","await","bankTransfer","sdk"],"mappings":"26BAOA,MAAMA,EAAkB,CAACC,EAAaC,EAAqBC,EAAeC,KACtE,MAAMC,EAAUH,EAASI,aAAaH,GAEtC,IAAKE,EACD,MAAME,MAAM,0BAA0BJ,+BAG1C,OAAO,IAAIE,EAAQJ,EAAMO,EAAKJ,EAAAA,CAAAA,EAAAA,GAAAA,CAAOK,GAAI,GAAGN,KAAiBO,UAG3DC,EAAmBC,GACd,CAACX,EAAaC,EAAqBW,EAAuBT,KAC7D,MAAMU,EAASN,OACRJ,EACAS,GAAAA,CACHE,WAAYX,EAAMY,oBAClBC,QAASb,EAAMa,QACfL,eAGJ,OAAOZ,EAAgBC,EAAMC,EAAUW,EAAOK,kBAAmBJ,EAAAA,EAInEK,EAAc,CAChBC,SAAU,CAACnB,EAAaC,EAAUW,EAAuBT,KACrD,MAAMU,EAASN,OACRJ,EACAS,GAAAA,CACHD,WAAY,aAGhB,OAAOZ,EAAgBC,EAAMC,EAAU,WAAYY,EAAAA,EAGvDO,SAAU,CAACpB,EAAaC,EAAUW,EAAuBT,SAoBlCA,EACAA,EApBnB,MAAMD,EAAmC,gBAAnBU,EAAOS,QAA4B,4BAA8B,oBAEjFC,EAAiC,gBAAnBV,EAAOS,SAA6BlB,EAAMoB,SAAWX,EAAOU,YAAcV,EAAOY,mBAE/FX,EAASY,EAAA,CAEXzB,KAAMA,EACN0B,MAAOd,EAAOc,MACdJ,cACAK,gBAAiBxB,EAAMwB,gBACvBb,WAAYX,EAAMoB,SAAWpB,EAAMW,WAAaX,EAAMY,oBACtDC,QAASb,EAAMa,QACfY,WAAYzB,EAAMyB,SAClBC,eAAgB1B,EAAM0B,eACtBC,UAAW3B,EAAM2B,UACjBb,kBAAmBd,EAAMc,kBACzBc,oBAAqB5B,EAAM4B,oBAC3BR,SAAUpB,EAAMoB,SAChBS,QAAS,CACLC,UAAW9B,QAAAA,EAAAA,EAAM6B,eAAN7B,IAAAA,OAAAA,EAAAA,EAAe8B,UAC1BC,UAAW/B,QAAAA,EAAAA,EAAM6B,eAAN7B,IAAAA,OAAAA,EAAAA,EAAe+B,YAI3BC,EAAiBvB,EAAOS,QAASlB,IAGxC,OAAOJ,EAAgBC,EAAMC,EAAUC,EAAeW,EAAAA,EAG1DuB,QAAS1B,EAAiB,UAC1B2B,OAAQ3B,EAAiB,UACzB4B,MAAO5B,EAAiB,UACxB6B,aAAc7B,EAAiB,UAC/B8B,IAAK9B,EAAiB"}
1
+ {"version":3,"file":"actionTypes.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/actionTypes.ts"],"sourcesContent":["import { get3DS2FlowProps } from '../../../components/ThreeDS2/components/utils';\nimport uuid from '../../../utils/uuid';\nimport UIElement from '../../../components/internal/UIElement';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\n\nconst createComponent = (core: ICore, registry: IRegistry, componentType, props): UIElement => {\n const Element = registry.getComponent(componentType);\n\n if (!Element) {\n throw Error(`Action Element of type ${componentType} not found in the registry`);\n }\n\n return new Element(core, { ...props, id: `${componentType}-${uuid()}` });\n};\n\nconst getActionHandler = statusType => {\n return (core: ICore, registry: IRegistry, action: PaymentAction, props) => {\n const config = {\n ...props,\n ...action,\n onComplete: props.onAdditionalDetails,\n onError: props.onError,\n statusType\n };\n\n return createComponent(core, registry, action.paymentMethodType, config);\n };\n};\n\nconst actionTypes = {\n redirect: (core: ICore, registry, action: PaymentAction, props) => {\n const config = {\n ...props,\n ...action,\n statusType: 'redirect'\n };\n\n return createComponent(core, registry, 'redirect', config);\n },\n\n threeDS2: (core: ICore, registry, action: PaymentAction, props) => {\n const componentType = action.subtype === 'fingerprint' ? 'threeDS2DeviceFingerprint' : 'threeDS2Challenge';\n\n /**\n * NOTE: the isMDFlow prop comes from the options object, added within the MDFlow when it calls createFromAction(action, options) to initiate a 3DS2 component\n * It replaces the useOriginalFlow config prop that the MDFlow used to pass when directly initiating the threeDS2Fingerprint or threeDS2Challenge components\n */\n const paymentData = action.subtype === 'fingerprint' || props.isMDFlow ? action.paymentData : action.authorisationToken;\n\n const config = {\n // Props common to both flows\n core: core,\n token: action.token,\n paymentData,\n onActionHandled: props.onActionHandled,\n onComplete: props.isMDFlow ? props.onComplete : props.onAdditionalDetails,\n onError: props.onError,\n isDropin: !!props.isDropin,\n loadingContext: props.loadingContext,\n clientKey: props.clientKey,\n paymentMethodType: props.paymentMethodType,\n challengeWindowSize: props.challengeWindowSize, // always pass challengeWindowSize in case it's been set directly in the handleAction config object\n isMDFlow: props.isMDFlow,\n modules: {\n analytics: props.modules?.analytics,\n resources: props.modules?.resources\n },\n\n // Props unique to a particular flow\n ...get3DS2FlowProps(action.subtype, props)\n };\n\n return createComponent(core, registry, componentType, config);\n },\n\n voucher: getActionHandler('custom'),\n qrCode: getActionHandler('custom'),\n await: getActionHandler('custom'),\n bankTransfer: getActionHandler('custom'),\n sdk: getActionHandler('custom')\n} as const;\n\nexport default actionTypes;\n"],"names":["createComponent","core","registry","componentType","props","Element","getComponent","Error","_object_spread_props","id","uuid","getActionHandler","statusType","action","config","onComplete","onAdditionalDetails","onError","paymentMethodType","actionTypes","redirect","threeDS2","subtype","paymentData","isMDFlow","authorisationToken","_object_spread","token","onActionHandled","isDropin","loadingContext","clientKey","challengeWindowSize","modules","analytics","resources","get3DS2FlowProps","voucher","qrCode","await","bankTransfer","sdk"],"mappings":"26BAOA,MAAMA,EAAkB,CAACC,EAAaC,EAAqBC,EAAeC,KACtE,MAAMC,EAAUH,EAASI,aAAaH,GAEtC,IAAKE,EACD,MAAME,MAAM,0BAA0BJ,+BAG1C,OAAO,IAAIE,EAAQJ,EAAMO,EAAKJ,EAAAA,CAAAA,EAAAA,GAAAA,CAAOK,GAAI,GAAGN,KAAiBO,UAG3DC,EAAmBC,GACd,CAACX,EAAaC,EAAqBW,EAAuBT,KAC7D,MAAMU,EAASN,OACRJ,EACAS,GAAAA,CACHE,WAAYX,EAAMY,oBAClBC,QAASb,EAAMa,QACfL,eAGJ,OAAOZ,EAAgBC,EAAMC,EAAUW,EAAOK,kBAAmBJ,EAAAA,EAInEK,EAAc,CAChBC,SAAU,CAACnB,EAAaC,EAAUW,EAAuBT,KACrD,MAAMU,EAASN,OACRJ,EACAS,GAAAA,CACHD,WAAY,aAGhB,OAAOZ,EAAgBC,EAAMC,EAAU,WAAYY,EAAAA,EAGvDO,SAAU,CAACpB,EAAaC,EAAUW,EAAuBT,SAwBlCA,EACAA,EAxBnB,MAAMD,EAAmC,gBAAnBU,EAAOS,QAA4B,4BAA8B,oBAMjFC,EAAiC,gBAAnBV,EAAOS,SAA6BlB,EAAMoB,SAAWX,EAAOU,YAAcV,EAAOY,mBAE/FX,EAASY,EAAA,CAEXzB,KAAMA,EACN0B,MAAOd,EAAOc,MACdJ,cACAK,gBAAiBxB,EAAMwB,gBACvBb,WAAYX,EAAMoB,SAAWpB,EAAMW,WAAaX,EAAMY,oBACtDC,QAASb,EAAMa,QACfY,WAAYzB,EAAMyB,SAClBC,eAAgB1B,EAAM0B,eACtBC,UAAW3B,EAAM2B,UACjBb,kBAAmBd,EAAMc,kBACzBc,oBAAqB5B,EAAM4B,oBAC3BR,SAAUpB,EAAMoB,SAChBS,QAAS,CACLC,UAAW9B,QAAAA,EAAAA,EAAM6B,eAAN7B,IAAAA,OAAAA,EAAAA,EAAe8B,UAC1BC,UAAW/B,QAAAA,EAAAA,EAAM6B,eAAN7B,IAAAA,OAAAA,EAAAA,EAAe+B,YAI3BC,EAAiBvB,EAAOS,QAASlB,IAGxC,OAAOJ,EAAgBC,EAAMC,EAAUC,EAAeW,EAAAA,EAG1DuB,QAAS1B,EAAiB,UAC1B2B,OAAQ3B,EAAiB,UACzB4B,MAAO5B,EAAiB,UACxB6B,aAAc7B,EAAiB,UAC/B8B,IAAK9B,EAAiB"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.0-alpha.8",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.0-beta.0",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","_object_spread","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch"],"mappings":"uMAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,wUAAiCC,CAAA,CAEnCC,QAAS,gBAETC,QAAS,MACTC,SAAU,MACVC,UAAWZ,EACXF,SACAe,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,OACxBb,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKJ,EAAW,OAAOuB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,KAAKA,aAAAA,EAAAA,EAA0BE,IAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDzB,EAAUgC,EAAS/B,EAASK,GACvB2B,MAAKC,IACF,GAAIA,aAAAA,EAAAA,EAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,iBAEfE,IAEVC,OAAM,IACInB,QAAQC,OAAO3B,KAGvBO,EAAAA,CACX"}
1
+ {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","_object_spread","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch"],"mappings":"uMAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,wUAAiCC,CAAA,CAEnCC,QAAS,eAETC,QAAS,MACTC,SAAU,MACVC,UAAWZ,EACXF,SACAe,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,OACxBb,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKJ,EAAW,OAAOuB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,KAAKA,aAAAA,EAAAA,EAA0BE,IAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDzB,EAAUgC,EAAS/B,EAASK,GACvB2B,MAAKC,IACF,GAAIA,aAAAA,EAAAA,EAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,iBAEfE,IAEVC,OAAM,IACInB,QAAQC,OAAO3B,KAGvBO,EAAAA,CACX"}
@@ -1,2 +1,2 @@
1
- import{FALLBACK_CONTEXT as e,DEFAULT_HTTP_TIMEOUT as r}from"../config.js";import t from"../Errors/AdyenCheckoutError.js";function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),n.forEach((function(r){o(e,r,t[r])}))}return e}function i(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function c(o,i){var c,s;const{headers:l=[],errorLevel:u="warn",loadingContext:f=e,method:p="GET",path:b,timeout:O=r}=o,d=n({method:p,mode:"cors",cache:"default",credentials:"same-origin",headers:n({Accept:"application/json, text/plain, */*","Content-Type":"POST"===p?"application/json":"text/plain"},l),redirect:"follow",referrerPolicy:"no-referrer-when-downgrade"},(null===(c=AbortSignal)||void 0===c?void 0:c.timeout)&&{signal:null===(s=AbortSignal)||void 0===s?void 0:s.timeout(O)},i&&{body:JSON.stringify(i)}),y=`${f}${b}`;return fetch(y,d).then((async e=>{const r=await e.json();if(e.ok)return r;if(function(e){return e&&e.errorCode&&e.errorType&&e.message&&e.status}(r))return void a(r.message,u);a(o.errorMessage||`Service at ${y} is not available`,u)})).catch((e=>{if(e instanceof t)throw e;a(o.errorMessage||`Call to ${y} failed. Error= ${e}`,u)}))}function a(e,r){switch(r){case"silent":break;case"info":case"warn":case"error":console[r](e);break;default:throw new t("NETWORK_ERROR",e)}}function s(e,r){return c(i(n({},e),{method:"GET"}),r)}function l(e,r){return c(i(n({},e),{method:"POST"}),r)}export{c as http,s as httpGet,l as httpPost};
1
+ import{FALLBACK_CONTEXT as e,DEFAULT_HTTP_TIMEOUT as r}from"../config.js";import t from"../Errors/AdyenCheckoutError.js";function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),n.forEach((function(r){o(e,r,t[r])}))}return e}function i(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function c(o,i){var c,s;const{headers:l=[],errorLevel:u="warn",loadingContext:f=e,method:p="GET",path:b,timeout:O=r}=o,d=n({method:p,mode:"cors",cache:"default",credentials:"same-origin",headers:n({Accept:"application/json, text/plain, */*","Content-Type":"POST"===p?"application/json":"text/plain"},l),redirect:"follow",referrerPolicy:"no-referrer-when-downgrade"},(null===(c=AbortSignal)||void 0===c?void 0:c.timeout)&&{signal:null===(s=AbortSignal)||void 0===s?void 0:s.timeout(O)},i&&{body:JSON.stringify(i)}),y=`${f}${b}`;return fetch(y,d).then((async e=>{const r=await e.json();if(e.ok)return r;if(function(e){return e&&e.errorCode&&e.errorType&&e.message&&e.status}(r))return void a(r.message,u,r);a(o.errorMessage||`Service at ${y} is not available`,u,r)})).catch((e=>{if(e instanceof t)throw e;a(o.errorMessage||`Call to ${y} failed. Error= ${e}`,u,e)}))}function a(e,r,o){switch(r){case"silent":break;case"info":case"warn":case"error":console[r](e);break;default:throw new t("NETWORK_ERROR",e,{cause:o})}}function s(e,r){return c(i(n({},e),{method:"GET"}),r)}function l(e,r){return c(i(n({},e),{method:"POST"}),r)}export{c as http,s as httpGet,l as httpPost};
2
2
  //# sourceMappingURL=http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sources":["../../../../src/core/Services/http.ts"],"sourcesContent":["import { DEFAULT_HTTP_TIMEOUT, FALLBACK_CONTEXT } from '../config';\nimport AdyenCheckoutError from '../Errors/AdyenCheckoutError';\n\nexport interface HttpOptions {\n accept?: string;\n contentType?: string;\n errorMessage?: string;\n headers?;\n loadingContext?: string;\n method?: string;\n path: string;\n errorLevel?: ErrorLevel;\n timeout?: number;\n}\n\ntype ErrorLevel = 'silent' | 'info' | 'warn' | 'error' | 'fatal';\n\ntype AdyenErrorResponse = {\n errorCode: string;\n message: string;\n errorType: string;\n status: number;\n};\n\nfunction isAdyenErrorResponse(data: any): data is AdyenErrorResponse {\n return data && data.errorCode && data.errorType && data.message && data.status;\n}\n\nexport function http<T>(options: HttpOptions, data?: any): Promise<T> {\n const { headers = [], errorLevel = 'warn', loadingContext = FALLBACK_CONTEXT, method = 'GET', path, timeout = DEFAULT_HTTP_TIMEOUT } = options;\n\n const request: RequestInit = {\n method,\n mode: 'cors',\n cache: 'default',\n credentials: 'same-origin',\n headers: {\n Accept: 'application/json, text/plain, */*',\n 'Content-Type': method === 'POST' ? 'application/json' : 'text/plain',\n ...headers\n },\n redirect: 'follow',\n referrerPolicy: 'no-referrer-when-downgrade',\n ...(AbortSignal?.timeout && { signal: AbortSignal?.timeout(timeout) }),\n ...(data && { body: JSON.stringify(data) })\n };\n\n const url = `${loadingContext}${path}`;\n\n return (\n fetch(url, request)\n .then(async response => {\n const data = await response.json();\n\n if (response.ok) {\n return data;\n }\n\n if (isAdyenErrorResponse(data)) {\n handleFetchError(data.message, errorLevel);\n return;\n }\n\n const errorMessage = options.errorMessage || `Service at ${url} is not available`;\n handleFetchError(errorMessage, errorLevel);\n return;\n })\n /**\n * Catch block handles Network error, CORS error, or exception throw by the `handleFetchError`\n * inside the `then` block\n */\n .catch(error => {\n /**\n * If error is instance of AdyenCheckoutError, which means that it was already\n * handled by the `handleFetchError` on the `then` block, then we just throw it.\n * There is no need to create it again\n */\n if (error instanceof AdyenCheckoutError) {\n throw error;\n }\n\n const errorMessage = options.errorMessage || `Call to ${url} failed. Error= ${error}`;\n handleFetchError(errorMessage, errorLevel);\n })\n );\n}\n\nfunction handleFetchError(message: string, level: ErrorLevel): void {\n switch (level) {\n case 'silent': {\n break;\n }\n case 'info':\n case 'warn':\n case 'error': {\n console[level](message);\n break;\n }\n default:\n throw new AdyenCheckoutError('NETWORK_ERROR', message);\n }\n}\n\nexport function httpGet<T = any>(options: HttpOptions, data?: any): Promise<T> {\n return http<T>({ ...options, method: 'GET' }, data);\n}\n\nexport function httpPost<T = any>(options: HttpOptions, data?: any): Promise<T> {\n return http<T>({ ...options, method: 'POST' }, data);\n}\n"],"names":["http","options","data","AbortSignal","headers","errorLevel","loadingContext","FALLBACK_CONTEXT","method","path","timeout","DEFAULT_HTTP_TIMEOUT","request","_object_spread","mode","cache","credentials","Accept","redirect","referrerPolicy","signal","body","JSON","stringify","url","fetch","then","async","response","json","ok","errorCode","errorType","message","status","isAdyenErrorResponse","handleFetchError","errorMessage","catch","error","AdyenCheckoutError","level","console","httpGet","_object_spread_props","httpPost"],"mappings":"06BA4BO,SAASA,EAAQC,EAAsBC,OAelCC,EAAkCA,EAd1C,MAAMC,QAAEA,EAAU,GAAEC,WAAEA,EAAa,OAAMC,eAAEA,EAAiBC,EAAgBC,OAAEA,EAAS,MAAKC,KAAEA,EAAIC,QAAEA,EAAUC,GAAyBV,EAEjIW,EAAuBC,EAAA,CACzBL,SACAM,KAAM,OACNC,MAAO,UACPC,YAAa,cACbZ,QAASS,EAAA,CACLI,OAAQ,oCACR,eAA2B,SAAXT,EAAoB,mBAAqB,cACtDJ,GAEPc,SAAU,SACVC,eAAgB,+BACZhB,QAAAA,EAAAA,mBAAAA,IAAAA,OAAAA,EAAAA,EAAaO,UAAW,CAAEU,OAAQjB,QAAAA,EAAAA,mBAAAA,IAAAA,OAAAA,EAAAA,EAAaO,QAAQA,IACvDR,GAAQ,CAAEmB,KAAMC,KAAKC,UAAUrB,KAGjCsB,EAAM,GAAGlB,IAAiBG,IAEhC,OACIgB,MAAMD,EAAKZ,GACNc,MAAKC,MAAMC,IACR,MAAM1B,QAAa0B,EAASC,OAE5B,GAAID,EAASE,GACT,OAAO5B,EAGX,GAlChB,SAA8BA,GAC1B,OAAOA,GAAQA,EAAK6B,WAAa7B,EAAK8B,WAAa9B,EAAK+B,SAAW/B,EAAKgC,MAC5E,CAgCoBC,CAAqBjC,GAErB,YADAkC,EAAiBlC,EAAK+B,QAAS5B,GAKnC+B,EADqBnC,EAAQoC,cAAgB,cAAcb,qBAC5BnB,EAC/B,IAMHiC,OAAMC,IAMH,GAAIA,aAAiBC,EACjB,MAAMD,EAIVH,EADqBnC,EAAQoC,cAAgB,WAAWb,oBAAsBe,IAC/ClC,EAAAA,GAG/C,CAEA,SAAS+B,EAAiBH,EAAiBQ,GACvC,OAAQA,GACJ,IAAK,SACD,MAEJ,IAAK,OACL,IAAK,OACL,IAAK,QACDC,QAAQD,GAAOR,GACf,MAEJ,QACI,MAAM,IAAIO,EAAmB,gBAAiBP,GAE1D,CAEO,SAASU,EAAiB1C,EAAsBC,GACnD,OAAOF,EAAQ4C,EAAK3C,EAAAA,CAAAA,EAAAA,GAAAA,CAASO,OAAQ,QAASN,EAClD,CAEO,SAAS2C,EAAkB5C,EAAsBC,GACpD,OAAOF,EAAQ4C,EAAK3C,EAAAA,CAAAA,EAAAA,GAAAA,CAASO,OAAQ,SAAUN,EACnD"}
1
+ {"version":3,"file":"http.js","sources":["../../../../src/core/Services/http.ts"],"sourcesContent":["import { DEFAULT_HTTP_TIMEOUT, FALLBACK_CONTEXT } from '../config';\nimport AdyenCheckoutError from '../Errors/AdyenCheckoutError';\n\nexport interface HttpOptions {\n accept?: string;\n contentType?: string;\n headers?;\n loadingContext?: string;\n method?: string;\n path: string;\n timeout?: number;\n errorLevel?: ErrorLevel;\n errorMessage?: string;\n}\n\ntype ErrorLevel = 'silent' | 'info' | 'warn' | 'error' | 'fatal';\n\ntype AdyenApiErrorResponse = {\n errorCode: string;\n message: string;\n errorType: string;\n status: number;\n};\n\nfunction isAdyenApiErrorResponse(data: any): data is AdyenApiErrorResponse {\n return data && data.errorCode && data.errorType && data.message && data.status;\n}\n\nexport function http<T>(options: HttpOptions, data?: any): Promise<T> {\n const { headers = [], errorLevel = 'warn', loadingContext = FALLBACK_CONTEXT, method = 'GET', path, timeout = DEFAULT_HTTP_TIMEOUT } = options;\n\n const request: RequestInit = {\n method,\n mode: 'cors',\n cache: 'default',\n credentials: 'same-origin',\n headers: {\n Accept: 'application/json, text/plain, */*',\n 'Content-Type': method === 'POST' ? 'application/json' : 'text/plain',\n ...headers\n },\n redirect: 'follow',\n referrerPolicy: 'no-referrer-when-downgrade',\n ...(AbortSignal?.timeout && { signal: AbortSignal?.timeout(timeout) }),\n ...(data && { body: JSON.stringify(data) })\n };\n\n const url = `${loadingContext}${path}`;\n\n return (\n fetch(url, request)\n .then(async response => {\n const data = await response.json();\n\n if (response.ok) {\n return data;\n }\n\n if (isAdyenApiErrorResponse(data)) {\n handleFetchError(data.message, errorLevel, data);\n return;\n }\n\n const errorMessage = options.errorMessage || `Service at ${url} is not available`;\n handleFetchError(errorMessage, errorLevel, data);\n return;\n })\n /**\n * Catch block handles Network error, CORS error, or exception throw by the `handleFetchError`\n * inside the `then` block\n */\n .catch((error: unknown) => {\n /**\n * If error is instance of AdyenCheckoutError, which means that it was already\n * handled by the `handleFetchError` on the `then` block, then we just throw it.\n * There is no need to create it again\n */\n if (error instanceof AdyenCheckoutError) {\n throw error;\n }\n\n const errorMessage = options.errorMessage || `Call to ${url} failed. Error= ${error}`;\n handleFetchError(errorMessage, errorLevel, error);\n })\n );\n}\n\nfunction handleFetchError(message: string, level: ErrorLevel, error: unknown): void {\n switch (level) {\n case 'silent': {\n break;\n }\n case 'info':\n case 'warn':\n case 'error': {\n console[level](message);\n break;\n }\n default:\n throw new AdyenCheckoutError('NETWORK_ERROR', message, { cause: error });\n }\n}\n\nexport function httpGet<T = any>(options: HttpOptions, data?: any): Promise<T> {\n return http<T>({ ...options, method: 'GET' }, data);\n}\n\nexport function httpPost<T = any>(options: HttpOptions, data?: any): Promise<T> {\n return http<T>({ ...options, method: 'POST' }, data);\n}\n"],"names":["http","options","data","AbortSignal","headers","errorLevel","loadingContext","FALLBACK_CONTEXT","method","path","timeout","DEFAULT_HTTP_TIMEOUT","request","_object_spread","mode","cache","credentials","Accept","redirect","referrerPolicy","signal","body","JSON","stringify","url","fetch","then","async","response","json","ok","errorCode","errorType","message","status","isAdyenApiErrorResponse","handleFetchError","errorMessage","catch","error","AdyenCheckoutError","level","console","cause","httpGet","_object_spread_props","httpPost"],"mappings":"06BA4BO,SAASA,EAAQC,EAAsBC,OAelCC,EAAkCA,EAd1C,MAAMC,QAAEA,EAAU,GAAEC,WAAEA,EAAa,OAAMC,eAAEA,EAAiBC,EAAgBC,OAAEA,EAAS,MAAKC,KAAEA,EAAIC,QAAEA,EAAUC,GAAyBV,EAEjIW,EAAuBC,EAAA,CACzBL,SACAM,KAAM,OACNC,MAAO,UACPC,YAAa,cACbZ,QAASS,EAAA,CACLI,OAAQ,oCACR,eAA2B,SAAXT,EAAoB,mBAAqB,cACtDJ,GAEPc,SAAU,SACVC,eAAgB,+BACZhB,QAAAA,EAAAA,mBAAAA,IAAAA,OAAAA,EAAAA,EAAaO,UAAW,CAAEU,OAAQjB,QAAAA,EAAAA,mBAAAA,IAAAA,OAAAA,EAAAA,EAAaO,QAAQA,IACvDR,GAAQ,CAAEmB,KAAMC,KAAKC,UAAUrB,KAGjCsB,EAAM,GAAGlB,IAAiBG,IAEhC,OACIgB,MAAMD,EAAKZ,GACNc,MAAKC,MAAMC,IACR,MAAM1B,QAAa0B,EAASC,OAE5B,GAAID,EAASE,GACT,OAAO5B,EAGX,GAlChB,SAAiCA,GAC7B,OAAOA,GAAQA,EAAK6B,WAAa7B,EAAK8B,WAAa9B,EAAK+B,SAAW/B,EAAKgC,MAC5E,CAgCoBC,CAAwBjC,GAExB,YADAkC,EAAiBlC,EAAK+B,QAAS5B,EAAYH,GAK/CkC,EADqBnC,EAAQoC,cAAgB,cAAcb,qBAC5BnB,EAAYH,EAC3C,IAMHoC,OAAOC,IAMJ,GAAIA,aAAiBC,EACjB,MAAMD,EAIVH,EADqBnC,EAAQoC,cAAgB,WAAWb,oBAAsBe,IAC/ClC,EAAYkC,EAAAA,GAG3D,CAEA,SAASH,EAAiBH,EAAiBQ,EAAmBF,GAC1D,OAAQE,GACJ,IAAK,SACD,MAEJ,IAAK,OACL,IAAK,OACL,IAAK,QACDC,QAAQD,GAAOR,GACf,MAEJ,QACI,MAAM,IAAIO,EAAmB,gBAAiBP,EAAS,CAAEU,MAAOJ,IAE5E,CAEO,SAASK,EAAiB3C,EAAsBC,GACnD,OAAOF,EAAQ6C,EAAK5C,EAAAA,CAAAA,EAAAA,GAAAA,CAASO,OAAQ,QAASN,EAClD,CAEO,SAAS4C,EAAkB7C,EAAsBC,GACpD,OAAOF,EAAQ6C,EAAK5C,EAAAA,CAAAA,EAAAA,GAAAA,CAASO,OAAQ,SAAUN,EACnD"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import{API_VERSION as r}from"./constants.js";function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(n,o){const a=`${r}/sessions/${n.id}/setup?clientKey=${n.clientKey}`,i=function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(r){t(e,r,n[r])}))}return e}({sessionData:n.data},o.order?{order:{orderData:o.order.orderData,pspReference:o.order.pspReference}}:{});return e({loadingContext:n.loadingContext,path:a,errorLevel:"fatal",errorMessage:"ERROR: Invalid ClientKey"},i)}export{n as default};
1
+ import{httpPost as e}from"../http.js";import{API_VERSION as t}from"./constants.js";function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(n,o){const a=`${t}/sessions/${n.id}/setup?clientKey=${n.clientKey}`,c=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(t){r(e,t,n[t])}))}return e}({sessionData:n.data},o.order?{order:{orderData:o.order.orderData,pspReference:o.order.pspReference}}:{});return e({loadingContext:n.loadingContext,path:a,errorLevel:"fatal"},c)}export{n as default};
2
2
  //# sourceMappingURL=setup-session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-session.js","sources":["../../../../../src/core/Services/sessions/setup-session.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Session from '../../CheckoutSession';\nimport { CheckoutSessionSetupResponse } from '../../CheckoutSession/types';\nimport { API_VERSION } from './constants';\n\n/**\n */\nfunction setupSession(session: Session, options): Promise<CheckoutSessionSetupResponse> {\n const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;\n const data = {\n sessionData: session.data,\n ...(options.order\n ? {\n order: { orderData: options.order.orderData, pspReference: options.order.pspReference }\n }\n : {})\n };\n\n return httpPost<CheckoutSessionSetupResponse>(\n {\n loadingContext: session.loadingContext,\n path,\n errorLevel: 'fatal',\n errorMessage: 'ERROR: Invalid ClientKey'\n },\n data\n );\n}\n\nexport default setupSession;\n"],"names":["setupSession","session","options","path","API_VERSION","id","clientKey","data","_object_spread","sessionData","order","orderData","pspReference","httpPost","loadingContext","errorLevel","errorMessage"],"mappings":"2MAOA,SAASA,EAAaC,EAAkBC,GACpC,MAAMC,EAAO,GAAGC,cAAwBH,EAAQI,sBAAsBJ,EAAQK,YACxEC,wUAAOC,CAAA,CACTC,YAAaR,EAAQM,MACjBL,EAAQQ,MACN,CACIA,MAAO,CAAEC,UAAWT,EAAQQ,MAAMC,UAAWC,aAAcV,EAAQQ,MAAME,eAE7E,CAAC,GAGX,OAAOC,EACH,CACIC,eAAgBb,EAAQa,eACxBX,OACAY,WAAY,QACZC,aAAc,4BAElBT,EAER"}
1
+ {"version":3,"file":"setup-session.js","sources":["../../../../../src/core/Services/sessions/setup-session.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Session from '../../CheckoutSession';\nimport { CheckoutSessionSetupResponse } from '../../CheckoutSession/types';\nimport { API_VERSION } from './constants';\n\nfunction setupSession(session: Session, options): Promise<CheckoutSessionSetupResponse> {\n const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;\n const data = {\n sessionData: session.data,\n ...(options.order\n ? {\n order: { orderData: options.order.orderData, pspReference: options.order.pspReference }\n }\n : {})\n };\n\n return httpPost<CheckoutSessionSetupResponse>(\n {\n loadingContext: session.loadingContext,\n path,\n errorLevel: 'fatal'\n },\n data\n );\n}\n\nexport default setupSession;\n"],"names":["setupSession","session","options","path","API_VERSION","id","clientKey","data","_object_spread","sessionData","order","orderData","pspReference","httpPost","loadingContext","errorLevel"],"mappings":"2MAKA,SAASA,EAAaC,EAAkBC,GACpC,MAAMC,EAAO,GAAGC,cAAwBH,EAAQI,sBAAsBJ,EAAQK,YACxEC,wUAAOC,CAAA,CACTC,YAAaR,EAAQM,MACjBL,EAAQQ,MACN,CACIA,MAAO,CAAEC,UAAWT,EAAQQ,MAAMC,UAAWC,aAAcV,EAAQQ,MAAME,eAE7E,CAAC,GAGX,OAAOC,EACH,CACIC,eAAgBb,EAAQa,eACxBX,OACAY,WAAY,SAEhBR,EAER"}
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as v}from"./Analytics/constants.js";import{THREEDS2_FULL as g}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t,o){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class R{static setBundleType(t){R.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,R.metadata.version,this.options.locale,this.options.translations)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===g?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:v,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:R.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substr(0,4);var c;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=R.metadata)}}E(R,"metadata",{version:"6.0.0-alpha.8",bundleType:"eslegacy"}),E(R,"registry",p);export{R as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as v}from"./Analytics/constants.js";import{THREEDS2_FULL as g}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t,o){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class R{static setBundleType(t){R.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,R.metadata.version,this.options.locale,this.options.translations)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===g?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:v,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:R.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substr(0,4);var c;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=R.metadata)}}E(R,"metadata",{version:"6.0.0-beta.0",bundleType:"eslegacy"}),E(R,"registry",p);export{R as default};
2
2
  //# sourceMappingURL=core.js.map