@adyen/adyen-web 6.46.0 → 6.47.0-alpha.41c41fe

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 (273) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +63 -46
  4. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  5. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  6. package/dist/es/components/AmazonPay/components/AmazonPayButton.js +1 -1
  7. package/dist/es/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  8. package/dist/es/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  9. package/dist/es/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  10. package/dist/es/components/AmazonPay/components/OrderButton.js +1 -1
  11. package/dist/es/components/AmazonPay/components/OrderButton.js.map +1 -1
  12. package/dist/es/components/AmazonPay/components/SignOutButton.js +1 -1
  13. package/dist/es/components/AmazonPay/components/SignOutButton.js.map +1 -1
  14. package/dist/es/components/AmazonPay/utils.js +1 -1
  15. package/dist/es/components/AmazonPay/utils.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  19. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  20. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  21. package/dist/es/components/CashAppPay/components/CashAppComponent.js +1 -1
  22. package/dist/es/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  23. package/dist/es/components/CashAppPay/services/CashAppService.js +1 -1
  24. package/dist/es/components/CashAppPay/services/CashAppService.js.map +1 -1
  25. package/dist/es/components/CashAppPay/services/types.js.map +1 -1
  26. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  27. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  28. package/dist/es/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js +1 -1
  29. package/dist/es/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js.map +1 -1
  30. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  31. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  32. package/dist/es/components/PayByBankPix/PayByBankPix.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/PayByBankUS/PayByBankUS.js +1 -1
  36. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  37. package/dist/es/components/PayPal/Paypal.js +1 -1
  38. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  39. package/dist/es/components/PayPal/utils/get-paypal-locale.js.map +1 -1
  40. package/dist/es/components/PayPal/utils/get-paypal-settings.js +1 -1
  41. package/dist/es/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  42. package/dist/es/components/PayPalFastlane/Fastlane.js +1 -1
  43. package/dist/es/components/PayPalFastlane/Fastlane.js.map +1 -1
  44. package/dist/es/components/PayPalFastlane/FastlaneSDK.js +1 -1
  45. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  46. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  47. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  48. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  49. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  50. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  51. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  52. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  53. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  54. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  55. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js +1 -1
  56. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  57. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  58. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  59. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  60. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  61. package/dist/es/components/internal/Address/Address.js +1 -1
  62. package/dist/es/components/internal/Address/Address.js.map +1 -1
  63. package/dist/es/components/internal/Address/Specifications.js +1 -1
  64. package/dist/es/components/internal/Address/Specifications.js.map +1 -1
  65. package/dist/es/components/internal/Address/components/AddressSearch.js +1 -1
  66. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  67. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  68. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  69. package/dist/es/components/internal/Address/constants.js.map +1 -1
  70. package/dist/es/components/internal/Address/utils.js.map +1 -1
  71. package/dist/es/components/internal/Address/validate.formats.js +1 -1
  72. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  73. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  74. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  75. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  76. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  77. package/dist/es/components/internal/CompanyDetails/validate.js +1 -1
  78. package/dist/es/components/internal/CompanyDetails/validate.js.map +1 -1
  79. package/dist/es/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.js.map +1 -1
  80. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  81. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  82. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  83. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  84. package/dist/es/components/internal/FormFields/InputDate/InputDate.js +1 -1
  85. package/dist/es/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  86. package/dist/es/components/internal/FormFields/InputDate/utils.js.map +1 -1
  87. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  88. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  89. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  90. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  91. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  92. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  93. package/dist/es/components/internal/IbanInput/specifications.js.map +1 -1
  94. package/dist/es/components/internal/IbanInput/utils.js +1 -1
  95. package/dist/es/components/internal/IbanInput/utils.js.map +1 -1
  96. package/dist/es/components/internal/PayButton/utils.js.map +1 -1
  97. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  98. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  99. package/dist/es/components/internal/PersonalDetails/validate.js +1 -1
  100. package/dist/es/components/internal/PersonalDetails/validate.js.map +1 -1
  101. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  102. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  103. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  104. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  105. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  106. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  107. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  108. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  109. package/dist/es/core/config.js +1 -1
  110. package/dist/es/core/config.js.map +1 -1
  111. package/dist/es/core/core.js +1 -1
  112. package/dist/es/core/core.js.map +1 -1
  113. package/dist/es/core/utils.js +1 -1
  114. package/dist/es/core/utils.js.map +1 -1
  115. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
  116. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  117. package/dist/es/index.d.ts +63 -46
  118. package/dist/es/utils/Script.js.map +1 -1
  119. package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
  120. package/dist/es/utils/Validator/Validator.js +1 -1
  121. package/dist/es/utils/Validator/Validator.js.map +1 -1
  122. package/dist/es/utils/Validator/defaultRules.js +1 -1
  123. package/dist/es/utils/Validator/defaultRules.js.map +1 -1
  124. package/dist/es/utils/browserInfo.js.map +1 -1
  125. package/dist/es/utils/createSdkData.js.map +1 -1
  126. package/dist/es/utils/get-issuer-image.js +1 -1
  127. package/dist/es/utils/get-issuer-image.js.map +1 -1
  128. package/dist/es/utils/get-process-message-handler.js.map +1 -1
  129. package/dist/es/utils/getConsentUrl.js +1 -1
  130. package/dist/es/utils/getConsentUrl.js.map +1 -1
  131. package/dist/es/utils/getErrorMessage.js.map +1 -1
  132. package/dist/es/utils/getOrigin.js.map +1 -1
  133. package/dist/es/utils/isValidURL.js +1 -1
  134. package/dist/es/utils/isValidURL.js.map +1 -1
  135. package/dist/es/utils/promiseTimeout.js.map +1 -1
  136. package/dist/es/utils/useAutoFocus.js.map +1 -1
  137. package/dist/es/utils/validator-utils.js +1 -1
  138. package/dist/es/utils/validator-utils.js.map +1 -1
  139. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  140. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  141. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js +1 -1
  142. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  143. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  144. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  145. package/dist/es-legacy/components/AmazonPay/components/OrderButton.js +1 -1
  146. package/dist/es-legacy/components/AmazonPay/components/OrderButton.js.map +1 -1
  147. package/dist/es-legacy/components/AmazonPay/components/SignOutButton.js +1 -1
  148. package/dist/es-legacy/components/AmazonPay/components/SignOutButton.js.map +1 -1
  149. package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
  150. package/dist/es-legacy/components/AmazonPay/utils.js.map +1 -1
  151. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  152. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  153. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  154. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  155. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  156. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js +1 -1
  157. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  158. package/dist/es-legacy/components/CashAppPay/services/CashAppService.js +1 -1
  159. package/dist/es-legacy/components/CashAppPay/services/CashAppService.js.map +1 -1
  160. package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
  161. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  162. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  163. package/dist/es-legacy/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js +1 -1
  164. package/dist/es-legacy/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js.map +1 -1
  165. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  166. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  167. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  168. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  169. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  170. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
  171. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  172. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  173. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  174. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js.map +1 -1
  175. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +1 -1
  176. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  177. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js +1 -1
  178. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js.map +1 -1
  179. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js +1 -1
  180. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  181. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  182. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  183. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  184. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  185. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  186. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  187. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  188. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  189. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  190. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js +1 -1
  191. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  192. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  193. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  194. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  195. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  196. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  197. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  198. package/dist/es-legacy/components/internal/Address/Specifications.js +1 -1
  199. package/dist/es-legacy/components/internal/Address/Specifications.js.map +1 -1
  200. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js +1 -1
  201. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  202. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  203. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  204. package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
  205. package/dist/es-legacy/components/internal/Address/utils.js.map +1 -1
  206. package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
  207. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  208. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  209. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  210. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  211. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  212. package/dist/es-legacy/components/internal/CompanyDetails/validate.js +1 -1
  213. package/dist/es-legacy/components/internal/CompanyDetails/validate.js.map +1 -1
  214. package/dist/es-legacy/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.js.map +1 -1
  215. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  216. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  217. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  218. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  219. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js +1 -1
  220. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  221. package/dist/es-legacy/components/internal/FormFields/InputDate/utils.js.map +1 -1
  222. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  223. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  224. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  225. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  226. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  227. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  228. package/dist/es-legacy/components/internal/IbanInput/specifications.js.map +1 -1
  229. package/dist/es-legacy/components/internal/IbanInput/utils.js +1 -1
  230. package/dist/es-legacy/components/internal/IbanInput/utils.js.map +1 -1
  231. package/dist/es-legacy/components/internal/PayButton/utils.js.map +1 -1
  232. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  233. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  234. package/dist/es-legacy/components/internal/PersonalDetails/validate.js +1 -1
  235. package/dist/es-legacy/components/internal/PersonalDetails/validate.js.map +1 -1
  236. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  237. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  238. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  239. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  240. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  241. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  242. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  243. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  244. package/dist/es-legacy/core/config.js +1 -1
  245. package/dist/es-legacy/core/config.js.map +1 -1
  246. package/dist/es-legacy/core/core.js +1 -1
  247. package/dist/es-legacy/core/core.js.map +1 -1
  248. package/dist/es-legacy/core/utils.js +1 -1
  249. package/dist/es-legacy/core/utils.js.map +1 -1
  250. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
  251. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  252. package/dist/es-legacy/utils/Script.js.map +1 -1
  253. package/dist/es-legacy/utils/Validator/ValidationRuleResult.js.map +1 -1
  254. package/dist/es-legacy/utils/Validator/Validator.js +1 -1
  255. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  256. package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
  257. package/dist/es-legacy/utils/Validator/defaultRules.js.map +1 -1
  258. package/dist/es-legacy/utils/browserInfo.js.map +1 -1
  259. package/dist/es-legacy/utils/createSdkData.js.map +1 -1
  260. package/dist/es-legacy/utils/get-issuer-image.js +1 -1
  261. package/dist/es-legacy/utils/get-issuer-image.js.map +1 -1
  262. package/dist/es-legacy/utils/get-process-message-handler.js.map +1 -1
  263. package/dist/es-legacy/utils/getConsentUrl.js +1 -1
  264. package/dist/es-legacy/utils/getConsentUrl.js.map +1 -1
  265. package/dist/es-legacy/utils/getErrorMessage.js.map +1 -1
  266. package/dist/es-legacy/utils/getOrigin.js.map +1 -1
  267. package/dist/es-legacy/utils/isValidURL.js +1 -1
  268. package/dist/es-legacy/utils/isValidURL.js.map +1 -1
  269. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  270. package/dist/es-legacy/utils/useAutoFocus.js.map +1 -1
  271. package/dist/es-legacy/utils/validator-utils.js +1 -1
  272. package/dist/es-legacy/utils/validator-utils.js.map +1 -1
  273. package/package.json +3 -2
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import i from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as o}from"./constants.js";import{TxVariants as s}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as a}from"./utils/format-paypal-order-contact-to-adyen-format.js";import{AnalyticsInfoEvent as p,InfoEventType as l}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{sanitizeResponse as h,verifyPaymentDidNotFail as d}from"../internal/UIElement/utils.js";import c from"../../core/Errors/CancelError.js";function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){u(e,t,n[t])})}return e}function y(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function O(e,t){if(null==e)return{};var n,r,i,o={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(n=Reflect.ownKeys(Object(e)),i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,i={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,t),Object.getOwnPropertySymbols)for(n=Object.getOwnPropertySymbols(e),i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}class f extends t{formatProps(e){var t,n,r;const i=null===(t=e.configuration)||void 0===t?void 0:t.merchantId,o=null===(n=e.configuration)||void 0===n?void 0:n.intent,s=0===(null===(r=e.amount)||void 0===r?void 0:r.value)?"tokenize":e.intent||o,a="tokenize"===s||e.vault,p="continue"===e.userAction;return y(m({},e),{commit:!p&&e.commit,vault:a,configuration:{intent:s,merchantId:i}})}beforeRender(e){const t=new p(m({type:l.rendered,component:this.type,configData:y(m({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.isExpress)&&{isExpress:e.isExpress},(null==e?void 0:e.expressPage)&&{expressPage:e.expressPage}));this.analytics.sendAnalytics(t)}updatePaymentData(e){e||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=e}formatData(){const{isExpress:e,userAction:t}=this.props;return{paymentMethod:{type:f.type,userAction:t,subtype:e?"express":f.subtype}}}get isValid(){return!0}handleResolve(e){if(!this.resolve)return this.handleError(new i("ERROR",o.WRONG_INSTANCE));this.resolve(e)}handleReject(e){if(!this.reject)return this.handleError(new i("ERROR",o.WRONG_INSTANCE));this.reject(new Error(e))}handleSubmit(){return new Promise((e,t)=>{this.resolve=e,this.reject=t,this.makePaymentsCall().then(h).then(d).then(this.handleResponse).catch(e=>{if(e instanceof c)return void this.setElementStatus("ready");this.handleFailedResult(e);const t=e instanceof Error?e.message:JSON.stringify(e),n=e?`: ${t}`:"";this.handleReject(`${o.PAYMENT_FAILED}${n}`)})})}handleOnShippingAddressChange(e,t){const{onShippingAddressChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}handleOnShippingOptionsChange(e,t){const{onShippingOptionsChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}componentToRender(){if(!this.props.showPayButton)return null;const t=this.props,{onShippingAddressChange:r,onShippingOptionsChange:o}=t,s=O(t,["onShippingAddressChange","onShippingOptionsChange"]);return e(n,y(m(y(m({},s),{setComponentRef:this.setComponentRef}),r&&{onShippingAddressChange:this.handleOnShippingAddressChange},o&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new i("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:e=>{this.handleError(new i("ERROR",String(e),{cause:e}))},onScriptLoadFailure:e=>this.handleError(e),onSubmit:this.handleSubmit}))}constructor(e,t){super(e,t),u(this,"paymentData",null),u(this,"resolve",null),u(this,"reject",null),u(this,"submit",()=>{this.handleError(new i("IMPLEMENTATION_ERROR",o.SUBMIT_NOT_SUPPORTED))}),u(this,"handleAction",e=>this.updateWithAction(e)),u(this,"updateWithAction",e=>{if(e.paymentMethodType!==this.type)throw new Error("Invalid Action");return e.paymentData&&(this.paymentData=e.paymentData),e.sdkData&&e.sdkData.token?(this.onActionHandled({componentType:this.type,actionDescription:"sdk-loaded",originalAction:e}),this.handleResolve(e.sdkData.token)):this.handleReject(o.NO_TOKEN_PROVIDED),null}),u(this,"handleOnApprove",(e,t)=>{var n;const{onAuthorized:r}=this.props,o={data:{details:Object.entries(e).reduce((e,[t,n])=>(e[t]=null!=n?n:void 0,e),{}),paymentData:null!==(n=this.paymentData)&&void 0!==n?n:void 0}};return r?t.order?t.order.get().then(e=>{var t;const n=a(null==e?void 0:e.payer),i=a(null==e||null===(t=e.purchase_units)||void 0===t?void 0:t[0].shipping,!0);return this.setState(m({authorizedEvent:e},n&&{billingAddress:n},i&&{deliveryAddress:i})),new Promise((t,o)=>r(m({authorizedEvent:e},n&&{billingAddress:n},i&&{deliveryAddress:i}),{resolve:t,reject:o}))}).then(()=>this.handleAdditionalDetails(o)).catch(e=>this.handleError(new i("ERROR","Something went wrong while parsing PayPal Order",{cause:e}))):(this.handleError(new i("ERROR","PayPal order actions are not available")),Promise.resolve()):(this.handleAdditionalDetails(o),Promise.resolve())}),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}}u(f,"type",s.paypal),u(f,"subtype","sdk"),u(f,"defaultProps",r);export{f as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import i from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as o}from"./constants.js";import{TxVariants as s}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as a}from"./utils/format-paypal-order-contact-to-adyen-format.js";import{AnalyticsInfoEvent as l,InfoEventType as p}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{sanitizeResponse as h,verifyPaymentDidNotFail as d}from"../internal/UIElement/utils.js";import c from"../../core/Errors/CancelError.js";function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){u(e,t,n[t])})}return e}function y(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function O(e,t){if(null==e)return{};var n,r,i,o={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(n=Reflect.ownKeys(Object(e)),i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,i={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,t),Object.getOwnPropertySymbols)for(n=Object.getOwnPropertySymbols(e),i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}class f extends t{formatProps(e){var t,n,r;const i=null===(t=e.configuration)||void 0===t?void 0:t.merchantId,o=null===(n=e.configuration)||void 0===n?void 0:n.intent,s=0===(null===(r=e.amount)||void 0===r?void 0:r.value)?"tokenize":e.intent||o,a="tokenize"===s||e.vault,l="continue"===e.userAction;return y(m({},e),{commit:!l&&e.commit,vault:a,configuration:{intent:s,merchantId:i}})}beforeRender(e){const t=new l(m({type:p.rendered,component:this.type,configData:y(m({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.isExpress)&&{isExpress:e.isExpress},(null==e?void 0:e.expressPage)&&{expressPage:e.expressPage}));this.analytics.sendAnalytics(t)}updatePaymentData(e){e||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=e}formatData(){const{isExpress:e,userAction:t}=this.props;return{paymentMethod:{type:f.type,userAction:t,subtype:e?"express":f.subtype}}}get isValid(){return!0}handleResolve(e){if(!this.resolve)return this.handleError(new i("ERROR",o.WRONG_INSTANCE));this.resolve(e)}handleReject(e){if(!this.reject)return this.handleError(new i("ERROR",o.WRONG_INSTANCE));this.reject(new Error(e))}handleSubmit(){return new Promise((e,t)=>{var n;this.resolve=e,this.reject=t,null===(n=this.makePaymentsCall())||void 0===n||n.then(h).then(d).then(this.handleResponse).catch(e=>{if(e instanceof c)return void this.setElementStatus("ready");this.handleFailedResult(e);const t=e instanceof Error?e.message:JSON.stringify(e),n=e?`: ${t}`:"";this.handleReject(`${o.PAYMENT_FAILED}${n}`)})})}handleOnShippingAddressChange(e,t){const{onShippingAddressChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}handleOnShippingOptionsChange(e,t){const{onShippingOptionsChange:n}=this.props;return n?n(e,t,this):Promise.resolve()}componentToRender(){if(!this.props.showPayButton)return null;const t=this.props,{onShippingAddressChange:r,onShippingOptionsChange:o}=t,s=O(t,["onShippingAddressChange","onShippingOptionsChange"]);return e(n,y(m(y(m({},s),{setComponentRef:this.setComponentRef}),r&&{onShippingAddressChange:this.handleOnShippingAddressChange},o&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new i("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:e=>{this.handleError(new i("ERROR",String(e),{cause:e}))},onScriptLoadFailure:e=>this.handleError(e),onSubmit:this.handleSubmit}))}constructor(e,t){super(e,t),u(this,"paymentData",null),u(this,"resolve",null),u(this,"reject",null),u(this,"submit",()=>{this.handleError(new i("IMPLEMENTATION_ERROR",o.SUBMIT_NOT_SUPPORTED))}),u(this,"handleAction",e=>this.updateWithAction(e)),u(this,"updateWithAction",e=>{if(e.paymentMethodType!==this.type)throw new Error("Invalid Action");return e.paymentData&&(this.paymentData=e.paymentData),e.sdkData&&e.sdkData.token?(this.onActionHandled({componentType:this.type,actionDescription:"sdk-loaded",originalAction:e}),this.handleResolve(e.sdkData.token)):this.handleReject(o.NO_TOKEN_PROVIDED),null}),u(this,"handleOnApprove",(e,t)=>{var n;const{onAuthorized:r}=this.props,o={data:{details:Object.entries(e).reduce((e,[t,n])=>(e[t]=null!=n?n:void 0,e),{}),paymentData:null!==(n=this.paymentData)&&void 0!==n?n:void 0}};return r?t.order?t.order.get().then(e=>{var t;const n=a(null==e?void 0:e.payer),i=a(null==e||null===(t=e.purchase_units)||void 0===t?void 0:t[0].shipping,!0);return this.setState(m({authorizedEvent:e},n&&{billingAddress:n},i&&{deliveryAddress:i})),new Promise((t,o)=>r(m({authorizedEvent:e},n&&{billingAddress:n},i&&{deliveryAddress:i}),{resolve:t,reject:o}))}).then(()=>this.handleAdditionalDetails(o)).catch(e=>this.handleError(new i("ERROR","Something went wrong while parsing PayPal Order",{cause:e}))):(this.handleError(new i("ERROR","PayPal order actions are not available")),Promise.resolve()):(this.handleAdditionalDetails(o),Promise.resolve())}),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}}u(f,"type",s.paypal),u(f,"subtype","sdk"),u(f,"defaultProps",r);export{f as default};
2
2
  //# sourceMappingURL=Paypal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\nimport type {\n PayPalOnApproveActions,\n PayPalOnApproveData,\n PayPalOnShippingAddressChangeActions,\n PayPalOnShippingAddressChangeData,\n PayPalOnShippingOptionsChangeActions,\n PayPalOnShippingOptionsChangeData,\n PayPalOrderResponseBody\n} from './paypal-js-types';\n\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport CancelError from '../../core/Errors/CancelError';\nimport './Paypal.scss';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static readonly type = TxVariants.paypal;\n public static readonly subtype = 'sdk';\n\n public paymentData: string | null = null;\n\n private resolve: ((value: string) => void) | null = null;\n private reject: ((error?: Error) => void) | null = null;\n\n protected static readonly defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent | undefined = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\n };\n }\n\n protected override beforeRender(configSetByMerchant?: PayPalConfiguration) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.onActionHandled({ componentType: this.type, actionDescription: 'sdk-loaded', originalAction: action });\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private readonly handleOnApprove = (data: PayPalOnApproveData, actions: PayPalOnApproveActions): Promise<void> => {\n const { onAuthorized } = this.props;\n\n const details = Object.entries(data).reduce<Record<string, string | undefined>>((result, [key, value]) => {\n result[key] = value ?? undefined;\n return result;\n }, {});\n\n const state = { data: { details, paymentData: this.paymentData ?? undefined } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return Promise.resolve();\n }\n\n if (!actions.order) {\n this.handleError(new AdyenCheckoutError('ERROR', 'PayPal order actions are not available'));\n return Promise.resolve();\n }\n\n return actions.order\n .get()\n .then((paypalOrder: PayPalOrderResponseBody) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n const errorDetail = e instanceof Error ? e.message : JSON.stringify(e);\n const errorMessage = e ? `: ${errorDetail}` : '';\n this.handleReject(`${ERRORS.PAYMENT_FAILED}${errorMessage}`);\n });\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: PayPalOnShippingAddressChangeData, actions: PayPalOnShippingAddressChangeActions): Promise<void> {\n const { onShippingAddressChange } = this.props;\n\n if (!onShippingAddressChange) return Promise.resolve();\n\n return onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: PayPalOnShippingOptionsChangeData, actions: PayPalOnShippingOptionsChangeActions): Promise<void> {\n const { onShippingOptionsChange } = this.props;\n\n if (!onShippingOptionsChange) return Promise.resolve();\n\n return onShippingOptionsChange(data, actions, this);\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <PaypalComponent\n {...rest}\n setComponentRef={this.setComponentRef}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', String(error), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","_object_spread","commit","beforeRender","configSetByMerchant","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","this","configData","showPayButton","isExpress","expressPage","analytics","sendAnalytics","updatePaymentData","paymentData","console","warn","formatData","paymentMethod","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","Promise","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","setElementStatus","handleFailedResult","errorDetail","message","JSON","stringify","PAYMENT_FAILED","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","componentToRender","_this_props","rest","h","PaypalComponent","setComponentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","String","cause","onScriptLoadFailure","onSubmit","constructor","checkout","super","_define_property","submit","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","onActionHandled","componentType","actionDescription","originalAction","NO_TOKEN_PROVIDED","_this_paymentData","onAuthorized","state","details","Object","entries","reduce","result","key","undefined","order","get","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","bind","TxVariants","paypal","defaultProps"],"mappings":"4mEA2BA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACWA,IAAAA,EACMA,EACNA,EAFnB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E2DA,IAAAA,EAD9D,MAAMC,EAAiBC,EAAsCF,aAAAA,EAAAA,EAAaG,OACpEC,EAAkBF,EAAsCF,SAA2B,QAA3BA,EAAAA,EAAaK,0BAAbL,SAAAA,EAA8B,GAAGM,UAAU,GAQzG,OANApG,KAAKyD,SAASnE,EAAA,CACV+G,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,qBAGtB,IAAIvE,QAAc,CAACV,EAASO,IAC/B2D,EACI7F,EAAA,CACI+G,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,oBAE7B,CAAEjF,UAASO,cAItBK,KAAK,IAAM7B,KAAKsG,wBAAwBlB,IACxCnD,MAAM4B,GAAS7D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAE4C,MAAOF,OA5B7H7D,KAAKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CQ,QAAQV,YANfjB,KAAKsG,wBAAwBlB,GACtBzD,QAAQV,aA5GnBjB,KAAK0B,aAAe1B,KAAK0B,aAAa6E,KAAKvG,MAC3CA,KAAK2C,8BAAgC3C,KAAK2C,8BAA8B4D,KAAKvG,MAC7EA,KAAK+C,8BAAgC/C,KAAK+C,8BAA8BwD,KAAKvG,KACjF,EAfAqE,EADE7F,EACqBoB,OAAO4G,EAAWC,QACzCpC,EAFE7F,EAEqBqC,UAAU,OAOjCwD,EATE7F,EASwBkI,eAAeA"}
1
+ {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction, PaymentResponseData } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\nimport type {\n PayPalOnApproveActions,\n PayPalOnApproveData,\n PayPalOnShippingAddressChangeActions,\n PayPalOnShippingAddressChangeData,\n PayPalOnShippingOptionsChangeActions,\n PayPalOnShippingOptionsChangeData,\n PayPalOrderResponseBody\n} from './paypal-js-types';\n\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport CancelError from '../../core/Errors/CancelError';\nimport './Paypal.scss';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static readonly type = TxVariants.paypal;\n public static readonly subtype = 'sdk';\n\n public paymentData: string | null = null;\n\n private resolve: ((value: string) => void) | null = null;\n private reject: ((error?: Error) => void) | null = null;\n\n protected static readonly defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent | undefined = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\n };\n }\n\n protected override beforeRender(configSetByMerchant?: PayPalConfiguration) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.onActionHandled({ componentType: this.type, actionDescription: 'sdk-loaded', originalAction: action });\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private readonly handleOnApprove = (data: PayPalOnApproveData, actions: PayPalOnApproveActions): Promise<void> => {\n const { onAuthorized } = this.props;\n\n const details = Object.entries(data).reduce<Record<string, string | undefined>>((result, [key, value]) => {\n result[key] = value ?? undefined;\n return result;\n }, {});\n\n const state = { data: { details, paymentData: this.paymentData ?? undefined } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return Promise.resolve();\n }\n\n if (!actions.order) {\n this.handleError(new AdyenCheckoutError('ERROR', 'PayPal order actions are not available'));\n return Promise.resolve();\n }\n\n return actions.order\n .get()\n .then((paypalOrder: PayPalOrderResponseBody) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<string> {\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n\n this.makePaymentsCall()\n ?.then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n const errorDetail = e instanceof Error ? e.message : JSON.stringify(e);\n const errorMessage = e ? `: ${errorDetail}` : '';\n this.handleReject(`${ERRORS.PAYMENT_FAILED}${errorMessage}`);\n });\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: PayPalOnShippingAddressChangeData, actions: PayPalOnShippingAddressChangeActions): Promise<void> {\n const { onShippingAddressChange } = this.props;\n\n if (!onShippingAddressChange) return Promise.resolve();\n\n return onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: PayPalOnShippingOptionsChangeData, actions: PayPalOnShippingOptionsChangeActions): Promise<void> {\n const { onShippingOptionsChange } = this.props;\n\n if (!onShippingOptionsChange) return Promise.resolve();\n\n return onShippingOptionsChange(data, actions, this);\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <PaypalComponent\n {...rest}\n setComponentRef={this.setComponentRef}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', String(error), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","_object_spread","commit","beforeRender","configSetByMerchant","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","this","configData","showPayButton","isExpress","expressPage","analytics","sendAnalytics","updatePaymentData","paymentData","console","warn","formatData","paymentMethod","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","Promise","_this_makePaymentsCall","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","setElementStatus","handleFailedResult","errorDetail","message","JSON","stringify","PAYMENT_FAILED","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","componentToRender","_this_props","rest","h","PaypalComponent","setComponentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","String","cause","onScriptLoadFailure","onSubmit","constructor","checkout","super","_define_property","submit","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","onActionHandled","componentType","actionDescription","originalAction","NO_TOKEN_PROVIDED","_this_paymentData","onAuthorized","state","details","Object","entries","reduce","result","key","undefined","order","get","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","bind","TxVariants","paypal","defaultProps"],"mappings":"4mEA2BA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACWA,IAAAA,EACMA,EACNA,EAFnB,MAAMC,EAAgC,QAAnBD,EAAAA,EAAME,qBAANF,IAAAA,SAAAA,EAAqBC,WAClCE,EAAsC,QAAnBH,EAAAA,EAAME,qBAANF,IAAAA,SAAAA,EAAqBI,OAExCA,EADqC,KAAZ,QAAZJ,EAAAA,EAAMK,cAANL,IAAAA,OAAAA,EAAAA,EAAcM,OACe,WAAaN,EAAMI,QAAUD,EACvEI,EAAmB,aAAXH,GAAyBJ,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,OAAOC,EAAAC,EAAA,CAAA,EACAX,GAAAA,CACHY,QAAQJ,GAA4CR,EAAMY,OAC1DL,QACAL,cAAe,CACXE,SACAH,eAGZ,CAEmBY,YAAAA,CAAaC,GAC5B,MAAMC,EAAQ,IAAIC,EAAmBL,EAAA,CACjCM,KAAMC,EAAcC,SACpBC,UAAWC,KAAKJ,KAChBK,WAAYZ,EAAAC,EAAA,CAAA,EAAKG,GA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AKkB,YAAY,IAAIC,EAAmB,QAAS,2CAC1CQ,QAAQV,YANfjB,KAAKuG,wBAAwBlB,GACtB1D,QAAQV,aA5GnBjB,KAAK0B,aAAe1B,KAAK0B,aAAa8E,KAAKxG,MAC3CA,KAAK4C,8BAAgC5C,KAAK4C,8BAA8B4D,KAAKxG,MAC7EA,KAAKgD,8BAAgChD,KAAKgD,8BAA8BwD,KAAKxG,KACjF,EAfAsE,EADE9F,EACqBoB,OAAO6G,EAAWC,QACzCpC,EAFE9F,EAEqBqC,UAAU,OAOjCyD,EATE9F,EASwBmI,eAAeA"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-paypal-locale.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-locale.ts"],"sourcesContent":["import { SUPPORTED_LOCALES } from '../config';\nimport type { PayPalSupportedLocale } from './types';\n\n/**\n * Returns either a locale supported by PayPal or null, in order to let the PayPal SDK auto-detect the shopper locale.\n */\nexport const getSupportedLocale = (locale: string): PayPalSupportedLocale => {\n const formattedLocale = locale ? locale.replace('-', '_') : null;\n const supportedLocale = SUPPORTED_LOCALES.includes(formattedLocale as PayPalSupportedLocale) ? formattedLocale : null;\n return supportedLocale as PayPalSupportedLocale;\n};\n"],"names":["getSupportedLocale","locale","formattedLocale","replace","SUPPORTED_LOCALES","includes"],"mappings":"iDAMO,MAAMA,EAAsBC,IAC/B,MAAMC,EAAkBD,EAASA,EAAOE,QAAQ,IAAK,KAAO,KAE5D,OADwBC,EAAkBC,SAASH,GAA4CA,EAAkB"}
1
+ {"version":3,"file":"get-paypal-locale.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-locale.ts"],"sourcesContent":["import { SUPPORTED_LOCALES } from '../config';\nimport type { PayPalSupportedLocale } from './types';\n\n/**\n * Returns either a locale supported by PayPal or null, in order to let the PayPal SDK auto-detect the shopper locale.\n */\nexport const getSupportedLocale = (locale?: string): PayPalSupportedLocale => {\n const formattedLocale = locale ? locale.replace('-', '_') : null;\n const supportedLocale = SUPPORTED_LOCALES.includes(formattedLocale as PayPalSupportedLocale) ? formattedLocale : null;\n return supportedLocale as PayPalSupportedLocale;\n};\n"],"names":["getSupportedLocale","locale","formattedLocale","replace","SUPPORTED_LOCALES","includes"],"mappings":"iDAMO,MAAMA,EAAsBC,IAC/B,MAAMC,EAAkBD,EAASA,EAAOE,QAAQ,IAAK,KAAO,KAE5D,OADwBC,EAAkBC,SAASH,GAA4CA,EAAkB"}
@@ -1,2 +1,2 @@
1
- import{getSupportedLocale as e}from"./get-paypal-locale.js";import{INTEGRATION_DATE as t,ADYEN_CLIENTID_TEST as n,ADYEN_CLIENTID_LIVE as r}from"../config.js";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const i=({amount:i,countryCode:u,debug:a,environment:l="",locale:b,configuration:s,commit:p,vault:y,enableMessages:f})=>{const O=e(b),g=i?i.currency:null,m="test"===l.toLowerCase(),j=m?n:r,{merchantId:d,intent:P}=s,w="buttons,funding-eligibility"+(f?",messages":"");return c(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o(e,t,n[t])})}return e}({},d&&{"merchant-id":d},O&&{locale:O},u&&m&&{"buyer-country":u},a&&m&&{debug:a},g&&{currency:g},P&&{intent:P}),{commit:p,vault:y,"client-id":j,"integration-date":t,"enable-funding":"paylater,venmo",components:w})};export{i as getPaypalSettings};
1
+ import{getSupportedLocale as e}from"./get-paypal-locale.js";import{INTEGRATION_DATE as t,ADYEN_CLIENTID_TEST as n,ADYEN_CLIENTID_LIVE as r}from"../config.js";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const i=({amount:i,countryCode:u,debug:a,environment:l="",locale:b,configuration:s={},commit:p,vault:y,enableMessages:f})=>{const O=e(b),g=i?i.currency:null,m="test"===l.toLowerCase(),j=m?n:r,{merchantId:d,intent:P}=s,w="buttons,funding-eligibility"+(f?",messages":"");return c(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o(e,t,n[t])})}return e}({},d&&{"merchant-id":d},O&&{locale:O},u&&m&&{"buyer-country":u},a&&m&&{debug:a},g&&{currency:g},P&&{intent:P}),{commit:p,vault:y,"client-id":j,"integration-date":t,"enable-funding":"paylater,venmo",components:w})};export{i as getPaypalSettings};
2
2
  //# sourceMappingURL=get-paypal-settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-paypal-settings.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-settings.ts"],"sourcesContent":["import { getSupportedLocale } from './get-paypal-locale';\nimport { ADYEN_CLIENTID_LIVE, ADYEN_CLIENTID_TEST, INTEGRATION_DATE } from '../config';\nimport type { PaypalSettings, PayPalSupportedLocale } from './types';\nimport type { PayPalComponentProps } from '../components/types';\n\n/**\n * Returns an object of settings for the PayPal SDK\n */\nexport const getPaypalSettings = ({\n amount,\n countryCode,\n debug,\n environment = '',\n locale,\n configuration,\n commit,\n vault,\n enableMessages\n}: Partial<PayPalComponentProps>): PaypalSettings => {\n const shopperLocale: PayPalSupportedLocale = getSupportedLocale(locale);\n const currency: string = amount ? amount.currency : null;\n const isTestEnvironment: boolean = environment.toLowerCase() === 'test';\n const clientId: string = isTestEnvironment ? ADYEN_CLIENTID_TEST : ADYEN_CLIENTID_LIVE;\n const { merchantId, intent } = configuration;\n const components = `buttons,funding-eligibility${enableMessages ? ',messages' : ''}`;\n\n return {\n ...(merchantId && { 'merchant-id': merchantId }),\n ...(shopperLocale && { locale: shopperLocale }),\n ...(countryCode && isTestEnvironment && { 'buyer-country': countryCode }),\n ...(debug && isTestEnvironment && { debug }),\n ...(currency && { currency }),\n ...(intent && { intent }),\n commit,\n vault,\n 'client-id': clientId,\n 'integration-date': INTEGRATION_DATE,\n 'enable-funding': 'paylater,venmo',\n components\n };\n};\n"],"names":["getPaypalSettings","amount","countryCode","debug","environment","locale","configuration","commit","vault","enableMessages","shopperLocale","getSupportedLocale","currency","isTestEnvironment","toLowerCase","clientId","ADYEN_CLIENTID_TEST","ADYEN_CLIENTID_LIVE","merchantId","intent","components","_object_spread_props","INTEGRATION_DATE"],"mappings":"yoBAQaA,EAAoB,EAC7BC,SACAC,cACAC,QACAC,cAAc,GACdC,SACAC,gBACAC,SACAC,QACAC,qBAEA,MAAMC,EAAuCC,EAAmBN,GAC1DO,EAAmBX,EAASA,EAAOW,SAAW,KAC9CC,EAA2D,SAA9BT,EAAYU,cACzCC,EAAmBF,EAAoBG,EAAsBC,GAC7DC,WAAEA,EAAUC,OAAEA,GAAWb,EACzBc,EAAa,+BAA8BX,EAAiB,YAAc,IAEhF,OAAOY,wUACCH,GAAc,CAAE,cAAeA,GAC/BR,GAAiB,CAAEL,OAAQK,GAC3BR,GAAeW,GAAqB,CAAE,gBAAiBX,GACvDC,GAASU,GAAqB,CAAEV,SAChCS,GAAY,CAAEA,YACdO,GAAU,CAAEA,WAAO,CACvBZ,SACAC,QACA,YAAaO,EACb,mBAAoBO,EACpB,iBAAkB,iBAClBF"}
