@adyen/adyen-web 6.19.0 → 6.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/adyen.css +10 -11
  3. package/dist/cjs/adyen.css.map +1 -1
  4. package/dist/cjs/index.cjs +2 -2
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.cts +43 -65
  7. package/dist/es/adyen.css +10 -11
  8. package/dist/es/adyen.css.map +1 -1
  9. package/dist/es/components/Ach/Ach.js +1 -1
  10. package/dist/es/components/Ach/Ach.js.map +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  12. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  13. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  14. package/dist/es/components/Card/Card.js +1 -1
  15. package/dist/es/components/Card/Card.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  19. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  20. package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
  21. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  22. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  23. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  24. package/dist/es/components/Dropin/Dropin.js +1 -1
  25. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  26. package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  27. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  28. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  29. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  30. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  31. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  32. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  33. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  34. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  35. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  36. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  37. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  38. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  39. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  40. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  41. package/dist/es/components/UPI/UPI.js +1 -1
  42. package/dist/es/components/UPI/UPI.js.map +1 -1
  43. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  44. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  45. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  46. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  47. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  48. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  49. package/dist/es/components/UPI/constants.js +2 -0
  50. package/dist/es/components/UPI/constants.js.map +1 -0
  51. package/dist/es/components/internal/Address/Address.js.map +1 -1
  52. package/dist/es/components/internal/Alert/Alert.js +1 -1
  53. package/dist/es/components/internal/Alert/Alert.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  56. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  57. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  58. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  59. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  60. package/dist/es/components/internal/PayButton/PayButton.js +1 -1
  61. package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
  62. package/dist/es/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  65. package/dist/es/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  69. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  70. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  71. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  72. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  73. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  74. package/dist/es/core/Analytics/utils.js.map +1 -1
  75. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  76. package/dist/es/core/Errors/utils.js.map +1 -1
  77. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  78. package/dist/es/core/core.js +1 -1
  79. package/dist/es/core/core.registry.js.map +1 -1
  80. package/dist/es/core/utils.js.map +1 -1
  81. package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
  82. package/dist/es/external/preact/dist/preact.js.map +1 -1
  83. package/dist/es/index.d.ts +43 -65
  84. package/dist/es/language/utils.js.map +1 -1
  85. package/dist/es/utils/clipboard.js.map +1 -1
  86. package/dist/es/utils/setFocus.js.map +1 -1
  87. package/dist/es/utils/useForm/reducer.js.map +1 -1
  88. package/dist/es-legacy/adyen.css +10 -11
  89. package/dist/es-legacy/adyen.css.map +1 -1
  90. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  91. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  92. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  93. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  94. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  95. package/dist/es-legacy/components/Card/Card.js +1 -1
  96. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  97. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  98. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  99. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  100. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  101. package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
  102. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  103. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  104. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  105. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  106. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  107. package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
  108. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  109. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  110. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  111. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  112. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +1 -1
  113. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -1
  114. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  115. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  116. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
  117. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
  118. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  119. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  120. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  121. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  122. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  123. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  124. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  125. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  126. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  127. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  128. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  129. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  130. package/dist/es-legacy/components/UPI/constants.js +2 -0
  131. package/dist/es-legacy/components/UPI/constants.js.map +1 -0
  132. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  133. package/dist/es-legacy/components/internal/Alert/Alert.js +1 -1
  134. package/dist/es-legacy/components/internal/Alert/Alert.js.map +1 -1
  135. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  136. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  137. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  138. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  139. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  140. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  141. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  142. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  143. package/dist/es-legacy/components/internal/PayButton/components/SecondaryButtonLabel.js.map +1 -1
  144. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  145. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js +1 -1
  146. package/dist/es-legacy/components/internal/SecuredFields/binLookup/createCardVariantSwitcher.js.map +1 -1
  147. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  148. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  149. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  150. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  151. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  152. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  153. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  154. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  155. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  156. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  157. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  158. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  159. package/dist/es-legacy/core/core.js +1 -1
  160. package/dist/es-legacy/core/core.registry.js.map +1 -1
  161. package/dist/es-legacy/core/utils.js.map +1 -1
  162. package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
  163. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  164. package/dist/es-legacy/language/utils.js.map +1 -1
  165. package/dist/es-legacy/utils/clipboard.js.map +1 -1
  166. package/dist/es-legacy/utils/setFocus.js.map +1 -1
  167. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  168. package/package.json +159 -159
  169. package/styles/adyen.css +10 -11
  170. package/dist/es/components/UPI/components/UPIComponent/constants.js +0 -2
  171. package/dist/es/components/UPI/components/UPIComponent/constants.js.map +0 -1
  172. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  173. package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
  174. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js +0 -2
  175. package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js.map +0 -1
  176. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
  177. package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PayByBankPix.js","sources":["../../../../src/components/PayByBankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n issuer={this.props?.payByBankPixDetails?.ispb}\n receiver={this.props?.payByBankPixDetails?.receiver}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","_this_state","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","_this_props_payByBankPixDetails","_this_props","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","_object_spread_props","_object_spread","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","_this_props_payByBankPixDetails1","_this_props1","_this_props_paymentMethodData","_this_props_paymentMethodData1","_this_props_paymentMethodData2","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","issuer","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","_ref","captureRiskSignalsEnrollment","deviceId","riskSignals","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEOUT_MINUTES","defaultProps","URL","window","location","href","hostname","endsWith","e","isAdyenHosted"],"mappings":"63DAyBA,MAAMA,UAA4BC,EAoB9B,WAAIC,GAKS,IAAAC,EAHT,QAAKC,KAAKC,MAAMC,iBAAkBF,KAAKC,MAAME,2BAG1B,QAAVJ,EAAAC,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B7D,EACAC,EAHlB,MAAMsD,QAAsBjH,KAAKsB,eAAekG,2BAA2BD,GACrEE,EAAU,CACZjD,aAA0C,QAA5Bd,EAAA1D,KAAKC,MAAMwE,yBAAX,IAAAf,OAAA,EAAAA,EAA8Bc,aAC5CE,aAA0C,QAA5Bf,EAAA3D,KAAKC,MAAMwE,yBAAX,IAAAd,OAAA,EAAAA,EAA8Be,aAC5CuC,kBAEEG,eAAEA,SAAyBrC,EAAiB,CAC9C0C,UACApD,UAAWrE,KAAKC,MAAMoE,UACtBN,eAAgB/D,KAAKC,MAAM8D,iBAE/B/D,KAAK2C,wBAAwB,CAAEU,KAAM,CAAEgE,QAAS,CAAED,oBACtD,CAAE,MAAOrF,GACL,MAAMgF,EAAWhF,aAAiBC,MAAQD,EAAME,QAAU,wCAC1DjC,KAAKkF,YAAYnD,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAOoF,GACjG,IA1KA,MAAMH,EAAW5G,KAAKC,MAAME,sBAAkC,QAAVI,EAAAP,KAAKC,iBAALM,GAA+B,QAA/BD,EAAAC,EAAYK,2BAAZ,IAAAN,SAAAA,EAAiCsG,SAAW5G,KAAKC,MAAM2G,SAC3G5G,KAAKsB,eAAiB,IAAIoG,EAAe,CAAEC,YAAa3H,KAAKC,MAAM0H,YAAaf,aAC5E5G,KAAKC,MAAMC,gBACNF,KAAKsB,eAAeO,YAEjC,EAjBA0E,EADE3G,EACqBqB,OAAOiC,EAAWC,eACzCoD,EAFE3G,EAEsBgI,kBAAkB,GAG1CrB,EALE3G,EAKqBiI,eAA0C,CAC7DhC,eAAe,EACf3F,eAhBc,MAClB,IAEI,OADmB,IAAI4H,IAAIC,OAAOC,SAASC,MACzBC,SAASC,SAAS,aACxC,CAAE,MAAOC,GAEL,OAAO,CACX,GASoBC,GAChBlD,cAAevF,EAAoBgI"}
