@adyen/adyen-web 6.18.1 → 6.20.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 (189) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/adyen.css +11 -8
  3. package/dist/cjs/adyen.css.map +1 -1
  4. package/dist/cjs/index.cjs +2 -2
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.cts +43 -65
  7. package/dist/es/adyen.css +11 -8
  8. package/dist/es/adyen.css.map +1 -1
  9. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  10. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  11. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  12. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  13. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  14. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  15. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  16. package/dist/es/components/BankTransfer/components/BankTransferInput/validationRule.js +2 -0
  17. package/dist/es/components/BankTransfer/components/BankTransferInput/validationRule.js.map +1 -0
  18. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferResult.js +1 -1
  19. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferResult.js.map +1 -1
  20. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferResultInstructions.js +2 -0
  21. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferResultInstructions.js.map +1 -0
  22. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js +2 -0
  23. package/dist/es/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js.map +1 -0
  24. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  25. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  26. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  27. package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
  28. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  29. package/dist/es/components/Dropin/Dropin.js +1 -1
  30. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  31. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  32. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  33. package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  34. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  35. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  36. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  37. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  38. package/dist/es/components/UPI/UPI.js +1 -1
  39. package/dist/es/components/UPI/UPI.js.map +1 -1
  40. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  41. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  42. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  43. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  44. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  45. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  46. package/dist/es/components/UPI/constants.js +2 -0
  47. package/dist/es/components/UPI/constants.js.map +1 -0
  48. package/dist/es/components/internal/Address/Address.js.map +1 -1
  49. package/dist/es/components/internal/Alert/Alert.js +1 -1
  50. package/dist/es/components/internal/Alert/Alert.js.map +1 -1
  51. package/dist/es/components/internal/Button/Button.js +1 -1
  52. package/dist/es/components/internal/Button/Button.js.map +1 -1
  53. package/dist/es/components/internal/Button/CopyIconButton.js +2 -0
  54. package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -0
  55. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  56. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  57. package/dist/es/components/internal/DetailsTable/DetailsTable.js +1 -1
  58. package/dist/es/components/internal/DetailsTable/DetailsTable.js.map +1 -1
  59. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +1 -1
  60. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  61. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  62. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  65. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  67. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  68. package/dist/es/components/internal/Tooltip/SingletonTooltipProvider.js +2 -0
  69. package/dist/es/components/internal/Tooltip/SingletonTooltipProvider.js.map +1 -0
  70. package/dist/es/components/internal/Tooltip/Tooltip.js +2 -0
  71. package/dist/es/components/internal/Tooltip/Tooltip.js.map +1 -0
  72. package/dist/es/components/internal/Tooltip/TooltipController.js +2 -0
  73. package/dist/es/components/internal/Tooltip/TooltipController.js.map +1 -0
  74. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  75. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  76. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  77. package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
  78. package/dist/es/core/Analytics/utils.js.map +1 -1
  79. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  80. package/dist/es/core/Errors/utils.js.map +1 -1
  81. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  82. package/dist/es/core/core.js +1 -1
  83. package/dist/es/core/core.registry.js.map +1 -1
  84. package/dist/es/core/utils.js.map +1 -1
  85. package/dist/es/external/preact/compat/dist/compat.js +2 -0
  86. package/dist/es/external/preact/compat/dist/compat.js.map +1 -0
  87. package/dist/es/external/preact/dist/preact.js.map +1 -1
  88. package/dist/es/index.d.ts +43 -65
  89. package/dist/es/language/utils.js.map +1 -1
  90. package/dist/es/utils/clipboard.js +1 -1
  91. package/dist/es/utils/clipboard.js.map +1 -1
  92. package/dist/es/utils/setFocus.js.map +1 -1
  93. package/dist/es/utils/useForm/reducer.js.map +1 -1
  94. package/dist/es-legacy/adyen.css +11 -8
  95. package/dist/es-legacy/adyen.css.map +1 -1
  96. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  97. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  98. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  99. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  100. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  101. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  102. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  103. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/validationRule.js +2 -0
  104. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/validationRule.js.map +1 -0
  105. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferResult.js +1 -1
  106. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferResult.js.map +1 -1
  107. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferResultInstructions.js +2 -0
  108. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferResultInstructions.js.map +1 -0
  109. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js +2 -0
  110. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js.map +1 -0
  111. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  112. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  113. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  114. package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
  115. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  116. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  117. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  118. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  119. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  120. package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  121. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  122. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  123. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  124. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  125. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  126. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  127. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  128. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  129. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  130. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  131. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  132. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  133. package/dist/es-legacy/components/UPI/constants.js +2 -0
  134. package/dist/es-legacy/components/UPI/constants.js.map +1 -0
  135. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  136. package/dist/es-legacy/components/internal/Alert/Alert.js +1 -1
  137. package/dist/es-legacy/components/internal/Alert/Alert.js.map +1 -1
  138. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  139. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  140. package/dist/es-legacy/components/internal/Button/CopyIconButton.js +2 -0
  141. package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -0
  142. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  143. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  144. package/dist/es-legacy/components/internal/DetailsTable/DetailsTable.js +1 -1
  145. package/dist/es-legacy/components/internal/DetailsTable/DetailsTable.js.map +1 -1
  146. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +1 -1
  147. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  148. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  149. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  150. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  151. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  152. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  153. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  154. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  155. package/dist/es-legacy/components/internal/Tooltip/SingletonTooltipProvider.js +2 -0
  156. package/dist/es-legacy/components/internal/Tooltip/SingletonTooltipProvider.js.map +1 -0
  157. package/dist/es-legacy/components/internal/Tooltip/Tooltip.js +2 -0
  158. package/dist/es-legacy/components/internal/Tooltip/Tooltip.js.map +1 -0
  159. package/dist/es-legacy/components/internal/Tooltip/TooltipController.js +2 -0
  160. package/dist/es-legacy/components/internal/Tooltip/TooltipController.js.map +1 -0
  161. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  162. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  163. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  164. package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
  165. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  166. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  167. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  168. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  169. package/dist/es-legacy/core/core.js +1 -1
  170. package/dist/es-legacy/core/core.registry.js.map +1 -1
  171. package/dist/es-legacy/core/utils.js.map +1 -1
  172. package/dist/es-legacy/external/preact/compat/dist/compat.js +2 -0
  173. package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -0
  174. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  175. package/dist/es-legacy/language/utils.js.map +1 -1
  176. package/dist/es-legacy/utils/clipboard.js +1 -1
  177. package/dist/es-legacy/utils/clipboard.js.map +1 -1
  178. package/dist/es-legacy/utils/setFocus.js.map +1 -1
  179. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  180. package/package.json +159 -159
  181. package/styles/adyen.css +11 -8
  182. package/dist/es/components/UPI/components/UPIComponent/constants.js +0 -2
  183. package/dist/es/components/UPI/components/UPIComponent/constants.js.map +0 -1
  184. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  185. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
  186. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js +0 -2
  187. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js.map +0 -1
  188. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  189. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Dropin.js","sources":["../../../../src/components/Dropin/Dropin.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { getCommonProps } from './components/utils';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\nimport { TxVariants } from '../tx-variants';\n\nimport type { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n public static type = TxVariants.dropin;\n\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n type: 'dropin', // for analytics\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n public displayFinalAnimation(type: 'success' | 'error') {\n if (this.props.disableFinalAnimation) return;\n\n this.dropinRef.setStatus(type);\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods, fastlanePaymentMethod } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const commonProps = getCommonProps({ ...this.props, elementRef: this.elementRef });\n\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, commonProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, commonProps, this.core);\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(\n this.props.filterStoredPaymentMethods?.(storedPaymentMethods) ?? storedPaymentMethods,\n paymentMethodsConfiguration,\n commonProps,\n this.core\n )\n : [];\n const fastlanePaymentElement = fastlanePaymentMethod\n ? createElements([fastlanePaymentMethod], paymentMethodsConfiguration, commonProps, this.core)\n : [];\n\n return [storedElements, elements, instantPaymentElements, fastlanePaymentElement];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | 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 if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n onAdditionalDetails: this.handleAdditionalDetails,\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n void this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n // If the active element has role=\"radio\", we're on a header in the PMList, in which case we don't want to validate the form, or, prevent the default behaviour\n const isPMHeader = document?.activeElement?.getAttribute('role') === 'radio';\n if (isPMHeader) {\n return;\n }\n super.handleKeyPress(e);\n }\n }\n\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n // We want to have a ref to the activePM, if we can; not a ref to the Dropin\n const pmComponent = this.activePaymentMethod ?? component;\n this.activePaymentMethod?.onEnterKeyPressed(activeElement, pmComponent);\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <DropinComponent\n {...this.props}\n core={this.core}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","storeElementRefOnCore","this","core","storeElementReference","formatProps","props","type","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","data","displayFinalAnimation","disableFinalAnimation","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","onAdditionalDetails","handleAdditionalDetails","isDropin","statusType","component","componentFromAction","handleKeyPress","e","key","code","document","activeElement","getAttribute","onEnterKeyPressed","pmComponent","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","DropinComponent","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","fastlanePaymentMethod","splitPaymentMethods","paymentMethodsResponse","commonProps","getCommonProps","elements","createElements","instantPaymentElements","createInstantPaymentElements","createStoredElements","filterStoredPaymentMethods","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","TxVariants","dropin","defaultProps"],"mappings":"m0BAkBA,MAAMA,EAA6B,CAAC,gBAAiB,YAAa,YAElE,MAAMC,UAAsBC,EAsBLC,qBAAAA,GACfC,KAAKC,KAAKC,sBAAsBF,KACpC,CAEAG,WAAAA,CAAYC,GACR,MAAO,CACHC,KAAM,YACHC,MAAMH,YAAYC,GACrBG,oBAAqBC,MAAMC,KAA0B,IAAIC,IAAIN,EAAMG,sBAAsBI,OAAOC,GAC5FhB,EAA2BiB,SAASD,IAGhD,CAEA,WAAIE,GACA,QAASd,KAAKe,aAAef,KAAKe,UAAUC,MAAMC,uBAAyBjB,KAAKe,UAAUC,MAAMC,oBAAoBH,OACxH,CAEAI,cAAAA,GAKI,OAJIlB,KAAKe,UAAUC,MAAMC,qBACrBjB,KAAKe,UAAUC,MAAMC,oBAAoBC,iBAGtClB,IACX,CAEOmB,SAAAA,CAAUC,EAAQhB,EAAQ,IAE7B,OADAJ,KAAKe,WAAWI,UAAUC,EAAQhB,GAC3BJ,IACX,CAEA,uBAAIiB,GACA,OAAKjB,KAAKe,WAAWC,OAAUhB,KAAKe,WAAWC,MAAMC,oBAI9CjB,KAAKe,UAAUC,MAAMC,oBAHjB,IAIf,CAEA,QAAII,GACA,OAAKrB,KAAKiB,oBAIHjB,KAAKe,UAAUC,MAAMC,oBAAoBI,KAHrC,IAIf,CAEOC,qBAAAA,CAAsBjB,GACrBL,KAAKI,MAAMmB,uBAEfvB,KAAKe,UAAUI,UAAUd,EAC7B,CAKA,MAAAmB,GACI,IAAKxB,KAAKiB,oBACN,MAAM,IAAIQ,MAAM,6BAGfzB,KAAKiB,oBAAoBH,SAC1Bd,KAAKiB,oBAAoBC,iBAGzBlB,KAAKiB,oBAAoBS,kBACzB1B,KAAK2B,2BAGT3B,KAAKiB,oBAAoBO,QAC7B,CAgCOI,YAAAA,CAAaC,EA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"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport defaultProps from './defaultProps';\nimport DropinComponent from '../../components/Dropin/components/DropinComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { getCommonProps } from './components/utils';\nimport { createElements, createStoredElements } from './elements';\nimport createInstantPaymentElements from './elements/createInstantPaymentElements';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport splitPaymentMethods from './elements/splitPaymentMethods';\nimport { TxVariants } from '../tx-variants';\n\nimport type { DropinConfiguration, InstantPaymentTypes, PaymentMethodsConfiguration } from './types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\nimport type { IDropin } from './types';\n\nconst SUPPORTED_INSTANT_PAYMENTS = ['paywithgoogle', 'googlepay', 'applepay'];\n\nclass DropinElement extends UIElement<DropinConfiguration> implements IDropin {\n public static type = TxVariants.dropin;\n\n protected static defaultProps = defaultProps;\n\n public dropinRef = null;\n\n private paymentMethodsConfiguration: PaymentMethodsConfiguration;\n /**\n * Reference to the component created from `handleAction` (Ex.: ThreeDS2Challenge)\n */\n public componentFromAction?: UIElement;\n\n constructor(checkout: ICore, props?: DropinConfiguration) {\n super(checkout, props);\n this.submit = this.submit.bind(this);\n this.handleAction = this.handleAction.bind(this);\n\n this.props.paymentMethodComponents.forEach(PaymentMethod => this.core.register(PaymentMethod));\n this.paymentMethodsConfiguration = this.props.paymentMethodsConfiguration || {};\n }\n\n protected override storeElementRefOnCore() {\n this.core.storeElementReference(this);\n }\n\n formatProps(props) {\n return {\n type: 'dropin', // for analytics\n ...super.formatProps(props),\n instantPaymentTypes: Array.from<InstantPaymentTypes>(new Set(props.instantPaymentTypes)).filter(value =>\n SUPPORTED_INSTANT_PAYMENTS.includes(value)\n )\n };\n }\n\n get isValid() {\n return !!this.dropinRef && !!this.dropinRef.state.activePaymentMethod && !!this.dropinRef.state.activePaymentMethod.isValid;\n }\n\n showValidation() {\n if (this.dropinRef.state.activePaymentMethod) {\n this.dropinRef.state.activePaymentMethod.showValidation();\n }\n\n return this;\n }\n\n public setStatus(status, props = {}): this {\n this.dropinRef?.setStatus(status, props);\n return this;\n }\n\n get activePaymentMethod() {\n if (!this.dropinRef?.state && !this.dropinRef?.state.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod;\n }\n\n get data() {\n if (!this.activePaymentMethod) {\n return null;\n }\n\n return this.dropinRef.state.activePaymentMethod.data;\n }\n\n public displayFinalAnimation(type: 'success' | 'error') {\n if (this.props.disableFinalAnimation) return;\n\n this.dropinRef?.setStatus(type);\n }\n\n /**\n * Calls the onSubmit event with the state of the activePaymentMethod\n */\n public override submit(): void {\n if (!this.activePaymentMethod) {\n throw new Error('No active payment method.');\n }\n\n if (!this.activePaymentMethod.isValid) {\n this.activePaymentMethod.showValidation();\n }\n\n if (this.activePaymentMethod.isInstantPayment) {\n this.closeActivePaymentMethod();\n }\n\n this.activePaymentMethod.submit();\n }\n\n /**\n * Creates the Drop-in elements\n */\n private handleCreate = () => {\n const { paymentMethodsConfiguration, showStoredPaymentMethods, showPaymentMethods, instantPaymentTypes } = this.props;\n\n const { paymentMethods, storedPaymentMethods, instantPaymentMethods, fastlanePaymentMethod } = splitPaymentMethods(\n this.core.paymentMethodsResponse,\n instantPaymentTypes\n );\n\n const commonProps = getCommonProps({ ...this.props, elementRef: this.elementRef });\n\n const elements = showPaymentMethods ? createElements(paymentMethods, paymentMethodsConfiguration, commonProps, this.core) : [];\n const instantPaymentElements = createInstantPaymentElements(instantPaymentMethods, paymentMethodsConfiguration, commonProps, this.core);\n const storedElements = showStoredPaymentMethods\n ? createStoredElements(\n this.props.filterStoredPaymentMethods?.(storedPaymentMethods) ?? storedPaymentMethods,\n paymentMethodsConfiguration,\n commonProps,\n this.core\n )\n : [];\n const fastlanePaymentElement = fastlanePaymentMethod\n ? createElements([fastlanePaymentMethod], paymentMethodsConfiguration, commonProps, this.core)\n : [];\n\n return [storedElements, elements, instantPaymentElements, fastlanePaymentElement];\n };\n\n public handleAction(action: PaymentAction, props = {}): this | 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 if (action.type !== 'redirect' && this.activePaymentMethod?.updateWithAction) {\n return this.activePaymentMethod.updateWithAction(action);\n }\n\n if (this.elementRef instanceof DropinElement) {\n props = {\n ...this.elementRef.activePaymentMethod?.props,\n ...props\n };\n }\n\n const paymentAction: UIElement = this.core.createFromAction(action, {\n ...props,\n elementRef: this.elementRef, // maintain elementRef for 3DS2 flow\n onAdditionalDetails: this.handleAdditionalDetails,\n isDropin: true\n });\n\n if (paymentAction) {\n this.setStatus(paymentAction.props.statusType, { component: paymentAction });\n this.componentFromAction = paymentAction;\n return this;\n }\n\n return null;\n }\n\n /**\n * handleOrder is implemented so we don't trigger a callback like in the components\n * @param response - PaymentResponse\n */\n protected handleOrder = ({ order }: PaymentResponseData): void => {\n void this.updateParent({ order });\n };\n\n closeActivePaymentMethod() {\n this.dropinRef.closeActivePaymentMethod();\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n // If the active element has role=\"radio\", we're on a header in the PMList, in which case we don't want to validate the form, or, prevent the default behaviour\n const isPMHeader = document?.activeElement?.getAttribute('role') === 'radio';\n if (isPMHeader) {\n return;\n }\n super.handleKeyPress(e);\n }\n }\n\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n // We want to have a ref to the activePM, if we can; not a ref to the Dropin\n const pmComponent = this.activePaymentMethod ?? component;\n this.activePaymentMethod?.onEnterKeyPressed(activeElement, pmComponent);\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <DropinComponent\n {...this.props}\n core={this.core}\n elementRef={this.elementRef}\n onCreateElements={this.handleCreate}\n ref={dropinRef => {\n this.dropinRef = dropinRef;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default DropinElement;\n"],"names":["SUPPORTED_INSTANT_PAYMENTS","DropinElement","UIElement","storeElementRefOnCore","this","core","storeElementReference","formatProps","props","type","super","instantPaymentTypes","Array","from","Set","filter","value","includes","isValid","dropinRef","state","activePaymentMethod","showValidation","setStatus","status","data","displayFinalAnimation","disableFinalAnimation","submit","Error","isInstantPayment","closeActivePaymentMethod","handleAction","action","hasOwnProperty","updateWithAction","elementRef","paymentAction","createFromAction","onAdditionalDetails","handleAdditionalDetails","isDropin","statusType","component","componentFromAction","handleKeyPress","e","key","code","document","activeElement","getAttribute","onEnterKeyPressed","pmComponent","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","DropinComponent","onCreateElements","handleCreate","ref","constructor","checkout","_define_property","paymentMethodsConfiguration","showStoredPaymentMethods","showPaymentMethods","paymentMethods","storedPaymentMethods","instantPaymentMethods","fastlanePaymentMethod","splitPaymentMethods","paymentMethodsResponse","commonProps","getCommonProps","elements","createElements","instantPaymentElements","createInstantPaymentElements","createStoredElements","filterStoredPaymentMethods","handleOrder","order","updateParent","bind","paymentMethodComponents","forEach","PaymentMethod","register","TxVariants","dropin","defaultProps"],"mappings":"m0BAkBA,MAAMA,EAA6B,CAAC,gBAAiB,YAAa,YAElE,MAAMC,UAAsBC,EAsBLC,qBAAAA,GACfC,KAAKC,KAAKC,sBAAsBF,KACpC,CAEAG,WAAAA,CAAYC,GACR,MAAO,CACHC,KAAM,YACHC,MAAMH,YAAYC,GACrBG,oBAAqBC,MAAMC,KAA0B,IAAIC,IAAIN,EAAMG,sBAAsBI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qBC,sBAAEA,GAA0BC,EAC3FzE,KAAKC,KAAKyE,uBACVnE,GAGEoE,EAAcC,EAAe,IAAK5E,KAAKI,MAAO4B,WAAYhC,KAAKgC,aAE/D6C,EAAWT,EAAqBU,EAAeT,EAAgBH,EAA6BS,EAAa3E,KAAKC,MAAQ,GACtH8E,EAAyBC,EAA6BT,EAAuBL,EAA6BS,EAAa3E,KAAKC,MAalI,MAAO,CAZgBkE,EACjBc,EACIjF,KAAKI,MAAM8E,6BAA6BZ,IAAyBA,EACjEJ,EACAS,EACA3E,KAAKC,MAET,GAKkB4E,EAAUE,EAJHP,EACzBM,EAAe,CAACN,GAAwBN,EAA6BS,EAAa3E,KAAKC,MACvF,MA+CVgE,EAAAjE,KAAUmF,cAAc,EAAGC,YAClBpF,KAAKqF,aAAa,CAAED,YAxJzBpF,KAAKwB,OAASxB,KAAKwB,OAAO8D,KAAKtF,MAC/BA,KAAK4B,aAAe5B,KAAK4B,aAAa0D,KAAKtF,MAE3CA,KAAKI,MAAMmF,wBAAwBC,QAAQC,GAAiBzF,KAAKC,KAAKyF,SAASD,IAC/EzF,KAAKkE,4BAA8BlE,KAAKI,MAAM8D,6BAA+B,CAAA,CACjF,EAnBAD,EADEpE,EACYQ,OAAOsF,EAAWC,QAEhC3B,EAHEpE,EAGegG,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import n from"../PaymentMethodDetails.js";import a from"../PaymentMethodIcon.js";import i from"../DisableOneClickConfirmation.js";import s from"../PaymentMethodBrands/PaymentMethodBrands.js";import{BRAND_ICON_UI_EXCLUSION_LIST as d}from"../../../../internal/SecuredFields/lib/constants.js";import r from"../PaymentMethodName.js";import{useCoreContext as m}from"../../../../../core/Context/CoreProvider.js";import h from"../../../../internal/ExpandButton/ExpandButton.js";function l(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class p extends e{render({paymentMethod:e,isSelected:l,isDisablingPaymentMethod:p,isLoaded:c,isLoading:y,standalone:u,showRadioButton:b}){const{i18n:f}=m();if(!e)return null;const _="card"===e.props.type||"scheme"===e.props.type,k=o({"adyen-checkout__payment-method":!0,[`adyen-checkout__payment-method--${e.props.type}`]:!0,..._&&{[`adyen-checkout__payment-method--${e.props.fundingSource??"credit"}`]:!0},"adyen-checkout__payment-method--selected":l,"adyen-checkout__payment-method--loading":y,"adyen-checkout__payment-method--disabling":p,"adyen-checkout__payment-method--confirming":this.state.showDisableStoredPaymentMethodConfirmation,"adyen-checkout__payment-method--standalone":u,[e._id]:!0,[this.props.className]:!0}),C=this.props.showRemovePaymentMethodButton&&e.props.oneClick&&l,M=`remove-${e._id}`,P=`container-${e._id}`,D=`button-${e._id}`,S=!e.props.oneClick&&e.brands&&e.brands.length>0;return t("div",{key:e._id,className:k,onClick:this.handleOnListItemClick},t("div",{className:"adyen-checkout__payment-method__header"},t(h,{buttonId:D,showRadioButton:b,isSelected:l,expandContentId:P,standalone:u},t(a,{...e.props.oneClick&&{altDescription:e.props.name},type:e.type,src:e.icon}),t(r,{displayName:e.displayName,isSelected:l,additionalInfo:e.additionalInfo})),C&&t("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link",onClick:this.toggleDisableConfirmation,"aria-expanded":this.state.showDisableStoredPaymentMethodConfirmation,"aria-controls":M},f.get("storedPaymentMethod.disable.button")),S&&t(s,{showOtherInsteafOfNumber:e.props.showOtherInsteafOfNumber,keepBrandsVisible:e.props.keepBrandsVisible,brands:e.brands,excludedUIBrands:d,isPaymentMethodSelected:l})),t("div",{className:"adyen-checkout-pm-details-wrapper","aria-hidden":!l},t("div",{className:"adyen-checkout__payment-method__details",id:P},C&&t(i,{id:M,open:this.state.showDisableStoredPaymentMethodConfirmation,onDisable:this.onDisableStoredPaymentMethod,onCancel:this.toggleDisableConfirmation}),t(n,{paymentMethodComponent:e.render(),isLoaded:c}))))}constructor(...e){super(...e),l(this,"state",{showDisableStoredPaymentMethodConfirmation:!1}),l(this,"toggleDisableConfirmation",()=>{this.setState({showDisableStoredPaymentMethodConfirmation:!this.state.showDisableStoredPaymentMethodConfirmation})}),l(this,"onDisableStoredPaymentMethod",()=>{this.props.onDisableStoredPaymentMethod(this.props.paymentMethod),this.toggleDisableConfirmation()}),l(this,"handleOnListItemClick",()=>{const{onSelect:e,paymentMethod:t}=this.props;e(t)})}}l(p,"defaultProps",{paymentMethod:null,isSelected:!1,isLoaded:!1,isLoading:!1,showDisableStoredPaymentMethodConfirmation:!1,showRadioButton:!1});export{p as default};
1
+ import{Component as e,createElement as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import n from"../PaymentMethodDetails.js";import a from"../PaymentMethodIcon.js";import i from"../DisableOneClickConfirmation.js";import s from"../PaymentMethodBrands/PaymentMethodBrands.js";import{BRAND_ICON_UI_EXCLUSION_LIST as d}from"../../../../internal/SecuredFields/lib/constants.js";import r from"../PaymentMethodName.js";import{useCoreContext as m}from"../../../../../core/Context/CoreProvider.js";import h from"../../../../internal/ExpandButton/ExpandButton.js";import{getFullBrandName as l}from"../../../../Card/components/CardInput/utils.js";function p(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class c extends e{render({paymentMethod:e,isSelected:p,isDisablingPaymentMethod:c,isLoaded:y,isLoading:u,standalone:b,showRadioButton:f}){const{i18n:_}=m();if(!e)return null;const C="card"===e.props.type||"scheme"===e.props.type,k=o({"adyen-checkout__payment-method":!0,[`adyen-checkout__payment-method--${e.props.type}`]:!0,...C&&{[`adyen-checkout__payment-method--${e.props.fundingSource??"credit"}`]:!0},"adyen-checkout__payment-method--selected":p,"adyen-checkout__payment-method--loading":u,"adyen-checkout__payment-method--disabling":c,"adyen-checkout__payment-method--confirming":this.state.showDisableStoredPaymentMethodConfirmation,"adyen-checkout__payment-method--standalone":b,[e._id]:!0,[this.props.className]:!0}),M=this.props.showRemovePaymentMethodButton&&e.props.oneClick&&p,P=`remove-${e._id}`,D=`container-${e._id}`,S=`button-${e._id}`,g=!e.props.oneClick&&e.brands&&e.brands.length>0;return t("div",{key:e._id,className:k,onClick:this.handleOnListItemClick},t("div",{className:"adyen-checkout__payment-method__header"},t(h,{buttonId:S,showRadioButton:f,isSelected:p,expandContentId:D,standalone:b},t(a,{...e.props.oneClick&&{altDescription:l(e.props.brand)},type:e.type,src:e.icon}),t(r,{displayName:e.displayName,isSelected:p,additionalInfo:e.additionalInfo})),M&&t("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link",onClick:this.toggleDisableConfirmation,"aria-expanded":this.state.showDisableStoredPaymentMethodConfirmation,"aria-controls":P},_.get("storedPaymentMethod.disable.button")),g&&t(s,{showOtherInsteafOfNumber:e.props.showOtherInsteafOfNumber,keepBrandsVisible:e.props.keepBrandsVisible,brands:e.brands,excludedUIBrands:d,isPaymentMethodSelected:p})),t("div",{className:"adyen-checkout-pm-details-wrapper","aria-hidden":!p},t("div",{className:"adyen-checkout__payment-method__details",id:D},M&&t(i,{id:P,open:this.state.showDisableStoredPaymentMethodConfirmation,onDisable:this.onDisableStoredPaymentMethod,onCancel:this.toggleDisableConfirmation}),t(n,{paymentMethodComponent:e.render(),isLoaded:y}))))}constructor(...e){super(...e),p(this,"state",{showDisableStoredPaymentMethodConfirmation:!1}),p(this,"toggleDisableConfirmation",()=>{this.setState({showDisableStoredPaymentMethodConfirmation:!this.state.showDisableStoredPaymentMethodConfirmation})}),p(this,"onDisableStoredPaymentMethod",()=>{this.props.onDisableStoredPaymentMethod(this.props.paymentMethod),this.toggleDisableConfirmation()}),p(this,"handleOnListItemClick",()=>{const{onSelect:e,paymentMethod:t}=this.props;e(t)})}}p(c,"defaultProps",{paymentMethod:null,isSelected:!1,isLoaded:!1,isLoading:!1,showDisableStoredPaymentMethodConfirmation:!1,showRadioButton:!1});export{c as default};
2
2
  //# sourceMappingURL=PaymentMethodItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentMethodItem.js","sources":["../../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport PaymentMethodDetails from '../PaymentMethodDetails';\nimport PaymentMethodIcon from '../PaymentMethodIcon';\nimport DisableOneClickConfirmation from '../DisableOneClickConfirmation';\nimport './PaymentMethodItem.scss';\nimport UIElement from '../../../../internal/UIElement/UIElement';\nimport PaymentMethodBrands from '../PaymentMethodBrands/PaymentMethodBrands';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../../../../internal/SecuredFields/lib/constants';\nimport PaymentMethodName from '../PaymentMethodName';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport ExpandButton from '../../../../internal/ExpandButton';\n\nexport interface PaymentMethodItemProps {\n paymentMethod: UIElement;\n isSelected?: boolean;\n isLoaded?: boolean;\n isLoading?: boolean;\n isDisablingPaymentMethod: boolean;\n showRemovePaymentMethodButton: boolean;\n onDisableStoredPaymentMethod: (paymentMethod) => void;\n onSelect: (paymentMethod: UIElement) => void;\n standalone: boolean;\n className?: string;\n showRadioButton?: boolean;\n}\n\nclass PaymentMethodItem extends Component<PaymentMethodItemProps> {\n public static defaultProps = {\n paymentMethod: null,\n isSelected: false,\n isLoaded: false,\n isLoading: false,\n showDisableStoredPaymentMethodConfirmation: false,\n showRadioButton: false\n };\n\n public state = {\n showDisableStoredPaymentMethodConfirmation: false\n };\n\n public toggleDisableConfirmation = () => {\n this.setState({ showDisableStoredPaymentMethodConfirmation: !this.state.showDisableStoredPaymentMethodConfirmation });\n };\n\n public onDisableStoredPaymentMethod = () => {\n this.props.onDisableStoredPaymentMethod(this.props.paymentMethod);\n this.toggleDisableConfirmation();\n };\n\n private handleOnListItemClick = (): void => {\n const { onSelect, paymentMethod } = this.props;\n onSelect(paymentMethod);\n };\n\n // @ts-ignore need to refine the type for paymentMethod\n render({ paymentMethod, isSelected, isDisablingPaymentMethod, isLoaded, isLoading, standalone, showRadioButton }) {\n const { i18n } = useCoreContext();\n\n if (!paymentMethod) {\n return null;\n }\n\n const isCard = paymentMethod.props.type === 'card' || paymentMethod.props.type === 'scheme';\n\n const paymentMethodClassnames = classNames({\n 'adyen-checkout__payment-method': true,\n [`adyen-checkout__payment-method--${paymentMethod.props.type}`]: true,\n ...(isCard && { [`adyen-checkout__payment-method--${paymentMethod.props.fundingSource ?? 'credit'}`]: true }),\n 'adyen-checkout__payment-method--selected': isSelected,\n 'adyen-checkout__payment-method--loading': isLoading,\n 'adyen-checkout__payment-method--disabling': isDisablingPaymentMethod,\n 'adyen-checkout__payment-method--confirming': this.state.showDisableStoredPaymentMethodConfirmation,\n 'adyen-checkout__payment-method--standalone': standalone,\n [paymentMethod._id]: true,\n [this.props.className]: true\n });\n\n const showRemovePaymentMethodButton = this.props.showRemovePaymentMethodButton && paymentMethod.props.oneClick && isSelected;\n const disableConfirmationId = `remove-${paymentMethod._id}`;\n const containerId = `container-${paymentMethod._id}`;\n const buttonId = `button-${paymentMethod._id}`;\n\n const showBrands = !paymentMethod.props.oneClick && paymentMethod.brands && paymentMethod.brands.length > 0;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n <div key={paymentMethod._id} className={paymentMethodClassnames} onClick={this.handleOnListItemClick}>\n <div className=\"adyen-checkout__payment-method__header\">\n <ExpandButton\n buttonId={buttonId}\n showRadioButton={showRadioButton}\n isSelected={isSelected}\n expandContentId={containerId}\n standalone={standalone}\n >\n <PaymentMethodIcon\n // Only add alt attribute to storedPaymentMethods (to avoid SR reading the PM name twice)\n {...(paymentMethod.props.oneClick && { altDescription: paymentMethod.props.name })}\n type={paymentMethod.type}\n src={paymentMethod.icon}\n />\n\n <PaymentMethodName\n displayName={paymentMethod.displayName}\n isSelected={isSelected}\n additionalInfo={paymentMethod.additionalInfo}\n />\n </ExpandButton>\n\n {showRemovePaymentMethodButton && (\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link\"\n onClick={this.toggleDisableConfirmation}\n aria-expanded={this.state.showDisableStoredPaymentMethodConfirmation}\n aria-controls={disableConfirmationId}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </button>\n )}\n\n {showBrands && (\n <PaymentMethodBrands\n showOtherInsteafOfNumber={paymentMethod.props.showOtherInsteafOfNumber}\n keepBrandsVisible={paymentMethod.props.keepBrandsVisible}\n brands={paymentMethod.brands}\n excludedUIBrands={BRAND_ICON_UI_EXCLUSION_LIST}\n isPaymentMethodSelected={isSelected}\n />\n )}\n </div>\n\n <div className=\"adyen-checkout-pm-details-wrapper\" aria-hidden={!isSelected}>\n <div className=\"adyen-checkout__payment-method__details\" id={containerId}>\n {showRemovePaymentMethodButton && (\n <DisableOneClickConfirmation\n id={disableConfirmationId}\n open={this.state.showDisableStoredPaymentMethodConfirmation}\n onDisable={this.onDisableStoredPaymentMethod}\n onCancel={this.toggleDisableConfirmation}\n />\n )}\n\n <PaymentMethodDetails paymentMethodComponent={paymentMethod.render()} isLoaded={isLoaded} />\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default PaymentMethodItem;\n"],"names":["PaymentMethodItem","Component","render","paymentMethod","isSelected","isDisablingPaymentMethod","isLoaded","isLoading","standalone","showRadioButton","i18n","useCoreContext","isCard","props","type","paymentMethodClassnames","classNames","fundingSource","this","state","showDisableStoredPaymentMethodConfirmation","_id","className","showRemovePaymentMethodButton","oneClick","disableConfirmationId","containerId","buttonId","showBrands","brands","length","h","div","key","onClick","handleOnListItemClick","ExpandButton","expandContentId","PaymentMethodIcon","altDescription","name","src","icon","PaymentMethodName","displayName","additionalInfo","button","toggleDisableConfirmation","aria-expanded","aria-controls","get","PaymentMethodBrands","showOtherInsteafOfNumber","keepBrandsVisible","excludedUIBrands","BRAND_ICON_UI_EXCLUSION_LIST","isPaymentMethodSelected","aria-hidden","id","DisableOneClickConfirmation","open","onDisable","onDisableStoredPaymentMethod","onCancel","PaymentMethodDetails","paymentMethodComponent","super","args","_define_property","setState","onSelect","defaultProps"],"mappings":"4tBA2BA,MAAMA,UAA0BC,EA6B5BC,MAAAA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,yBAAEA,EAAwBC,SAAEA,EAAQC,UAAEA,EAASC,WAAEA,EAAUC,gBAAEA,IAC3F,MAAMC,KAAEA,GAASC,IAEjB,IAAKR,EACD,OAAO,KAGX,MAAMS,EAAsC,SAA7BT,EAAcU,MAAMC,MAAgD,WAA7BX,EAAcU,MAAMC,KAEpEC,EAA0BC,EAAW,CACvC,kCAAkC,EAClC,CAAC,mCAAmCb,EAAcU,MAAMC,SAAS,KAC7DF,GAAU,CAAE,CAAC,mCAAmCT,EAAcU,MAAMI,eAAiB,aAAa,GACtG,2CAA4Cb,EAC5C,0CAA2CG,EAC3C,4CAA6CF,EAC7C,6CAA8Ca,KAAKC,MAAMC,2CACzD,6CAA8CZ,EAC9C,CAACL,EAAckB,MAAM,EACrB,CAACH,KAAKL,MAAMS,YAAY,IAGtBC,EAAgCL,KAAKL,MAAMU,+BAAiCpB,EAAcU,MAAMW,UAAYpB,EAC5GqB,EAAwB,UAAUtB,EAAckB,MAChDK,EAAc,aAAavB,EAAckB,MACzCM,EAAW,UAAUxB,EAAckB,MAEnCO,GAAczB,EAAcU,MAAMW,UAAYrB,EAAc0B,QAAU1B,EAAc0B,OAAOC,OAAS,EAE1G,OAEIC,EAACC,MAAAA,CAAIC,IAAK9B,EAAckB,IAAKC,UAAWP,EAAyBmB,QAAShB,KAAKiB,uBAC3EJ,EAACC,MAAAA,CAAIV,UAAU,0CACXS,EAACK,EAAAA,CACGT,SAAUA,EACVlB,gBAAiBA,EACjBL,WAAYA,EACZiC,gBAAiBX,EACjBlB,WAAYA,GAEZuB,EAACO,EAAAA,IAEQnC,EAAcU,MAAMW,UAAY,CAAEe,eAAgBpC,EAAcU,MAAM2B,MAC3E1B,KAAM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components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport PaymentMethodDetails from '../PaymentMethodDetails';\nimport PaymentMethodIcon from '../PaymentMethodIcon';\nimport DisableOneClickConfirmation from '../DisableOneClickConfirmation';\nimport './PaymentMethodItem.scss';\nimport UIElement from '../../../../internal/UIElement/UIElement';\nimport PaymentMethodBrands from '../PaymentMethodBrands/PaymentMethodBrands';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../../../../internal/SecuredFields/lib/constants';\nimport PaymentMethodName from '../PaymentMethodName';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport { getFullBrandName } from '../../../../Card/components/CardInput/utils';\n\nexport interface PaymentMethodItemProps {\n paymentMethod: UIElement;\n isSelected?: boolean;\n isLoaded?: boolean;\n isLoading?: boolean;\n isDisablingPaymentMethod: boolean;\n showRemovePaymentMethodButton: boolean;\n onDisableStoredPaymentMethod: (paymentMethod) => void;\n onSelect: (paymentMethod: UIElement) => void;\n standalone: boolean;\n className?: string;\n showRadioButton?: boolean;\n}\n\nclass PaymentMethodItem extends Component<PaymentMethodItemProps> {\n public static defaultProps = {\n paymentMethod: null,\n isSelected: false,\n isLoaded: false,\n isLoading: false,\n showDisableStoredPaymentMethodConfirmation: false,\n showRadioButton: false\n };\n\n public state = {\n showDisableStoredPaymentMethodConfirmation: false\n };\n\n public toggleDisableConfirmation = () => {\n this.setState({ showDisableStoredPaymentMethodConfirmation: !this.state.showDisableStoredPaymentMethodConfirmation });\n };\n\n public onDisableStoredPaymentMethod = () => {\n this.props.onDisableStoredPaymentMethod(this.props.paymentMethod);\n this.toggleDisableConfirmation();\n };\n\n private handleOnListItemClick = (): void => {\n const { onSelect, paymentMethod } = this.props;\n onSelect(paymentMethod);\n };\n\n // @ts-ignore need to refine the type for paymentMethod\n render({ paymentMethod, isSelected, isDisablingPaymentMethod, isLoaded, isLoading, standalone, showRadioButton }) {\n const { i18n } = useCoreContext();\n\n if (!paymentMethod) {\n return null;\n }\n\n const isCard = paymentMethod.props.type === 'card' || paymentMethod.props.type === 'scheme';\n\n const paymentMethodClassnames = classNames({\n 'adyen-checkout__payment-method': true,\n [`adyen-checkout__payment-method--${paymentMethod.props.type}`]: true,\n ...(isCard && { [`adyen-checkout__payment-method--${paymentMethod.props.fundingSource ?? 'credit'}`]: true }),\n 'adyen-checkout__payment-method--selected': isSelected,\n 'adyen-checkout__payment-method--loading': isLoading,\n 'adyen-checkout__payment-method--disabling': isDisablingPaymentMethod,\n 'adyen-checkout__payment-method--confirming': this.state.showDisableStoredPaymentMethodConfirmation,\n 'adyen-checkout__payment-method--standalone': standalone,\n [paymentMethod._id]: true,\n [this.props.className]: true\n });\n\n const showRemovePaymentMethodButton = this.props.showRemovePaymentMethodButton && paymentMethod.props.oneClick && isSelected;\n const disableConfirmationId = `remove-${paymentMethod._id}`;\n const containerId = `container-${paymentMethod._id}`;\n const buttonId = `button-${paymentMethod._id}`;\n\n const showBrands = !paymentMethod.props.oneClick && paymentMethod.brands && paymentMethod.brands.length > 0;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n <div key={paymentMethod._id} className={paymentMethodClassnames} onClick={this.handleOnListItemClick}>\n <div className=\"adyen-checkout__payment-method__header\">\n <ExpandButton\n buttonId={buttonId}\n showRadioButton={showRadioButton}\n isSelected={isSelected}\n expandContentId={containerId}\n standalone={standalone}\n >\n <PaymentMethodIcon\n // Only add alt attribute to storedPaymentMethods (to avoid SR reading the PM name twice)\n {...(paymentMethod.props.oneClick && { altDescription: getFullBrandName(paymentMethod.props.brand) })}\n type={paymentMethod.type}\n src={paymentMethod.icon}\n />\n\n <PaymentMethodName\n displayName={paymentMethod.displayName}\n isSelected={isSelected}\n additionalInfo={paymentMethod.additionalInfo}\n />\n </ExpandButton>\n\n {showRemovePaymentMethodButton && (\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link\"\n onClick={this.toggleDisableConfirmation}\n aria-expanded={this.state.showDisableStoredPaymentMethodConfirmation}\n aria-controls={disableConfirmationId}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </button>\n )}\n\n {showBrands && (\n <PaymentMethodBrands\n showOtherInsteafOfNumber={paymentMethod.props.showOtherInsteafOfNumber}\n keepBrandsVisible={paymentMethod.props.keepBrandsVisible}\n brands={paymentMethod.brands}\n excludedUIBrands={BRAND_ICON_UI_EXCLUSION_LIST}\n isPaymentMethodSelected={isSelected}\n />\n )}\n </div>\n\n <div className=\"adyen-checkout-pm-details-wrapper\" aria-hidden={!isSelected}>\n <div className=\"adyen-checkout__payment-method__details\" id={containerId}>\n {showRemovePaymentMethodButton && (\n <DisableOneClickConfirmation\n id={disableConfirmationId}\n open={this.state.showDisableStoredPaymentMethodConfirmation}\n onDisable={this.onDisableStoredPaymentMethod}\n onCancel={this.toggleDisableConfirmation}\n />\n )}\n\n <PaymentMethodDetails paymentMethodComponent={paymentMethod.render()} isLoaded={isLoaded} />\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default PaymentMethodItem;\n"],"names":["PaymentMethodItem","Component","render","paymentMethod","isSelected","isDisablingPaymentMethod","isLoaded","isLoading","standalone","showRadioButton","i18n","useCoreContext","isCard","props","type","paymentMethodClassnames","classNames","fundingSource","this","state","showDisableStoredPaymentMethodConfirmation","_id","className","showRemovePaymentMethodButton","oneClick","disableConfirmationId","containerId","buttonId","showBrands","brands","length","h","div","key","onClick","handleOnListItemClick","ExpandButton","expandContentId","PaymentMethodIcon","altDescription","getFullBrandName","brand","src","icon","PaymentMethodName","displayName","additionalInfo","button","toggleDisableConfirmation","aria-expanded","aria-controls","get","PaymentMethodBrands","showOtherInsteafOfNumber","keepBrandsVisible","excludedUIBrands","BRAND_ICON_UI_EXCLUSION_LIST","isPaymentMethodSelected","aria-hidden","id","DisableOneClickConfirmation","open","onDisable","onDisableStoredPaymentMethod","onCancel","PaymentMethodDetails","paymentMethodComponent","super","args","_define_property","setState","onSelect","defaultProps"],"mappings":"8yBA4BA,MAAMA,UAA0BC,EA6B5BC,MAAAA,EAAOC,cAAEA,EAAaC,WAAEA,EAAUC,yBAAEA,EAAwBC,SAAEA,EAAQC,UAAEA,EAASC,WAAEA,EAAUC,gBAAEA,IAC3F,MAAMC,KAAEA,GAASC,IAEjB,IAAKR,EACD,OAAO,KAGX,MAAMS,EAAsC,SAA7BT,EAAcU,MAAMC,MAAgD,WAA7BX,EAAcU,MAAMC,KAEpEC,EAA0BC,EAAW,CACvC,kCAAkC,EAClC,CAAC,mCAAmCb,EAAcU,MAAMC,SAAS,KAC7DF,GAAU,CAAE,CAAC,mCAAmCT,EAAcU,MAAMI,eAAiB,aAAa,GACtG,2CAA4Cb,EAC5C,0CAA2CG,EAC3C,4CAA6CF,EAC7C,6CAA8Ca,KAAKC,MAAMC,2CACzD,6CAA8CZ,EAC9C,CAACL,EAAckB,MAAM,EACrB,CAACH,KAAKL,MAAMS,YAAY,IAGtBC,EAAgCL,KAAKL,MAAMU,+BAAiCpB,EAAcU,MAAMW,UAAYpB,EAC5GqB,EAAwB,UAAUtB,EAAckB,MAChDK,EAAc,aAAavB,EAAckB,MACzCM,EAAW,UAAUxB,EAAckB,MAEnCO,GAAczB,EAAcU,MAAMW,UAAYrB,EAAc0B,QAAU1B,EAAc0B,OAAOC,OAAS,EAE1G,OAEIC,EAACC,MAAAA,CAAIC,IAAK9B,EAAckB,IAAKC,UAAWP,EAAyBmB,QAAShB,KAAKiB,uBAC3EJ,EAACC,MAAAA,CAAIV,UAAU,0CACXS,EAACK,EAAAA,CACGT,SAAUA,EACVlB,gBAAiBA,EACjBL,WAAYA,EACZiC,gBAAiBX,EACjBlB,WAAYA,GAEZuB,EAACO,EAAAA,IAEQnC,EAAcU,MAAMW,UAAY,CAAEe,eAAgBC,EAAiBrC,EAAcU,MAAM4B,QAC5F3B,KAAMX,EA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js","sources":["../../../../../src/components/Giftcard/components/useSRPanelForGiftcardErrors.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\n\n/**\n * Interface for transformed error objects returned from mapErrorsToValidationRuleResult\n */\ninterface TransformedError {\n isValid: boolean;\n errorMessage: string;\n errorI18n: string;\n error: string;\n rootNode: HTMLElement;\n}\n\n/**\n * Interface for errors object with transformed error entries\n */\ninterface TransformedErrorsObj {\n [key: string]: TransformedError | null;\n}\n\n/**\n * Props interface for the error handling hook\n */\ninterface UseSRPanelForGiftcardErrorsProps {\n errors: TransformedErrorsObj;\n isValidating: boolean;\n sfp: SecuredFieldsProvider;\n}\n\n/**\n * Interface for sorted error objects used for comparison\n */\ninterface SortedErrorObject {\n field: string;\n errorMessage: string;\n}\n\n/**\n * Custom hook for handling gift card component errors and screen reader announcements\n *\n * This hook manages both visual and screen reader error announcements for the gift card component,\n * handling both blur-based validation errors and form-wide validation errors.\n */\nconst useSRPanelForGiftcardErrors = ({ errors, isValidating, sfp }: UseSRPanelForGiftcardErrorsProps) => {\n // Track sorted list of errors for comparison with previous state\n const [sortedErrorList, setSortedErrorList] = useState<SortedErrorObject[]>(null);\n // Track previous error list for detecting changes\n const previousSortedErrors = usePrevious(sortedErrorList);\n\n // Get SRPanel context for managing screen reader messages\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n\n // Fixed layout array defining the order of fields for error sorting\n // Assume fields in this order, and adds encryptedExpiryDate for MealVoucher, this is ignored in giftcard\n const layout = ['encryptedCardNumber', 'encryptedExpiryDate', 'encryptedSecurityCode'];\n\n useEffect(() => {\n try {\n // Create a partial function for setting SR messages with fixed configuration\n const setMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n // Set messages with current errors and layout\n\n // Unlike Card SR Panel, isValidating is a boolean\n const srPanelResp: SetSRMessagesReturnObject = setMessages?.({\n errors,\n isValidating,\n layout\n });\n\n // Store the sorted list of errors for comparison\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n setSortedErrorList(currentErrorsSortedByLayout);\n\n // Handle different error scenarios based on the action type\n switch (srPanelResp?.action) {\n case ERROR_ACTION_FOCUS_FIELD:\n // When a field needs to be focused due to validation error\n if (shouldMoveFocusSR) {\n sfp?.setFocusOn(srPanelResp?.fieldToFocus);\n }\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n if (typeof isValidating === 'boolean') {\n isValidating = false;\n }\n }, 300);\n break;\n\n case ERROR_ACTION_BLUR_SCENARIO: {\n // Handle blur-based validation errors\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Only announce blur-based errors to screen reader\n const isBlurBasedError = true;\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // Clear SR panel if there are no more errors\n clearSRPanel();\n }\n break;\n }\n }\n } catch (_) {\n // Fail silently - we don't want to break the component if SRPanel fails\n }\n }, [errors]);\n};\n\n// Export all interfaces and the hook\nexport type { TransformedError, TransformedErrorsObj };\n\nexport { useSRPanelForGiftcardErrors };\n"],"names":["useSRPanelForGiftcardErrors","errors","isValidating","sfp","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","layout","useEffect","setMessages","srPanelResp","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOn","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorMessage","_"],"mappings":"0XAkDA,MAAMA,EAA8B,EAAGC,SAAQC,eAAcC,UAEzD,MAAOC,EAAiBC,GAAsBC,EAA8B,MAEtEC,EAAuBC,EAAYJ,IAGnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAI1FC,EAAS,CAAC,sBAAuB,sBAAuB,yBAE9DC,EAAU,KACN,IAEI,MAAMC,EAAqCP,IAA2B,IAIhEQ,EAAyCD,IAAc,CACzDf,SACAC,eACAY,WAIEI,EAA8BD,GAAaC,4BAIjD,OAHAb,EAAmBa,GAGXD,GAAaE,QACjB,KAAKC,EAEGR,GACAT,GAAKkB,WAAWJ,GAAaK,cAGjCC,WAAW,KACqB,kBAAjBrB,IACPA,GAAe,IAEpB,KACH,MAEJ,KAAKsB,EAA4B,CAE7B,MAAMC,EAAaC,EAAoBR,EAA6BX,EAAsB,SACpFoB,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MACMC,GADmB,EACgBD,EAAeE,aAAe,KACvEnB,EAAyBkB,QAGzBjB,IAEJ,KACJ,EAER,CAAE,MAAOmB,GAET,GACD,CAAC7B"}
1
+ {"version":3,"file":"useSRPanelForGiftcardErrors.js","sources":["../../../../../src/components/Giftcard/components/useSRPanelForGiftcardErrors.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\n\n/**\n * Interface for transformed error objects returned from mapErrorsToValidationRuleResult\n */\ninterface TransformedError {\n isValid: boolean;\n errorMessage: string;\n errorI18n: string;\n error: string;\n rootNode: HTMLElement;\n}\n\n/**\n * Interface for errors object with transformed error entries\n */\ninterface TransformedErrorsObj {\n [key: string]: TransformedError | null;\n}\n\n/**\n * Props interface for the error handling hook\n */\ninterface UseSRPanelForGiftcardErrorsProps {\n errors: TransformedErrorsObj;\n isValidating: boolean;\n sfp: SecuredFieldsProvider;\n}\n\n/**\n * Interface for sorted error objects used for comparison\n */\ninterface SortedErrorObject {\n field: string;\n errorMessage: string;\n}\n\n/**\n * Custom hook for handling gift card component errors and screen reader announcements\n *\n * This hook manages both visual and screen reader error announcements for the gift card component,\n * handling both blur-based validation errors and form-wide validation errors.\n */\nconst useSRPanelForGiftcardErrors = ({ errors, isValidating, sfp }: UseSRPanelForGiftcardErrorsProps) => {\n // Track sorted list of errors for comparison with previous state\n const [sortedErrorList, setSortedErrorList] = useState<SortedErrorObject[]>(null);\n // Track previous error list for detecting changes\n const previousSortedErrors = usePrevious(sortedErrorList);\n\n // Get SRPanel context for managing screen reader messages\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n\n // Fixed layout array defining the order of fields for error sorting\n // Assume fields in this order, and adds encryptedExpiryDate for MealVoucher, this is ignored in giftcard\n const layout = ['encryptedCardNumber', 'encryptedExpiryDate', 'encryptedSecurityCode'];\n\n useEffect(() => {\n try {\n // Create a partial function for setting SR messages with fixed configuration\n const setMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n // Set messages with current errors and layout\n\n // Unlike Card SR Panel, isValidating is a boolean\n const srPanelResp: SetSRMessagesReturnObject = setMessages?.({\n errors,\n isValidating,\n layout\n });\n\n // Store the sorted list of errors for comparison\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n setSortedErrorList(currentErrorsSortedByLayout);\n\n // Handle different error scenarios based on the action type\n switch (srPanelResp?.action) {\n case ERROR_ACTION_FOCUS_FIELD:\n // When a field needs to be focused due to validation error\n if (shouldMoveFocusSR) {\n sfp?.setFocusOn(srPanelResp?.fieldToFocus);\n }\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n if (typeof isValidating === 'boolean') {\n isValidating = false;\n }\n }, 300);\n break;\n\n case ERROR_ACTION_BLUR_SCENARIO: {\n // Handle blur-based validation errors\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Only announce blur-based errors to screen reader\n const isBlurBasedError = true;\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // Clear SR panel if there are no more errors\n clearSRPanel();\n }\n break;\n }\n }\n } catch (_) {\n // Fail silently - we don't want to break the component if SRPanel fails\n }\n }, [errors]);\n};\n\n// Export all interfaces and the hook\nexport type { TransformedError, TransformedErrorsObj };\n\nexport { useSRPanelForGiftcardErrors };\n"],"names":["useSRPanelForGiftcardErrors","errors","isValidating","sfp","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","layout","useEffect","setMessages","srPanelResp","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOn","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorMessage","_"],"mappings":"0XAkDA,MAAMA,EAA8B,EAAGC,SAAQC,eAAcC,UAEzD,MAAOC,EAAiBC,GAAsBC,EAA8B,MAEtEC,EAAuBC,EAAYJ,IAGnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAI1FC,EAAS,CAAC,sBAAuB,sBAAuB,yBAE9DC,EAAU,KACN,IAEI,MAAMC,EAAqCP,IAA2B,IAIhEQ,EAAyCD,IAAc,CACzDf,SACAC,eACAY,WAIEI,EAA8BD,GAAaC,4BAIjD,OAHAb,EAAmBa,GAGXD,GAAaE,QACjB,KAAKC,EAEGR,GACAT,GAAKkB,WAAWJ,GAAaK,cAGjCC,WAAW,KACqB,kBAAjBrB,IACPA,GAAe,IAEpB,KACH,MAEJ,KAAKsB,EAA4B,CAE7B,MAAMC,EAAaC,EAAoBR,EAA6BX,EAAsB,SACpFoB,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MACMC,GADmB,EACgBD,EAAeE,aAAe,KACvEnB,EAAyBkB,EAC7B,MAEIjB,IAEJ,KACJ,EAER,CAAE,MAAOmB,GAET,GACD,CAAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"2DAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,EAAmC,IAAKC,GAErCC,OAAOC,KAAKF,GAAOG,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQN,EAAMK,GAIpB,OAHa,UAATA,GAAoBE,EAA4BC,SAASF,MACzDF,EAAIC,GAAQC,GAETF,GACR"}
1
+ {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"2DAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,EAAmC,IAAKC,GAErCC,OAAOC,KAAKF,GAAOG,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQN,EAAMK,GAIpB,OAHa,UAATA,GAAoBE,EAA4BC,SAASF,MACzDF,EAAIC,GAAQC,GAETF,GACR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FastlaneSDK.js","sources":["../../../../src/components/PayPalFastlane/FastlaneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport requestFastlaneToken from './services/request-fastlane-token';\nimport { convertAdyenLocaleToFastlaneLocale } from './utils/convert-locale';\nimport Script from '../../utils/Script';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport type {\n FastlanePaymentMethodConfiguration,\n FastlaneWindowInstance,\n FastlaneAuthenticatedCustomerResult,\n FastlaneShippingAddressSelectorResult,\n FastlaneSDKConfiguration,\n FastlaneConsentRenderState\n} from './types';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly locale: string;\n private readonly forceConsentDetails: boolean;\n\n private fastlaneSdk?: FastlaneWindowInstance;\n private latestShopperDetails?: { email: string; customerId: string };\n private fastlaneSessionId?: string;\n\n constructor(configuration: FastlaneSDKConfiguration) {\n if (!configuration?.environment) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'environment' property is required\");\n if (!configuration?.clientKey) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'clientKey' property is required\");\n\n if (configuration.forceConsentDetails && configuration.environment.includes('live'))\n console.warn(\"Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment\");\n\n const { apiUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.locale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n return this;\n }\n\n /**\n * Triggers the authentication for Fastlane using shopper's email.\n * If shopper is recognized, the OTP flow is initialized.\n *\n * @param email\n */\n public async authenticate(email: string): Promise<FastlaneAuthenticatedCustomerResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'authenticate(): Fastlane SDK is not initialized');\n }\n\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n return this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n } else {\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n }\n }\n\n /**\n * Creates the Adyen Component configuration based on the Fastlane authentication result.\n *\n * In case the shopper authenticated successfully, it returns config to be used in the Fastlane component\n * Otherwise, it returns the configuration to be used in the Card component\n *\n * @param authResult\n */\n public async getComponentConfiguration(authResult: FastlaneAuthenticatedCustomerResult): Promise<FastlanePaymentMethodConfiguration> {\n if (!authResult) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'FastlaneSDK: you must pass the authentication result to get the component configuration'\n );\n }\n\n if (authResult.authenticationState === 'succeeded') {\n const hasCard = !!authResult.profileData?.card;\n\n if (!hasCard) {\n throw new AdyenCheckoutError('ERROR', 'getComponentConfiguration(): There is no card associated with the authenticated profile');\n }\n\n return {\n paymentType: 'fastlane',\n configuration: {\n fastlaneSessionId: this.fastlaneSessionId,\n email: this.latestShopperDetails.email,\n tokenId: authResult.profileData.card.id,\n lastFour: authResult.profileData.card.paymentSource.card.lastDigits,\n brand: authResult.profileData.card.paymentSource.card.brand.toLowerCase()\n }\n };\n } else {\n const consentDetails = await this.fetchConsentDetails();\n return {\n paymentType: 'card',\n configuration: {\n ...(consentDetails && {\n fastlaneConfiguration: {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n }\n })\n }\n };\n }\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n return this.fastlaneSdk.profile.showShippingAddressSelector();\n }\n\n /**\n * Render the \"Fastlane by PayPal\" logo in the specified HTML container\n */\n public async mountWatermark(container: HTMLElement | string, options = { includeAdditionalInfo: true }): Promise<void> {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n }\n\n private requestClientToken(): Promise<FastlaneTokenData> {\n return requestFastlaneToken(this.checkoutShopperURL, this.clientKey);\n }\n\n private async fetchSdk(clientToken: string, clientId: string): Promise<void> {\n const url = `https://www.paypal.com/sdk/js?client-id=${clientId}&components=buttons,fastlane`;\n const script = new Script(url, 'body', {}, { sdkClientToken: clientToken });\n\n await script.load();\n }\n\n /**\n * Fetch the fastlane session ID used internally by PayPal for Network Token Usage event\n * This ID is not critical for the payment processing part\n *\n * @private\n */\n private async fetchSessionIdAsync(): Promise<void> {\n try {\n const { sessionId } = await this.fastlaneSdk.identity.getSession();\n this.fastlaneSessionId = sessionId;\n } catch (error) {\n console.warn('Fastlane SDK: Failed to fetch session ID', error);\n }\n }\n\n /**\n * Fetch object containing that details that will be used to display the sign-up UI\n * inside the card component\n * @private\n */\n private async fetchConsentDetails(): Promise<FastlaneConsentRenderState> {\n try {\n const consentComponent = await this.fastlaneSdk.ConsentComponent();\n return await consentComponent.getRenderState();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'fetchConsentDetails(): failed to fetch consent details', { cause: error });\n }\n }\n\n private async initializeFastlaneInstance(): Promise<void> {\n try {\n this.fastlaneSdk = await window.paypal.Fastlane({\n intendedExperience: 'externalProcessorCustomConsent',\n ...(this.forceConsentDetails && {\n metadata: {\n geoLocOverride: 'US'\n }\n })\n });\n this.fastlaneSdk.setLocale(this.locale);\n\n void this.fetchSessionIdAsync();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor', {\n cause: error\n });\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","tokenData","this","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","authenticate","email","fastlaneSdk","AdyenCheckoutError","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","triggerAuthenticationFlow","authenticationState","profileData","undefined","getComponentConfiguration","authResult","card","paymentType","configuration","fastlaneSessionId","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fetchConsentDetails","fastlaneConfiguration","showShippingAddressSelector","profile","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","script","Script","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","error","console","warn","consentComponent","ConsentComponent","getRenderState","cause","window","paypal","Fastlane","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","locale","constructor","_define_property","environment","includes","apiUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale"],"mappings":"maAeA,MAAMA,EA4BF,gBAAaC,GACT,MAAMC,QAAkBC,KAAKC,qBAG7B,aAFMD,KAAKE,SAASH,EAAUI,MAAOJ,EAAUK,gBACzCJ,KAAKK,6BACJL,IACX,CAQA,kBAAaM,CAAaC,GACtB,IAAKP,KAAKQ,YACN,MAAM,IAAIC,EAAmB,uBAAwB,mDAGzD,MAAMC,kBAAEA,SAA4BV,KAAKQ,YAAYG,SAASC,sBAAsBL,GAEpF,OAAIG,GACAV,KAAKa,qBAAuB,CAAEN,QAAOO,WAAYJ,GAC1CV,KAAKQ,YAAYG,SAASI,0BAA0BL,IAEpD,CACHM,oBAAqB,YACrBC,iBAAaC,EAGzB,CAUA,+BAAaC,CAA0BC,GACnC,IAAKA,EACD,MAAM,IAAIX,EACN,uBACA,2FAIR,GAAuC,cAAnCW,EAAWJ,oBAAqC,CAGhD,MAFkBI,EAAWH,aAAaI,KAGtC,MAAM,IAAIZ,EAAmB,QAAS,2FAG1C,MAAO,CACHa,YAAa,WACbC,cAAe,CACXC,kBAAmBxB,KAAKwB,kBACxBjB,MAAOP,KAAKa,qBAAqBN,MACjCkB,QAASL,EAAWH,YAAYI,KAAKK,GACrCC,SAAUP,EAAWH,YAAYI,KAAKO,cAAcP,KAAKQ,WACzDC,MAAOV,EAAWH,YAAYI,KAAKO,cAAcP,KAAKS,MAAMC,gBAGjE,CACH,MAAMC,QAAuBhC,KAAKiC,sBAClC,MAAO,CACHX,YAAa,OACbC,cAAe,IACPS,GAAkB,CAClBE,sBAAuB,CACnBV,kBAAmBxB,KAAKwB,qBACrBQ,KAKvB,CACJ,CAKA,2BAAAG,GACI,OAAOnC,KAAKQ,YAAY4B,QAAQD,6BACpC,CAKA,oBAAaE,CAAeC,EAAiCC,EAAU,CAAEC,uBAAuB,WACpExC,KAAKQ,YAAYiC,2BAA2BF,IAC1DG,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,qBAAuB1C,EAAciD,YAAYC,SAAS,SACxElB,QAAQC,KAAK,gFAEjB,MAAMkB,OAAEA,GAAWC,EAAoBpD,EAAciD,aAErDxE,KAAK4C,mBAAqB8B,EAC1B1E,KAAK6C,UAAYtB,EAAcsB,UAC/B7C,KAAKiE,oBAAsB1C,EAAc0C,sBAAuB,EAChEjE,KAAKqE,OAASO,EAAmCrD,EAAc8C,QAAU,QAC7E"}
1
+ {"version":3,"file":"FastlaneSDK.js","sources":["../../../../src/components/PayPalFastlane/FastlaneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport requestFastlaneToken from './services/request-fastlane-token';\nimport { convertAdyenLocaleToFastlaneLocale } from './utils/convert-locale';\nimport Script from '../../utils/Script';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport type {\n FastlanePaymentMethodConfiguration,\n FastlaneWindowInstance,\n FastlaneAuthenticatedCustomerResult,\n FastlaneShippingAddressSelectorResult,\n FastlaneSDKConfiguration,\n FastlaneConsentRenderState\n} from './types';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly locale: string;\n private readonly forceConsentDetails: boolean;\n\n private fastlaneSdk?: FastlaneWindowInstance;\n private latestShopperDetails?: { email: string; customerId: string };\n private fastlaneSessionId?: string;\n\n constructor(configuration: FastlaneSDKConfiguration) {\n if (!configuration?.environment) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'environment' property is required\");\n if (!configuration?.clientKey) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', \"FastlaneSDK: 'clientKey' property is required\");\n\n if (configuration.forceConsentDetails && configuration.environment.includes('live'))\n console.warn(\"Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment\");\n\n const { apiUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.locale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n return this;\n }\n\n /**\n * Triggers the authentication for Fastlane using shopper's email.\n * If shopper is recognized, the OTP flow is initialized.\n *\n * @param email\n */\n public async authenticate(email: string): Promise<FastlaneAuthenticatedCustomerResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'authenticate(): Fastlane SDK is not initialized');\n }\n\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n return this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n } else {\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n }\n }\n\n /**\n * Creates the Adyen Component configuration based on the Fastlane authentication result.\n *\n * In case the shopper authenticated successfully, it returns config to be used in the Fastlane component\n * Otherwise, it returns the configuration to be used in the Card component\n *\n * @param authResult\n */\n public async getComponentConfiguration(authResult: FastlaneAuthenticatedCustomerResult): Promise<FastlanePaymentMethodConfiguration> {\n if (!authResult) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'FastlaneSDK: you must pass the authentication result to get the component configuration'\n );\n }\n\n if (authResult.authenticationState === 'succeeded') {\n const hasCard = !!authResult.profileData?.card;\n\n if (!hasCard) {\n throw new AdyenCheckoutError('ERROR', 'getComponentConfiguration(): There is no card associated with the authenticated profile');\n }\n\n return {\n paymentType: 'fastlane',\n configuration: {\n fastlaneSessionId: this.fastlaneSessionId,\n email: this.latestShopperDetails.email,\n tokenId: authResult.profileData.card.id,\n lastFour: authResult.profileData.card.paymentSource.card.lastDigits,\n brand: authResult.profileData.card.paymentSource.card.brand.toLowerCase()\n }\n };\n } else {\n const consentDetails = await this.fetchConsentDetails();\n return {\n paymentType: 'card',\n configuration: {\n ...(consentDetails && {\n fastlaneConfiguration: {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n }\n })\n }\n };\n }\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n return this.fastlaneSdk.profile.showShippingAddressSelector();\n }\n\n /**\n * Render the \"Fastlane by PayPal\" logo in the specified HTML container\n */\n public async mountWatermark(container: HTMLElement | string, options = { includeAdditionalInfo: true }): Promise<void> {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n }\n\n private requestClientToken(): Promise<FastlaneTokenData> {\n return requestFastlaneToken(this.checkoutShopperURL, this.clientKey);\n }\n\n private async fetchSdk(clientToken: string, clientId: string): Promise<void> {\n const url = `https://www.paypal.com/sdk/js?client-id=${clientId}&components=buttons,fastlane`;\n const script = new Script(url, 'body', {}, { sdkClientToken: clientToken });\n\n await script.load();\n }\n\n /**\n * Fetch the fastlane session ID used internally by PayPal for Network Token Usage event\n * This ID is not critical for the payment processing part\n *\n * @private\n */\n private async fetchSessionIdAsync(): Promise<void> {\n try {\n const { sessionId } = await this.fastlaneSdk.identity.getSession();\n this.fastlaneSessionId = sessionId;\n } catch (error) {\n console.warn('Fastlane SDK: Failed to fetch session ID', error);\n }\n }\n\n /**\n * Fetch object containing that details that will be used to display the sign-up UI\n * inside the card component\n * @private\n */\n private async fetchConsentDetails(): Promise<FastlaneConsentRenderState> {\n try {\n const consentComponent = await this.fastlaneSdk.ConsentComponent();\n return await consentComponent.getRenderState();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'fetchConsentDetails(): failed to fetch consent details', { cause: error });\n }\n }\n\n private async initializeFastlaneInstance(): Promise<void> {\n try {\n this.fastlaneSdk = await window.paypal.Fastlane({\n intendedExperience: 'externalProcessorCustomConsent',\n ...(this.forceConsentDetails && {\n metadata: {\n geoLocOverride: 'US'\n }\n })\n });\n this.fastlaneSdk.setLocale(this.locale);\n\n void this.fetchSessionIdAsync();\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor', {\n cause: error\n });\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","tokenData","this","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","authenticate","email","fastlaneSdk","AdyenCheckoutError","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","triggerAuthenticationFlow","authenticationState","profileData","undefined","getComponentConfiguration","authResult","card","paymentType","configuration","fastlaneSessionId","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fetchConsentDetails","fastlaneConfiguration","showShippingAddressSelector","profile","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","script","Script","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","error","console","warn","consentComponent","ConsentComponent","getRenderState","cause","window","paypal","Fastlane","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","locale","constructor","_define_property","environment","includes","apiUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale"],"mappings":"maAeA,MAAMA,EA4BF,gBAAaC,GACT,MAAMC,QAAkBC,KAAKC,qBAG7B,aAFMD,KAAKE,SAASH,EAAUI,MAAOJ,EAAUK,gBACzCJ,KAAKK,6BACJL,IACX,CAQA,kBAAaM,CAAaC,GACtB,IAAKP,KAAKQ,YACN,MAAM,IAAIC,EAAmB,uBAAwB,mDAGzD,MAAMC,kBAAEA,SAA4BV,KAAKQ,YAAYG,SAASC,sBAAsBL,GAEpF,OAAIG,GACAV,KAAKa,qBAAuB,CAAEN,QAAOO,WAAYJ,GAC1CV,KAAKQ,YAAYG,SAASI,0BAA0BL,IAEpD,CACHM,oBAAqB,YACrBC,iBAAaC,EAGzB,CAU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7C,EAAmB,QAAS,yDAA0D,CAAEmD,MAAON,GAC7G,CACJ,CAEA,gCAAcjD,GACV,IACIL,KAAKQ,kBAAoBqD,OAAOC,OAAOC,SAAS,CAC5CC,mBAAoB,oCAChBhE,KAAKiE,qBAAuB,CAC5BC,SAAU,CACNC,eAAgB,SAI5BnE,KAAKQ,YAAY4D,UAAUpE,KAAKqE,QAE3BrE,KAAKmD,qBACd,CAAE,MAAOG,GACL,MAAM,IAAI7C,EAAmB,QAAS,2FAA4F,CAC9HmD,MAAON,GAEf,CACJ,CA3KA,WAAAgB,CAAY/C,GACR,GAVJgD,EAAAvE,KAAiB6C,iBAAjB,GACA0B,EAAAvE,KAAiB4C,0BAAjB,GACA2B,EAAAvE,KAAiBqE,cAAjB,GACAE,EAAAvE,KAAiBiE,2BAAjB,GAEAM,EAAAvE,KAAQQ,mBAAR,GACA+D,EAAAvE,KAAQa,4BAAR,GACA0D,EAAAvE,KAAQwB,yBAAR,IAGSD,GAAeiD,YAAa,MAAM,IAAI/D,EAAmB,uBAAwB,mDACtF,IAAKc,GAAesB,UAAW,MAAM,IAAIpC,EAAmB,uBAAwB,iDAEhFc,EAAc0C,qBAAuB1C,EAAciD,YAAYC,SAAS,SACxElB,QAAQC,KAAK,gFAEjB,MAAMkB,OAAEA,GAAWC,EAAoBpD,EAAciD,aAErDxE,KAAK4C,mBAAqB8B,EAC1B1E,KAAK6C,UAAYtB,EAAcsB,UAC/B7C,KAAKiE,oBAAsB1C,EAAc0C,sBAAuB,EAChEjE,KAAKqE,OAASO,EAAmCrD,EAAc8C,QAAU,QAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_FULL, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.CHALLENGE_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n code: errorCode,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subType: Analytics3DS2Events.CHALLENGE_COMPLETED,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","code","errorType","ANALYTICS_ERROR_TYPE","apiError","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","network","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"unCAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,GAAWT,KAAKC,MAAMC,cAI9B,IAHuBQ,EAAeD,EAAQN,GAGzB,CAEjBH,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAoBC,4BAA4Bd,KAAKI,MAAMW,KAAKC,IAAI,oBAEtF,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,KAAMN,EAAoBC,wBAC1BM,UAAWC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,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAtVA,WAAAiF,CAAY7F,GAGR,GAFA8F,MAAM9F,GAoBV+F,EAAAnG,KAAO0F,eAAgBU,IACnB,MAAMnF,EAAQ,IAAIyC,EAAkB,CAChCC,KAAMC,EACNrC,QAAS6E,EACTtC,QAASC,EAAoBsC,sBAGjCrG,KAAKI,MAAMqB,kBAAkBR,KAzBzBjB,KAAKI,MAAMkG,MAAO,CAClB,MAAMpG,EAA6CqG,EAAqB,CACpED,MAAOtG,KAAKI,MAAMkG,MAClBE,KAAMxG,KAAKI,MAAMqG,qBAAuBzG,KAAKI,MAAMoG,OAGvDxG,KAAKC,MAAQ,CACTiC,OAAQ,OACRhC,cAAeA,QAInBF,KAAKC,MAAQ,CAAEC,cAAe,CAAEwG,SAAS,EAAOtE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA4D,EADEvG,EACY+G,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTtB,UAAU"}
1
+ {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_FULL, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.CHALLENGE_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n code: errorCode,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subType: Analytics3DS2Events.CHALLENGE_COMPLETED,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","code","errorType","ANALYTICS_ERROR_TYPE","apiError","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","network","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"unCAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,GAAWT,KAAKC,MAAMC,cAI9B,IAHuBQ,EAAeD,EAAQN,GAGzB,CAEjBH,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAoBC,4BAA4Bd,KAAKI,MAAMW,KAAKC,IAAI,oBAEtF,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,KAAMN,EAAoBC,wBAC1BM,UAAWC,EAAqBC,SAChCC,QAAS,GAAGC,wDAKhB,OAHAxB,KAAKI,MAAMqB,kBAAkBR,QAE7BS,QAAQC,MAAM,sDAElB,CAEA,MAAMC,WAAEA,EAAUC,eAAEA,EAAcC,qBAAEA,GAA0B9B,KAAKC,MAAMC,cAAgC6B,SAGzG,IAAKH,IAAeC,IAAmBC,EAAsB,CAEzD9B,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAoBmB,iCAAiChC,KAAKI,MAAMW,KAAKC,IAAI,oBAG3F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,KAAMN,E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MqG,qBAAuBzG,KAAKI,MAAMoG,OAGvDxG,KAAKC,MAAQ,CACTiC,OAAQ,OACRhC,cAAeA,EAEvB,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAEwG,SAAS,EAAOtE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA4D,EADEvG,EACY+G,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTtB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CA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W1B,IAE9B,CAEA2B,MAAAA,EAAOC,YAAEA,IAAerC,OAAEA,EAAM3B,gBAAEA,IAC9B,MAAe,0BAAX2B,EAEIsC,EAACC,EAAAA,CACGC,sBAAuBC,IACnBtE,KAAKc,kBAAkBwD,EAAYd,SAEvCe,mBAAoBD,IAIhB,MAAME,EAAiC,CACnCxD,UAAWsD,EAAYtD,UACvBG,QAAS,GAAGsD,MAAyBH,EAAYtD,aAGrDhB,KAAKc,kBAAkBwD,EAAYd,OAAQgB,IAE/CN,YAAaA,KACThE,EACJwE,gBAAiB1E,KAAKI,MAAMsE,gBAC5BC,aAAc3E,KAAK2E,eAKxB,IACX,CAxOA,WAAAC,CAAYxE,GACRyE,MAAMzE,GAmBV0E,EAAA9E,KAAO2E,eAAgBI,IACnB,MAAMnC,EAAQ,IAAIa,EAAkB,CAChCC,KAAMC,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,wBAGjChF,KAAKI,MAAMmD,kBAAkBX,KAxB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBlF,KAAKI,MAExC,GAAI6E,EAAO,CACP,MAAM/E,EAAiDiF,EAAuB,CAAEF,QAAOC,oBAEvFlF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEkF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADElF,EACY8D,OAAO,UAErBoB,EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
1
+ {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBU,6BAC/BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORtB,KAAK4B,SAAS,CAAEC,OAAQ,yBAE5B,KAAO,CAGH,MAAMC,EAAmB9B,KAAMC,MAAMC,gBAAgC6B,MAE/Df,EACFc,EAASE,QAAQC,IAA+B,EAC1ChB,EAAoBiB,wBACpBjB,EAAoBkB,+BAE9BnC,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,YACAG,QAAS,GAAGC,MAA+BU,MAInDT,QAAQC,MAAM,oGAClB,CACJ,CAEAR,iBAAAA,CAAkBsB,EAAyBC,EAAmC,MAC1ErC,KAAK4B,SAAS,CAAEC,OAAQ,YAAc,KAKlC,MACMS,GADsBtC,KAAKI,MAAMmC,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MAAMnC,EAAQ,IAAIa,EAAkB,CAChCC,KAAMC,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,wBAGjChF,KAAKI,MAAMmD,kBAAkBX,KAxB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBlF,KAAKI,MAExC,GAAI6E,EAAO,CACP,MAAM/E,EAAiDiF,EAAuB,CAAEF,QAAOC,oBAEvFlF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,EAEzB,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEkF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADElF,EACY8D,OAAO,UAErBoB,EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import n from"../internal/Await/Await.js";import i from"../internal/QRLoader/QRLoader.js";import s from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import a from"../../utils/isMobile.js";function d(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class l extends e{formatProps(t){if(!a())return{...super.formatProps(t),defaultMode:t?.defaultMode??"qrCode",apps:[]};const e=t.apps?.length>0,o=e?"intent":"vpa",r=[o,"qrCode"],n={id:"vpa",name:t.i18n.get("upi.collect.dropdown.label"),type:p.upi_collect},i=e?[...t.apps.map(t=>({...t,type:p.upi_intent})),n]:[];return{...super.formatProps(t),defaultMode:r.includes(t?.defaultMode)?t.defaultMode:o,apps:i}}get isValid(){return this.state.isValid}formatData(){const{virtualPaymentAddress:t,app:e}=this.state.data||{};return{paymentMethod:{...this.paymentType&&{type:this.paymentType},...this.paymentType===p.upi_collect&&t&&{virtualPaymentAddress:t},...this.paymentType===p.upi_intent&&e?.id&&{appId:e.id}}}}get paymentType(){return"qrCode"===this.selectedMode?p.upi_qr:"vpa"===this.selectedMode?p.upi_collect:this.state.data?.app?.type}renderContent(e,r,s){switch(e){case"qrCode":return t(i,{ref:t=>{this.componentRef=t},...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:p.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:5,onActionHandled:this.onActionHandled});case"await":return t(n,{ref:t=>{this.componentRef=t},url:r,type:s,showCountdownTimer:!0,shouldRedirectAutomatically:!0,countdownTime:5,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon});default:return t(o,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,onUpdateMode:this.onUpdateMode,apps:this.props.apps,defaultMode:this.props.defaultMode,showPayButton:this.props.showPayButton})}}render(){const{type:e,url:o,paymentMethodType:n}=this.props;return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{srPanel:this.props.modules.srPanel},this.renderContent(e,o,n)))}constructor(t,e){super(t,e),d(this,"selectedMode",void 0),d(this,"onUpdateMode",t=>{this.selectedMode=t}),this.selectedMode=this.props.defaultMode}}d(l,"type",p.upi),d(l,"txVariants",[p.upi,p.upi_qr,p.upi_collect,p.upi_intent]);export{l as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as n}from"../../core/Context/CoreProvider.js";import r from"../internal/Await/Await.js";import s from"../internal/QRLoader/QRLoader.js";import i from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import a from"../../utils/isMobile.js";import{getQrOption as d,getVpaOption as l,getIntentOption as u}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class h extends e{formatProps(t){if(!a())return{...super.formatProps(t),defaultMode:["qrCode","vpa"].includes(t?.defaultMode)?t.defaultMode:"qrCode",apps:[],segmentedControlOptions:[d(t.i18n),l(t.i18n)]};const{i18n:e,apps:o=[]}=t;if(o.length>0){const n=["intent","vpa"].includes(t.defaultMode)?t.defaultMode:"intent";return{...super.formatProps(t),defaultMode:n,apps:o,segmentedControlOptions:[u(e),l(e)]}}return{...super.formatProps(t),defaultMode:"vpa",apps:[],segmentedControlOptions:[]}}get isValid(){return this.state.isValid}formatData(){const{virtualPaymentAddress:t,app:e}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===p.upi_collect&&t&&{virtualPaymentAddress:t},...this.paymentType===p.upi_intent&&e?.id&&{appId:e.id}}}}get paymentType(){return"qrCode"===this.selectedMode?p.upi_qr:"vpa"===this.selectedMode?p.upi_collect:p.upi_intent}renderContent(e,n,i){switch(e){case"qrCode":return t(s,{ref:t=>{this.componentRef=t},...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:p.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:5,onActionHandled:this.onActionHandled});case"await":return t(r,{ref:t=>{this.componentRef=t},url:n,type:i,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!0,countdownTime:5,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon,amount:this.props.amount});default:return t(o,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,onUpdateMode:this.onUpdateMode,apps:this.props.apps,segmentedControlOptions:this.props.segmentedControlOptions,defaultMode:this.props.defaultMode,showPayButton:this.props.showPayButton})}}render(){const{type:e,url:o,paymentMethodType:r}=this.props;return t(n,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},this.renderContent(e,o,r)))}constructor(t,e){super(t,e),m(this,"selectedMode",void 0),m(this,"onUpdateMode",t=>{this.selectedMode=t}),this.selectedMode=this.props.defaultMode}}m(h,"type",p.upi),m(h,"txVariants",[p.upi,p.upi_qr,p.upi_collect,p.upi_intent]);export{h as default};
2
2
  //# sourceMappingURL=UPI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"2lBAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CA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xDpBjD,KAAKQ,aAAeR,KAAKtB,MAAMG,WACnC,EARAmE,EADEzE,EACYiB,OAAOC,EAAWyD,KAChCF,EAFEzE,EAEY4E,aAAa,CAAC1D,EAAWyD,IAAKzD,EAAWgB,OAAQhB,EAAWC,YAAaD,EAAWI"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\nimport { getIntentOption, getQrOption, getVpaOption } from './constants';\n\n/**\n * For mobile:\n * We should show upi_collect and upi_intent depending on if `apps` are returned in /paymentMethods response.\n * If there is no apps, hide segmented controls.\n * The upi_collect should always be on the second tab.\n * Never show QR code.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration): UPIConfiguration {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: ['qrCode', 'vpa'].includes(props?.defaultMode) ? props.defaultMode : 'qrCode',\n apps: [], // For desktop, ignore the apps\n segmentedControlOptions: [getQrOption(props.i18n), getVpaOption(props.i18n)]\n };\n }\n\n const { i18n, apps = [] } = props;\n const hasIntentApps = apps.length > 0;\n if (hasIntentApps) {\n // Mobile with UPI apps\n const allowedModes: UpiMode[] = ['intent', 'vpa'];\n const defaultMode = allowedModes.includes(props.defaultMode) ? props.defaultMode : 'intent';\n return {\n ...super.formatProps(props),\n defaultMode,\n apps,\n segmentedControlOptions: [getIntentOption(i18n), getVpaOption(i18n)]\n };\n }\n\n // Mobile, but no UPI apps\n return {\n ...super.formatProps(props),\n defaultMode: 'vpa', // Only VPA is possible\n apps: [],\n segmentedControlOptions: []\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return TxVariants.upi_intent;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n amount={this.props.amount}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n segmentedControlOptions={this.props.segmentedControlOptions}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","includes","apps","segmentedControlOptions","getQrOption","i18n","getVpaOption","length","getIntentOption","isValid","this","state","formatData","virtualPaymentAddress","app","data","paymentMethod","type","paymentType","TxVariants","upi_collect","upi_intent","id","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","get","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","showAmount","clientKey","paymentData","onError","messageText","awaitText","amount","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"+qBAyBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAa,CAAC,SAAU,OAAOC,SAASJ,GAAOG,aAAeH,EAAMG,YAAc,SAClFE,KAAM,GACNC,w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