1
+ {"version":3,"file":"get-paypal-settings.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-settings.ts"],"sourcesContent":["import { getSupportedLocale } from './get-paypal-locale';\nimport { ADYEN_CLIENTID_LIVE, ADYEN_CLIENTID_TEST, INTEGRATION_DATE } from '../config';\nimport type { PaypalSettings, PayPalSupportedLocale } from './types';\nimport type { PayPalComponentProps } from '../components/types';\n\n/**\n * Returns an object of settings for the PayPal SDK\n */\nexport const getPaypalSettings = ({\n amount,\n countryCode,\n debug,\n environment = '',\n locale,\n configuration = {},\n commit,\n vault,\n enableMessages\n}: Partial<PayPalComponentProps>): PaypalSettings => {\n const shopperLocale: PayPalSupportedLocale = getSupportedLocale(locale);\n const currency: string | null = amount ? amount.currency : null;\n const isTestEnvironment: boolean = environment.toLowerCase() === 'test';\n const clientId: string = isTestEnvironment ? ADYEN_CLIENTID_TEST : ADYEN_CLIENTID_LIVE;\n const { merchantId, intent } = configuration;\n const components = `buttons,funding-eligibility${enableMessages ? ',messages' : ''}`;\n\n return {\n ...(merchantId && { 'merchant-id': merchantId }),\n ...(shopperLocale && { locale: shopperLocale }),\n ...(countryCode && isTestEnvironment && { 'buyer-country': countryCode }),\n ...(debug && isTestEnvironment && { debug }),\n ...(currency && { currency }),\n ...(intent && { intent }),\n commit,\n vault,\n 'client-id': clientId,\n 'integration-date': INTEGRATION_DATE,\n 'enable-funding': 'paylater,venmo',\n components\n };\n};\n"],"names":["getPaypalSettings","amount","countryCode","debug","environment","locale","configuration","commit","vault","enableMessages","shopperLocale","getSupportedLocale","currency","isTestEnvironment","toLowerCase","clientId","ADYEN_CLIENTID_TEST","ADYEN_CLIENTID_LIVE","merchantId","intent","components","_object_spread_props","INTEGRATION_DATE"],"mappings":"moBAQO,MAAMA,EAAoB,EAC7BC,SACAC,cACAC,QACAC,cAAc,GACdC,SACAC,gBAAgB,CAAA,EAChBC,SACAC,QACAC,qBAEA,MAAMC,EAAuCC,EAAmBN,GAC1DO,EAA0BX,EAASA,EAAOW,SAAW,KACrDC,EAA2D,SAA9BT,EAAYU,cACzCC,EAAmBF,EAAoBG,EAAsBC,GAC7DC,WAAEA,EAAUC,OAAEA,GAAWb,EACzBc,EAAa,+BAA8BX,EAAiB,YAAc,IAEhF,OAAOY,wUACCH,GAAc,CAAE,cAAeA,GAC/BR,GAAiB,CAAEL,OAAQK,GAC3BR,GAAeW,GAAqB,CAAE,gBAAiBX,GACvDC,GAASU,GAAqB,CAAEV,SAChCS,GAAY,CAAEA,YACdO,GAAU,CAAEA,WAAO,CACvBZ,SACAC,QACA,YAAaO,EACb,mBAAoBO,EACpB,iBAAkB,iBAClBF"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import{TxVariants as r}from"../tx-variants.js";import s from"./components/FastlaneComponent.js";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class o extends t{formatData(){return{paymentMethod:{type:o.type,fastlaneData:btoa(JSON.stringify({fastlaneSessionId:this.props.fastlaneSessionId,tokenId:this.props.tokenId}))}}}beforeRender(){super.beforeRender()}async isAvailable(){const{tokenId:e,lastFour:t,brand:r,email:s}=this.props;return e&&t&&r&&s?Promise.resolve():Promise.reject()}get isValid(){return!0}get icon(){var e;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()("card")}get brands(){const{brands:e}=this.props;return e.map(e=>({icon:this.props.modules.resources.getImage()(e),name:e}))}componentToRender(){return e(s,{lastFour:this.props.lastFour,brand:this.props.brand,payButton:this.payButton,setComponentRef:this.setComponentRef})}}n(o,"type",r.fastlane),n(o,"defaultProps",{keepBrandsVisible:!0});export{o as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import{TxVariants as r}from"../tx-variants.js";import s from"./components/FastlaneComponent.js";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class o extends t{formatData(){return{paymentMethod:{type:o.type,fastlaneData:btoa(JSON.stringify({fastlaneSessionId:this.props.fastlaneSessionId,tokenId:this.props.tokenId}))}}}beforeRender(){super.beforeRender()}async isAvailable(){const{tokenId:e,lastFour:t,brand:r,email:s}=this.props;return e&&t&&r&&s?Promise.resolve():Promise.reject()}get isValid(){return!0}get icon(){var e;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()("card")}get brands(){const{brands:e=[]}=this.props;return e.map(e=>({icon:this.resources.getImage()(e),name:e}))}componentToRender(){return e(s,{lastFour:this.props.lastFour,brand:this.props.brand,payButton:this.payButton,setComponentRef:this.setComponentRef})}}n(o,"type",r.fastlane),n(o,"defaultProps",{keepBrandsVisible:!0});export{o as default};
2
2
  //# sourceMappingURL=Fastlane.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Fastlane.js","sources":["../../../../src/components/PayPalFastlane/Fastlane.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement';\nimport { TxVariants } from '../tx-variants';\nimport FastlaneComponent from './components/FastlaneComponent';\nimport type { FastlaneConfiguration } from './types';\nimport { PaymentMethodBrand } from '../../types/global-types';\n\nclass Fastlane extends UIElement<FastlaneConfiguration> {\n public static readonly type = TxVariants.fastlane;\n\n protected static readonly defaultProps = {\n keepBrandsVisible: true\n };\n\n protected override formatData() {\n return {\n paymentMethod: {\n type: Fastlane.type,\n fastlaneData: btoa(\n JSON.stringify({\n fastlaneSessionId: this.props.fastlaneSessionId,\n tokenId: this.props.tokenId\n })\n )\n }\n };\n }\n\n /**\n *\n * Fastlane works differently than other payment methods: Merchant needs to pass to the payment method\n * configuration the values received from PayPal SDK to perform the payment (tokenId, etc). There is no\n * point in tracking these values, so we just omit them all in the analytics by calling the\n * 'beforeRender' without the props\n *\n * @protected\n */\n protected override beforeRender() {\n super.beforeRender();\n }\n\n public override async isAvailable(): Promise<void> {\n const { tokenId, lastFour, brand, email } = this.props;\n if (tokenId && lastFour && brand && email) {\n return Promise.resolve();\n }\n return Promise.reject();\n }\n\n public override get isValid(): boolean {\n return true;\n }\n\n /**\n * Used to display payment method logo within Drop-in\n */\n public override get icon(): string {\n return this.props.icon ?? this.resources.getImage()('card');\n }\n\n /**\n * Used to display the payment method supported brands within Drop-in\n */\n public get brands(): PaymentMethodBrand[] {\n const { brands } = this.props;\n return brands.map(brand => ({ icon: this.props.modules.resources.getImage()(brand), name: brand }));\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <FastlaneComponent\n lastFour={this.props.lastFour}\n brand={this.props.brand}\n payButton={this.payButton}\n setComponentRef={this.setComponentRef}\n />\n );\n }\n}\n\nexport default Fastlane;\n"],"names":["Fastlane","UIElement","formatData","paymentMethod","type","fastlaneData","btoa","JSON","stringify","fastlaneSessionId","this","props","tokenId","beforeRender","super","isAvailable","lastFour","brand","email","Promise","resolve","reject","isValid","icon","_this_props_icon","resources","getImage","brands","map","modules","name","componentToRender","h","FastlaneComponent","payButton","setComponentRef","_define_property","TxVariants","fastlane","defaultProps","keepBrandsVisible"],"mappings":"4VAOA,MAAMA,UAAiBC,EAOAC,UAAAA,GACf,MAAO,CACHC,cAAe,CACXC,KAAMJ,EAASI,KACfC,aAAcC,KACVC,KAAKC,UAAU,CACXC,kBAAmBC,KAAKC,MAAMF,kBAC9BG,QAASF,KAAKC,MAAMC,YAKxC,CAWA,YAAAC,GACIC,MAAMD,cACV,CAEA,iBAAsBE,GAClB,MAAMH,QAAEA,EAAOI,SAAEA,EAAQC,MAAEA,EAAKC,MAAEA,GAAUR,KAAKC,MACjD,OAAIC,GAAWI,GAAYC,GAASC,EACzBC,QAAQC,UAEZD,QAAQE,QACnB,CAEA,WAAoBC,GAChB,OAAO,CACX,CAKA,QAAoBC,GACT,IAAAC,EAAP,OAAsB,QAAfA,EAAAd,KAAKC,MAAMY,YAAX,IAAAC,EAAAA,EAAmBd,KAAKe,UAAUC,UAAfhB,CAA0B,OACxD,CAKA,UAAWiB,GACP,MAAMA,OAAEA,GAAWjB,KAAKC,MACxB,OAAOgB,EAAOC,IAAIX,KAAYM,KAAMb,KAAKC,MAAMkB,QAAQJ,UAAUC,UAA7BhB,CAAwCO,GAAQa,KAAMb,IAC9F,CAEmBc,iBAAAA,GACf,OACIC,EAACC,EAAAA,CACGjB,SAAUN,KAAKC,MAAMK,SACrBC,MAAOP,KAAKC,MAAMM,MAClBiB,UAAWxB,KAAKwB,UAChBC,gBAAiBzB,KAAKyB,iBAGlC,EArEAC,EADEpC,EACqBI,OAAOiC,EAAWC,UAEzCF,EAHEpC,EAGwBuC,eAAe,CACrCC,mBAAmB"}
1
+ {"version":3,"file":"Fastlane.js","sources":["../../../../src/components/PayPalFastlane/Fastlane.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement';\nimport { TxVariants } from '../tx-variants';\nimport FastlaneComponent from './components/FastlaneComponent';\nimport type { FastlaneConfiguration } from './types';\nimport { PaymentMethodBrand } from '../../types/global-types';\n\nclass Fastlane extends UIElement<FastlaneConfiguration> {\n public static readonly type = TxVariants.fastlane;\n\n protected static readonly defaultProps = {\n keepBrandsVisible: true\n };\n\n protected override formatData() {\n return {\n paymentMethod: {\n type: Fastlane.type,\n fastlaneData: btoa(\n JSON.stringify({\n fastlaneSessionId: this.props.fastlaneSessionId,\n tokenId: this.props.tokenId\n })\n )\n }\n };\n }\n\n /**\n *\n * Fastlane works differently than other payment methods: Merchant needs to pass to the payment method\n * configuration the values received from PayPal SDK to perform the payment (tokenId, etc). There is no\n * point in tracking these values, so we just omit them all in the analytics by calling the\n * 'beforeRender' without the props\n *\n * @protected\n */\n protected override beforeRender() {\n super.beforeRender();\n }\n\n public override async isAvailable(): Promise<void> {\n const { tokenId, lastFour, brand, email } = this.props;\n if (tokenId && lastFour && brand && email) {\n return Promise.resolve();\n }\n return Promise.reject();\n }\n\n public override get isValid(): boolean {\n return true;\n }\n\n /**\n * Used to display payment method logo within Drop-in\n */\n public override get icon(): string {\n return this.props.icon ?? this.resources.getImage()('card');\n }\n\n /**\n * Used to display the payment method supported brands within Drop-in\n */\n public get brands(): PaymentMethodBrand[] {\n const { brands = [] } = this.props;\n return brands.map(brand => ({ icon: this.resources.getImage()(brand), name: brand }));\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <FastlaneComponent\n lastFour={this.props.lastFour}\n brand={this.props.brand}\n payButton={this.payButton}\n setComponentRef={this.setComponentRef}\n />\n );\n }\n}\n\nexport default Fastlane;\n"],"names":["Fastlane","UIElement","formatData","paymentMethod","type","fastlaneData","btoa","JSON","stringify","fastlaneSessionId","this","props","tokenId","beforeRender","super","isAvailable","lastFour","brand","email","Promise","resolve","reject","isValid","icon","_this_props_icon","resources","getImage","brands","map","name","componentToRender","h","FastlaneComponent","payButton","setComponentRef","_define_property","TxVariants","fastlane","defaultProps","keepBrandsVisible"],"mappings":"4VAOA,MAAMA,UAAiBC,EAOAC,UAAAA,GACf,MAAO,CACHC,cAAe,CACXC,KAAMJ,EAASI,KACfC,aAAcC,KACVC,KAAKC,UAAU,CACXC,kBAAmBC,KAAKC,MAAMF,kBAC9BG,QAASF,KAAKC,MAAMC,YAKxC,CAWA,YAAAC,GACIC,MAAMD,cACV,CAEA,iBAAsBE,GAClB,MAAMH,QAAEA,EAAOI,SAAEA,EAAQC,MAAEA,EAAKC,MAAEA,GAAUR,KAAKC,MACjD,OAAIC,GAAWI,GAAYC,GAASC,EACzBC,QAAQC,UAEZD,QAAQE,QACnB,CAEA,WAAoBC,GAChB,OAAO,CACX,CAKA,QAAoBC,GACT,IAAAC,EAAP,OAAsB,QAAfA,EAAAd,KAAKC,MAAMY,YAAX,IAAAC,EAAAA,EAAmBd,KAAKe,UAAUC,UAAfhB,CAA0B,OACxD,CAKA,UAAWiB,GACP,MAAMA,OAAEA,EAAS,IAAOjB,KAAKC,MAC7B,OAAOgB,EAAOC,IAAIX,KAAYM,KAAMb,KAAKe,UAAUC,UAAfhB,CAA0BO,GAAQY,KAAMZ,IAChF,CAEmBa,iBAAAA,GACf,OACIC,EAACC,EAAAA,CACGhB,SAAUN,KAAKC,MAAMK,SACrBC,MAAOP,KAAKC,MAAMM,MAClBgB,UAAWvB,KAAKuB,UAChBC,gBAAiBxB,KAAKwB,iBAGlC,EArEAC,EADEnC,EACqBI,OAAOgC,EAAWC,UAEzCF,EAHEnC,EAGwBsC,eAAe,CACrCC,mBAAmB"}
@@ -1,2 +1,2 @@
1
- import{resolveEnvironments as t}from"../../core/Environment/Environment.js";import e from"./services/request-fastlane-token.js";import{convertAdyenLocaleToFastlaneLocale as n}from"./utils/convert-locale.js";import a from"../../utils/Script.js";import i from"../../core/Errors/AdyenCheckoutError.js";import s from"../../core/Analytics/Analytics.js";import{InfoEventType as o,AnalyticsInfoEvent as r}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsEventQueue as c}from"../../core/Analytics/AnalyticsEventQueue.js";import{AnalyticsService as l}from"../../core/Analytics/AnalyticsService.js";function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),a.forEach(function(e){h(t,e,n[e])})}return t}class u{async initialize(){this.analytics.setUp({checkoutStage:"precheckout"});const t=await this.requestClientToken();return await this.fetchSdk(t.value,t.clientId),await this.initializeFastlaneInstance(),this.trackEvent(o.Initialized),this}destroy(){document.removeEventListener("visibilitychange",this.handlePageVisibilityChanges),this.analytics.flush()}async authenticate(t){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","authenticate(): Fastlane SDK is not initialized");this.trackEvent(o.LookupStarted);try{const{customerContextId:e}=await this.fastlaneSdk.identity.lookupCustomerByEmail(t);if(e){this.latestShopperDetails={email:t,customerId:e},this.trackEvent(o.OtpStarted);const n=await this.fastlaneSdk.identity.triggerAuthenticationFlow(e);return this.trackEvent(this.getOtpAnalyticsSubtype(n.authenticationState)),n}return this.trackEvent(o.LookupUserNotFound),{authenticationState:"not_found",profileData:void 0}}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred during the authentication flow.",{cause:t})}}async getComponentConfiguration(t){var e,n;if(!t)throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: you must pass the authentication result to get the component configuration");this.analytics.flush();const a="succeeded"===t.authenticationState,s=!!(null===(e=t.profileData)||void 0===e?void 0:e.card),o=!!(null===(n=this.latestShopperDetails)||void 0===n?void 0:n.email);return a&&s&&o?this.createFastlaneComponentConfiguration(t):this.createCardComponentConfiguration()}async showShippingAddressSelector(){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","showShippingAddressSelector(): Fastlane SDK is not initialized");this.trackEvent(o.AddressSelectorClicked);try{const t=await this.fastlaneSdk.profile.showShippingAddressSelector();return t.selectionChanged&&this.trackEvent(o.AddressChanged),this.trackEvent(o.AddressSelectorClosed),t}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred when showing the shipping address selector",{cause:t})}}async mountWatermark(t,e={includeAdditionalInfo:!0}){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","mountWatermark(): Fastlane SDK is not initialized");try{(await this.fastlaneSdk.FastlaneWatermarkComponent(e)).render(t)}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred when rendering the watermark",{cause:t})}}requestClientToken(){return e(this.checkoutShopperURL,this.clientKey)}async fetchSdk(t,e){const n=new URL("https://www.paypal.com/sdk/js");n.searchParams.set("client-id",e),n.searchParams.set("components","buttons,fastlane");const i=new a({src:n.href,component:"fastlane",dataAttributes:{sdkClientToken:t},analytics:this.analytics});await i.load()}async fetchSessionIdAsync(){try{const{sessionId:t}=await this.fastlaneSdk.identity.getSession();this.fastlaneSessionId=t}catch(t){console.warn("Fastlane SDK: Failed to fetch session ID",t)}}async fetchConsentDetails(){try{const t=await this.fastlaneSdk.ConsentComponent();return await t.getRenderState()}catch(t){throw new i("ERROR","fetchConsentDetails(): failed to fetch consent details",{cause:t})}}async initializeFastlaneInstance(){try{this.fastlaneSdk=await window.paypal.Fastlane(d({intendedExperience:"externalProcessorCustomConsent"},this.forceConsentDetails&&{metadata:{geoLocOverride:"US"}})),this.fastlaneSdk.setLocale(this.fastlaneLocale),this.fetchSessionIdAsync()}catch(t){throw new i("ERROR","Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor",{cause:t})}}createFastlaneComponentConfiguration(t){return{paymentType:"fastlane",configuration:{fastlaneSessionId:this.fastlaneSessionId,email:this.latestShopperDetails.email,tokenId:t.profileData.card.id,lastFour:t.profileData.card.paymentSource.card.lastDigits,brand:t.profileData.card.paymentSource.card.brand.toLowerCase()}}}async createCardComponentConfiguration(){const t=await this.fetchConsentDetails(),e={};return t&&(e.fastlaneConfiguration=d({fastlaneSessionId:this.fastlaneSessionId},t)),{paymentType:"card",configuration:e}}trackEvent(t){const e=new r({type:t,component:"fastlane"});this.analytics.sendAnalytics(e)}getOtpAnalyticsSubtype(t){switch(t){case"succeeded":return o.OtpSucceeded;case"canceled":return o.OtpCanceled;case"failed":default:return o.OtpFailed;case"not_found":return o.LookupUserNotFound}}constructor(e){var a;if(h(this,"clientKey",void 0),h(this,"checkoutShopperURL",void 0),h(this,"fastlaneLocale",void 0),h(this,"forceConsentDetails",void 0),h(this,"analytics",void 0),h(this,"fastlaneSdk",void 0),h(this,"latestShopperDetails",void 0),h(this,"fastlaneSessionId",void 0),h(this,"handlePageVisibilityChanges",()=>{"hidden"===document.visibilityState&&this.analytics.flush()}),!(null==e?void 0:e.environment))throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: 'environment' property is required");if(!(null==e?void 0:e.clientKey))throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: 'clientKey' property is required");e.forceConsentDetails&&e.environment.includes("live")&&console.warn("Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment");const{apiUrl:o,analyticsUrl:r}=t(e.environment);this.checkoutShopperURL=o,this.clientKey=e.clientKey,this.forceConsentDetails=e.forceConsentDetails||!1,this.fastlaneLocale=n(e.locale||"en-US"),this.analytics=new s({eventQueue:new c,service:new l({analyticsContext:r,clientKey:this.clientKey}),enabled:null===(a=e.analytics)||void 0===a?void 0:a.enabled}),document.addEventListener("visibilitychange",this.handlePageVisibilityChanges)}}export{u as default};
1
+ import{resolveEnvironments as t}from"../../core/Environment/Environment.js";import e from"./services/request-fastlane-token.js";import{convertAdyenLocaleToFastlaneLocale as n}from"./utils/convert-locale.js";import a from"../../utils/Script.js";import i from"../../core/Errors/AdyenCheckoutError.js";import s from"../../core/Analytics/Analytics.js";import{InfoEventType as o,AnalyticsInfoEvent as r}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsEventQueue as c}from"../../core/Analytics/AnalyticsEventQueue.js";import{AnalyticsService as l}from"../../core/Analytics/AnalyticsService.js";function d(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),a.forEach(function(e){d(t,e,n[e])})}return t}class u{async initialize(){this.analytics.setUp({checkoutStage:"precheckout"});const t=await this.requestClientToken();return await this.fetchSdk(t.value,t.clientId),await this.initializeFastlaneInstance(),this.trackEvent(o.Initialized),this}destroy(){document.removeEventListener("visibilitychange",this.handlePageVisibilityChanges),this.analytics.flush()}async authenticate(t){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","authenticate(): Fastlane SDK is not initialized");this.trackEvent(o.LookupStarted);try{const{customerContextId:e}=await this.fastlaneSdk.identity.lookupCustomerByEmail(t);if(e){this.latestShopperDetails={email:t,customerId:e},this.trackEvent(o.OtpStarted);const n=await this.fastlaneSdk.identity.triggerAuthenticationFlow(e);return this.trackEvent(this.getOtpAnalyticsSubtype(n.authenticationState)),n}return this.trackEvent(o.LookupUserNotFound),{authenticationState:"not_found",profileData:void 0}}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred during the authentication flow.",{cause:t})}}async getComponentConfiguration(t){var e,n;if(!t)throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: you must pass the authentication result to get the component configuration");this.analytics.flush();const a="succeeded"===t.authenticationState?null===(e=t.profileData)||void 0===e?void 0:e.card:void 0,s=null===(n=this.latestShopperDetails)||void 0===n?void 0:n.email;return a&&s?this.createFastlaneComponentConfiguration(a,s):this.createCardComponentConfiguration()}async showShippingAddressSelector(){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","showShippingAddressSelector(): Fastlane SDK is not initialized");this.trackEvent(o.AddressSelectorClicked);try{const t=await this.fastlaneSdk.profile.showShippingAddressSelector();return t.selectionChanged&&this.trackEvent(o.AddressChanged),this.trackEvent(o.AddressSelectorClosed),t}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred when showing the shipping address selector",{cause:t})}}async mountWatermark(t,e={includeAdditionalInfo:!0}){if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","mountWatermark(): Fastlane SDK is not initialized");try{(await this.fastlaneSdk.FastlaneWatermarkComponent(e)).render(t)}catch(t){throw new i("ERROR","Fastlane SDK: An error occurred when rendering the watermark",{cause:t})}}requestClientToken(){return e(this.checkoutShopperURL,this.clientKey)}async fetchSdk(t,e){const n=new URL("https://www.paypal.com/sdk/js");n.searchParams.set("client-id",e),n.searchParams.set("components","buttons,fastlane");const i=new a({src:n.href,component:"fastlane",dataAttributes:{sdkClientToken:t},analytics:this.analytics});await i.load()}async fetchSessionIdAsync(){try{if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","fetchSessionIdAsync(): Fastlane SDK is not initialized");const{sessionId:t}=await this.fastlaneSdk.identity.getSession();this.fastlaneSessionId=t}catch(t){console.warn("Fastlane SDK: Failed to fetch session ID",t)}}async fetchConsentDetails(){try{if(!this.fastlaneSdk)throw new i("IMPLEMENTATION_ERROR","fetchConsentDetails(): Fastlane SDK is not initialized");const t=await this.fastlaneSdk.ConsentComponent();return await t.getRenderState()}catch(t){throw new i("ERROR","fetchConsentDetails(): failed to fetch consent details",{cause:t})}}async initializeFastlaneInstance(){try{const{paypal:t}=window;if(!(null==t?void 0:t.Fastlane))throw new i("ERROR","Fastlane SDK: window.paypal.Fastlane is not available");this.fastlaneSdk=await t.Fastlane(h({intendedExperience:"externalProcessorCustomConsent"},this.forceConsentDetails&&{metadata:{geoLocOverride:"US"}})),this.fastlaneSdk.setLocale(this.fastlaneLocale),this.fetchSessionIdAsync()}catch(t){throw new i("ERROR","Fastlane SDK: Failed to initialize fastlane using the window.paypal.Fastlane constructor",{cause:t})}}createFastlaneComponentConfiguration(t,e){var n;return{paymentType:"fastlane",configuration:{fastlaneSessionId:null!==(n=this.fastlaneSessionId)&&void 0!==n?n:"",email:e,tokenId:t.id,lastFour:t.paymentSource.card.lastDigits,brand:t.paymentSource.card.brand.toLowerCase()}}}async createCardComponentConfiguration(){const t=await this.fetchConsentDetails(),e={};return t&&(e.fastlaneConfiguration=h({fastlaneSessionId:this.fastlaneSessionId},t)),{paymentType:"card",configuration:e}}trackEvent(t){const e=new r({type:t,component:"fastlane"});this.analytics.sendAnalytics(e)}getOtpAnalyticsSubtype(t){switch(t){case"succeeded":return o.OtpSucceeded;case"canceled":return o.OtpCanceled;case"failed":default:return o.OtpFailed;case"not_found":return o.LookupUserNotFound}}constructor(e){var a;if(d(this,"clientKey",void 0),d(this,"checkoutShopperURL",void 0),d(this,"fastlaneLocale",void 0),d(this,"forceConsentDetails",void 0),d(this,"analytics",void 0),d(this,"fastlaneSdk",void 0),d(this,"latestShopperDetails",void 0),d(this,"fastlaneSessionId",void 0),d(this,"handlePageVisibilityChanges",()=>{"hidden"===document.visibilityState&&this.analytics.flush()}),!(null==e?void 0:e.environment))throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: 'environment' property is required");if(!(null==e?void 0:e.clientKey))throw new i("IMPLEMENTATION_ERROR","FastlaneSDK: 'clientKey' property is required");e.forceConsentDetails&&e.environment.includes("live")&&console.warn("Fastlane SDK: 'forceConsentDetails' should not be used on 'live' environment");const{apiUrl:o,analyticsUrl:r}=t(e.environment);this.checkoutShopperURL=o,this.clientKey=e.clientKey,this.forceConsentDetails=e.forceConsentDetails||!1,this.fastlaneLocale=n(e.locale||"en-US"),this.analytics=new s({eventQueue:new c,service:new l({analyticsContext:r,clientKey:this.clientKey}),enabled:null===(a=e.analytics)||void 0===a?void 0:a.enabled}),document.addEventListener("visibilitychange",this.handlePageVisibilityChanges)}}export{u as default};
2
2
  //# sourceMappingURL=FastlaneSDK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FastlaneSDK.js","sources":["../../../../src/components/PayPalFastlane/FastlaneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\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 {\n FastlaneAuthenticatedCustomerResult,\n FastlaneConsentRenderState,\n FastlanePaymentMethodConfiguration,\n FastlaneSDKConfiguration,\n FastlaneShippingAddressSelectorResult,\n FastlaneSignupConfiguration,\n FastlaneWindowInstance\n} from './types';\n\nimport Analytics from '../../core/Analytics';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport type { IAnalytics } from '../../core/Analytics/Analytics';\nimport { AnalyticsEventQueue } from '../../core/Analytics/AnalyticsEventQueue';\nimport { AnalyticsService } from '../../core/Analytics/AnalyticsService';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly fastlaneLocale: string;\n private readonly forceConsentDetails: boolean;\n\n private readonly analytics: IAnalytics;\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, analyticsUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.fastlaneLocale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n\n this.analytics = new Analytics({\n eventQueue: new AnalyticsEventQueue(),\n service: new AnalyticsService({\n analyticsContext: analyticsUrl,\n clientKey: this.clientKey\n }),\n enabled: configuration.analytics?.enabled\n });\n\n document.addEventListener('visibilitychange', this.handlePageVisibilityChanges);\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n void this.analytics.setUp({\n checkoutStage: 'precheckout'\n });\n\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n this.trackEvent(InfoEventType.Initialized);\n return this;\n }\n\n public destroy(): void {\n document.removeEventListener('visibilitychange', this.handlePageVisibilityChanges);\n this.analytics.flush();\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 this.trackEvent(InfoEventType.LookupStarted);\n\n try {\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n this.trackEvent(InfoEventType.OtpStarted);\n\n const authResult = await this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n this.trackEvent(this.getOtpAnalyticsSubtype(authResult.authenticationState));\n\n return authResult;\n }\n\n this.trackEvent(InfoEventType.LookupUserNotFound);\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred during the authentication flow.', { cause: error });\n }\n }\n\n /**\n * Creates the 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 this.analytics.flush();\n\n const isAuthSuccess = authResult.authenticationState === 'succeeded';\n const hasCardData = !!authResult.profileData?.card;\n const hasShopperDetails = !!this.latestShopperDetails?.email;\n\n if (isAuthSuccess && hasCardData && hasShopperDetails) {\n return this.createFastlaneComponentConfiguration(authResult);\n }\n\n return this.createCardComponentConfiguration();\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public async showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'showShippingAddressSelector(): Fastlane SDK is not initialized');\n }\n\n this.trackEvent(InfoEventType.AddressSelectorClicked);\n\n try {\n const addressSelectorResult = await this.fastlaneSdk.profile.showShippingAddressSelector();\n if (addressSelectorResult.selectionChanged) {\n this.trackEvent(InfoEventType.AddressChanged);\n }\n this.trackEvent(InfoEventType.AddressSelectorClosed);\n\n return addressSelectorResult;\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred when showing the shipping address selector', { cause: error });\n }\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 if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'mountWatermark(): Fastlane SDK is not initialized');\n }\n\n try {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred when rendering the watermark', { cause: error });\n }\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 sdkUrl = new URL('https://www.paypal.com/sdk/js');\n sdkUrl.searchParams.set('client-id', clientId);\n sdkUrl.searchParams.set('components', 'buttons,fastlane');\n\n const script = new Script({\n src: sdkUrl.href,\n component: 'fastlane',\n dataAttributes: { sdkClientToken: clientToken },\n analytics: this.analytics\n });\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.fastlaneLocale);\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 /**\n * Creates the configuration for the Fastlane component\n *\n * @param authResult\n * @private\n */\n private createFastlaneComponentConfiguration(authResult: FastlaneAuthenticatedCustomerResult): FastlanePaymentMethodConfiguration {\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 }\n\n /**\n * Creates the configuration for the Card component, including Fastlane sign-up details if available\n *\n * @private\n */\n private async createCardComponentConfiguration(): Promise<FastlanePaymentMethodConfiguration> {\n const consentDetails = await this.fetchConsentDetails();\n const configuration: { fastlaneConfiguration?: FastlaneSignupConfiguration } = {};\n\n if (consentDetails) {\n configuration.fastlaneConfiguration = {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n };\n }\n\n return {\n paymentType: 'card',\n configuration\n };\n }\n\n private trackEvent(eventType: InfoEventType): void {\n const event = new AnalyticsInfoEvent({ type: eventType, component: 'fastlane' });\n this.analytics.sendAnalytics(event);\n }\n\n private handlePageVisibilityChanges = (): void => {\n if (document.visibilityState === 'hidden') {\n this.analytics.flush();\n }\n };\n\n /**\n * Returns the Info event subtype based on the 'authenticationState'\n * @param authenticationState\n * @private\n */\n private getOtpAnalyticsSubtype(authenticationState: FastlaneAuthenticatedCustomerResult['authenticationState']) {\n switch (authenticationState) {\n case 'succeeded':\n return InfoEventType.OtpSucceeded;\n case 'canceled':\n return InfoEventType.OtpCanceled;\n case 'failed':\n return InfoEventType.OtpFailed;\n case 'not_found':\n return InfoEventType.LookupUserNotFound;\n default:\n return InfoEventType.OtpFailed;\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","this","analytics","setUp","checkoutStage","tokenData","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","trackEvent","InfoEventType","Initialized","destroy","document","removeEventListener","handlePageVisibilityChanges","flush","authenticate","email","fastlaneSdk","AdyenCheckoutError","LookupStarted","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","OtpStarted","authResult","triggerAuthenticationFlow","getOtpAnalyticsSubtype","authenticationState","LookupUserNotFound","profileData","undefined","error","cause","getComponentConfiguration","_this_latestShopperDetails","isAuthSuccess","hasCardData","card","hasShopperDetails","createFastlaneComponentConfiguration","createCardComponentConfiguration","showShippingAddressSelector","AddressSelectorClicked","addressSelectorResult","profile","selectionChanged","AddressChanged","AddressSelectorClosed","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","sdkUrl","URL","searchParams","set","script","Script","src","href","component","dataAttributes","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","fastlaneSessionId","console","warn","fetchConsentDetails","consentComponent","ConsentComponent","getRenderState","window","paypal","Fastlane","_object_spread","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","fastlaneLocale","paymentType","configuration","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fastlaneConfiguration","eventType","event","AnalyticsInfoEvent","type","sendAnalytics","OtpSucceeded","OtpCanceled","OtpFailed","constructor","_define_property","visibilityState","environment","includes","apiUrl","analyticsUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale","locale","Analytics","eventQueue","AnalyticsEventQueue","service","AnalyticsService","analyticsContext","enabled","addEventListener"],"mappings":"giCAsBA,MAAMA,EAyCF,gBAAaC,GACJC,KAAKC,UAAUC,MAAM,CACtBC,cAAe,gBAGnB,MAAMC,QAAkBJ,KAAKK,qBAI7B,aAHML,KAAKM,SAASF,EAAUG,MAAOH,EAAUI,gBACzCR,KAAKS,6BACXT,KAAKU,WAAWC,EAAcC,aACvBZ,IACX,CAEOa,OAAAA,GACHC,SAASC,oBAAoB,mBAAoBf,KAAKgB,6BACtDhB,KAAKC,UAAUgB,OACnB,CAQA,kBAAaC,CAAaC,GACtB,IAAKnB,KAAKoB,YACN,MAAM,IAAIC,EAAmB,uBAAwB,mDAGzDrB,KAAKU,WAAWC,EAAcW,eAE9B,IACI,MAAMC,kBAAEA,SAA4BvB,KAAKoB,YAAYI,SAASC,sBAAsBN,GAEpF,GAAII,EAAmB,CACnBvB,KAAK0B,qBAAuB,CAAEP,QAAOQ,WAAYJ,GACjDvB,KAAKU,WAAWC,EAAciB,YAE9B,MAAMC,QAAmB7B,KAAKoB,YAAYI,SAASM,0BAA0BP,GAG7E,OAFAvB,KAAKU,WAAWV,KAAK+B,uBAAuBF,EAAWG,sBAEhDH,CACX,CAGA,OADA7B,KAAKU,WAAWC,EAAcsB,oBACvB,CACHD,oBAAqB,YACrBE,iBAAaC,EAErB,CAAE,MAAOC,GACL,MAAM,IAAIf,EAAmB,QAAS,kEAAmE,CAAEgB,MAAOD,GACtH,CACJ,CAUA,+BAAaE,CAA0BT,OAWbA,EACMU,EAX5B,IAAKV,EACD,MAAM,IAAIR,EACN,uBACA,2FAIRrB,KAAKC,UAAUgB,QAEf,MAAMuB,EAAmD,cAAnCX,EAAWG,oBAC3BS,KAAsC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laneSDK.ts"],"sourcesContent":["import { resolveEnvironments } from '../../core/Environment';\nimport type { FastlaneTokenData } from './services/request-fastlane-token';\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 {\n FastlaneAuthenticatedCustomerResult,\n FastlaneConsentRenderState,\n FastlanePaymentMethodConfiguration,\n FastlaneProfile,\n FastlaneSDKConfiguration,\n FastlaneShippingAddressSelectorResult,\n FastlaneSignupConfiguration,\n FastlaneWindowInstance\n} from './types';\n\nimport Analytics from '../../core/Analytics';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport type { IAnalytics } from '../../core/Analytics/Analytics';\nimport { AnalyticsEventQueue } from '../../core/Analytics/AnalyticsEventQueue';\nimport { AnalyticsService } from '../../core/Analytics/AnalyticsService';\n\nclass FastlaneSDK {\n private readonly clientKey: string;\n private readonly checkoutShopperURL: string;\n private readonly fastlaneLocale: string;\n private readonly forceConsentDetails: boolean;\n\n private readonly analytics: IAnalytics;\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, analyticsUrl } = resolveEnvironments(configuration.environment);\n\n this.checkoutShopperURL = apiUrl;\n this.clientKey = configuration.clientKey;\n this.forceConsentDetails = configuration.forceConsentDetails || false;\n this.fastlaneLocale = convertAdyenLocaleToFastlaneLocale(configuration.locale || 'en-US');\n\n this.analytics = new Analytics({\n eventQueue: new AnalyticsEventQueue(),\n service: new AnalyticsService({\n analyticsContext: analyticsUrl,\n clientKey: this.clientKey\n }),\n enabled: configuration.analytics?.enabled\n });\n\n document.addEventListener('visibilitychange', this.handlePageVisibilityChanges);\n }\n\n /**\n * Initializes the Fastlane SDK\n */\n public async initialize(): Promise<FastlaneSDK> {\n void this.analytics.setUp({\n checkoutStage: 'precheckout'\n });\n\n const tokenData = await this.requestClientToken();\n await this.fetchSdk(tokenData.value, tokenData.clientId);\n await this.initializeFastlaneInstance();\n this.trackEvent(InfoEventType.Initialized);\n return this;\n }\n\n public destroy(): void {\n document.removeEventListener('visibilitychange', this.handlePageVisibilityChanges);\n this.analytics.flush();\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 this.trackEvent(InfoEventType.LookupStarted);\n\n try {\n const { customerContextId } = await this.fastlaneSdk.identity.lookupCustomerByEmail(email);\n\n if (customerContextId) {\n this.latestShopperDetails = { email, customerId: customerContextId };\n this.trackEvent(InfoEventType.OtpStarted);\n\n const authResult = await this.fastlaneSdk.identity.triggerAuthenticationFlow(customerContextId);\n this.trackEvent(this.getOtpAnalyticsSubtype(authResult.authenticationState));\n\n return authResult;\n }\n\n this.trackEvent(InfoEventType.LookupUserNotFound);\n return {\n authenticationState: 'not_found',\n profileData: undefined\n };\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred during the authentication flow.', { cause: error });\n }\n }\n\n /**\n * Creates the 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 this.analytics.flush();\n\n const card = authResult.authenticationState === 'succeeded' ? authResult.profileData?.card : undefined;\n const email = this.latestShopperDetails?.email;\n\n if (card && email) {\n return this.createFastlaneComponentConfiguration(card, email);\n }\n\n return this.createCardComponentConfiguration();\n }\n\n /**\n * Displays the Fastlane Shipping Address selector UI\n */\n public async showShippingAddressSelector(): Promise<FastlaneShippingAddressSelectorResult> {\n if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'showShippingAddressSelector(): Fastlane SDK is not initialized');\n }\n\n this.trackEvent(InfoEventType.AddressSelectorClicked);\n\n try {\n const addressSelectorResult = await this.fastlaneSdk.profile.showShippingAddressSelector();\n if (addressSelectorResult.selectionChanged) {\n this.trackEvent(InfoEventType.AddressChanged);\n }\n this.trackEvent(InfoEventType.AddressSelectorClosed);\n\n return addressSelectorResult;\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred when showing the shipping address selector', { cause: error });\n }\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 if (!this.fastlaneSdk) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'mountWatermark(): Fastlane SDK is not initialized');\n }\n\n try {\n const component = await this.fastlaneSdk.FastlaneWatermarkComponent(options);\n component.render(container);\n } catch (error: unknown) {\n throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: An error occurred when rendering the watermark', { cause: error });\n }\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 sdkUrl = new URL('https://www.paypal.com/sdk/js');\n sdkUrl.searchParams.set('client-id', clientId);\n sdkUrl.searchParams.set('components', 'buttons,fastlane');\n\n const script = new Script({\n src: sdkUrl.href,\n component: 'fastlane',\n dataAttributes: { sdkClientToken: clientToken },\n analytics: this.analytics\n });\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 if (!this.fastlaneSdk) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'fetchSessionIdAsync(): Fastlane SDK is not initialized');\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 if (!this.fastlaneSdk) throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'fetchConsentDetails(): Fastlane SDK is not initialized');\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 const { paypal } = window;\n if (!paypal?.Fastlane) throw new AdyenCheckoutError('ERROR', 'Fastlane SDK: window.paypal.Fastlane is not available');\n\n this.fastlaneSdk = await paypal.Fastlane({\n intendedExperience: 'externalProcessorCustomConsent',\n ...(this.forceConsentDetails && {\n metadata: {\n geoLocOverride: 'US'\n }\n })\n });\n this.fastlaneSdk.setLocale(this.fastlaneLocale);\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 /**\n * Creates the configuration for the Fastlane component\n *\n * @param card - card from the authenticated shopper's Fastlane profile\n * @param email - email of the authenticated shopper\n * @private\n */\n private createFastlaneComponentConfiguration(card: NonNullable<FastlaneProfile['card']>, email: string): FastlanePaymentMethodConfiguration {\n return {\n paymentType: 'fastlane',\n configuration: {\n fastlaneSessionId: this.fastlaneSessionId ?? '',\n email,\n tokenId: card.id,\n lastFour: card.paymentSource.card.lastDigits,\n brand: card.paymentSource.card.brand.toLowerCase()\n }\n };\n }\n\n /**\n * Creates the configuration for the Card component, including Fastlane sign-up details if available\n *\n * @private\n */\n private async createCardComponentConfiguration(): Promise<FastlanePaymentMethodConfiguration> {\n const consentDetails = await this.fetchConsentDetails();\n const configuration: { fastlaneConfiguration?: FastlaneSignupConfiguration } = {};\n\n if (consentDetails) {\n configuration.fastlaneConfiguration = {\n fastlaneSessionId: this.fastlaneSessionId,\n ...consentDetails\n };\n }\n\n return {\n paymentType: 'card',\n configuration\n };\n }\n\n private trackEvent(eventType: InfoEventType): void {\n const event = new AnalyticsInfoEvent({ type: eventType, component: 'fastlane' });\n this.analytics.sendAnalytics(event);\n }\n\n private handlePageVisibilityChanges = (): void => {\n if (document.visibilityState === 'hidden') {\n this.analytics.flush();\n }\n };\n\n /**\n * Returns the Info event subtype based on the 'authenticationState'\n * @param authenticationState\n * @private\n */\n private getOtpAnalyticsSubtype(authenticationState: FastlaneAuthenticatedCustomerResult['authenticationState']) {\n switch (authenticationState) {\n case 'succeeded':\n return InfoEventType.OtpSucceeded;\n case 'canceled':\n return InfoEventType.OtpCanceled;\n case 'failed':\n return InfoEventType.OtpFailed;\n case 'not_found':\n return InfoEventType.LookupUserNotFound;\n default:\n return InfoEventType.OtpFailed;\n }\n }\n}\n\nexport default FastlaneSDK;\n"],"names":["FastlaneSDK","initialize","this","analytics","setUp","checkoutStage","tokenData","requestClientToken","fetchSdk","value","clientId","initializeFastlaneInstance","trackEvent","InfoEventType","Initialized","destroy","document","removeEventListener","handlePageVisibilityChanges","flush","authenticate","email","fastlaneSdk","AdyenCheckoutError","LookupStarted","customerContextId","identity","lookupCustomerByEmail","latestShopperDetails","customerId","OtpStarted","authResult","triggerAuthenticationFlow","getOtpAnalyticsSubtype","authenticationState","LookupUserNotFound","profileData","undefined","error","cause","getComponentConfiguration","_this_latestShopperDetails","card","createFastlaneComponentConfiguration","createCardComponentConfiguration","showShippingAddressSelector","AddressSelectorClicked","addressSelectorResult","profile","selectionChanged","AddressChanged","AddressSelectorClosed","mountWatermark","container","options","includeAdditionalInfo","FastlaneWatermarkComponent","render","requestFastlaneToken","checkoutShopperURL","clientKey","clientToken","sdkUrl","URL","searchParams","set","script","Script","src","href","component","dataAttributes","sdkClientToken","load","fetchSessionIdAsync","sessionId","getSession","fastlaneSessionId","console","warn","fetchConsentDetails","consentComponent","ConsentComponent","getRenderState","paypal","window","Fastlane","_object_spread","intendedExperience","forceConsentDetails","metadata","geoLocOverride","setLocale","fastlaneLocale","_this_fastlaneSessionId","paymentType","configuration","tokenId","id","lastFour","paymentSource","lastDigits","brand","toLowerCase","consentDetails","fastlaneConfiguration","eventType","event","AnalyticsInfoEvent","type","sendAnalytics","OtpSucceeded","OtpCanceled","OtpFailed","constructor","_define_property","visibilityState","environment","includes","apiUrl","analyticsUrl","resolveEnvironments","convertAdyenLocaleToFastlaneLocale","locale","Analytics","eventQueue","AnalyticsEventQueue","service","AnalyticsService","analyticsContext","enabled","addEventListener"],"mappings":"giCAuBA,MAAMA,EAyCF,gBAAaC,GACJC,KAAKC,UAAUC,MAAM,CACtBC,cAAe,gBAGnB,MAAMC,QAAkBJ,KAAKK,qBAI7B,aAHML,KAAKM,SAASF,EAAUG,MAAOH,EAAUI,gBACzCR,KAAKS,6BACXT,KAAKU,WAAWC,EAAcC,aACvBZ,IACX,CAEOa,OAAAA,GACHC,SAASC,oBAAoB,mBAAoBf,KAAKgB,6BACtDhB,KAAKC,UAAUgB,OACnB,CAQ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jBgH,EAAAjH,KAAQoB,sBACR6F,EAAAjH,KAAQ0B,+BACRuF,EAAAjH,KAAQ2E,4BA+QRsC,EAAAjH,KAAQgB,8BAA8B,KACD,WAA7BF,SAASoG,iBACTlH,KAAKC,UAAUgB,YA9Qd6E,aAAAA,EAAAA,EAAeqB,aAAa,MAAM,IAAI9F,EAAmB,uBAAwB,mDACtF,KAAKyE,aAAAA,EAAAA,EAAepC,WAAW,MAAM,IAAIrC,EAAmB,uBAAwB,iDAEhFyE,EAAcP,qBAAuBO,EAAcqB,YAAYC,SAAS,SACxExC,QAAQC,KAAK,gFAEjB,MAAMwC,OAAEA,EAAMC,aAAEA,GAAiBC,EAAoBzB,EAAcqB,aAEnEnH,KAAKyD,mBAAqB4D,EAC1BrH,KAAK0D,UAAYoC,EAAcpC,UAC/B1D,KAAKuF,oBAAsBO,EAAcP,sBAAuB,EAChEvF,KAAK2F,eAAiB6B,EAAmC1B,EAAc2B,QAAU,SAEjFzH,KAAKC,UAAY,IAAIyH,EAAU,CAC3BC,WAAY,IAAIC,EAChBC,QAAS,IAAIC,EAAiB,CAC1BC,iBAAkBT,EAClB5D,UAAW1D,KAAK0D,YAEpBsE,QAAgC,QAAvBlC,EAAAA,EAAc7F,iBAAd6F,IAAAA,OAAAA,EAAAA,EAAyBkC,UAGtClH,SAASmH,iBAAiB,mBAAoBjI,KAAKgB,4BACvD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/Challenge/PrepareChallenge3DS2.js";import{THREEDS2_CHALLENGE_ERROR as o,THREEDS2_CHALLENGE as n,DEFAULT_CHALLENGE_WINDOW_SIZE as s}from"./constants.js";import{existy as i}from"../../utils/commonUtils.js";import{hasOwnProperty as p}from"../../utils/hasOwnProperty.js";import{TxVariants as c}from"../tx-variants.js";import a,{API_ERROR as l}from"../../core/Errors/AdyenCheckoutError.js";import{AnalyticsLogEvent as m,LogEventSubtype as u,LogEventType as y}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as f,ErrorEventType as h,ErrorEventCode as b}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(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}class O extends t{beforeRender(){}onComplete(e){var t,r;this.props.isMDFlow?null===(t=(r=this.props).on3DS2RedirectFlowComplete)||void 0===t||t.call(r,e,this.elementRef):super.onComplete(e);this.unmount()}componentToRender(){if(!i(this.props.paymentData)){const e=p(this.props,"isMDFlow")?"paymentData":"authorisationToken";this.props.onError(new a(l,`No ${e} received. 3DS2 Challenge cannot proceed`));const t=new f({component:this.type,code:b.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:h.threeDS2,message:`${o}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(t),null}return e(r,j(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){d(e,t,r[t])})}return e}({},this.props),{onComplete:this.onComplete,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled}))}constructor(...e){super(...e),d(this,"onActionHandled",e=>{const t=new m({component:this.type,type:y.threeDS2,subType:u.challengeIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}d(O,"type",c.threeDS2Challenge),d(O,"defaultProps",{dataKey:"threeDSResult",size:s,type:n});export{O as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/Challenge/PrepareChallenge3DS2.js";import{THREEDS2_CHALLENGE_ERROR as o,THREEDS2_CHALLENGE as n,DEFAULT_CHALLENGE_WINDOW_SIZE as s}from"./constants.js";import{existy as i}from"../../utils/commonUtils.js";import{hasOwnProperty as c}from"../../utils/hasOwnProperty.js";import{TxVariants as p}from"../tx-variants.js";import l,{API_ERROR as a}from"../../core/Errors/AdyenCheckoutError.js";import{AnalyticsLogEvent as m,LogEventSubtype as u,LogEventType as y}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as f,ErrorEventType as h,ErrorEventCode as b}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(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}class O extends t{beforeRender(){}onComplete(e){var t,r;this.props.isMDFlow?null===(t=(r=this.props).on3DS2RedirectFlowComplete)||void 0===t||t.call(r,e,this.elementRef):super.onComplete(e);this.unmount()}componentToRender(){if(!i(this.props.paymentData)){var t,n;const e=c(this.props,"isMDFlow")?"paymentData":"authorisationToken";null===(t=(n=this.props).onError)||void 0===t||t.call(n,new l(a,`No ${e} received. 3DS2 Challenge cannot proceed`));const r=new f({component:this.type,code:b.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:h.threeDS2,message:`${o}: Missing '${e}' property from threeDS2 action`});return this.submitAnalytics(r),null}return e(r,j(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){d(e,t,r[t])})}return e}({},this.props),{i18n:this.core.modules.i18n,onComplete:this.onComplete,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled}))}constructor(...e){super(...e),d(this,"onActionHandled",e=>{const t=new m({component:this.type,type:y.threeDS2,subType:u.challengeIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}d(O,"type",p.threeDS2Challenge),d(O,"defaultProps",{dataKey:"threeDSResult",size:s,type:n});export{O as default};