1
+ {"version":3,"file":"PayByBankPix.js","sources":["../../../../src/components/PayByBankPix/PayByBankPix.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { PayByBankPixData, PayByBankPixConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\nimport UIElement from '../internal/UIElement';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport AdyenCheckoutError, { ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { PasskeyService } from './services/PasskeyService';\nimport { authorizeEnrollment } from './services/authorizeEnrollment';\nimport { authorizePayment } from './services/authorizePayment';\nimport StoredPayment from './components/StoredPayment';\nimport Enrollment from './components/Enrollment';\nimport { PaymentAction } from '../../types/global-types';\nimport type { ICore } from '../../core/types';\n\nconst isAdyenHosted = () => {\n try {\n const currentUrl = new URL(window.location.href);\n return currentUrl.hostname.endsWith('.adyen.com');\n } catch (e) {\n // SSR, or it fails to parse the full url\n return false;\n }\n};\nclass PayByBankPixElement extends UIElement<PayByBankPixConfiguration> {\n public static readonly type = TxVariants.paybybank_pix;\n private static readonly TIMEOUT_MINUTES = 1;\n private readonly passkeyService: PasskeyService;\n\n public static readonly defaultProps: PayByBankPixConfiguration = {\n showPayButton: true,\n _isAdyenHosted: isAdyenHosted(),\n countdownTime: PayByBankPixElement.TIMEOUT_MINUTES\n };\n\n constructor(checkout: ICore, props?: PayByBankPixConfiguration) {\n super(checkout, props);\n const deviceId = this.props.storedPaymentMethodId ? this.props?.payByBankPixDetails?.deviceId : this.props.deviceId;\n this.passkeyService = new PasskeyService({ environment: this.props.environment, deviceId });\n if (this.props._isAdyenHosted) {\n void this.passkeyService.initialize();\n }\n }\n\n get isValid(): boolean {\n // Always true for non-hosted page or stored payment\n if (!this.props._isAdyenHosted || this.props.storedPaymentMethodId) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Display in the drop-in\n */\n get additionalInfo() {\n return this.props.storedPaymentMethodId\n ? this.props.i18n.get('paybybankpix.storedPayment.additionalLabel', { values: { receiver: this.props?.payByBankPixDetails?.receiver } })\n : '';\n }\n\n /**\n * Display in the drop-in\n */\n public override get icon() {\n return this.props.storedPaymentMethodId\n ? this.resources.getImage({ parentFolder: `${PayByBankPixElement.type}/` })(this.props?.payByBankPixDetails?.ispb)\n : super.icon;\n }\n\n /**\n * Method used to let the merchant know if the shopper's device supports WebAuthn APIs: https://featuredetect.passkeys.dev/\n */\n public override async isAvailable(): Promise<void> {\n const unsupportedReason = await this.passkeyService.getWebAuthnUnsupportedReason();\n if (unsupportedReason) {\n return Promise.reject(new AdyenCheckoutError(ERROR, unsupportedReason));\n }\n if (!this.props._isAdyenHosted) {\n return Promise.resolve();\n }\n\n // Load passkey sdk on the hosted page\n try {\n await this.passkeyService.initialize();\n\n if (this.props.storedPaymentMethodId) {\n // If the provided deviceId from the server does not match the localstorage deviceId, do not render the stored payment component.\n const shouldShowStoredPaymentMethod = await this.passkeyService.canUseStoredCredential();\n return shouldShowStoredPaymentMethod\n ? Promise.resolve()\n : Promise.reject(new AdyenCheckoutError('ERROR', 'The stored payment method is not available on this device'));\n }\n\n return Promise.resolve();\n } catch (error) {\n return Promise.reject(error instanceof Error ? error?.message : 'Unknown error');\n }\n }\n\n /**\n * Make sure the await action UIElement is available before mounting\n */\n public override handleAction(action: PaymentAction, props: {} = {}): UIElement | null {\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props,\n onAdditionalDetails: this.handleAdditionalDetails\n });\n if (paymentAction) {\n this.unmount();\n void paymentAction.isAvailable().then(() => {\n paymentAction.mount(this._node);\n });\n return paymentAction;\n }\n\n return null;\n }\n\n formatData(): PayByBankPixData {\n if (!this.props._isAdyenHosted) {\n return {\n paymentMethod: { type: TxVariants.paybybank_pix }\n };\n }\n\n const isEnrollment = this.props.storedPaymentMethodId == null;\n return {\n paymentMethod: { type: TxVariants.paybybank_pix, ...this.state.data },\n // Always store the payment method for the enrollment flow.\n ...(isEnrollment ? { storePaymentMethod: true } : {})\n };\n }\n\n /**\n * There are 3 endpoints (stages) we need to call for the enrollment flow.\n * The first one is the regular payments call on issuer selection - we indicate to store the payment token for the selected issuer.\n * The second one is to poll the enrollment eligibility - we poll the server to get the enrollment challenge in the `getEnrollmentStatus` function.\n * The third one is in the `authorizeEnrollment` function - we create passkeys and authorize the enrollment with shopper's passkey.\n */\n private readonly onIssuerSelected = async payload => {\n try {\n const { data = {} } = payload;\n if (!data.issuer) {\n return;\n }\n\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsEnrollment();\n this.setState({ ...payload, data: { ...data, riskSignals, deviceId } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the onIssuerSelected';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizeEnrollment = async (registrationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.createCredentialForEnrollment(registrationOptions); // Create passkey and trigger biometrics\n const enrollment = { enrollmentId: this.props.paymentMethodData?.enrollmentId, fidoAssertion };\n const { redirectResult } = await authorizeEnrollment({\n enrollment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n // Make paymentDetails call to finalize the enrollment.\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizeEnrollment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n /**\n * There are 3 endpoints (stages) we need to call for the payment flow.\n * The first one `payWithStoredPayment` is the regular payments call - we attempt to pay with the stored payment token.\n * The second one is to poll the authorization options - we poll the server to get the challenge in the `getAuthorizationStatus` function.\n * The third one is in the `authorizePayment` function - we authorize the payment with shopper's passkey.\n */\n private readonly payWithStoredPayment = async () => {\n try {\n const { deviceId, ...riskSignals } = await this.passkeyService.captureRiskSignalsAuthentication();\n this.state = { ...this.state, ...{ data: { storedPaymentMethodId: this.props.storedPaymentMethodId, riskSignals, deviceId } } };\n super.submit();\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the payWithStoredPayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n private readonly authorizePayment = async (authenticationOptions: string): Promise<void> => {\n try {\n const fidoAssertion = await this.passkeyService.authenticateWithCredential(authenticationOptions);\n const payment = {\n enrollmentId: this.props.paymentMethodData?.enrollmentId,\n initiationId: this.props.paymentMethodData?.initiationId,\n fidoAssertion\n };\n const { redirectResult } = await authorizePayment({\n payment,\n clientKey: this.props.clientKey,\n loadingContext: this.props.loadingContext\n });\n this.handleAdditionalDetails({ data: { details: { redirectResult } } });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : 'Unknown error in the authorizePayment';\n this.handleError(error instanceof AdyenCheckoutError ? error : new AdyenCheckoutError(ERROR, errorMsg));\n }\n };\n\n render() {\n // Always render the redirect button on the merchant's page\n if (!this.props._isAdyenHosted) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n label={this.props.i18n.get('paybybankpix.redirectBtn.label')}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n {this.props.storedPaymentMethodId != null ? (\n <StoredPayment\n txVariant={PayByBankPixElement.type}\n type={this.props.type}\n clientKey={this.props.clientKey}\n amount={this.props.amount}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n initiationId={this.props.paymentMethodData?.initiationId}\n setComponentRef={this.setComponentRef}\n onPay={this.payWithStoredPayment}\n onAuthorize={this.authorizePayment}\n />\n ) : (\n <Enrollment\n onError={this.handleError}\n txVariant={PayByBankPixElement.type}\n // Await\n type={this.props.type}\n clientKey={this.props.clientKey}\n enrollmentId={this.props.paymentMethodData?.enrollmentId}\n countdownTime={this.props.countdownTime}\n onEnroll={this.authorizeEnrollment}\n // Issuer List\n issuers={this.props.issuers}\n payButton={this.payButton}\n onChange={this.onIssuerSelected}\n onSubmitAnalytics={this.submitAnalytics}\n setComponentRef={this.setComponentRef}\n />\n )}\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n//\nexport default PayByBankPixElement;\n"],"names":["PayByBankPixElement","UIElement","isValid","_this_state","this","props","_isAdyenHosted","storedPaymentMethodId","state","additionalInfo","_this_props_payByBankPixDetails","_this_props","i18n","get","values","receiver","payByBankPixDetails","icon","resources","getImage","parentFolder","type","ispb","super","isAvailable","unsupportedReason","passkeyService","getWebAuthnUnsupportedReason","Promise","reject","AdyenCheckoutError","ERROR","resolve","initialize","canUseStoredCredential","error","Error","message","handleAction","action","paymentAction","core","createFromAction","_object_spread_props","_object_spread","elementRef","onAdditionalDetails","handleAdditionalDetails","unmount","then","mount","_node","formatData","paymentMethod","TxVariants","paybybank_pix","isEnrollment","data","storePaymentMethod","render","_this_props_paymentMethodData","_this_props_paymentMethodData1","_this_props_paymentMethodData2","h","CoreProvider","loadingContext","SRPanelProvider","srPanel","modules","StoredPayment","txVariant","clientKey","amount","enrollmentId","paymentMethodData","initiationId","setComponentRef","onPay","payWithStoredPayment","onAuthorize","authorizePayment","Enrollment","onError","handleError","countdownTime","onEnroll","authorizeEnrollment","issuers","payButton","onChange","onIssuerSelected","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","name","displayName","label","onSubmit","submit","ref","componentRef","constructor","checkout","_define_property","async","payload","issuer","_ref","captureRiskSignalsEnrollment","deviceId","riskSignals","setState","errorMsg","registrationOptions","fidoAssertion","createCredentialForEnrollment","enrollment","redirectResult","details","captureRiskSignalsAuthentication","authenticationOptions","authenticateWithCredential","payment","PasskeyService","environment","TIMEO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0C,QAA5Bb,EAAAxD,KAAKC,MAAMqE,yBAAX,IAAAd,OAAA,EAAAA,EAA8Ba,aAC5CE,aAA0C,QAA5Bd,EAAAzD,KAAKC,MAAMqE,yBAAX,IAAAb,OAAA,EAAAA,EAA8Bc,aAC5CwC,kBAEEG,eAAEA,SAAyBtC,EAAiB,CAC9C2C,UACApD,UAAWnE,KAAKC,MAAMkE,UACtBN,eAAgB7D,KAAKC,MAAM4D,iBAE/B7D,KAAK2C,wBAAwB,CAAEU,KAAM,CAAE8D,QAAS,CAAED,oBACtD,CAAE,MAAOnF,GACL,MAAM8E,EAAW9E,aAAiBC,MAAQD,EAAME,QAAU,wCAC1DjC,KAAK+E,YAAYhD,aAAiBL,EAAqBK,EAAQ,IAAIL,EAAmBC,EAAOkF,GACjG,IA1KA,MAAMH,EAAW1G,KAAKC,MAAME,sBAAkC,QAAVI,EAAAP,KAAKC,iBAALM,GAA+B,QAA/BD,EAAAC,EAAYK,2BAAZ,IAAAN,SAAAA,EAAiCoG,SAAW1G,KAAKC,MAAMyG,SAC3G1G,KAAKsB,eAAiB,IAAIkG,EAAe,CAAEC,YAAazH,KAAKC,MAAMwH,YAAaf,aAC5E1G,KAAKC,MAAMC,gBACNF,KAAKsB,eAAeO,YAEjC,EAjBAuE,EADExG,EACqBqB,OAAOiC,EAAWC,eACzCiD,EAFExG,EAEsB8H,kBAAkB,GAG1CtB,EALExG,EAKqB+H,eAA0C,CAC7DjC,eAAe,EACfxF,eAhBc,MAClB,IAEI,OADmB,IAAI0H,IAAIC,OAAOC,SAASC,MACzBC,SAASC,SAAS,aACxC,CAAE,MAAOC,GAEL,OAAO,CACX,GASoBC,GAChBnD,cAAepF,EAAoB8H"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as r}from"./useIssuerWithLogo.js";import s from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[x,f]=n(null),b=[{name:"open-finance",alt:y.get("paybybankpix.await.logoAlt.openFinance"),src:`${g({parentFolder:`${u.txVariant}/`})("open-finance")}`},{name:"arrow-down",alt:y.get("paybybankpix.await.logoAlt.arrowDown"),src:`${g({imageFolder:"components/"})("arrow_down")}`},{name:"bank",alt:y.get("paybybankpix.await.logoAlt.bank"),src:`${g({imageFolder:"components/"})("bank")}`}],k=e({showValidation:()=>{var t;null==w||null===(t=w.current)||void 0===t||t.showValidation()},setStatus:t=>{var e;null==w||null===(e=w.current)||void 0===e||e.setStatus(t)}});return a(()=>{u.setComponentRef(k.current)},[u.setComponentRef]),a(()=>{x&&u.onEnroll(x)},[x]),t("div",{className:"adyen-checkout-pix-enrollment"},(t=>"await"===t.type)(u)?t(m,{logos:b,type:u.txVariant,countdownTime:u.countdownTime,clientKey:u.clientKey,onError:u.onError,awaitText:y.get("paybybankpix.await.waitForConfirmation"),instructions:y.get("paybybankpix.await.timeToPay",{values:{numberOfMin:u.countdownTime}}),pollStatus:async()=>{if(x)return;const{enrollmentId:t,clientKey:e}=u,n=await s({enrollmentId:t,clientKey:e,loadingContext:d});return n.registrationOptions&&f(n.registrationOptions),n},endSlot:()=>t("span",null,y.get("paybybankpix.await.withOpenFinance"))}):t("div",{className:"adyen-checkout-pix-enrollment-issuer-list"},t(l,{txVariant:u.txVariant}),t(i,{items:r({issuers:u.issuers,txVariant:u.txVariant}),onSubmitAnalytics:u.onSubmitAnalytics,onChange:u.onChange,payButton:u.payButton,showPayButton:!0,ref:w}),t("span",{className:"adyen-checkout-disclaimer__label"},t(c,{message:y.get("paybybankpix.issuerList.disclaimer"),urls:[""]}))))}export{u as default};
1
+ import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useRef as e,useState as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import i from"../../../internal/IssuerList/IssuerList.js";import{useIssuerWithLogo as r}from"./useIssuerWithLogo.js";import s from"./getEnrollmentStatus.js";import l from"./components/IssuerListIntroduction.js";import m from"./components/PayByBankPixAwait.js";import p from"../../../../core/Context/useImage.js";import{LabelOnlyDisclaimerMessage as c}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";function u(u){const{i18n:y,loadingContext:d}=o(),g=p(),w=e(null),[b,x]=n(null),f=[{name:"open-finance",alt:y.get("paybybankpix.await.logoAlt.openFinance"),src:`${g({parentFolder:`${u.txVariant}/`})("open-finance")}`},{name:"arrow-down",alt:y.get("paybybankpix.await.logoAlt.arrowDown"),src:`${g({imageFolder:"components/"})("arrow_down")}`},{name:"bank",alt:y.get("paybybankpix.await.logoAlt.bank"),src:`${g({imageFolder:"components/"})("bank")}`}],k=e({showValidation:()=>{var t;null==w||null===(t=w.current)||void 0===t||t.showValidation()},setStatus:t=>{var e;null==w||null===(e=w.current)||void 0===e||e.setStatus(t)}});return a(()=>{u.setComponentRef(k.current)},[u.setComponentRef]),a(()=>{b&&u.onEnroll(b)},[b]),t("div",{className:"adyen-checkout-pix-enrollment"},(t=>"await"===t.type)(u)?t(m,{logos:f,type:u.txVariant,countdownTime:u.countdownTime,clientKey:u.clientKey,onError:u.onError,awaitText:y.get("paybybankpix.await.waitForConfirmation"),instructions:y.get("paybybankpix.await.timeToPay",{values:{numberOfMin:u.countdownTime}}),pollStatus:async()=>{if(b)return;const{enrollmentId:t,clientKey:e}=u,n=await s({enrollmentId:t,clientKey:e,loadingContext:d});return n.registrationOptions&&x(n.registrationOptions),n},endSlot:()=>t("span",null,y.get("paybybankpix.await.withOpenFinance"))}):t("div",{className:"adyen-checkout-pix-enrollment-issuer-list"},t(l,{txVariant:u.txVariant}),t(i,{items:r({issuers:u.issuers,txVariant:u.txVariant}),selectFieldLabel:y.get("paybybankpix.issuerList.selectField.label"),onSubmitAnalytics:u.onSubmitAnalytics,onChange:u.onChange,payButton:u.payButton,showPayButton:!0,ref:w}),t("span",{className:"adyen-checkout-disclaimer__label"},t(c,{message:y.get("paybybankpix.issuerList.disclaimer"),urls:["https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br"]}))))}export{u as default};
2
2
  //# sourceMappingURL=Enrollment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\n//todo: add\nconst TERMS_CONDITIONS_URL = '';\n\nfunction Enrollment(props: EnrollmentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const issuerListRef = useRef<ComponentMethodsRef>(null);\n const [registrationOptions, setRegistrationOptions] = useState<string>(null);\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${props.txVariant}/` })('open-finance')}`\n },\n {\n name: 'arrow-down',\n alt: i18n.get('paybybankpix.await.logoAlt.arrowDown'),\n src: `${getImage({ imageFolder: 'components/' })('arrow_down')}`\n },\n { name: 'bank', alt: i18n.get('paybybankpix.await.logoAlt.bank'), src: `${getImage({ imageFolder: 'components/' })('bank')}` }\n ];\n const self = useRef({\n showValidation: () => {\n issuerListRef?.current?.showValidation();\n },\n setStatus: (newStatus: UIElementStatus) => {\n issuerListRef?.current?.setStatus(newStatus);\n }\n });\n\n const pollStatus = async () => {\n if (registrationOptions) return;\n\n const { enrollmentId, clientKey } = props as AwaitProps;\n const response = await getEnrollmentStatus({ enrollmentId, clientKey, loadingContext });\n if (response.registrationOptions) {\n setRegistrationOptions(response.registrationOptions);\n }\n return response;\n };\n // Assist typescript to narrow down the type.\n const isAwait = (props: EnrollmentProps): props is AwaitProps => props.type === 'await';\n const awaitEndSlot = () => <span>{i18n.get('paybybankpix.await.withOpenFinance')}</span>;\n\n useEffect(() => {\n props.setComponentRef(self.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (registrationOptions) {\n props.onEnroll(registrationOptions);\n }\n }, [registrationOptions]);\n\n return (\n <div className={'adyen-checkout-pix-enrollment'}>\n {isAwait(props) ? (\n <PayByBankPixAwait\n logos={logos}\n type={props.txVariant}\n countdownTime={props.countdownTime}\n clientKey={props.clientKey}\n onError={props.onError}\n awaitText={i18n.get('paybybankpix.await.waitForConfirmation')}\n instructions={i18n.get('paybybankpix.await.timeToPay', {\n values: { numberOfMin: props.countdownTime }\n })}\n pollStatus={pollStatus}\n endSlot={awaitEndSlot}\n ></PayByBankPixAwait>\n ) : (\n <div className=\"adyen-checkout-pix-enrollment-issuer-list\">\n <IssuerListIntroduction txVariant={props.txVariant} />\n <IssuerList\n items={useIssuerWithLogo({ issuers: props.issuers, txVariant: props.txVariant })}\n onSubmitAnalytics={props.onSubmitAnalytics}\n onChange={props.onChange}\n payButton={props.payButton}\n showPayButton={true}\n ref={issuerListRef}\n ></IssuerList>\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={i18n.get('paybybankpix.issuerList.disclaimer')} urls={[TERMS_CONDITIONS_URL]} />\n </span>\n </div>\n )}\n </div>\n );\n}\n\nexport default Enrollment;\n"],"names":["Enrollment","props","i18n","loadingContext","useCoreContext","getImage","useImage","issuerListRef","useRef","registrationOptions","setRegistrationOptions","useState","logos","name","alt","get","src","parentFolder","txVariant","imageFolder","self","showValidation","current","setStatus","newStatus","useEffect","setComponentRef","onEnroll","h","div","className","type","isAwait","PayByBankPixAwait","countdownTime","clientKey","onError","awaitText","instructions","values","numberOfMin","pollStatus","async","enrollmentId","response","getEnrollmentStatus","endSlot","span","IssuerListIntroduction","IssuerList","items","useIssuerWithLogo","issuers","onSubmitAnalytics","onChange","payButton","showPayButton","ref","LabelOnlyDisclaimerMessage","message","urls"],"mappings":"ypBAiBA,SAASA,EAAWC,GAChB,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAgBC,EAA4B,OAC3CC,EAAqBC,GAA0BC,EAAiB,MACjEC,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGhB,EAAMiB,cAAlCb,CAAkD,mBAE9D,CACIQ,KAAM,aACNC,IAAKZ,EAAKa,IAAI,wCACdC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAErD,CAAEQ,KAAM,OAAQC,IAAKZ,EAAKa,IAAI,mCAAoCC,IAAK,GAAGX,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,YAEjHe,EAAOZ,EAAO,CAChBa,eAAgB,KACZd,IAAAA,EAAAA,SAAsB,QAAtBA,EAAAA,EAAee,eAAff,IAAAA,GAAAA,EAAwBc,kBAE5BE,UAAYC,IACRjB,IAAAA,EAAAA,iBAAAA,EAAAA,EAAee,eAAff,IAAAA,GAAAA,EAAwBgB,UAAUC,MA4B1C,OAVAC,EAAU,KACNxB,EAAMyB,gBAAgBN,EAAKE,UAC5B,CAACrB,EAAMyB,kBAEVD,EAAU,KACFhB,GACAR,EAAM0B,SAASlB,IAEpB,CAACA,IAGAmB,EAACC,MAAAA,CAAIC,UAAW,iCAdJ,CAAC7B,GAA+D,UAAfA,EAAM8B,KAe9DC,CAAQ/B,GACL2B,EAACK,EAAAA,CACGrB,MAAOA,EACPmB,KAAM9B,EAAMiB,UACZgB,cAAejC,EAAMiC,cACrBC,UAAWlC,EAAMkC,UACjBC,QAASnC,EAAMmC,QACfC,UAAWnC,EAAKa,IAAI,0CACpBuB,aAAcpC,EAAKa,IAAI,+BAAgC,CACnDwB,OAAQ,CAAEC,YAAavC,EAAMiC,iBAEjCO,WArCGC,UACf,GAAIjC,EAAqB,OAEzB,MAAMkC,aAAEA,EAAYR,UAAEA,GAAclC,EAC9B2C,QAAiBC,EAAoB,CAAEF,eAAcR,YAAWhC,mBAItE,OAHIyC,EAASnC,qBACTC,EAAuBkC,EAASnC,qBAE7BmC,GA8BKE,QA1BK,IAAMlB,EAACmB,OAAAA,KAAM7C,EAAKa,IAAI,yCA6B/Ba,EAACC,MAAAA,CAAIC,UAAU,6CACXF,EAACoB,EAAAA,CAAuB9B,UAAWjB,EAAMiB,YACzCU,EAACqB,EAAAA,CACGC,MAAOC,EAAkB,CAAEC,QAASnD,EAAMmD,QAASlC,UAAWjB,EAAMiB,YACpEmC,kBAAmBpD,EAAMoD,kBACzBC,SAAUrD,EAAMqD,SAChBC,UAAWtD,EAAMsD,UACjBC,eAAe,EACfC,IAAKlD,IAETqB,EAACmB,OAAAA,CAAKjB,UAAU,oCACZF,EAAC8B,EAAAA,CAA2BC,QAASzD,EAAKa,IAAI,sCAAuC6C,KAAM,CAjFtF,QAuF7B"}
