@adyen/adyen-web 6.40.2 → 6.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +49 -41
  4. package/dist/es/components/ANCV/ANCV.js +1 -1
  5. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  6. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  7. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  8. package/dist/es/components/Card/Card.js +1 -1
  9. package/dist/es/components/Card/Card.js.map +1 -1
  10. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  13. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  14. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  15. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  16. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  17. package/dist/es/components/Dropin/Dropin.js +1 -1
  18. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  19. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  20. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  21. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  22. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  23. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  24. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  26. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  27. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  28. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  29. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  30. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  31. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  32. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  33. package/dist/es/components/Giftcard/components/GiftcardPinField.js +1 -1
  34. package/dist/es/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  35. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  36. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  37. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  38. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  39. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  40. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  41. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  42. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  43. package/dist/es/components/internal/Button/Button.js +1 -1
  44. package/dist/es/components/internal/Button/Button.js.map +1 -1
  45. package/dist/es/components/internal/Button/CopyButton.js +1 -1
  46. package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
  47. package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
  48. package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
  49. package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  50. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  51. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  56. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  57. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  58. package/dist/es/components/internal/Modal/Modal.js +1 -1
  59. package/dist/es/components/internal/Modal/Modal.js.map +1 -1
  60. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  61. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  62. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  65. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  69. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  70. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  71. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  72. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  73. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  74. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  75. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  76. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  77. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  78. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  79. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  80. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  81. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  82. package/dist/es/core/config.js +1 -1
  83. package/dist/es/index.d.ts +49 -41
  84. package/dist/es/utils/commonUtils.js +1 -1
  85. package/dist/es/utils/commonUtils.js.map +1 -1
  86. package/dist/es/utils/promiseTimeout.js.map +1 -1
  87. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  88. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  89. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  90. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  91. package/dist/es-legacy/components/Card/Card.js +1 -1
  92. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  93. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  94. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  95. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  96. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  97. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  98. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  99. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  100. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  101. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  102. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  103. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  104. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  105. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  106. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  107. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  108. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  109. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  110. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  111. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  112. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  113. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  114. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  115. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  116. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js +1 -1
  117. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  118. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  119. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  120. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  121. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  122. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  123. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  124. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  125. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  126. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  127. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  128. package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
  129. package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
  130. package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
  131. package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
  132. package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  133. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  134. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  135. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  136. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  137. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  138. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  139. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  140. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  141. package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
  142. package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
  143. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  144. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  145. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  146. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  147. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  148. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  149. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  150. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  151. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  152. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  153. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  154. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  155. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  156. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  157. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  158. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  159. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  160. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  161. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  162. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  163. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  164. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  165. package/dist/es-legacy/core/config.js +1 -1
  166. package/dist/es-legacy/utils/commonUtils.js +1 -1
  167. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  168. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  169. package/package.json +1 -1