2
2
  //# sourceMappingURL=ThreeDS2Challenge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2Challenge.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2Challenge.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareChallenge from './components/Challenge';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR } from './constants';\nimport { existy } from '../../utils/commonUtils';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport { TxVariants } from '../tx-variants';\nimport { ChallengeResolveData, ThreeDS2ChallengeConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2Challenge extends UIElement<ThreeDS2ChallengeConfiguration> {\n public static readonly type = TxVariants.threeDS2Challenge;\n\n public static readonly defaultProps = {\n dataKey: 'threeDSResult',\n size: DEFAULT_CHALLENGE_WINDOW_SIZE,\n type: THREEDS2_CHALLENGE\n };\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2Challenge - it will have the same timestamp as the \"creq sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Will make a call to onAdditionalDetails (as set in actionTypes.ts) for the regular, \"native\" flow.\n * However, if the action to create this component came from the 3DS2InMDFlow process it will instead equal a call to the onComplete callback\n * (as defined in the 3DS2InMDFlow and passed in as a config prop).\n */\n onComplete(state: ChallengeResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back challenge calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n // existy used because threeds2InMDFlow might send an empty string for paymentData and we should be allowed to proceed with this\n if (!existy(this.props.paymentData)) {\n /**\n * The presence of props.isMDFlow indicates the action to create this component came from the threeds2InMDFlow process which passes (an empty) paymentsData.\n * The regular, \"native\" flow uses the authorisationToken from the 3DS2 action, which actionTypes.ts assigns to a property called paymentData\n */\n const dataTypeForError = hasOwnProperty(this.props, 'isMDFlow') ? 'paymentData' : 'authorisationToken';\n\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No ${dataTypeForError} received. 3DS2 Challenge cannot proceed`));\n\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n return (\n <PrepareChallenge\n {...this.props}\n onComplete={this.onComplete}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2Challenge;\n"],"names":["ThreeDS2Challenge","UIElement","beforeRender","onComplete","state","_this_props_on3DS2RedirectFlowComplete","_this_props","this","props","isMDFlow","on3DS2RedirectFlowComplete","call","elementRef","super","unmount","componentToRender","existy","paymentData","dataTypeForError","hasOwnProperty","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","submitAnalytics","h","PrepareChallenge","onSubmitAnalytics","onActionHandled","args","_define_property","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeIframeLoaded","actionDescription","TxVariants","threeDS2Challenge","defaultProps","dataKey","size","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS2_CHALLENGE"],"mappings":"kwCAaA,MAAMA,UAA0BC,EASTC,YAAAA,GAEnB,CAoBAC,UAAAA,CAAWC,OAEHC,EAAAC,EADAC,KAAKC,MAAMC,SAC0B,QAArCJ,GAAAC,EAAAC,KAAKC,OAAME,kCAAX,IAAAL,GAAAA,EAAAM,KAAAL,EAAwCF,EAAOG,KAAKK,YAEpDC,MAAMV,WAAWC,GAGrBG,KAAKO,SACT,CAEmBC,iBAAAA,GAEf,IAAKC,EAAOT,KAAKC,MAAMS,aAAc,CAKjC,MAAMC,EAAmBC,EAAeZ,KAAKC,MAAO,YAAc,cAAgB,qBAElFD,KAAKC,MAAMY,QAAQ,IAAIC,EAAmBC,EAAW,MAAMJ,8CAE3D,MAAMK,EAAQ,IAAIC,EAAoB,CAClCC,UAAWlB,KAAKmB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFA3B,KAAK4B,gBAAgBZ,GAEd,IACX,CAEA,OACIa,EAACC,EAAAA,oUAAAA,CAAAA,GACO9B,KAAKC,OAAK,CACdL,WAAYI,KAAKJ,WACjBmC,kBAAmB/B,KAAK4B,gBACxBI,gBAAiBhC,KAAKgC,kBAGlC,mBAxEJ1B,SAAA2B,GAaIC,EAAAlC,KAAUgC,kBAAmBG,IACzB,MAAMnB,EAAQ,IAAIoB,EAAkB,CAChClB,UAAWlB,KAAKmB,KAChBA,KAAMkB,EAAaZ,SACnBa,QAASC,EAAgBC,sBACzBd,QAASS,EAAOM,oBAGpBzC,KAAK4B,gBAAgBZ,GAErBV,MAAM0B,gBAAgBG,MAtB1BD,EADEzC,EACqB0B,OAAOuB,EAAWC,mBAEzCT,EAHEzC,EAGqBmD,eAAe,CAClCC,QAAS,gBACTC,KAAMC,EACN5B,KAAM6B"}