1
+ {"version":3,"file":"Enrollment.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/Enrollment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport { AwaitProps, EnrollmentProps } from './types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport IssuerList from '../../../internal/IssuerList';\nimport { useIssuerWithLogo } from './useIssuerWithLogo';\nimport getEnrollmentStatus from './getEnrollmentStatus';\nimport IssuerListIntroduction from './components/IssuerListIntroduction';\nimport PayByBankPixAwait from './components/PayByBankPixAwait';\nimport useImage from '../../../../core/Context/useImage';\nimport './Enrollment.scss';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../internal/UIElement/types';\n\nconst TERMS_CONDITIONS_URL = 'https://www.adyen.com/pt_BR/legal/termo-de-consentimento-br';\n\nfunction Enrollment(props: EnrollmentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const issuerListRef = useRef<ComponentMethodsRef>(null);\n const [registrationOptions, setRegistrationOptions] = useState<string>(null);\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${props.txVariant}/` })('open-finance')}`\n },\n {\n name: 'arrow-down',\n alt: i18n.get('paybybankpix.await.logoAlt.arrowDown'),\n src: `${getImage({ imageFolder: 'components/' })('arrow_down')}`\n },\n { name: 'bank', alt: i18n.get('paybybankpix.await.logoAlt.bank'), src: `${getImage({ imageFolder: 'components/' })('bank')}` }\n ];\n const self = useRef({\n showValidation: () => {\n issuerListRef?.current?.showValidation();\n },\n setStatus: (newStatus: UIElementStatus) => {\n issuerListRef?.current?.setStatus(newStatus);\n }\n });\n\n const pollStatus = async () => {\n if (registrationOptions) return;\n\n const { enrollmentId, clientKey } = props as AwaitProps;\n const response = await getEnrollmentStatus({ enrollmentId, clientKey, loadingContext });\n if (response.registrationOptions) {\n setRegistrationOptions(response.registrationOptions);\n }\n return response;\n };\n // Assist typescript to narrow down the type.\n const isAwait = (props: EnrollmentProps): props is AwaitProps => props.type === 'await';\n const awaitEndSlot = () => <span>{i18n.get('paybybankpix.await.withOpenFinance')}</span>;\n\n useEffect(() => {\n props.setComponentRef(self.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (registrationOptions) {\n props.onEnroll(registrationOptions);\n }\n }, [registrationOptions]);\n\n return (\n <div className={'adyen-checkout-pix-enrollment'}>\n {isAwait(props) ? (\n <PayByBankPixAwait\n logos={logos}\n type={props.txVariant}\n countdownTime={props.countdownTime}\n clientKey={props.clientKey}\n onError={props.onError}\n awaitText={i18n.get('paybybankpix.await.waitForConfirmation')}\n instructions={i18n.get('paybybankpix.await.timeToPay', {\n values: { numberOfMin: props.countdownTime }\n })}\n pollStatus={pollStatus}\n endSlot={awaitEndSlot}\n ></PayByBankPixAwait>\n ) : (\n <div className=\"adyen-checkout-pix-enrollment-issuer-list\">\n <IssuerListIntroduction txVariant={props.txVariant} />\n <IssuerList\n items={useIssuerWithLogo({ issuers: props.issuers, txVariant: props.txVariant })}\n selectFieldLabel={i18n.get('paybybankpix.issuerList.selectField.label')}\n onSubmitAnalytics={props.onSubmitAnalytics}\n onChange={props.onChange}\n payButton={props.payButton}\n showPayButton={true}\n ref={issuerListRef}\n ></IssuerList>\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={i18n.get('paybybankpix.issuerList.disclaimer')} urls={[TERMS_CONDITIONS_URL]} />\n </span>\n </div>\n )}\n </div>\n );\n}\n\nexport default Enrollment;\n"],"names":["Enrollment","props","i18n","loadingContext","useCoreContext","getImage","useImage","issuerListRef","useRef","registrationOptions","setRegistrationOptions","useState","logos","name","alt","get","src","parentFolder","txVariant","imageFolder","self","showValidation","current","setStatus","newStatus","useEffect","setComponentRef","onEnroll","h","div","className","type","isAwait","PayByBankPixAwait","countdownTime","clientKey","onError","awaitText","instructions","values","numberOfMin","pollStatus","async","enrollmentId","response","getEnrollmentStatus","endSlot","span","IssuerListIntroduction","IssuerList","items","useIssuerWithLogo","issuers","selectFieldLabel","onSubmitAnalytics","onChange","payButton","showPayButton","ref","LabelOnlyDisclaimerMessage","message","urls"],"mappings":"ypBAgBA,SAASA,EAAWC,G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AoB,CAAEF,eAAcR,YAAWhC,mBAItE,OAHIyC,EAASnC,qBACTC,EAAuBkC,EAASnC,qBAE7BmC,GA8BKE,QA1BK,IAAMlB,EAACmB,OAAAA,KAAM7C,EAAKa,IAAI,yCA6B/Ba,EAACC,MAAAA,CAAIC,UAAU,6CACXF,EAACoB,EAAAA,CAAuB9B,UAAWjB,EAAMiB,YACzCU,EAACqB,EAAAA,CACGC,MAAOC,EAAkB,CAAEC,QAASnD,EAAMmD,QAASlC,UAAWjB,EAAMiB,YACpEmC,iBAAkBnD,EAAKa,IAAI,6CAC3BuC,kBAAmBrD,EAAMqD,kBACzBC,SAAUtD,EAAMsD,SAChBC,UAAWvD,EAAMuD,UACjBC,eAAe,EACfC,IAAKnD,IAETqB,EAACmB,OAAAA,CAAKjB,UAAU,oCACZF,EAAC+B,EAAAA,CAA2BC,QAAS1D,EAAKa,IAAI,sCAAuC8C,KAAM,CAlFtF,mEAwF7B"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import n from"../../../../../core/Context/useImage.js";const i="open-finance",o="paybybankpix.await.logoAlt.openFinance";function s({txVariant:s}){const{i18n:c}=e(),a=n();return t("div",{className:"adyen-checkout-issuer-list-introduction"},t("div",{className:"adyen-checkout-issuer-list-introduction-logo-container"},t("img",{src:a({parentFolder:`${s}/`})(i),alt:c.get(o),className:"adyen-checkout-issuer-list-introduction-logo-container__logo"}),t("p",{className:"adyen-checkout-issuer-list-introduction-logo-container__title"},c.get("paybybankpix.issuerList.introduction.logo.content"))),t("div",{className:"adyen-checkout-issuer-list-introduction-text-container"},t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__title"},c.get("paybybankpix.issuerList.introduction.title")),t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__content"},c.get("paybybankpix.issuerList.introduction.content1")),t("p",{className:"adyen-checkout-issuer-list-introduction-text-container__content"},c.get("paybybankpix.issuerList.introduction.content2"))))}export{s as default};
1
+ import{createElement as t}from"../../../../../external/preact/dist/preact.js";import{useCoreContext as e}from"../../../../../core/Context/CoreProvider.js";import o from"../../../../../core/Context/useImage.js";const n="open-finance",i="paybybankpix.await.logoAlt.openFinance";function a({txVariant:a}){const{i18n:r}=e(),s=o();return t("div",{className:"adyen-checkout-issuer-list-introduction"},t("div",{className:"adyen-checkout-issuer-list-introduction-logo-container"},t("img",{src:s({parentFolder:`${a}/`})(n),alt:r.get(i),className:"adyen-checkout-issuer-list-introduction-logo-container__logo"}),t("p",{className:"adyen-checkout-issuer-list-introduction-logo-container__title"},r.get("paybybankpix.issuerList.introduction.logo.content"))))}export{a as default};
2
2
  //# sourceMappingURL=IssuerListIntroduction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n <div className=\"adyen-checkout-issuer-list-introduction-text-container\">\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.title')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content1')}\n </p>\n <p className=\"adyen-checkout-issuer-list-introduction-text-container__content\">\n {i18n.get('paybybankpix.issuerList.introduction.content2')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAGlBP,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,+CAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,kDAEdP,EAACQ,IAAAA,CAAEN,UAAU,mEACRN,EAAKW,IAAI,mDAK9B"}