@@ -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/GiftcardComponent.js";import n from"../internal/PayButton/PayButton.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as i}from"../tx-variants.js";function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(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){s(e,t,r[t])})}return 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 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 p extends t{formatProps(e){return a({},null==e?void 0:e.configuration,e)}formatData(){var e,t;return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:null===(e=this.state.data)||void 0===e?void 0:e.encryptedCardNumber,encryptedSecurityCode:null===(t=this.state.data)||void 0===t?void 0:t.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){var e;return(null===(e=this.props.brandsConfiguration[this.props.brand])||void 0===e?void 0:e.icon)||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){var e;return(null===(e=this.props.brandsConfiguration[this.props.brand])||void 0===e?void 0:e.name)||this.props.name}setBalanceCheckError(e){var t,r;null===(r=this.componentRef)||void 0===r||null===(t=r.setBalanceCheckErrors)||void 0===t||t.call(r,e)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return e(r,c(a({ref:e=>{this.componentRef=e}},this.props),{handleKeyPress:this.handleKeyPress,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton,onSubmitAnalytics:this.submitAnalytics}))}constructor(...t){super(...t),s(this,"componentRef",void 0),s(this,"handleBalanceCheck",e=>this.props.onBalanceCheck?new Promise((t,r)=>{this.props.onBalanceCheck(t,r,e)}):this.props.session?this.props.session.checkBalance(e):void 0),s(this,"onOrderRequest",e=>this.props.onOrderRequest?new Promise((t,r)=>{this.props.onOrderRequest(t,r,e)}):this.props.session?this.props.session.createOrder():void 0),s(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:e,transactionLimit:t={}})=>{var r;if(this.setBalanceCheckError(null),!e)throw new Error("card-error");if((null==e?void 0:e.currency)!==(null===(r=this.props.amount)||void 0===r?void 0:r.currency))throw new Error("currency-error");if((null==e?void 0:e.value)<=0)throw new Error("no-balance");return this.props.amount.value>e.value||this.props.amount.value>t.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(e=>(this.setState({order:{orderData:e.orderData,pspReference:e.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(e,t)}).catch(e=>{this.setBalanceCheckError(null==e?void 0:e.message),e instanceof o?this.handleError(e):this.handleError(new o("ERROR",e))})}),s(this,"handleOnRequiringConfirmation",(e,t)=>{if(this.componentRef.setBalance({balance:e,transactionLimit:t}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new o("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((e,t)=>{this.props.onRequiringConfirmation(e,t)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),s(this,"payButton",t=>e(n,t))}}s(p,"type",i.giftcard),s(p,"defaultProps",{brandsConfiguration:{}});export{p as GiftcardElement,p as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import n from"../internal/PayButton/PayButton.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as i}from"../tx-variants.js";function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){s(t,e,r[e])})}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class p extends e{formatProps(t){return a({},null==t?void 0:t.configuration,t)}formatData(){var t,e;return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:null===(t=this.state.data)||void 0===t?void 0:t.encryptedCardNumber,encryptedSecurityCode:null===(e=this.state.data)||void 0===e?void 0:e.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){var t;return(null===(t=this.props.brandsConfiguration[this.props.brand])||void 0===t?void 0:t.icon)||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){var t;return(null===(t=this.props.brandsConfiguration[this.props.brand])||void 0===t?void 0:t.name)||this.props.name}setBalanceCheckError(t){var e,r;null===(r=this.componentRef)||void 0===r||null===(e=r.setBalanceCheckErrors)||void 0===e||e.call(r,t)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return t(r,c(a({ref:t=>{this.componentRef=t}},this.props),{handleKeyDown:this.handleKeyDown,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton,onSubmitAnalytics:this.submitAnalytics}))}constructor(...e){super(...e),s(this,"componentRef",void 0),s(this,"handleBalanceCheck",t=>this.props.onBalanceCheck?new Promise((e,r)=>{this.props.onBalanceCheck(e,r,t)}):this.props.session?this.props.session.checkBalance(t):void 0),s(this,"onOrderRequest",t=>this.props.onOrderRequest?new Promise((e,r)=>{this.props.onOrderRequest(e,r,t)}):this.props.session?this.props.session.createOrder():void 0),s(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:t,transactionLimit:e={}})=>{var r;if(this.setBalanceCheckError(null),!t)throw new Error("card-error");if((null==t?void 0:t.currency)!==(null===(r=this.props.amount)||void 0===r?void 0:r.currency))throw new Error("currency-error");if((null==t?void 0:t.value)<=0)throw new Error("no-balance");return this.props.amount.value>t.value||this.props.amount.value>e.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(t=>(this.setState({order:{orderData:t.orderData,pspReference:t.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(t,e)}).catch(t=>{this.setBalanceCheckError(null==t?void 0:t.message),t instanceof o?this.handleError(t):this.handleError(new o("ERROR",t))})}),s(this,"handleOnRequiringConfirmation",(t,e)=>{if(this.componentRef.setBalance({balance:t,transactionLimit:e}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new o("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((t,e)=>{this.props.onRequiringConfirmation(t,e)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),s(this,"payButton",e=>t(n,e))}}s(p,"type",i.giftcard),s(p,"defaultProps",{brandsConfiguration:{}});export{p as GiftcardElement,p as default};
2
2
  //# sourceMappingURL=Giftcard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"snCAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,OAAOC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KAAKK,MAAM+C,KAAMQ,IACxC5D,KAAKkC,SAAS,CAAE0B,MAAO,CAAEC,UAAWD,EAAMC,UAAWC,aAAcF,EAAME,gBAClE9D,KAAKyB,mBAGTzB,KAAK+D,8BAA8BV,EAASC,KAG1DU,MAAMC,IAEHjE,KAAKe,qBAAqBkD,aAAAA,EAAAA,EAAOC,SAG7BD,aAAiBE,EACjBnE,KAAKoE,YAAYH,GAEjBjE,KAAKoE,YAAY,IAAID,EAAmB,QAASF,QAQjExB,EAAAzC,KAAQ+D,gCAAgC,CAACV,EAASC,KAK9C,GAJAtD,KAAKmB,aAAakD,WAAW,CAAEhB,UAASC,qBACxCtD,KAAKmD,UAAU,UAGXnD,KAAKR,MAAMwC,cAAf,CAIA,IAAKhC,KAAKR,MAAM8E,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIxB,QAAc,CAACC,EAASC,KACnB7C,KAAKR,MAAM8E,wBAAwB1B,EAASC,KAGhDO,KAAK,IAAMpD,KAAKyB,kBAEhBuC,MAAM,OAbf,IA6BJvB,EAAAzC,KAAmBqC,YAAa7C,GACrBoC,EAAC2C,EAAc/E,KA5J1BiD,EADSpD,EACcU,OAAmByE,EAAWC,UAIrDhC,EALSpD,EAKiBqF,eAAe,CACrChE,oBAAqB,CAAA"}
1
+ {"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n protected override payButton = (props: PayButtonProps) => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyDown={this.handleKeyDown}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyDown","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"snCAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,OAAOC,EAAA,CAAA,EACAD,eAAAA,EAAOE,cACPF,EAEX,CAEAG,UAAAA,OAKiCC,EACEC,EAL/B,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKR,MAAMU,MAClBC,oBAAoC,QAAfP,EAAAI,KAAKI,MAAMC,YAAX,IAAAT,OAAA,EAAAA,EAAiBO,oBACtCG,sBAAsC,QAAfT,EAAAG,KAAKI,MAAMC,YAAX,IAAAR,OAAA,EAAAA,EAAiBS,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,M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D,GAJAtD,KAAKmB,aAAakD,WAAW,CAAEhB,UAASC,qBACxCtD,KAAKmD,UAAU,UAGXnD,KAAKR,MAAMwC,cAAf,CAIA,IAAKhC,KAAKR,MAAM8E,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIxB,QAAc,CAACC,EAASC,KACnB7C,KAAKR,MAAM8E,wBAAwB1B,EAASC,KAGhDO,KAAK,IAAMpD,KAAKyB,kBAEhBuC,MAAM,OAbf,IA6BJvB,EAAAzC,KAAmBqC,YAAa7C,GACrBoC,EAAC2C,EAAc/E,KA5J1BiD,EADSpD,EACcU,OAAmByE,EAAWC,UAIrDhC,EALSpD,EAKiBqF,eAAe,CACrChE,oBAAqB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, any>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, any> {\n const balanceCheckErrors: Record<string, any> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","hasEnoughBalance","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"k3CA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA0C,CAAA,EAMhD,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc,aAAc,kBAAkBC,SAASD,EACnE,CA2BAE,MAAAA,CAAOC,GAAOC,eAAEA,EAAcC,QAAEA,EAAOC,iBAAEA,EAAgBC,aAAEA,EAAYC,kBAAEA,IACrE,MAAMC,KAAEA,GAASC,KACXC,OAAEA,GAAWC,IAGnBC,EAA4B,CACxBC,OAAQN,EACRD,eACAQ,gBAAiBC,KAAKD,gBACtBE,IAAKD,KAAKC,MAGd,MAAMC,GAAoBZ,aAAAA,EAAAA,EAAkBa,QAAQd,aAAAA,EAAAA,EAASc,OAAQb,EAAmBD,EAClFe,GAAmBF,eAAAA,EAAmBC,SAASR,aAAAA,EAAAA,EAAQQ,OAE7D,GAAID,GAAqBE,EACrB,OACIC,EAACC,EAAAA,CACGjB,QAASA,EACTC,iBAAkBA,EAClBiB,YAAapB,EAAMoB,YACnBvB,OAAQgB,KAAKQ,MAAMxB,OACnByB,iBAAkBtB,EAAMsB,iBACxBC,cAAeV,KAAKb,MAAMuB,cAC1BC,UAAWX,KAAKb,MAAMwB,YAKlC,MAAMC,EAAsBC,GACpBA,EAASf,OAAOgB,oBAA4BrB,EAAKsB,IAAIF,EAASf,OAAOgB,qBAIrEtB,EAAkBsB,oBACXrB,EAAKsB,IAAIvB,EAAkBsB,oBAAoBjC,cAGnD,KAGX,OACIwB,EAACW,MAAAA,CAAIC,UAAU,4BACY,UAAtBjB,KAAKQ,MAAMxB,QAAsBqB,EAACa,E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KACf5D,QAASiC,EAASkC,eAI1BR,EAAAvC,KAAO0B,cAAcsB,IACjBhD,KAAK8C,SAAS,CAAE1D,eAAgB4D,EAAEC,sBAEJ,IAAZD,EAAEE,MAEhBlD,KAAKb,MAAMsC,QAAQuB,GAEnBhD,KAAKb,MAAMgE,OAAOH,KAI1BT,OAAOa,aAAa,EAAG/D,UAASC,uBAC5BU,KAAK8C,SAAS,CAAEzD,UAASC,uBAsC7BiD,EAAAvC,KAAOqD,wBAAyB3E,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK2C,wBAAwBhE,EACjC,IAGJ4D,OAAOe,iBAAiB,SAIpBC,EAHAvD,KAAK8C,SAAS,CAAEvD,cAAc,IAGtB,QAARgE,EAAAvD,KAAKC,eAALsD,GAAAA,EAAUD,mBAGdf,EAAAvC,KAAOD,kBAAmByD,IACtBxD,KAAK8C,SAAS,CAAEvD,aAAciE,OA1GlCjB,EAbEhE,EAaqBkF,eAAe,CAClCvB,aAAa,EACbwB,oBAAoB,EACpBlC,SAAU,OACVC,QAAS,OACT0B,OAAQ,OACRlB,sBAAuB0B"}
1
+ {"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<GiftcardComponentProps>> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static readonly defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, GiftCardValidationError>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","hasEnoughBalance","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"k3CA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA8D,CAAA,EAMpE,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc,aAAc,kBAAkBC,SAASD,EACnE,CA2BAE,MAAAA,CAAOC,GAAOC,eAAEA,EAAcC,QAAEA,EAAOC,iBAAEA,EAAgBC,aAAEA,EAAYC,kBAAEA,IACrE,MAAMC,KAAEA,GAASC,KACXC,OAAEA,GAAWC,IAGnBC,EAA4B,CACxBC,OAAQN,EACRD,eACAQ,gBAAiBC,KAAKD,gBACtBE,IAAKD,KAAKC,MAGd,MAAMC,GAAoBZ,aAAAA,EAAAA,EAAkBa,QAAQd,aAAAA,EAAAA,EAASc,OAAQb,EAAmBD,EAClFe,GAAmBF,eAAAA,EAAmBC,SAASR,aAAAA,EAAAA,EAAQQ,OAE7D,GAAID,GAAqBE,EACrB,OACIC,EAACC,EAAAA,CACGjB,QAASA,EACTC,iBAAkBA,EAClBiB,YAAapB,EAAMoB,YACnBvB,OAAQgB,KAAKQ,MAAMxB,OACnByB,iBAAkBtB,EAAMs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KAAKC,IACHD,KAAKC,IAAIyC,kCADM,CAAA,GAI1BH,EAAAvC,KAAQ2C,0BAA2BhE,IAC/B,MAEMiE,EAAeC,KAFK7C,KAAKyC,+BAEiB9D,GAEhDqB,KAAK8C,SAAS,CAAEtD,kBAAmBoD,MAGvCL,EAAAvC,KAAOwB,WAAWX,IACdb,KAAK8C,SAAS,CAAEjC,YAAY,IAAMb,KAAK2C,2BAEvC3C,KAAKb,MAAMqC,SAAS,CAChBgB,KAAM3B,EAAS2B,KACf5D,QAASiC,EAASkC,eAI1BR,EAAAvC,KAAO0B,cAAcsB,IACjBhD,KAAK8C,SAAS,CAAE1D,eAAgB4D,EAAEC,sBAEJ,IAAZD,EAAEE,MAEhBlD,KAAKb,MAAMsC,QAAQuB,GAEnBhD,KAAKb,MAAMgE,OAAOH,KAI1BT,OAAOa,aAAa,EAAG/D,UAASC,uBAC5BU,KAAK8C,SAAS,CAAEzD,UAASC,uBAsC7BiD,EAAAvC,KAAOqD,wBAAyB3E,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK2C,wBAAwBhE,EACjC,IAGJ4D,OAAOe,iBAAiB,SAIpBC,EAHAvD,KAAK8C,SAAS,CAAEvD,cAAc,IAGtB,QAARgE,EAAAvD,KAAKC,eAALsD,GAAAA,EAAUD,mBAGdf,EAAAvC,KAAOD,kBAAmByD,IACtBxD,KAAK8C,SAAS,CAAEvD,aAAciE,OA1GlCjB,EAbEhE,EAaqBkF,eAAe,CAClCvB,aAAa,EACbwB,oBAAoB,EACpBlC,SAAU,OACVC,QAAS,OACT0B,OAAQ,OACRlB,sBAAuB0B"}
@@ -1,2 +1,2 @@
1
- import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as o}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const c=({i18n:c,classNameModifiers:d,sfpState:a,focusedElement:i,setFocusOn:s,label:p=c.get("creditCard.pin.label")})=>n(t,{label:p,classNameModifiers:["pin",...d],errorMessage:a.errors.encryptedSecurityCode&&c.get(a.errors.encryptedSecurityCode),focused:"encryptedSecurityCode"===i,onFocusField:()=>s("encryptedSecurityCode"),dir:"ltr",name:"encryptedSecurityCode",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:o},n(e,{encryptedFieldType:"encryptedSecurityCode","data-info":'{"length":"3-10", "maskInterval": 0}',className:r({"adyen-checkout__input":!0,"adyen-checkout__input--large":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":a.errors.encryptedSecurityCode,"adyen-checkout__input--focus":"encryptedSecurityCode"===i})}));export{c as GiftcardPinField};
1
+ import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as o}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const c=({i18n:c,classNameModifiers:d,sfpState:i,focusedElement:a,setFocusOn:s,label:l=c.get("creditCard.pin.label")})=>{var p,u;return n(t,{label:l,classNameModifiers:["pin",...d],errorMessage:(null===(p=i.errors)||void 0===p?void 0:p.encryptedSecurityCode)&&c.get(i.errors.encryptedSecurityCode),focused:"encryptedSecurityCode"===a,onFocusField:()=>s("encryptedSecurityCode"),dir:"ltr",name:"encryptedSecurityCode",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:o},n(e,{encryptedFieldType:"encryptedSecurityCode","data-info":'{"length":"3-10", "maskInterval": 0}',className:r({"adyen-checkout__input":!0,"adyen-checkout__input--large":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":null===(u=i.errors)||void 0===u?void 0:u.encryptedSecurityCode,"adyen-checkout__input--focus":"encryptedSecurityCode"===a})}))};export{c as GiftcardPinField};
2
2
  //# sourceMappingURL=GiftcardPinField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GiftcardPinField.js","sources":["../../../../../src/components/Giftcard/components/GiftcardPinField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from './types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const GiftcardPinField = ({\n i18n,\n classNameModifiers,\n sfpState,\n focusedElement,\n setFocusOn,\n label = i18n.get('creditCard.pin.label')\n}: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={label}\n classNameModifiers={['pin', ...classNameModifiers]}\n errorMessage={sfpState.errors.encryptedSecurityCode && i18n.get(sfpState.errors.encryptedSecurityCode)}\n focused={focusedElement === 'encryptedSecurityCode'}\n onFocusField={() => setFocusOn('encryptedSecurityCode')}\n dir={'ltr'}\n name={'encryptedSecurityCode'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType=\"encryptedSecurityCode\"\n data-info='{\"length\":\"3-10\", \"maskInterval\": 0}'\n className={classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--large': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': sfpState.errors.encryptedSecurityCode,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedSecurityCode'\n })}\n />\n </Field>\n );\n};\n"],"names":["GiftcardPinField","i18n","classNameModifiers","sfpState","focusedElement","setFocusOn","label","get","h","Field","errorMessage","errors","encryptedSecurityCode","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","data-info","className","classNames"],"mappings":"sWAOaA,EAAmB,EAC5BC,OACAC,qBACAC,WACAC,iBACAC,aACAC,QAAQL,EAAKM,IAAI,2BAGbC,EAACC,EAAAA,CACGH,MAAOA,EACPJ,mBAAoB,CAAC,SAAUA,GAC/BQ,aAAcP,EAASQ,OAAOC,uBAAyBX,EAAKM,IAAIJ,EAASQ,OAAOC,uBAChFC,QAA4B,0BAAnBT,EACTU,aAAc,IAAMT,EAAW,yBAC/BU,IAAK,MACLC,KAAM,wBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1BZ,EAACa,EAAAA,CACGC,mBAAmB,wBACnBC,YAAU,uCACVC,UAAWC,EAAW,CAClB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,+BAAgCtB,EAASQ,OAAOC,sBAChD,+BAAmD,0BAAnBR"}
1
+ {"version":3,"file":"GiftcardPinField.js","sources":["../../../../../src/components/Giftcard/components/GiftcardPinField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from './types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const GiftcardPinField = ({\n i18n,\n classNameModifiers,\n sfpState,\n focusedElement,\n setFocusOn,\n label = i18n.get('creditCard.pin.label')\n}: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={label}\n classNameModifiers={['pin', ...classNameModifiers]}\n errorMessage={sfpState.errors?.encryptedSecurityCode && i18n.get(sfpState.errors.encryptedSecurityCode)}\n focused={focusedElement === 'encryptedSecurityCode'}\n onFocusField={() => setFocusOn('encryptedSecurityCode')}\n dir={'ltr'}\n name={'encryptedSecurityCode'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType=\"encryptedSecurityCode\"\n data-info='{\"length\":\"3-10\", \"maskInterval\": 0}'\n className={classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--large': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': sfpState.errors?.encryptedSecurityCode,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedSecurityCode'\n })}\n />\n </Field>\n );\n};\n"],"names":["GiftcardPinField","i18n","classNameModifiers","sfpState","focusedElement","setFocusOn","label","get","h","Field","errorMessage","errors","encryptedSecurityCode","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","data-info","className","classNames"],"mappings":"sWAOaA,EAAmB,EAC5BC,OACAC,qBACAC,WACAC,iBACAC,aACAC,QAAQL,EAAKM,IAAI,gCAMKJ,EAgB0BA,EApBhD,OACIK,EAACC,EAAAA,CACGH,MAAOA,EACPJ,mBAAoB,CAAC,SAAUA,GAC/BQ,sBAAcP,EAAAA,EAASQ,cAATR,IAAAA,OAAAA,EAAAA,EAAiBS,wBAAyBX,EAAKM,IAAIJ,EAASQ,OAAOC,uBACjFC,QAA4B,0BAAnBT,EACTU,aAAc,IAAMT,EAAW,yBAC/BU,IAAK,MACLC,KAAM,wBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1BZ,EAACa,EAAAA,CACGC,mBAAmB,wBACnBC,YAAU,uCACVC,UAAWC,EAAW,CAClB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,+BAA+C,QAAftB,EAAAA,EAASQ,cAATR,IAAAA,SAAAA,EAAiBS,sBACjD,+BAAmD,0BAAnBR"}
@@ -1,2 +1,2 @@
1
- import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as a}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as n}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const p=({i18n:p,sfpState:i,focusedElement:o,setFocusOn:c})=>a(t,{label:p.get("giftcard.expiryDate.label"),classNameModifiers:["expireDate","50"],errorMessage:i.errors.encryptedExpiryDate&&p.get(i.errors.encryptedExpiryDate),focused:"encryptedExpiryDate"===o,onFocusField:()=>c("encryptedExpiryDate"),dir:"ltr",name:"encryptedExpiryDate",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:n},a(e,{encryptedFieldType:"encryptedExpiryDate",className:r("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":i.errors.encryptedExpiryDate,"adyen-checkout__input--focus":"encryptedExpiryDate"===o,"adyen-checkout__input--valid":!!i.valid.encryptedExpiryMonth&&!!i.valid.encryptedExpiryYear})}));export{p as MealVoucherExpiryField};
1
+ import e from"../../Card/components/CardInput/components/DataSfSpan.js";import r from"../../../_virtual/index.js";import t from"../../internal/FormFields/Field/Field.js";import{createElement as n}from"../../../external/preact/dist/preact.js";import{alternativeLabelContent as a}from"../../Card/components/CardInput/components/FieldLabelAlternative.js";const i=({i18n:i,sfpState:o,focusedElement:p,setFocusOn:d})=>{var c,l;return n(t,{label:i.get("giftcard.expiryDate.label"),classNameModifiers:["expireDate","50"],errorMessage:(null===(c=o.errors)||void 0===c?void 0:c.encryptedExpiryDate)&&i.get(o.errors.encryptedExpiryDate),focused:"encryptedExpiryDate"===p,onFocusField:()=>d("encryptedExpiryDate"),dir:"ltr",name:"encryptedExpiryDate",contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:a},n(e,{encryptedFieldType:"encryptedExpiryDate",className:r("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":null===(l=o.errors)||void 0===l?void 0:l.encryptedExpiryDate,"adyen-checkout__input--focus":"encryptedExpiryDate"===p,"adyen-checkout__input--valid":!!o.valid.encryptedExpiryMonth&&!!o.valid.encryptedExpiryYear})}))};export{i as MealVoucherExpiryField};
2
2
  //# sourceMappingURL=MealVoucherExpiryField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MealVoucherExpiryField.js","sources":["../../../../../src/components/MealVoucherFR/components/MealVoucherExpiryField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from '../../Giftcard/components/types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const MealVoucherExpiryField = ({ i18n, sfpState, focusedElement, setFocusOn }: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={i18n.get('giftcard.expiryDate.label')}\n classNameModifiers={['expireDate', '50']}\n errorMessage={sfpState.errors.encryptedExpiryDate && i18n.get(sfpState.errors.encryptedExpiryDate)}\n focused={focusedElement === 'encryptedExpiryDate'}\n onFocusField={() => setFocusOn('encryptedExpiryDate')}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType={'encryptedExpiryDate'}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': sfpState.errors.encryptedExpiryDate,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedExpiryDate',\n 'adyen-checkout__input--valid': !!sfpState.valid.encryptedExpiryMonth && !!sfpState.valid.encryptedExpiryYear\n })}\n />\n </Field>\n );\n};\n"],"names":["MealVoucherExpiryField","i18n","sfpState","focusedElement","setFocusOn","h","Field","label","get","classNameModifiers","errorMessage","errors","encryptedExpiryDate","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","className","classNames","valid","encryptedExpiryMonth","encryptedExpiryYear"],"mappings":"gWAOO,MAAMA,EAAyB,EAAGC,OAAMC,WAAUC,iBAAgBC,gBAEjEC,EAACC,EAAAA,CACGC,MAAON,EAAKO,IAAI,6BAChBC,mBAAoB,CAAC,aAAc,MACnCC,aAAcR,EAASS,OAAOC,qBAAuBX,EAAKO,IAAIN,EAASS,OAAOC,qBAC9EC,QAA4B,wBAAnBV,EACTW,aAAc,IAAMV,EAAW,uBAC/BW,IAAK,MACLC,KAAM,sBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1Bf,EAACgB,EAAAA,CACGC,mBAAoB,sBACpBC,UAAWC,EAAW,wBAAyB,+BAAgC,wCAAyC,CACpH,+BAAgCtB,EAASS,OAAOC,oBAChD,+BAAmD,wBAAnBT,EAChC,iCAAkCD,EAASuB,MAAMC,wBAA0BxB,EAASuB,MAAME"}
1
+ {"version":3,"file":"MealVoucherExpiryField.js","sources":["../../../../../src/components/MealVoucherFR/components/MealVoucherExpiryField.tsx"],"sourcesContent":["import DataSfSpan from '../../Card/components/CardInput/components/DataSfSpan';\nimport classNames from 'classnames';\nimport Field from '../../internal/FormFields/Field';\nimport { h } from 'preact';\nimport { GiftcardFieldProps } from '../../Giftcard/components/types';\nimport { alternativeLabelContent } from '../../Card/components/CardInput/components/FieldLabelAlternative';\n\nexport const MealVoucherExpiryField = ({ i18n, sfpState, focusedElement, setFocusOn }: Readonly<GiftcardFieldProps>) => {\n return (\n <Field\n label={i18n.get('giftcard.expiryDate.label')}\n classNameModifiers={['expireDate', '50']}\n errorMessage={sfpState.errors?.encryptedExpiryDate && i18n.get(sfpState.errors.encryptedExpiryDate)}\n focused={focusedElement === 'encryptedExpiryDate'}\n onFocusField={() => setFocusOn('encryptedExpiryDate')}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n >\n <DataSfSpan\n encryptedFieldType={'encryptedExpiryDate'}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': sfpState.errors?.encryptedExpiryDate,\n 'adyen-checkout__input--focus': focusedElement === 'encryptedExpiryDate',\n 'adyen-checkout__input--valid': !!sfpState.valid.encryptedExpiryMonth && !!sfpState.valid.encryptedExpiryYear\n })}\n />\n </Field>\n );\n};\n"],"names":["MealVoucherExpiryField","i18n","sfpState","focusedElement","setFocusOn","h","Field","label","get","classNameModifiers","errorMessage","errors","encryptedExpiryDate","focused","onFocusField","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","className","classNames","valid","encryptedExpiryMonth","encryptedExpiryYear"],"mappings":"gWAOO,MAAMA,EAAyB,EAAGC,OAAMC,WAAUC,iBAAgBC,qBAK/CF,EAY0BA,EAhBhD,OACIG,EAACC,EAAAA,CACGC,MAAON,EAAKO,IAAI,6BAChBC,mBAAoB,CAAC,aAAc,MACnCC,sBAAcR,EAAAA,EAASS,cAATT,IAAAA,OAAAA,EAAAA,EAAiBU,sBAAuBX,EAAKO,IAAIN,EAASS,OAAOC,qBAC/EC,QAA4B,wBAAnBV,EACTW,aAAc,IAAMV,EAAW,uBAC/BW,IAAK,MACLC,KAAM,sBACNC,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,GAE1Bf,EAACgB,EAAAA,CACGC,mBAAoB,sBACpBC,UAAWC,EAAW,wBAAyB,+BAAgC,wCAAyC,CACpH,+BAA+C,QAAftB,EAAAA,EAASS,cAATT,IAAAA,SAAAA,EAAiBU,oBACjD,+BAAmD,wBAAnBT,EAChC,iCAAkCD,EAASuB,MAAMC,wBAA0BxB,EAASuB,MAAME"}
@@ -1 +1 @@
1
- {"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler;\n private challengePromise: { cancel: () => void; promise: Promise<any> };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit }, { base64URLencodedData, status }) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe name={iframeName} width={width} height={height} callback={this.iframeCallback} />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","_this_props_onActionHandled","_this_props","setState","state","onActionHandled","call","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","encodeBase64URL"],"mappings":"2pBAYA,MAAMA,EAAa,gBAEnB,MAAMC,UAAwBC,EAwBlBC,uBAAAA,GACJ,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,mBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAA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G,EAAuBkC,EAAgBH,GAC7C1D,KAAKoD,MAAQ,CAAEzB,uBAAsBC,OAAQ,OACjD"}
1
+ {"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler: (event: Pick<MessageEvent, 'origin' | 'data'>) => string | boolean;\n private challengePromise: { promise: Promise<ThreeDS2FlowObject>; cancel: () => void };\n\n constructor(props: DoChallenge3DS2Props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit }, { base64URLencodedData, status }) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe name={iframeName} width={width} height={height} callback={this.iframeCallback} />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","_this_props_onActionHandled","_this_props","setState","state","onActionHandled","call","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","encodeBase64URL"],"mappings":"2pBAYA,MAAMA,EAAa,gBAEnB,MAAMC,UAAwBC,EAwBlBC,uBAAAA,GACJ,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,mBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAAAA,GAEIP,KAAKQ,iBAAmBC,EAAeC,EAAmBV,KAAKJ,0BAA2Be,GAC1FX,KAAKQ,iBAAiBI,QACjBC,KAAMC,IACHT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,oBAAoBF,KAGlCG,MAAOC,IACJb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,iBAAiBD,IAExC,CAEAE,oBAAAA,GACQpB,KAAKQ,kBAAkBR,KAAKQ,iBAAiBa,SACjDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,OAAEA,EAAMC,SAAEA,EAAQC,cAAEA,EAAaC,aAAEA,IAAgBC,qBAAEA,EAAoBC,OAAEA,IAC9E,MAAOC,EAAOC,GAAUL,EAExB,OACIM,EAACC,MAAAA,CACGC,UAAWC,EAAW,CAClB,sCACA,wCAAwCV,EAASW,yBAGzC,iBAAXP,GAA6BG,EAACK,EAAAA,MAE/BL,EAACM,EAAAA,CAAOC,KAAM7C,EAAYoC,MAAOA,EAAOC,OAAQA,EAAQS,SAAUvC,KAAKwC,iBACvET,EAACU,EAAAA,CACGH,KAAM,WACNI,OAAQnB,EACRoB,OAAQlD,EACRmD,UAAW,OACXC,WAAYlB,EACZD,aAAcA,IAI9B,CA1EA,WAAAoB,CAAY3C,GACR4C,MAAM5C,GAJV6C,EAAAhD,KAAQC,6BAAR,GACA+C,EAAAhD,KAAQQ,wBAAR,GAaAwC,EAAAhD,KAAQwC,iBAAiB,SAKjBS,EAAAC,GAJJlD,KAAKmD,SAAS,CAAEvB,OAAQ,iBAGE,SAAtB5B,KAAKoD,MAAMxB,UACe,QAA1BqB,GAAAC,EAAAlD,KAAKG,OAAMkD,uBAAX,IAAAJ,GAAAA,EAAAK,KAAAJ,EAA6B,CAAEK,cAAe,gBAAiBC,kBAAmB,GAAGC,iCAVzF,MAAMC,EAAUC,KAAKC,UAAU5D,KAAKG,MAAMqB,UACpCG,EAAuBkC,EAAgBH,GAC7C1D,KAAKoD,MAAQ,CAAEzB,uBAAsBC,OAAQ,OACjD"}
@@ -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 o,createChallengeResolveData as s,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 f}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as y,AnalyticsErrorEvent as E,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]:{},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){_(e,r,t[r])})}return e}function T(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 C extends e{componentDidMount(){if(!o(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:o}=this.state.challengeData;if(!S(o,t)){this.setError({errorInfo:`${y.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new E({component:this.props.type,code:y.THREEDS2_TOKEN_IS_MISSING_ACSURL,errorType:b.threeDS2,message:`${u}: Decoded token is missing a valid acsURL property`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: no valid acsURL")}const{acsTransID:s,messageVersion:n,threeDSServerTransID:i}=this.state.challengeData.cReqData;if(!s||!n||!i){this.setError({errorInfo:`${y.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new E({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 E({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=s(this.props.dataKey,e.transStatus,this.props.paymentData);let o;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};o=new E(O({component:this.props.type,message:n.message},e)),this.props.onSubmitAnalytics(o)}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"),o=new d({component:this.props.type,type:f.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),this.props.onSubmitAnalytics(o),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:o}){const s=l();return"performingChallenge"===this.state.status?r(t,T(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 E({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})):"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:s({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:f.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}`)}}_(C,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{C as default};
1
+ import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as o,createChallengeResolveData as s,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 h,MISSING_TOKEN_IN_ACTION_MSG as u,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 f,AnalyticsErrorEvent as y,ErrorEventType as _}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function b(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]:{},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){b(e,r,t[r])})}return e}function T(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{componentDidMount(){if(!o(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:o,postMessageDomain:s}=this.state.challengeData,n=S(o,t),i=S(s,t);if(!n||!i){const e=n?f.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL:f.THREEDS2_TOKEN_IS_MISSING_ACSURL,r=n?"threeDSNotificationURL":"acsURL";this.setError({errorInfo:`${e}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new y({component:this.props.type,code:e,errorType:_.threeDS2,message:`${h}: Decoded token is missing a valid ${r} property`});return this.props.onSubmitAnalytics(t),void console.debug(`### PrepareChallenge3DS2::exiting:: no valid ${r}.${i?"":` postMessageDomain=${s}`}`)}const{acsTransID:a,messageVersion:l,threeDSServerTransID:p}=this.state.challengeData.cReqData;if(!a||!l||!p){this.setError({errorInfo:`${f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new y({component:this.props.type,code:f.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:_.threeDS2,message:`${h}: 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(u)?f.THREEDS2_ACTION_IS_MISSING_TOKEN:f.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new y({component:this.props.type,code:r,errorType:_.threeDS2,message:`${h}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=s(this.props.dataKey,e.transStatus,this.props.paymentData);let o;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?f.THREEDS2_TIMEOUT:f.THREEDS2_NO_TRANSSTATUS,errorType:_.threeDS2};o=new y(O({component:this.props.type,message:n.message},e)),this.props.onSubmitAnalytics(o)}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"),o=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),this.props.onSubmitAnalytics(o),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:o}){const s=o,n=l();return"performingChallenge"===this.state.status?r(t,T(O({onCompleteChallenge:e=>{let r=null;if(a(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${h}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new y({component:this.props.type,code:f.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:_.threeDS2,message:`${h}: 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,`${h}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}}},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):"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),b(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:u}},console.debug(`${h}: ${u}`)}}b(I,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{I as default};
2
2
  //# sourceMappingURL=PrepareChallenge3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_ACSURL","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","_object_spread","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"8sDAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,GAAWZ,KAAKC,MAAMC,cAI9B,IAHuBW,EAAeD,EAAQN,GAGzB,CAEjBN,KAAKc,SACD,CACIC,UAAW,GAAGC,EAAeC,qCAAqCjB,KAAKO,MAAMW,KAAKC,IAAI,oBAE1F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWtB,KAAKO,MAAMgB,KACtBC,KAAMR,EAAeC,iCACrBQ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,wDAKhB,OAHA7B,KAAK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MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAnVA,WAAAgF,CAAY5F,GAGR,GAFA6F,MAAM7F,GAoBV8F,EAAArG,KAAO4F,eAAgBU,IACnB,MAAMlF,EAAQ,IAAIwC,EAAkB,CAChCtC,UAAWtB,KAAKO,MAAMgB,KACtBA,KAAMsC,EAAalC,SACnBmC,QAASC,EAAgBwC,qBACzB3E,QAAS0E,IAGbtG,KAAKO,MAAMuB,kBAAkBV,KA1BzBpB,KAAKO,MAAMiG,MAAO,CAClB,MAAMtG,EAA6CuG,EAAqB,CACpED,MAAOxG,KAAKO,MAAMiG,MAClBE,KAAM1G,KAAKO,MAAMoG,qBAAuB3G,KAAKO,MAAMmG,OAGvD1G,KAAKC,MAAQ,CACTsC,OAAQ,OACRrC,gBAER,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAE0G,SAAS,EAAOnE,MAAOE,IAEvDZ,QAAQC,MAAM,GAAGH,MAA6Bc,IAEtD,EAzBA0D,EADEzG,EACqBiH,eAAe,CAClC3C,WAAY,OACZG,QAAS,OACTgB,UAAU"}
1
+ {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL, postMessageDomain } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n\n // Only render component if we have a valid acsURL & postMessageDomain.\n // i.e. a url to load into the iframe, and the domain that we expect the iframe to be sending messages back from\n if (!hasValidAcsURL || !hasValidPostMessageDomain) {\n const errorCode = !hasValidAcsURL\n ? ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL\n : ErrorEventCode.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL;\n const missingProperty = !hasValidAcsURL ? 'acsURL' : 'threeDSNotificationURL';\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid ${missingProperty} property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n `### PrepareChallenge3DS2::exiting:: no valid ${missingProperty}.${!hasValidPostMessageDomain ? ` postMessageDomain=${postMessageDomain}` : ''}`\n );\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData: stateChallengeData }: PrepareChallenge3DS2State) {\n const challengeData = stateChallengeData as ChallengeData;\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","postMessageDomain","hasValidAcsURL","isValidHttpUrl","hasValidPostMessageDomain","errorCode","ErrorEventCode","THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL","THREEDS2_TOKEN_IS_MISSING_ACSURL","missingProperty","setError","errorInfo","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","_object_spread","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","stateChallengeData","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"8sDAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,EAAMC,kBAAEA,GAAsBb,KAAKC,MAAMC,cAC3CY,EAAiBC,EAAeH,EAAQN,GACxCU,EAA4BD,EAAeF,EAAmBP,GAIpE,IAAKQ,IAAmBE,EAA2B,CAC/C,MAAMC,EAAaH,EAEbI,EAAeC,2DADfD,EAAeE,iCAEfC,EAAmBP,EAA4B,yBAAX,SAG1Cd,KAAKsB,SACD,CACIC,UAAW,GAAGN,MAAcjB,KAAKO,MAAMiB,KAAKC,IAAI,oBAEpD,GAIJ,MAAMC,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MAAAA,CAAIC,UAAU,4CACXhB,EAACiB,EAAAA,CACGD,UAAU,mEACVE,IAAKpB,EAAS,CACVqB,YAAa,eADZrB,CAEF,SACHsB,IAAK,KAETpB,EAACe,MAAAA,CAAIC,UAAU,gCACVpG,KAAKC,MAAMsB,UAAYvB,KAAKC,MAAMsB,UAAYvB,KAAKO,MAAMiB,KAAKC,IAAI,2BAM5E,IACX,CA7VA,WAAAgF,CAAYlG,GAGR,GAFAmG,MAAMnG,GAoBVoG,EAAA3G,KAAOkG,eAAgBU,IACnB,MAAMlF,EAAQ,IAAIuC,EAAkB,CAChCrC,UAAW5B,KAAKO,MAAMsB,KACtBA,KAAMqC,EAAajC,SACnBkC,QAASC,EAAgByC,qBACzB3E,QAAS0E,IAGb5G,KAAKO,MAAM6B,kBAAkBV,KA1BzB1B,KAAKO,MAAMuG,MAAO,CAClB,MAAM5G,EAA6C6G,EAAqB,CACpED,MAAO9G,KAAKO,MAAMuG,MAClBE,KAAMhH,KAAKO,MAAM0G,qBAAuBjH,KAAKO,MAAMyG,OAGvDhH,KAAKC,MAAQ,CACT4C,OAAQ,OACR3C,gBAER,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAEgH,SAAS,EAAOnE,MAAOC,IAEvDX,QAAQC,MAAM,GAAGH,MAA6Ba,IAEtD,EAzBA2D,EADE/G,EACqBuH,eAAe,CAClC5C,WAAY,OACZG,QAAS,OACTiB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: any;\n public static readonly defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise() {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then(resolveObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch(rejectObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAUA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,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int/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: { cancel: () => void; promise: Promise<ThreeDS2FlowObject> };\n public static readonly defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAWA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAAAA,GAEIP,KAAKQ,mBAAqBC,EAAeC,EAAwBV,KAAKJ,uBAAwBe,GAC9FX,KAAKQ,mBAAmBI,QACnBC,KAAMC,IACHT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,sBAAsBF,KAEpCG,MAAOC,IACJb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,mBAAmBD,IAE1C,CAEAE,oBAAAA,GACQpB,KAAKQ,oBAAoBR,KAAKQ,mBAAmBa,SACrDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,iBAAEA,EAAgBC,gBAAEA,EAAeC,aAAEA,IAAgBC,qBAAEA,IAC1D,OACIC,EAACC,MAAAA,CAAIC,UAAU,2CACV7B,KAAKG,MAAM2B,aAAeH,EAACI,QAC5BJ,EAACC,MAAAA,CAAII,MAAO,CAAEC,QAAS,SACnBN,EAACO,EAAAA,CACGC,KAAM1C,EACN2C,SAAU,KACNZ,SAAAA,EAAkB,CAAEa,cAAe,kBAAmBC,kBAAmB,GAAGC,mCAGpFZ,EAACa,EAAAA,CACGL,KAAM,oBACNM,OAAQlB,EACRmB,OAAQjD,EACRkD,UAAW,oBACXC,WAAYlB,EACZD,aAAcA,KAKlC,CApEA,WAAAoB,CAAY1C,GACR2C,MAAM3C,GAPV4C,EAAA/C,KAAQC,6BAAR,GACA8C,EAAA/C,KAAQQ,0BAAR,GAWI,MAAMwC,qBAAEA,EAAoBC,6BAAEA,GAAiCjD,KAAKG,MAE9D+C,EAAUC,KAAKC,UAAU,CAC3BJ,uBACAC,iCAEEvB,EAAuB2B,EAAgBH,GAC7ClD,KAAKsD,MAAQ,CAAE5B,uBACnB,EAlBAqB,EAHErD,EAGqB6D,eAAe,CAClCzB,aAAa"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import r from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as o}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as c}from"../../../core/config.js";function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),o.forEach(function(e){u(t,e,r[e])})}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class d{buildElementProps(t){this.props=this.formatProps(p({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=p({},this.state,t)}get data(){var t,e;const r=this.state.order||this.props.order,n=this.formatData(),s=Boolean(a(null===(e=n.paymentMethod)||void 0===e?void 0:e.type)),u=this.core.modules.risk.data,d=null!==(t=this.core.modules.analytics.checkoutAttemptId)&&void 0!==t?t:o,m=s?c.NATIVE:c.GENERIC,l=i(d,u,m);return n.paymentMethod&&d&&(n.paymentMethod.checkoutAttemptId=d),n.paymentMethod&&l&&(n.paymentMethod.sdkData=l),h(p({},u&&{riskData:{clientData:u}},r&&{order:{orderData:r.orderData,pspReference:r.pspReference}},n),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=r,n(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),this}update(t){return this.props=this.formatProps(p({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,o){u(this,"_id",`${this.constructor.type}-${e()}`),u(this,"core",void 0),u(this,"props",void 0),u(this,"state",{}),u(this,"_component",void 0),u(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new r("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(o),this.handleKeyPress=this.handleKeyPress.bind(this)}}u(d,"defaultProps",{});export{d as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as c}from"../../../core/config.js";function u(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function p(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){u(t,e,o[e])})}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}class d{buildElementProps(t){this.props=this.formatProps(p({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state=p({},this.state,t)}get data(){var t,e;const o=this.state.order||this.props.order,n=this.formatData(),s=Boolean(a(null===(e=n.paymentMethod)||void 0===e?void 0:e.type)),u=this.core.modules.risk.data,d=null!==(t=this.core.modules.analytics.checkoutAttemptId)&&void 0!==t?t:r,m=s?c.NATIVE:c.GENERIC,l=i(d,u,m);return n.paymentMethod&&d&&(n.paymentMethod.checkoutAttemptId=d),n.paymentMethod&&l&&(n.paymentMethod.sdkData=l),h(p({},u&&{riskData:{clientData:u}},o&&{order:{orderData:o.orderData,pspReference:o.pspReference}},n),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps(p({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){u(this,"_id",`${this.constructor.type}-${e()}`),u(this,"core",void 0),u(this,"props",void 0),u(this,"state",{}),u(this,"_component",void 0),u(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}u(d,"defaultProps",{});export{d as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","_this_core_modules_analytics_checkoutAttemptId","componentData","order","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"owCAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAA,CACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,GAKmB,IAAAC,EAFyDC,EAFnF,MAAMC,EAAQhB,KAAKY,MAAMI,OAAShB,KAAKC,MAAMe,MACvCD,EAAgBf,KAAKK,aACrBY,EAAuCC,QAAQC,EAAyD,QAA3BJ,EAAAA,EAAcK,qBAAdL,IAAAA,OAAAA,EAAAA,EAA6BM,OAC1GC,EAAatB,KAAKuB,KAAKC,QAAQC,KAAKZ,KACpCa,EAAiE,QAA7CZ,EAAAd,KAAKuB,KAAKC,QAAQG,UAAUD,6BAA5BZ,EAAAA,EAAiDc,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARId,EAAcK,eAAiBM,IAC/BX,EAAcK,cAAcM,kBAAoBA,GAGhDX,EAAcK,eAAiBa,IAC/BlB,EAAcK,cAAca,QAAUA,GAGnCE,OACC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M,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC/D,KAAKI,YAAY,6DAIhEJ,KAAKuB,KAAOgC,EACZvD,KAAKF,kBAAkBG,GAEvBD,KAAKQ,eAAiBR,KAAKQ,eAAewD,KAAKhE,KACnD,EAhBAwD,EAVW3D,EAUeoE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","setState","newState","state","data","_this_core_modules_analytics_checkoutAttemptId","componentData","order","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"owCAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAA,CACX,CAEUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,aAAAA,CAAcC,GACpB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,GAKmB,IAAAC,EAFyDC,EAFnF,MAAMC,EAAQhB,KAAKY,MAAMI,OAAShB,KAAKC,MAAMe,MACvCD,EAAgBf,KAAKK,aACrBY,EAAuCC,QAAQC,EAAyD,QAA3BJ,EAAAA,EAAcK,qBAAdL,IAAAA,OAAAA,EAAAA,EAA6BM,OAC1GC,EAAatB,KAAKuB,KAAKC,QAAQC,KAAKZ,KACpCa,EAAiE,QAA7CZ,EAAAd,KAAKuB,KAAKC,QAAQG,UAAUD,6BAA5BZ,EAAAA,EAAiDc,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARId,EAAcK,eAAiBM,IAC/BX,EAAcK,cAAcM,kBAAoBA,GAGhDX,EAAcK,eAAiBa,IAC/BlB,EAAcK,cAAca,QAAUA,GAGnCE,OACCb,GAAc,CAAEc,SAAU,CAAEd,eAC5BN,GAAS,CAAEA,MAAO,CAAEqB,UAAWrB,EAAMqB,UAAWC,aAActB,EAAMsB,eACrEvB,GAAAA,CACHwB,0BAA0B,GAElC,CAMA,QAAAC,GAEA,CAEOC,MAAAA,GAEH,MA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,KAAKhE,KACjD,EAhBAwD,EAVW3D,EAUeoE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:i=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S,onKeyPress:L}=this.props,{completed:B}=this.state,{i18n:j}=o(),D=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=c?c:l,alt:"","aria-hidden":"true"}):"",M=[...i,..."primary"===f?[]:[f],...d?["inline"]:[],...B?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],P=a(["adyen-checkout__button",...M.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),j.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},D,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=k?k:u))},K=E[y]||E.default;return s?t("a",{className:P,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},K):t("button",{ref:g,id:e,className:P,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N,onKeyPress:L},K,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},j.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),i(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
1
+ import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";function o(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:o=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S}=this.props,{completed:L}=this.state,{i18n:B}=i(),j=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=c?c:l,alt:"","aria-hidden":"true"}):"",D=[...o,..."primary"===f?[]:[f],...d?["inline"]:[],...L?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],M=a(["adyen-checkout__button",...D.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),B.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},j,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=k?k:u))},w=E[y]||E.default;return s?t("a",{className:M,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},w):t("button",{ref:g,id:e,className:M,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N},w,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},B.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),o(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),o(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),o(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}o(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
2
2
  //# sourceMappingURL=Button.js.map