1
+ {"version":3,"file":"ThreeDS2Challenge.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2Challenge.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareChallenge from './components/Challenge';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR } from './constants';\nimport { existy } from '../../utils/commonUtils';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport { TxVariants } from '../tx-variants';\nimport { ChallengeResolveData, ThreeDS2ChallengeConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass ThreeDS2Challenge extends UIElement<ThreeDS2ChallengeConfiguration> {\n public static readonly type = TxVariants.threeDS2Challenge;\n\n public static readonly defaultProps = {\n dataKey: 'threeDSResult',\n size: DEFAULT_CHALLENGE_WINDOW_SIZE,\n type: THREEDS2_CHALLENGE\n };\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2Challenge - it will have the same timestamp as the \"creq sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Will make a call to onAdditionalDetails (as set in actionTypes.ts) for the regular, \"native\" flow.\n * However, if the action to create this component came from the 3DS2InMDFlow process it will instead equal a call to the onComplete callback\n * (as defined in the 3DS2InMDFlow and passed in as a config prop).\n */\n onComplete(state: ChallengeResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state);\n }\n\n this.unmount(); // re. fixing issue around back to back challenge calls\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n // existy used because threeds2InMDFlow might send an empty string for paymentData and we should be allowed to proceed with this\n if (!existy(this.props.paymentData)) {\n /**\n * The presence of props.isMDFlow indicates the action to create this component came from the threeds2InMDFlow process which passes (an empty) paymentsData.\n * The regular, \"native\" flow uses the authorisationToken from the 3DS2 action, which actionTypes.ts assigns to a property called paymentData\n */\n const dataTypeForError = hasOwnProperty(this.props, 'isMDFlow') ? 'paymentData' : 'authorisationToken';\n\n this.props.onError?.(new AdyenCheckoutError(API_ERROR, `No ${dataTypeForError} received. 3DS2 Challenge cannot proceed`));\n\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Missing '${dataTypeForError}' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n return (\n <PrepareChallenge\n {...this.props}\n i18n={this.core.modules.i18n}\n onComplete={this.onComplete}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2Challenge;\n"],"names":["ThreeDS2Challenge","UIElement","beforeRender","onComplete","state","_this_props_on3DS2RedirectFlowComplete","_this_props","this","props","isMDFlow","on3DS2RedirectFlowComplete","call","elementRef","super","unmount","componentToRender","existy","paymentData","_this_props_onError","dataTypeForError","hasOwnProperty","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","submitAnalytics","h","PrepareChallenge","i18n","core","modules","onSubmitAnalytics","onActionHandled","args","_define_property","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeIframeLoaded","actionDescription","TxVariants","threeDS2Challenge","defaultProps","dataKey","size","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS2_CHALLENGE"],"mappings":"kwCAaA,MAAMA,UAA0BC,EASTC,YAAAA,GAEnB,CAoBAC,UAAAA,CAAWC,OAEHC,EAAAC,EADAC,KAAKC,MAAMC,SAC0B,QAArCJ,GAAAC,EAAAC,KAAKC,OAAME,kCAAX,IAAAL,GAAAA,EAAAM,KAAAL,EAAwCF,EAAOG,KAAKK,YAEpDC,MAAMV,WAAWC,GAGrBG,KAAKO,SACT,CAEmBC,iBAAAA,GAEf,IAAKC,EAAOT,KAAKC,MAAMS,aAAc,KAOjCC,EAAAZ,EAFA,MAAMa,EAAmBC,EAAeb,KAAKC,MAAO,YAAc,cAAgB,qBAEhE,QAAlBU,GAAAZ,EAAAC,KAAKC,OAAMa,mBAAXH,GAAAA,OAAAZ,EAAqB,IAAIgB,EAAmBC,EAAW,MAAMJ,8CAE7D,MAAMK,EAAQ,IAAIC,EAAoB,CAClCC,UAAWnB,KAAKoB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,eAAsChB,qCAKtD,OAFAZ,KAAK6B,gBAAgBZ,GAEd,IACX,CAEA,OACIa,EAACC,EAAAA,oUAAAA,CAAAA,GACO/B,KAAKC,OAAK,CACd+B,KAAMhC,KAAKiC,KAAKC,QAAQF,KACxBpC,WAAYI,KAAKJ,WACjBuC,kBAAmBnC,KAAK6B,gBACxBO,gBAAiBpC,KAAKoC,kBAGlC,mBAzEJ9B,SAAA+B,GAaIC,EAAAtC,KAAUoC,kBAAmBG,IACzB,MAAMtB,EAAQ,IAAIuB,EAAkB,CAChCrB,UAAWnB,KAAKoB,KAChBA,KAAMqB,EAAaf,SACnBgB,QAASC,EAAgBC,sBACzBjB,QAASY,EAAOM,oBAGpB7C,KAAK6B,gBAAgBZ,GAErBX,MAAM8B,gBAAgBG,MAtB1BD,EADE7C,EACqB2B,OAAO0B,EAAWC,mBAEzCT,EAHE7C,EAGqBuD,eAAe,CAClCC,QAAS,gBACTC,KAAMC,EACN/B,KAAMgC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/DeviceFingerprint/PrepareFingerprint3DS2.js";import n from"./callSubmit3DS2Fingerprint.js";import{existy as o}from"../../utils/commonUtils.js";import{TxVariants as i}from"../tx-variants.js";import s,{API_ERROR as p}from"../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_FINGERPRINT_ERROR as c,THREEDS2_FINGERPRINT as a}from"./constants.js";import{AnalyticsLogEvent as l,LogEventSubtype as m,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as y,ErrorEventType as f,ErrorEventCode as b}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(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}class j extends t{beforeRender(){}onComplete(e){var t,r;this.props.isMDFlow?null===(t=(r=this.props).on3DS2RedirectFlowComplete)||void 0===t||t.call(r,e,this.elementRef):super.onComplete(e);this.unmount()}componentToRender(){if(!o(this.props.paymentData)){this.props.onError(new s(p,"No paymentData received. 3DS2 Fingerprint cannot proceed"));const e=new y({component:this.type,code:b.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:f.threeDS2,message:`${c}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(e),null}return e(r,d(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){h(e,t,r[t])})}return e}({},this.props),{onComplete:this.props.isMDFlow?this.onComplete:this.callSubmit3DS2Fingerprint,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled}))}constructor(...e){super(...e),h(this,"callSubmit3DS2Fingerprint",n.bind(this)),h(this,"onActionHandled",e=>{const t=new l({component:this.type,type:u.threeDS2,subType:m.fingerprintIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}h(j,"type",i.threeDS2Fingerprint),h(j,"defaultProps",{dataKey:"fingerprintResult",type:a});export{j as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/DeviceFingerprint/PrepareFingerprint3DS2.js";import n from"./callSubmit3DS2Fingerprint.js";import{existy as o}from"../../utils/commonUtils.js";import{TxVariants as i}from"../tx-variants.js";import s,{API_ERROR as p}from"../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_FINGERPRINT_ERROR as c,THREEDS2_FINGERPRINT as a}from"./constants.js";import{AnalyticsLogEvent as l,LogEventSubtype as m,LogEventType as u}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsErrorEvent as y,ErrorEventType as f,ErrorEventCode as b}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(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}class j extends t{beforeRender(){}onComplete(e){var t,r;this.props.isMDFlow?null===(t=(r=this.props).on3DS2RedirectFlowComplete)||void 0===t||t.call(r,e,this.elementRef):super.onComplete(e);this.unmount()}componentToRender(){if(!o(this.props.paymentData)){var t,n;null===(t=(n=this.props).onError)||void 0===t||t.call(n,new s(p,"No paymentData received. 3DS2 Fingerprint cannot proceed"));const e=new y({component:this.type,code:b.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,errorType:f.threeDS2,message:`${c}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(e),null}return e(r,h(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){d(e,t,r[t])})}return e}({},this.props),{onComplete:this.props.isMDFlow?this.onComplete:this.callSubmit3DS2Fingerprint,onSubmitAnalytics:this.submitAnalytics,onActionHandled:this.onActionHandled}))}constructor(...e){super(...e),d(this,"callSubmit3DS2Fingerprint",n.bind(this)),d(this,"onActionHandled",e=>{const t=new l({component:this.type,type:u.threeDS2,subType:m.fingerprintIframeLoaded,message:e.actionDescription});this.submitAnalytics(t),super.onActionHandled(e)})}}d(j,"type",i.threeDS2Fingerprint),d(j,"defaultProps",{dataKey:"fingerprintResult",type:a});export{j as default};
2
2
  //# sourceMappingURL=ThreeDS2DeviceFingerprint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2DeviceFingerprint.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2DeviceFingerprint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareFingerprint from './components/DeviceFingerprint';\nimport callSubmit3DS2Fingerprint from './callSubmit3DS2Fingerprint';\nimport { existy } from '../../utils/commonUtils';\nimport { TxVariants } from '../tx-variants';\nimport { FingerprintResolveData, ThreeDS2DeviceFingerprintConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR } from './constants';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AdditionalDetailsData } from '../../types';\n\nclass ThreeDS2DeviceFingerprint extends UIElement<ThreeDS2DeviceFingerprintConfiguration> {\n public static readonly type = TxVariants.threeDS2Fingerprint;\n\n public static readonly defaultProps = {\n dataKey: 'fingerprintResult',\n type: THREEDS2_FINGERPRINT\n };\n\n private readonly callSubmit3DS2Fingerprint = callSubmit3DS2Fingerprint.bind(this); // New 3DS2 flow\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2DeviceFingerprint - it will have the same timestamp as the \"threeDSMethodData sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Can be called directly from PrepareFingerprint (MDFlow) or after the call to /submitThreeDS2Fingerprint endpoint (native flow)\n */\n onComplete(state: FingerprintResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state as AdditionalDetailsData);\n }\n\n this.unmount(); // re. fixing issue around back to back fingerprinting calls\n }\n\n protected override componentToRender(): h.JSX.Element {\n /**\n * In the regular components (aka \"native\") flow we can't proceed because something has gone wrong with the payment if paymentData is missing from the threeDS2 action.\n * In the MDFlow the paymentData is always present (albeit an empty string, which is why we use 'existy' since we should be allowed to proceed with this)\n */\n if (!existy(this.props.paymentData)) {\n this.props.onError(new AdyenCheckoutError(API_ERROR, `No paymentData received. 3DS2 Fingerprint cannot proceed`));\n\n // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n /**\n * this.props.isMDFlow indicates the action to create this component came from the 3DS2InMDFlow process and upon completion should call the\n * passed onComplete callback (as defined in the 3DS2InMDFlow) instead of the /submitThreeDS2Fingerprint endpoint for the regular, \"native\" flow\n */\n return (\n <PrepareFingerprint\n {...this.props}\n // For MDFlow will bypass the /submitThreeDS2Fingerprint endpoint\n onComplete={this.props.isMDFlow ? this.onComplete : this.callSubmit3DS2Fingerprint}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2DeviceFingerprint;\n"],"names":["ThreeDS2DeviceFingerprint","UIElement","beforeRender","onComplete","state","_this_props_on3DS2RedirectFlowComplete","_this_props","this","props","isMDFlow","on3DS2RedirectFlowComplete","call","elementRef","super","unmount","componentToRender","existy","paymentData","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_ERROR","submitAnalytics","h","PrepareFingerprint","callSubmit3DS2Fingerprint","onSubmitAnalytics","onActionHandled","args","_define_property","bind","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintIframeLoaded","actionDescription","TxVariants","threeDS2Fingerprint","defaultProps","dataKey","THREEDS2_FINGERPRINT"],"mappings":"4tCAcA,MAAMA,UAAkCC,EAUjBC,YAAAA,GAEnB,CAkBAC,UAAAA,CAAWC,OAEHC,EAAAC,EADAC,KAAKC,MAAMC,SAC0B,QAArCJ,GAAAC,EAAAC,KAAKC,OAAME,kCAAX,IAAAL,GAAAA,EAAAM,KAAAL,EAAwCF,EAAOG,KAAKK,YAEpDC,MAAMV,WAAWC,GAGrBG,KAAKO,SACT,CAEmBC,iBAAAA,GAKf,IAAKC,EAAOT,KAAKC,MAAMS,aAAc,CACjCV,KAAKC,MAAMU,QAAQ,IAAIC,EAAmBC,EAAW,6DAGrD,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWhB,KAAKiB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFAzB,KAAK0B,gBAAgBZ,GAEd,IACX,CAMA,OACIa,EAACC,EAAAA,oUAAAA,CAAAA,GACO5B,KAAKC,OAAK,CAEdL,WAAYI,KAAKC,MAAMC,SAAWF,KAAKJ,WAAaI,KAAK6B,0BACzDC,kBAAmB9B,KAAK0B,gBACxBK,gBAAiB/B,KAAK+B,kBAGlC,mBA1EJzB,SAAA0B,GAQIC,OAAiBJ,4BAA4BA,EAA0BK,KAAKlC,OAM5EiC,EAAAjC,KAAU+B,kBAAmBI,IACzB,MAAMrB,EAAQ,IAAIsB,EAAkB,CAChCpB,UAAWhB,KAAKiB,KAChBA,KAAMoB,EAAad,SACnBe,QAASC,EAAgBC,wBACzBhB,QAASW,EAAOM,oBAGpBzC,KAAK0B,gBAAgBZ,GAErBR,MAAMyB,gBAAgBI,MAvB1BF,EADExC,EACqBwB,OAAOyB,EAAWC,qBAEzCV,EAHExC,EAGqBmD,eAAe,CAClCC,QAAS,oBACT5B,KAAM6B"}