1
+ {"version":3,"file":"IssuerListIntroduction.js","sources":["../../../../../../../src/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './IssuerListIntroduction.scss';\nimport useImage from '../../../../../core/Context/useImage';\n\nconst LOGO = {\n name: 'open-finance',\n altI18nKey: 'paybybankpix.await.logoAlt.openFinance'\n};\n\nfunction IssuerListIntroduction({ txVariant }) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div className={'adyen-checkout-issuer-list-introduction'}>\n <div className=\"adyen-checkout-issuer-list-introduction-logo-container\">\n <img\n src={getImage({ parentFolder: `${txVariant}/` })(LOGO.name)}\n alt={i18n.get(LOGO.altI18nKey)}\n className=\"adyen-checkout-issuer-list-introduction-logo-container__logo\"\n />\n <p className=\"adyen-checkout-issuer-list-introduction-logo-container__title\">\n {i18n.get('paybybankpix.issuerList.introduction.logo.content')}\n </p>\n </div>\n </div>\n );\n}\n\nexport default IssuerListIntroduction;\n"],"names":["LOGO","IssuerListIntroduction","txVariant","i18n","useCoreContext","getImage","useImage","h","div","className","img","src","parentFolder","alt","get","p"],"mappings":"kNAKA,MAAMA,EACI,eADJA,EAEU,yCAGhB,SAASC,GAAuBC,UAAEA,IAC9B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,UAAW,2CACZF,EAACC,MAAAA,CAAIC,UAAU,0DACXF,EAACG,MAAAA,CACGC,IAAKN,EAAS,CAAEO,aAAc,GAAGV,MAA5BG,CAA4CL,GACjDa,IAAKV,EAAKW,IAAId,GACdS,UAAU,iEAEdF,EAACQ,IAAAA,CAAEN,UAAU,iEACRN,EAAKW,IAAI,uDAK9B"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../../../../utils/get-issuer-image.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import n from"../../../../core/Context/useImage.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({issuers:s,txVariant:u})=>{const{loadingContext:p}=o(),a=n(),[f,l]=e(s);return t(()=>{if((null==s?void 0:s.length)>0){const e=r({loadingContext:p},u,a);l(s.map(t=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){c(e,t,r[t])})}return e}({},t),{icon:e(t.id)})))}},[s,u]),f};export{s as useIssuerWithLogo};
1
+ import{useState as e,useEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../../../../utils/get-issuer-image.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";import n from"../../../../core/Context/useImage.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({issuers:s=[],txVariant:u})=>{const{loadingContext:p}=o(),a=n(),[f,l]=e(s);return t(()=>{if((null==s?void 0:s.length)>0){const e=r({loadingContext:p},u,a);l(s.map(t=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){c(e,t,r[t])})}return e}({},t),{icon:e(t.id)})))}},[s,u]),f};export{s as useIssuerWithLogo};
2
2
  //# sourceMappingURL=useIssuerWithLogo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers, txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","_object_spread_props","_object_spread","icon","id"],"mappings":"wvBAUaA,EAAoB,EAAGC,UAASC,gBACzC,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,IAAIT,aAAAA,EAAAA,EAASU,QAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,GAASC,oUAAAC,CAAA,GACdF,GAAAA,CACHG,KAAMN,EAAcG,EAAKI,OAGrC,GACD,CAAClB,EAASC,IAENK"}
1
+ {"version":3,"file":"useIssuerWithLogo.js","sources":["../../../../../../src/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { IssuerItem } from '../../../internal/IssuerList/types';\nimport getIssuerImageUrl from '../../../../utils/get-issuer-image';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\n\ninterface UseIssuerWithLogoProps {\n txVariant: string;\n issuers: IssuerItem[];\n}\nexport const useIssuerWithLogo = ({ issuers = [], txVariant }: UseIssuerWithLogoProps): IssuerItem[] => {\n const { loadingContext } = useCoreContext();\n const getImage = useImage();\n const [issuersWithLogo, setIssuersWithLogo] = useState<IssuerItem[]>(issuers);\n\n useEffect(() => {\n if (issuers?.length > 0) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext }, txVariant, getImage);\n setIssuersWithLogo(\n issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }))\n );\n }\n }, [issuers, txVariant]);\n\n return issuersWithLogo;\n};\n"],"names":["useIssuerWithLogo","issuers","txVariant","loadingContext","useCoreContext","getImage","useImage","issuersWithLogo","setIssuersWithLogo","useState","useEffect","length","getIssuerIcon","getIssuerImageUrl","map","item","_object_spread_props","_object_spread","icon","id"],"mappings":"kvBAUO,MAAMA,EAAoB,EAAGC,UAAU,GAAIC,gBAC9C,MAAMC,eAAEA,GAAmBC,IACrBC,EAAWC,KACVC,EAAiBC,GAAsBC,EAAuBR,GAcrE,OAZAS,EAAU,KACN,IAAIT,aAAAA,EAAAA,EAASU,QAAS,EAAG,CACrB,MAAMC,EAAgBC,EAAkB,CAAEV,kBAAkBD,EAAWG,GACvEG,EACIP,EAAQa,IAAIC,GAASC,oUAAAC,CAAA,GACdF,GAAAA,CACHG,KAAMN,EAAcG,EAAKI,OAGrC,GACD,CAAClB,EAASC,IAENK"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useRef as n,useCallback as o,useEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import l from"../../../internal/Voucher/Voucher.js";import s from"../../../../core/Context/useImage.js";import p from"../../../internal/PayButton/PayButton.js";import m from"./getAuthorizationStatus.js";import u from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:y,countdownTime:b,receiver:d,amount:f,txVariant:x,issuer:g,setComponentRef:h,enrollmentId:k,initiationId:w,clientKey:j,onAuthorize:v,onError:C}){const{i18n:P,loadingContext:I}=i(),B=s(),[E,F]=a("ready"),[S,z]=a(null),A=[{name:"open-finance",alt:P.get("paybybankpix.await.logoAlt.openFinance"),src:`${B({parentFolder:`${x}/`})("open-finance")}`}],D=[{label:P.get("paybybankpix.payment.receiver.label"),value:d},{label:P.get("paybybankpix.payment.paymentDate.label"),value:P.date((new Date).toString())},{label:P.get("paybybankpix.payment.paymentMethod.label"),value:"Pix Open Finance"}],T=n({setStatus:F}),K=o(async()=>{if(S)return;const e=await m({enrollmentId:k,initiationId:w,clientKey:j,loadingContext:I});return e.authorizationOptions&&z(e.authorizationOptions),e},[S,k,w,j,I]);return r(()=>{h(T.current)},[h]),r(()=>{S&&v(S)},[S]),"await"===y?e(u,{logos:A,type:x,countdownTime:b,clientKey:j,onError:C,awaitText:P.get("paybybankpix.await.fetchDetails"),pollStatus:K}):e(t,null,e(l,{issuerImageUrl:B({imageFolder:`${x}/`})(g),paymentMethodType:x,amount:P.amount(f.value,f.currency),voucherDetails:D}),e(p,{classNameModifiers:["standalone"],label:P.get("paybybankpix.storedPayment.payButton.label"),status:E,amount:f,onClick:c}))}export{c as default};
1
+ import{createElement as t}from"../../../../external/preact/dist/preact.js";import{useState as e,useRef as n,useCallback as o,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import r from"../../../../core/Context/useImage.js";import s from"../../../internal/PayButton/PayButton.js";import l from"./getAuthorizationStatus.js";import p from"../Enrollment/components/PayByBankPixAwait.js";function c({onPay:c,type:m,countdownTime:u,amount:f,txVariant:y,setComponentRef:d,enrollmentId:x,initiationId:b,clientKey:g,onAuthorize:k,onError:w}){const{i18n:C,loadingContext:h}=i(),j=r(),[P,B]=e("ready"),[E,I]=e(null),z=[{name:"open-finance",alt:C.get("paybybankpix.await.logoAlt.openFinance"),src:`${j({parentFolder:`${y}/`})("open-finance")}`}],A=n({setStatus:B}),S=o(async()=>{if(E)return;const t=await l({enrollmentId:x,initiationId:b,clientKey:g,loadingContext:h});return t.authorizationOptions&&I(t.authorizationOptions),t},[E,x,b,g,h]);return a(()=>{d(A.current)},[d]),a(()=>{E&&k(E)},[E]),"await"===m?t(p,{logos:z,type:y,countdownTime:u,clientKey:g,onError:w,awaitText:C.get("paybybankpix.await.fetchDetails"),pollStatus:S}):t(s,{classNameModifiers:["standalone"],label:C.get("paybybankpix.redirectBtn.label"),status:P,amount:f,onClick:c})}export{c as default};
2
2
  //# sourceMappingURL=StoredPayment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport PaymentDetails from '../../../internal/Voucher';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n receiver,\n amount,\n txVariant,\n issuer,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n const details = [\n { label: i18n.get('paybybankpix.payment.receiver.label'), value: receiver },\n { label: i18n.get('paybybankpix.payment.paymentDate.label'), value: i18n.date(new Date().toString()) },\n { label: i18n.get('paybybankpix.payment.paymentMethod.label'), value: 'Pix Open Finance' }\n ];\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <Fragment>\n <PaymentDetails\n issuerImageUrl={getImage({ imageFolder: `${txVariant}/` })(issuer)}\n paymentMethodType={txVariant}\n amount={i18n.amount(amount.value, amount.currency)}\n voucherDetails={details}\n ></PaymentDetails>\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.storedPayment.payButton.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n </Fragment>\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","receiver","amount","txVariant","issuer","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","details","label","value","date","Date","toString","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","Fragment","PaymentDetails","issuerImageUrl","imageFolder","paymentMethodType","currency","voucherDetails","PayButton","classNameModifiers","onClick"],"mappings":"kiBAWA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,SACbA,EAAQC,OACRA,EAAMC,UACNA,EAASC,OACTA,EAAMC,gBACNA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGvB,MAA5BW,CAA4C,oBAGtDa,EAAU,CACZ,CAAEC,MAAOjB,EAAKa,IAAI,uCAAwCK,MAAO5B,GACjE,CAAE2B,MAAOjB,EAAKa,IAAI,0CAA2CK,MAAOlB,EAAKmB,MAAK,IAAIC,MAAOC,aACzF,CAAEJ,MAAOjB,EAAKa,IAAI,4CAA6CK,MAAO,qBAEpEI,EAAOC,EAAO,CAChBjB,cAGEkB,EAAaC,EAAYC,UAC3B,GAAIlB,EAAsB,OAE1B,MAAMmB,QAAiBC,EAAuB,CAAEjC,eAAcC,eAAcC,YAAWI,mBAKvF,OAJI0B,EAASnB,sBACTC,EAAwBkB,EAASnB,sBAG9BmB,GACR,CAACnB,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVA4B,EAAU,KACNnC,EAAgB4B,EAAKQ,UACtB,CAACpC,IAEJmC,EAAU,KACFrB,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATpB,EACH2C,EAACC,EAAAA,CACGtB,MAAOA,EACPtB,KAAMI,EACNH,cAAeA,EACfQ,UAAWA,EACXE,QAASA,EACTkC,UAAWjC,EAAKa,IAAI,mCACpBW,WAAYA,IAGhBO,EAACG,OACGH,EAACI,EAAAA,CACGC,eAAgBjC,EAAS,CAAEkC,YAAa,GAAG7C,MAA3BW,CAA2CV,GAC3D6C,kBAAmB9C,EACnBD,OAAQS,EAAKT,OAAOA,EAAO2B,MAAO3B,EAAOgD,UACzCC,eAAgBxB,IAEpBe,EAACU,EAAAA,CACGC,mBAzDY,CAAC,cA0DbzB,MAAOjB,EAAKa,IAAI,8CAChBR,OAAQA,EACRd,OAAQA,EACRoD,QAASxD,IAIzB"}
1
+ {"version":3,"file":"StoredPayment.js","sources":["../../../../../../src/components/PayByBankPix/components/StoredPayment/StoredPayment.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef, useCallback } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { PaymentProps } from './types';\nimport useImage from '../../../../core/Context/useImage';\nimport PayButton from '../../../internal/PayButton';\nimport './StoredPayment.scss';\nimport getAuthorizationStatus from './getAuthorizationStatus';\nimport PayByBankPixAwait from '../Enrollment/components/PayByBankPixAwait';\n\nfunction StoredPayment({\n onPay,\n type,\n countdownTime,\n amount,\n txVariant,\n setComponentRef,\n enrollmentId,\n initiationId,\n clientKey,\n onAuthorize,\n onError\n}: PaymentProps) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState('ready');\n const [authorizationOptions, setAuthorizationOptions] = useState<string>(null);\n const buttonModifiers = ['standalone'];\n const logos = [\n {\n name: 'open-finance',\n alt: i18n.get('paybybankpix.await.logoAlt.openFinance'),\n src: `${getImage({ parentFolder: `${txVariant}/` })('open-finance')}`\n }\n ];\n\n const self = useRef({\n setStatus\n });\n\n const pollStatus = useCallback(async () => {\n if (authorizationOptions) return;\n\n const response = await getAuthorizationStatus({ enrollmentId, initiationId, clientKey, loadingContext });\n if (response.authorizationOptions) {\n setAuthorizationOptions(response.authorizationOptions);\n }\n\n return response;\n }, [authorizationOptions, enrollmentId, initiationId, clientKey, loadingContext]);\n\n useEffect(() => {\n setComponentRef(self.current);\n }, [setComponentRef]);\n\n useEffect(() => {\n if (authorizationOptions) {\n onAuthorize(authorizationOptions);\n }\n }, [authorizationOptions]);\n\n return type === 'await' ? (\n <PayByBankPixAwait\n logos={logos}\n type={txVariant}\n countdownTime={countdownTime}\n clientKey={clientKey}\n onError={onError}\n awaitText={i18n.get('paybybankpix.await.fetchDetails')}\n pollStatus={pollStatus}\n ></PayByBankPixAwait>\n ) : (\n <PayButton\n classNameModifiers={buttonModifiers}\n label={i18n.get('paybybankpix.redirectBtn.label')}\n status={status}\n amount={amount}\n onClick={onPay}\n />\n );\n}\n\nexport default StoredPayment;\n"],"names":["StoredPayment","onPay","type","countdownTime","amount","txVariant","setComponentRef","enrollmentId","initiationId","clientKey","onAuthorize","onError","i18n","loadingContext","useCoreContext","getImage","useImage","status","setStatus","useState","authorizationOptions","setAuthorizationOptions","logos","name","alt","get","src","parentFolder","self","useRef","pollStatus","useCallback","async","response","getAuthorizationStatus","useEffect","current","h","PayByBankPixAwait","awaitText","PayButton","classNameModifiers","label","onClick"],"mappings":"geAUA,SAASA,GAAcC,MACnBA,EAAKC,KACLA,EAAIC,cACJA,EAAaC,OACbA,EAAMC,UACNA,EAASC,gBACTA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,UACZA,EAASC,YACTA,EAAWC,QACXA,IAEA,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,KACVC,EAAQC,GAAaC,EAAS,UAC9BC,EAAsBC,GAA2BF,EAAiB,MAEnEG,EAAQ,CACV,CACIC,KAAM,eACNC,IAAKZ,EAAKa,IAAI,0CACdC,IAAK,GAAGX,EAAS,CAAEY,aAAc,GAAGtB,MAA5BU,CAA4C,oBAItDa,EAAOC,EAAO,CAChBX,cAGEY,EAAaC,EAAYC,UAC3B,GAAIZ,EAAsB,OAE1B,MAAMa,QAAiBC,EAAuB,CAAE3B,eAAcC,eAAcC,YAAWI,mBAKvF,OAJIoB,EAASb,sBACTC,EAAwBY,EAASb,sBAG9Ba,GACR,CAACb,EAAsBb,EAAcC,EAAcC,EAAWI,IAYjE,OAVAsB,EAAU,KACN7B,EAAgBsB,EAAKQ,UACtB,CAAC9B,IAEJ6B,EAAU,KACFf,GACAV,EAAYU,IAEjB,CAACA,IAEY,UAATlB,EACHmC,EAACC,EAAAA,CACGhB,MAAOA,EACPpB,KAAMG,EACNF,cAAeA,EACfM,UAAWA,EACXE,QAASA,EACT4B,UAAW3B,EAAKa,IAAI,mCACpBK,WAAYA,IAGhBO,EAACG,EAAAA,CACGC,mBA9CgB,CAAC,cA+CjBC,MAAO9B,EAAKa,IAAI,kCAChBR,OAAQA,EACRb,OAAQA,EACRuC,QAAS1C,GAGrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","_object_spread","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"mLAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,oUAAmCE,CAAA,CAAA,EAAKD,GAErCE,OAAOC,KAAKH,GAAOI,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQP,EAAMM,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_spread","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"mLAMO,MAAMA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,oUAAmCE,CAAA,CAAA,EAAKD,GAErCE,OAAOC,KAAKH,GAAOI,OAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQP,EAAMM,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","_object_spread","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":"uuBAeA,MAAMA,EA4BF,gBAAaC,GACT,MAAMC,QA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S,SACxElB,QAAQC,KAAK,gFAEjB,MAAMkB,OAAEA,GAAWC,EAAoBrD,EAAckD,aAErDzE,KAAK6C,mBAAqB8B,EAC1B3E,KAAK8C,UAAYvB,EAAcuB,UAC/B9C,KAAKkE,oBAAsB3C,EAAc2C,sBAAuB,EAChElE,KAAKsE,OAASO,EAAmCtD,EAAc+C,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","_object_spread","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":"uuBAeA,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,GAC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,EAAiBE,gBAClC,CAAE,MAAOL,GACL,MAAM,IAAI9C,EAAmB,QAAS,yDAA0D,CAAEoD,MAAON,GAC7G,CACJ,CAEA,gCAAclD,GACV,IACIL,KAAKQ,kBAAoBsD,OAAOC,OAAOC,SAAS9B,EAAA,CAC5C+B,mBAAoB,kCAChBjE,KAAKkE,qBAAuB,CAC5BC,SAAU,CACNC,eAAgB,SAI5BpE,KAAKQ,YAAY6D,UAAUrE,KAAKsE,QAE3BtE,KAAKoD,qBACd,CAAE,MAAOG,GACL,MAAM,IAAI9C,EAAmB,QAAS,2FAA4F,CAC9HoD,MAAON,GAEf,CACJ,CA3KA,WAAAgB,CAAYhD,GACR,GAVJiD,EAAAxE,KAAiB8C,iBAAjB,GACA0B,EAAAxE,KAAiB6C,0BAAjB,GACA2B,EAAAxE,KAAiBsE,cAAjB,GACAE,EAAAxE,KAAiBkE,2BAAjB,GAEAM,EAAAxE,KAAQQ,mBAAR,GACAgE,EAAAxE,KAAQa,4BAAR,GACA2D,EAAAxE,KAAQwB,yBAAR,KAGSD,aAAAA,EAAAA,EAAekD,aAAa,MAAM,IAAIhE,EAAmB,uBAAwB,mDACtF,KAAKc,aAAAA,EAAAA,EAAeuB,WAAW,MAAM,IAAIrC,EAAmB,uBAAwB,iDAEhFc,EAAc2C,qBAAuB3C,EAAckD,YAAYC,SAAS,SACxElB,QAAQC,KAAK,gFAEjB,MAAMkB,OAAEA,GAAWC,EAAoBrD,EAAckD,aAErDzE,KAAK6C,mBAAqB8B,EAC1B3E,KAAK8C,UAAYvB,EAAcuB,UAC/B9C,KAAKkE,oBAAsB3C,EAAc2C,sBAAuB,EAChElE,KAAKsE,OAASO,EAAmCtD,EAAc+C,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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","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","_object_spread","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":"wyDAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,GAAWZ,KAAK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,gBAC5BC,aAAc9F,KAAK8F,gBAKL,UAAtB9F,KAAKC,MAAMoC,OAEP4C,EAACc,MAAAA,CAAIC,UAAU,4CACXf,EAACgB,EAAAA,CACGD,UAAU,mEACVE,IAAKnB,EAAS,CACVoB,YAAa,eADZpB,CAEF,SACHqB,IAAK,KAETnB,EAACc,MAAAA,CAAIC,UAAU,gCACVhG,KAAKC,MAAMc,UAAYf,KAAKC,MAAMc,UAAYf,KAAKO,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAtVA,WAAAkF,CAAY9F,GAGR,GAFA+F,MAAM/F,GAoBVgG,EAAAvG,KAAO8F,eAAgBU,IACnB,MAAMpF,EAAQ,IAAI0C,EAAkB,CAChCC,KAAMC,EACNtC,QAAS8E,EACTtC,QAASC,EAAoBsC,sBAGjCzG,KAAKO,MAAMqB,kBAAkBR,KAzBzBpB,KAAKO,MAAMmG,MAAO,CAClB,MAAMxG,EAA6CyG,EAAqB,CACpED,MAAO1G,KAAKO,MAAMmG,MAClBE,KAAM5G,KAAKO,MAAMsG,qBAAuB7G,KAAKO,MAAMqG,OAGvD5G,KAAKC,MAAQ,CACToC,OAAQ,OACRnC,cAAeA,QAInBF,KAAKC,MAAQ,CAAEC,cAAe,CAAE4G,SAAS,EAAOvE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA6D,EADE3G,EACYmH,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTvB,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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","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","_object_spread","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":"wyDAmBA,MAAMA,UAA6BC,EAsC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,GAAWZ,KAAKC,MAAMC,cAI9B,IAHuBW,EAAeD,EAAQN,GAGzB,CAEjBN,KAAKc,SACD,CACIC,UAAW,GAAGC,EAAoBC,4BAA4BjB,KAAKO,MAAMW,KAAKC,IAAI,oBAEtF,GAIJ,MAAMC,EAAQ,IAAIC,E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ADZpB,CAEF,SACHqB,IAAK,KAETnB,EAACc,MAAAA,CAAIC,UAAU,gCACVhG,KAAKC,MAAMc,UAAYf,KAAKC,MAAMc,UAAYf,KAAKO,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAtVA,WAAAkF,CAAY9F,GAGR,GAFA+F,MAAM/F,GAoBVgG,EAAAvG,KAAO8F,eAAgBU,IACnB,MAAMpF,EAAQ,IAAI0C,EAAkB,CAChCC,KAAMC,EACNtC,QAAS8E,EACTtC,QAASC,EAAoBsC,sBAGjCzG,KAAKO,MAAMqB,kBAAkBR,KAzBzBpB,KAAKO,MAAMmG,MAAO,CAClB,MAAMxG,EAA6CyG,EAAqB,CACpED,MAAO1G,KAAKO,MAAMmG,MAClBE,KAAM5G,KAAKO,MAAMsG,qBAAuB7G,KAAKO,MAAMqG,OAGvD5G,KAAKC,MAAQ,CACToC,OAAQ,OACRnC,cAAeA,EAEvB,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAE4G,SAAS,EAAOvE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA6D,EADE3G,EACYmH,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTvB,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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","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","_object_spread","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":"mlDAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAA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QAASC,EAAoBkB,wBAGjCpF,KAAKO,MAAMoD,kBAAkBZ,KAxB7B,MAAMsC,MAAEA,EAAKC,gBAAEA,GAAoBtF,KAAKO,MAExC,GAAI8E,EAAO,CACP,MAAMnF,EAAiDqF,EAAuB,CAAEF,QAAOC,oBAEvFtF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEsF,SAAS,EAAOtD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA8C,EADEtF,EACYkE,OAAO,UAErBoB,EAHEtF,EAGY6F,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT5C,YAAa,GACbwB,aAAa,EACb5B,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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","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","_object_spread","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":"mlDAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CAG2BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBf,KAAK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