1
+ {"version":3,"file":"ThreeDS2DeviceFingerprint.js","sources":["../../../../src/components/ThreeDS2/ThreeDS2DeviceFingerprint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PrepareFingerprint from './components/DeviceFingerprint';\nimport callSubmit3DS2Fingerprint from './callSubmit3DS2Fingerprint';\nimport { existy } from '../../utils/commonUtils';\nimport { TxVariants } from '../tx-variants';\nimport { FingerprintResolveData, ThreeDS2DeviceFingerprintConfiguration } from './types';\nimport AdyenCheckoutError, { API_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR } from './constants';\nimport { ActionHandledReturnObject } from '../../types/global-types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AdditionalDetailsData } from '../../types';\n\nclass ThreeDS2DeviceFingerprint extends UIElement<ThreeDS2DeviceFingerprintConfiguration> {\n public static readonly type = TxVariants.threeDS2Fingerprint;\n\n public static readonly defaultProps = {\n dataKey: 'fingerprintResult',\n type: THREEDS2_FINGERPRINT\n };\n\n private readonly callSubmit3DS2Fingerprint = callSubmit3DS2Fingerprint.bind(this); // New 3DS2 flow\n\n protected override beforeRender() {\n /* Do not send rendered events for ThreeDS2DeviceFingerprint - it will have the same timestamp as the \"threeDSMethodData sent\" event */\n }\n\n protected onActionHandled = (rtnObj: ActionHandledReturnObject) => {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintIframeLoaded,\n message: rtnObj.actionDescription\n });\n\n this.submitAnalytics(event);\n\n super.onActionHandled(rtnObj);\n };\n\n /**\n * Can be called directly from PrepareFingerprint (MDFlow) or after the call to /submitThreeDS2Fingerprint endpoint (native flow)\n */\n onComplete(state: FingerprintResolveData) {\n if (this.props.isMDFlow) {\n this.props.on3DS2RedirectFlowComplete?.(state, this.elementRef);\n } else {\n super.onComplete(state as AdditionalDetailsData);\n }\n\n this.unmount(); // re. fixing issue around back to back fingerprinting calls\n }\n\n protected override componentToRender(): h.JSX.Element | null {\n /**\n * In the regular components (aka \"native\") flow we can't proceed because something has gone wrong with the payment if paymentData is missing from the threeDS2 action.\n * In the MDFlow the paymentData is always present (albeit an empty string, which is why we use 'existy' since we should be allowed to proceed with this)\n */\n if (!existy(this.props.paymentData)) {\n this.props.onError?.(new AdyenCheckoutError(API_ERROR, `No paymentData received. 3DS2 Fingerprint cannot proceed`));\n\n // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.type,\n code: ErrorEventCode.THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Missing 'paymentData' property from threeDS2 action`\n });\n\n this.submitAnalytics(event);\n\n return null;\n }\n\n /**\n * this.props.isMDFlow indicates the action to create this component came from the 3DS2InMDFlow process and upon completion should call the\n * passed onComplete callback (as defined in the 3DS2InMDFlow) instead of the /submitThreeDS2Fingerprint endpoint for the regular, \"native\" flow\n */\n return (\n <PrepareFingerprint\n {...this.props}\n // For MDFlow will bypass the /submitThreeDS2Fingerprint endpoint\n onComplete={this.props.isMDFlow ? this.onComplete : this.callSubmit3DS2Fingerprint}\n onSubmitAnalytics={this.submitAnalytics}\n onActionHandled={this.onActionHandled}\n />\n );\n }\n}\n\nexport default ThreeDS2DeviceFingerprint;\n"],"names":["ThreeDS2DeviceFingerprint","UIElement","beforeRender","onComplete","state","_this_props_on3DS2RedirectFlowComplete","_this_props","this","props","isMDFlow","on3DS2RedirectFlowComplete","call","elementRef","super","unmount","componentToRender","existy","paymentData","_this_props_onError","onError","AdyenCheckoutError","API_ERROR","event","AnalyticsErrorEvent","component","type","code","ErrorEventCode","THREEDS2_ACTION_IS_MISSING_PAYMENT_DATA","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_ERROR","submitAnalytics","h","PrepareFingerprint","callSubmit3DS2Fingerprint","onSubmitAnalytics","onActionHandled","args","_define_property","bind","rtnObj","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintIframeLoaded","actionDescription","TxVariants","threeDS2Fingerprint","defaultProps","dataKey","THREEDS2_FINGERPRINT"],"mappings":"4tCAcA,MAAMA,UAAkCC,EAUjBC,YAAAA,GAEnB,CAkBAC,UAAAA,CAAWC,OAEHC,EAAAC,EADAC,KAAKC,MAAMC,SAC0B,QAArCJ,GAAAC,EAAAC,KAAKC,OAAME,kCAAX,IAAAL,GAAAA,EAAAM,KAAAL,EAAwCF,EAAOG,KAAKK,YAEpDC,MAAMV,WAAWC,GAGrBG,KAAKO,SACT,CAEmBC,iBAAAA,GAKf,IAAKC,EAAOT,KAAKC,MAAMS,aAAc,KACjCC,EAAAZ,EAAkB,QAAlBY,GAAAZ,EAAAC,KAAKC,OAAMW,eAAX,IAAAD,GAAAA,EAAAP,KAAAL,EAAqB,IAAIc,EAAmBC,EAAW,6DAGvD,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWjB,KAAKkB,KAChBC,KAAMC,EAAeC,wCACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,2DAKhB,OAFA1B,KAAK2B,gBAAgBZ,GAEd,IACX,CAMA,OACIa,EAACC,EAAAA,oUAAAA,CAAAA,GACO7B,KAAKC,OAAK,CAEdL,WAAYI,KAAKC,MAAMC,SAAWF,KAAKJ,WAAaI,KAAK8B,0BACzDC,kBAAmB/B,KAAK2B,gBACxBK,gBAAiBhC,KAAKgC,kBAGlC,mBA1EJ1B,SAAA2B,GAQIC,OAAiBJ,4BAA4BA,EAA0BK,KAAKnC,OAM5EkC,EAAAlC,KAAUgC,kBAAmBI,IACzB,MAAMrB,EAAQ,IAAIsB,EAAkB,CAChCpB,UAAWjB,KAAKkB,KAChBA,KAAMoB,EAAad,SACnBe,QAASC,EAAgBC,wBACzBhB,QAASW,EAAOM,oBAGpB1C,KAAK2B,gBAAgBZ,GAErBT,MAAM0B,gBAAgBI,MAvB1BF,EADEzC,EACqByB,OAAOyB,EAAWC,qBAEzCV,EAHEzC,EAGqBoD,eAAe,CAClCC,QAAS,oBACT5B,KAAM6B"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as s,createChallengeResolveData as o,prepareChallengeData as n}from"../utils.js";import i from"../../../internal/Img/Img.js";import{hasOwnProperty as a}from"../../../../utils/hasOwnProperty.js";import l from"../../../../core/Context/useImage.js";import p,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as u,MISSING_TOKEN_IN_ACTION_MSG as h,THREEDS2_NUM as m,THREEDS2_CHALLENGE as g}from"../../constants.js";import{isValidHttpUrl as S}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as d,LogEventSubtype as D,LogEventType as E}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as y,AnalyticsErrorEvent as f,ErrorEventType as b}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function _(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},s=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.forEach(function(r){_(e,r,t[r])})}return e}function I(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}class T extends e{componentDidMount(){if(!s(this.state.challengeData)){var e,r;const t="test"===this.props.environment&&(null===(r=this.props._environmentUrls)||void 0===r||null===(e=r.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{acsURL:s,postMessageDomain:o}=this.state.challengeData,n=S(s,t),i=S(o,t);if(!n||!i){const e=n?y.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL:y.THREEDS2_TOKEN_IS_MISSING_ACSURL,r=n?"threeDSNotificationURL":"acsURL";this.setError({errorInfo:`${e}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new f({component:this.props.type,code:e,errorType:b.threeDS2,message:`${u}: Decoded token is missing a valid ${r} property`});return this.props.onSubmitAnalytics(t),void console.debug(`### PrepareChallenge3DS2::exiting:: no valid ${r}.${i?"":` postMessageDomain=${o}`}`)}const{acsTransID:a,messageVersion:l,threeDSServerTransID:p}=this.state.challengeData.cReqData;if(!a||!l||!p){this.setError({errorInfo:`${y.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new f({component:this.props.type,code:y.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:b.threeDS2,message:`${u}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(h)?y.THREEDS2_ACTION_IS_MISSING_TOKEN:y.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new f({component:this.props.type,code:r,errorType:b.threeDS2,message:`${u}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=o(this.props.dataKey,e.transStatus,this.props.paymentData);let s;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?y.THREEDS2_TIMEOUT:y.THREEDS2_NO_TRANSSTATUS,errorType:b.threeDS2};s=new f(O({component:this.props.type,message:n.message},e)),this.props.onSubmitAnalytics(s)}let i;switch(null==e?void 0:e.transStatus){case"Y":i="success";break;case"N":i="failed";break;case"U":i=r?"timeout":"cancelled"}(null==e?void 0:e.errorCode)&&(i="noTransStatus"),s=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),this.props.onSubmitAnalytics(s),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new p(c,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:s}){const o=s,n=l();return"performingChallenge"===this.state.status?r(t,I(O({onCompleteChallenge:e=>{let r=null;if(a(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${u}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new f({component:this.props.type,code:y.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:b.threeDS2,message:`${u}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(a(e,"errorCode")){const r={errorCode:e.errorCode,message:`${g}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new p(c,`${u}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}}},o),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit,usePasskeyIFrameAttributes:this.props.usePasskeyIFrameAttributes})):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(i,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:n({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),_(this,"onFormSubmit",e=>{const r=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:h}},console.debug(`${u}: ${h}`)}}_(T,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{T as default};
1
+ import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isChallengeData as o,createChallengeResolveData as s,prepareChallengeData as n}from"../utils.js";import i from"../../../internal/Img/Img.js";import a from"../../../../core/Context/useImage.js";import l,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE as p,THREEDS2_CHALLENGE_ERROR as u,MISSING_TOKEN_IN_ACTION_MSG as h,THREEDS2_NUM as m,DEFAULT_CHALLENGE_WINDOW_SIZE as d}from"../../constants.js";import{isValidHttpUrl as S}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as g,LogEventSubtype as D,LogEventType as E}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as f,AnalyticsErrorEvent as b,ErrorEventType as _}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function y(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function v(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){y(e,r,t[r])})}return e}function O(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}class I extends e{get component(){var e;return null!==(e=this.props.type)&&void 0!==e?e:p}componentDidMount(){const{challengeData:e}=this.state;if(o(e)){var r,t;const o="test"===this.props.environment&&(null===(t=this.props._environmentUrls)||void 0===t||null===(r=t.api)||void 0===r?void 0:r.includes("http://localhost:8080")),{acsURL:s,postMessageDomain:n}=e,i=S(s,o),a=S(n,o);if(!i||!a){const e=i?f.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL:f.THREEDS2_TOKEN_IS_MISSING_ACSURL,r=i?"threeDSNotificationURL":"acsURL";this.setError({errorInfo:`${e}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new b({component:this.component,code:e,errorType:_.threeDS2,message:`${u}: Decoded token is missing a valid ${r} property`});return this.props.onSubmitAnalytics(t),void console.debug(`### PrepareChallenge3DS2::exiting:: no valid ${r}.${a?"":` postMessageDomain=${n}`}`)}const{acsTransID:l,messageVersion:c,threeDSServerTransID:p}=e.cReqData;if(!l||!c||!p){this.setError({errorInfo:`${f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new b({component:this.component,code:f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:_.threeDS2,message:`${u}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const r=e.error,t=r.includes(h)?f.THREEDS2_ACTION_IS_MISSING_TOKEN:f.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${t}: ${this.props.i18n.get("err.gen.9102")}`},!0);const o=new b({component:this.component,code:t,errorType:_.threeDS2,message:`${u}: ${r}`});this.props.onSubmitAnalytics(o),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r){this.setState({status:"complete"},()=>{var t,o,n,i,a;const l=s(null!==(t=this.props.dataKey)&&void 0!==t?t:"threeDSResult",null!==(o=null==e?void 0:e.transStatus)&&void 0!==o?o:"",null!==(n=this.props.paymentData)&&void 0!==n?n:"");let c;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const p=r||e;if(null==p?void 0:p.errorCode){const e={code:"timeout"===p.errorCode?f.THREEDS2_TIMEOUT:f.THREEDS2_NO_TRANSSTATUS,errorType:_.threeDS2};c=new b(v({component:this.component,message:p.message},e)),this.props.onSubmitAnalytics(c)}let u="unknown";switch(null==e?void 0:e.transStatus){case"Y":u="success";break;case"N":u="failed";break;case"U":u=r?"timeout":"cancelled"}(null==e?void 0:e.errorCode)&&(u="noTransStatus"),c=new g({component:this.component,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:u}),this.props.onSubmitAnalytics(c),null===(i=(a=this.props).onComplete)||void 0===i||i.call(a,l)})}setError(e,r){var t,o;(this.setState({status:"error",errorInfo:e.errorInfo}),r)&&(null===(t=(o=this.props).onError)||void 0===t||t.call(o,new l(c,e.errorInfo,{cause:e.errorObj})))}render(e,{challengeData:s}){const n=a();return"performingChallenge"===this.state.status&&o(s)?r(t,O(v({onCompleteChallenge:e=>{let r;if(!e.result){this.setError({errorInfo:`${u}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new b({component:this.component,code:f.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:_.threeDS2,message:`${u}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}var t,o;e.result.errorCode&&(r={errorCode:e.result.errorCode,message:`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&(null===(t=(o=this.props).onError)||void 0===t||t.call(o,new l(c,`${u}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))));this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(e.errorCode){const o={errorCode:e.errorCode,message:`${p}: ${e.errorCode}`};var r,t;if(this.props.isMDFlow)null===(r=(t=this.props).onError)||void 0===r||r.call(t,new l(c,`${u}: '3DS2 challenge timed out'`,{cause:e.errorCode}));return void this.setStatusComplete(e.result,o)}}},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit,usePasskeyIFrameAttributes:this.props.usePasskeyIFrameAttributes})):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(i,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:n({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),y(this,"onFormSubmit",e=>{const r=new g({component:this.component,type:E.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size||d});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:h}},console.debug(`${u}: ${h}`)}}y(I,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{I as default};
2
2
  //# sourceMappingURL=PrepareChallenge3DS2.js.map