@adyen/adyen-web 6.0.0-alpha.8 → 6.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/cjs/adyen.css +65 -65
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +861 -1243
  6. package/dist/es/adyen.css +65 -65
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Ach/Ach.js +1 -1
  9. package/dist/es/components/Ach/Ach.js.map +1 -1
  10. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  11. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  12. package/dist/es/components/Blik/Blik.js +1 -1
  13. package/dist/es/components/Blik/Blik.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  15. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/handlers.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +2 -0
  18. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -0
  19. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  20. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  21. package/dist/es/components/Dropin/Dropin.js +1 -1
  22. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  23. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  24. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  26. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  27. package/dist/es/components/Dropin/elements/createElements.js.map +1 -1
  28. package/dist/es/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  29. package/dist/es/components/Dropin/elements/createStoredElements.js.map +1 -1
  30. package/dist/es/components/Dropin/elements/filters.js.map +1 -1
  31. package/dist/es/components/Giropay/Giropay.js +1 -1
  32. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  33. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  34. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  35. package/dist/es/components/Redirect/Redirect.js +1 -1
  36. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  37. package/dist/es/components/Trustly/Trustly.js +1 -1
  38. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  39. package/dist/es/components/WeChat/config.js +1 -1
  40. package/dist/es/components/WeChat/config.js.map +1 -1
  41. package/dist/es/components/components-name-map.js +1 -1
  42. package/dist/es/components/components-name-map.js.map +1 -1
  43. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  44. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  45. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  46. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  47. package/dist/es/components/index.js +1 -1
  48. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  49. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  50. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  51. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/services/utils.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/services/utils.js.map +1 -1
  56. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  57. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  58. package/dist/es/components/internal/RedirectButton/RedirectButton.js +1 -1
  59. package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  60. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  61. package/dist/es/components/tx-variants.js +1 -1
  62. package/dist/es/components/tx-variants.js.map +1 -1
  63. package/dist/es/core/AdyenCheckout.js.map +1 -1
  64. package/dist/es/core/Analytics/Analytics.js +1 -1
  65. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  66. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  67. package/dist/es/core/ProcessResponse/PaymentAction/PaymentAction.js.map +1 -1
  68. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  69. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  70. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  71. package/dist/es/core/Services/http.js +1 -1
  72. package/dist/es/core/Services/http.js.map +1 -1
  73. package/dist/es/core/Services/sessions/setup-session.js +1 -1
  74. package/dist/es/core/Services/sessions/setup-session.js.map +1 -1
  75. package/dist/es/core/core.js +1 -1
  76. package/dist/es/core/core.js.map +1 -1
  77. package/dist/es/core/core.registry.js.map +1 -1
  78. package/dist/es/external/preact/dist/preact.js +1 -1
  79. package/dist/es/external/preact/dist/preact.js.map +1 -1
  80. package/dist/es/index.d.ts +861 -1243
  81. package/dist/es/index.js +1 -1
  82. package/dist/es/language/constants.js +1 -1
  83. package/dist/es/language/constants.js.map +1 -1
  84. package/dist/es-legacy/adyen.css +65 -65
  85. package/dist/es-legacy/adyen.css.map +1 -1
  86. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  87. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  88. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  89. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  90. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  91. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  92. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  93. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  94. package/dist/es-legacy/components/Card/components/CardInput/handlers.js +1 -1
  95. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +2 -0
  96. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -0
  97. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  98. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  99. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  100. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  101. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  102. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  103. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  104. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  105. package/dist/es-legacy/components/Dropin/elements/createElements.js.map +1 -1
  106. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  107. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js.map +1 -1
  108. package/dist/es-legacy/components/Dropin/elements/filters.js.map +1 -1
  109. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  110. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  111. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  112. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  113. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  114. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  115. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  116. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  117. package/dist/es-legacy/components/WeChat/config.js +1 -1
  118. package/dist/es-legacy/components/WeChat/config.js.map +1 -1
  119. package/dist/es-legacy/components/components-name-map.js +1 -1
  120. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  121. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  122. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  123. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  124. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  125. package/dist/es-legacy/components/index.js +1 -1
  126. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  127. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  128. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  129. package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  130. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js +1 -1
  131. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  132. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js +1 -1
  133. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js.map +1 -1
  134. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  135. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  136. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  137. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  138. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  139. package/dist/es-legacy/components/tx-variants.js +1 -1
  140. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  141. package/dist/es-legacy/core/AdyenCheckout.js.map +1 -1
  142. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  143. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  144. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  145. package/dist/es-legacy/core/ProcessResponse/PaymentAction/PaymentAction.js.map +1 -1
  146. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  147. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  148. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  149. package/dist/es-legacy/core/Services/http.js +1 -1
  150. package/dist/es-legacy/core/Services/http.js.map +1 -1
  151. package/dist/es-legacy/core/Services/sessions/setup-session.js +1 -1
  152. package/dist/es-legacy/core/Services/sessions/setup-session.js.map +1 -1
  153. package/dist/es-legacy/core/core.js +1 -1
  154. package/dist/es-legacy/core/core.js.map +1 -1
  155. package/dist/es-legacy/core/core.registry.js.map +1 -1
  156. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  157. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  158. package/dist/es-legacy/index.js +1 -1
  159. package/dist/es-legacy/language/constants.js +1 -1
  160. package/dist/es-legacy/language/constants.js.map +1 -1
  161. package/package.json +30 -30
  162. package/dist/es/components/Ideal/index.js +0 -2
  163. package/dist/es/components/Ideal/index.js.map +0 -1
  164. package/dist/es/core/Services/analytics/log-event.js +0 -2
  165. package/dist/es/core/Services/analytics/log-event.js.map +0 -1
  166. package/dist/es-legacy/components/Ideal/index.js +0 -2
  167. package/dist/es-legacy/components/Ideal/index.js.map +0 -1
  168. package/dist/es-legacy/core/Services/analytics/log-event.js +0 -2
  169. package/dist/es-legacy/core/Services/analytics/log-event.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import s from"./components/AchInput/AchInput.js";import{CoreProvider as o}from"../../core/Context/CoreProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as n}from"../tx-variants.js";class i extends e{static type=n.ach;formatProps(t){return{...t,holderNameRequired:t.hasHolderName??t.holderNameRequired}}formatData(){const t=!!this.props.storedPaymentMethodId,e={type:i.type,...this.state.data,ownerName:this.state.data?.holderName,...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}};return delete e.holderName,{paymentMethod:e,...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.storePaymentMethod&&{storePaymentMethod:this.state.storePaymentMethod}}}updateStyles(t){return this.componentRef&&this.componentRef.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef&&this.componentRef.setFocusOn&&this.componentRef.setFocusOn(t),this}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.bankAccountNumber?`•••• ${this.props.bankAccountNumber.slice(-4)}`:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("ach.savedBankAccount"):""}render(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.storedPaymentMethodId?t(r,{name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(s,{setComponentRef:this.setComponentRef,...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,resources:this.resources}))}}export{i as AchElement,i as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import s from"./components/AchInput/AchInput.js";import{CoreProvider as o}from"../../core/Context/CoreProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import{TxVariants as n}from"../tx-variants.js";class i extends e{static type=n.ach;formatProps(t){return{...t,holderNameRequired:t.hasHolderName??t.holderNameRequired}}formatData(){const t=!!this.props.storedPaymentMethodId,e={type:i.type,...this.state.data,ownerName:this.state.data?.holderName,...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}};return delete e.holderName,{paymentMethod:e,...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.storePaymentMethod&&{storePaymentMethod:this.state.storePaymentMethod}}}updateStyles(t){return this.componentRef&&this.componentRef.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef&&this.componentRef.setFocusOn&&this.componentRef.setFocusOn(t),this}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.bankAccountNumber?`•••• ${this.props.bankAccountNumber.slice(-4)}`:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?this.props.i18n.get("ach.savedBankAccount"):""}render(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.storedPaymentMethodId?t(r,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(s,{setComponentRef:this.setComponentRef,...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,resources:this.resources}))}}export{i as AchElement,i as default};
2
2
  //# sourceMappingURL=Ach.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Ach.js","sources":["../../../../src/components/Ach/Ach.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport AchInput from './components/AchInput';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport { AchConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\n\nexport class AchElement extends UIElement<AchConfiguration> {\n public static type = TxVariants.ach;\n\n formatProps(props: AchConfiguration) {\n return {\n ...props,\n // Fix mismatch between passed hasHolderName & holderNameRequired props\n // (when holderNameRequired = true, but hasHolderName = false - which means component will never be valid)\n holderNameRequired: props.hasHolderName ?? props.holderNameRequired\n // TODO - if it turns out that hasHolderName & holderNameRequired are not configurable by the merchant\n // then we will need to force these properties to true\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n // Map holderName to ownerName\n const paymentMethod = {\n type: AchElement.type,\n ...this.state.data,\n ownerName: this.state.data?.holderName,\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n };\n\n delete paymentMethod.holderName;\n\n return {\n paymentMethod,\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.storePaymentMethod && { storePaymentMethod: this.state.storePaymentMethod })\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef && this.componentRef.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef && this.componentRef.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n get isValid() {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.bankAccountNumber) {\n // get lastFour from bankAccountNumber, value comes from storedPaymentMethods\n return `•••• ${this.props.bankAccountNumber.slice(-4)}`;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n return this.props.storedPaymentMethodId ? this.props.i18n.get('ach.savedBankAccount') : '';\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <AchInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n resources={this.resources}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default AchElement;\n"],"names":["AchElement","UIElement","static","TxVariants","ach","formatProps","props","holderNameRequired","hasHolderName","formatData","recurringPayment","this","storedPaymentMethodId","paymentMethod","type","state","data","ownerName","holderName","billingAddress","storePaymentMethod","updateStyles","stylesObj","componentRef","setFocusOn","fieldName","isValid","displayName","bankAccountNumber","slice","name","additionalInfo","i18n","get","render","h","CoreProvider","loadingContext","resources","RedirectButton","amount","payButton","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T,KAAMnB,KAAKgB,YACXa,OAAQ7B,KAAKL,MAAMkC,OACnBC,UAAW9B,KAAK8B,UAChBC,SAAU/B,KAAKgC,OACfC,IAAKA,IACDjC,KAAKY,aAAeqB,CAAAA,IAI5BT,EAACU,EAAAA,CACGC,gBAAiBnC,KAAKmC,mBAClBnC,KAAKL,MACTyC,SAAUpC,KAAKqC,SACfN,SAAU/B,KAAKgC,OACfF,UAAW9B,KAAK8B,UAChBH,UAAW3B,KAAK2B,YAKpC"}
1
+ {"version":3,"file":"Ach.js","sources":["../../../../src/components/Ach/Ach.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport AchInput from './components/AchInput';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport { AchConfiguration } from './types';\nimport { TxVariants } from '../tx-variants';\n\nexport class AchElement extends UIElement<AchConfiguration> {\n public static type = TxVariants.ach;\n\n formatProps(props: AchConfiguration) {\n return {\n ...props,\n // Fix mismatch between passed hasHolderName & holderNameRequired props\n // (when holderNameRequired = true, but hasHolderName = false - which means component will never be valid)\n holderNameRequired: props.hasHolderName ?? props.holderNameRequired\n // TODO - if it turns out that hasHolderName & holderNameRequired are not configurable by the merchant\n // then we will need to force these properties to true\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n // Map holderName to ownerName\n const paymentMethod = {\n type: AchElement.type,\n ...this.state.data,\n ownerName: this.state.data?.holderName,\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n };\n\n delete paymentMethod.holderName;\n\n return {\n paymentMethod,\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.storePaymentMethod && { storePaymentMethod: this.state.storePaymentMethod })\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef && this.componentRef.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef && this.componentRef.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n get isValid() {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.bankAccountNumber) {\n // get lastFour from bankAccountNumber, value comes from storedPaymentMethods\n return `•••• ${this.props.bankAccountNumber.slice(-4)}`;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n return this.props.storedPaymentMethodId ? this.props.i18n.get('ach.savedBankAccount') : '';\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <AchInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n resources={this.resources}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default AchElement;\n"],"names":["AchElement","UIElement","static","TxVariants","ach","formatProps","props","holderNameRequired","hasHolderName","formatData","recurringPayment","this","storedPaymentMethodId","paymentMethod","type","state","data","ownerName","holderName","billingAddress","storePaymentMethod","updateStyles","stylesObj","componentRef","setFocusOn","fieldName","isValid","displayName","bankAccountNumber","slice","name","additionalInfo","i18n","get","render","h","CoreProvider","loadingContext","resources","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","ref","AchInput","setComponentRef","onChange","setState"],"mappings":"kWAQO,MAAMA,UAAmBC,EAC5BC,YAAqBC,EAAWC,IAEhCC,WAAAA,CAAYC,GACR,MAAO,IACAA,EAGHC,mBAAoBD,EAAME,eAAiBF,EAAMC,mBAIzD,CAKAE,UAAAA,GACI,MAAMC,IAAqBC,KAAKL,MAAMM,sBAGhCC,EAAgB,CAClBC,KAAMd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C,SACfN,SAAUhC,KAAKiC,OACfF,UAAW/B,KAAK+B,UAChBJ,UAAW3B,KAAK2B,YAKpC"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as s}from"../internal/UIElement/UIElement.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import o from"./components/BankTransferResult/BankTransferResult.js";import i from"./components/BankTransferInput/BankTransferInput.js";import{TxVariants as n}from"../tx-variants.js";class a extends s{static type=n.bankTransfer_IBAN;static defaultProps={showEmailAddress:!0};state={isValid:!this.props.showEmailAddress,data:{}};get isValid(){return!!this.state.isValid}formatData(){const{shopperEmail:t}=this.state.data;return{paymentMethod:{type:a.type},...t&&{shopperEmail:t}}}handleRef=t=>{this.componentRef=t};render(){return this.props.reference?t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(o,{ref:this.handleRef,...this.props})):t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.showEmailAddress&&t(i,{ref:this.handleRef,...this.props,onChange:this.setState}),this.props.showPayButton&&t(r,{...this.props,name:this.displayName,onSubmit:this.submit,payButton:this.payButton}))}}export{a as BankTransferElement,a as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as s}from"../internal/UIElement/UIElement.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import r from"../internal/RedirectButton/RedirectButton.js";import o from"./components/BankTransferResult/BankTransferResult.js";import n from"./components/BankTransferInput/BankTransferInput.js";import{TxVariants as a}from"../tx-variants.js";class i extends s{static type=a.bankTransfer_IBAN;static defaultProps={showEmailAddress:!0};state={isValid:!this.props.showEmailAddress,data:{}};get isValid(){return!!this.state.isValid}formatData(){const{shopperEmail:t}=this.state.data;return{paymentMethod:{type:i.type},...t&&{shopperEmail:t}}}handleRef=t=>{this.componentRef=t};render(){return this.props.reference?t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(o,{ref:this.handleRef,...this.props})):t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.showEmailAddress&&t(n,{ref:this.handleRef,...this.props,onChange:this.setState}),t(r,{...this.props,showPayButton:this.props.showPayButton,name:this.displayName,onSubmit:this.submit,payButton:this.payButton}))}}export{i as BankTransferElement,i as default};
2
2
  //# sourceMappingURL=BankTransfer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BankTransfer.js","sources":["../../../../src/components/BankTransfer/BankTransfer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport { BankTransferConfiguration, BankTransferState } from './types';\nimport BankTransferResult from './components/BankTransferResult';\nimport BankTransferInput from './components/BankTransferInput';\nimport { TxVariants } from '../tx-variants';\n\nexport class BankTransferElement extends UIElement<BankTransferConfiguration> {\n public static type = TxVariants.bankTransfer_IBAN;\n\n public static defaultProps = {\n showEmailAddress: true\n };\n\n // @ts-ignore Double check why state extends all props\n public state: BankTransferState = {\n isValid: !this.props.showEmailAddress,\n data: {}\n };\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { shopperEmail } = this.state.data;\n\n return {\n paymentMethod: {\n type: BankTransferElement.type\n },\n ...(shopperEmail && { shopperEmail })\n };\n }\n\n private handleRef = ref => {\n this.componentRef = ref;\n };\n\n render() {\n if (this.props.reference) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <BankTransferResult ref={this.handleRef} {...this.props} />\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.showEmailAddress && <BankTransferInput ref={this.handleRef} {...this.props} onChange={this.setState} />}\n {this.props.showPayButton && (\n <RedirectButton {...this.props} name={this.displayName} onSubmit={this.submit} payButton={this.payButton} />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default BankTransferElement;\n"],"names":["BankTransferElement","UIElement","static","TxVariants","bankTransfer_IBAN","showEmailAddress","state","isValid","this","props","data","formatData","shopperEmail","paymentMethod","type","handleRef","ref","componentRef","render","reference","h","CoreProvider","i18n","loadingContext","resources","BankTransferResult","BankTransferInput","onChange","setState","showPayButton","RedirectButton","name","displayName","onSubmit","submit","payButton"],"mappings":"ybASO,MAAMA,UAA4BC,EACrCC,YAAqBC,EAAWC,kBAEhCF,oBAA6B,CACzBG,kBAAkB,GAIfC,MAA2B,CAC9BC,SAAUC,KAAKC,MAAMJ,iBACrBK,KAAM,CAAC,GAGX,WAAIH,GACA,QAASC,KAAKF,MAAMC,OACxB,CAKAI,UAAAA,GACI,MAAMC,aAAEA,GAAiBJ,KAAKF,MAAMI,KAEpC,MAAO,CACHG,cAAe,CACXC,KAAMd,EAAoBc,SAE1BF,GAAgB,CAAEA,gBAE9B,CAEQG,UAAYC,IAChBR,KAAKS,aAAeD,CAAAA,EAGxBE,MAAAA,GACI,OAAIV,KAAKC,MAAMU,UAEPC,EAACC,EAAAA,CAAaC,KAAMd,KAAKC,MAAMa,KAAMC,eAAgBf,KAAKC,MAAMc,eAAgBC,UAAWhB,KAAKgB,WAC5FJ,EAACK,EAAAA,CAAmBT,IAAKR,KAAKO,aAAeP,KAAKC,SAM1DW,EAACC,EAAAA,CAAaC,KAAMd,KAAKC,MAAMa,KAAMC,eAAgBf,KAAKC,MAAMc,eAAgBC,UAAWhB,KAAKgB,WAC3FhB,KAAKC,MAAMJ,kBAAoBe,EAACM,EAAAA,CAAkBV,IAAKR,KAAKO,aAAeP,KAAKC,MAAOkB,SAAUnB,KAAKoB,WACtGpB,KAAKC,MAAMoB,eACRT,EAACU,EAAAA,IAAmBtB,KAAKC,MAAOsB,KAAMvB,KAAKwB,YAAaC,SAAUzB,KAAK0B,OAAQC,UAAW3B,KAAK2B,YAI/G"}
1
+ {"version":3,"file":"BankTransfer.js","sources":["../../../../src/components/BankTransfer/BankTransfer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport RedirectButton from '../internal/RedirectButton';\nimport { BankTransferConfiguration, BankTransferState } from './types';\nimport BankTransferResult from './components/BankTransferResult';\nimport BankTransferInput from './components/BankTransferInput';\nimport { TxVariants } from '../tx-variants';\n\nexport class BankTransferElement extends UIElement<BankTransferConfiguration> {\n public static type = TxVariants.bankTransfer_IBAN;\n\n public static defaultProps = {\n showEmailAddress: true\n };\n\n // @ts-ignore Double check why state extends all props\n public state: BankTransferState = {\n isValid: !this.props.showEmailAddress,\n data: {}\n };\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { shopperEmail } = this.state.data;\n\n return {\n paymentMethod: {\n type: BankTransferElement.type\n },\n ...(shopperEmail && { shopperEmail })\n };\n }\n\n private handleRef = ref => {\n this.componentRef = ref;\n };\n\n render() {\n if (this.props.reference) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <BankTransferResult ref={this.handleRef} {...this.props} />\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.showEmailAddress && <BankTransferInput ref={this.handleRef} {...this.props} onChange={this.setState} />}\n <RedirectButton\n {...this.props}\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default BankTransferElement;\n"],"names":["BankTransferElement","UIElement","static","TxVariants","bankTransfer_IBAN","showEmailAddress","state","isValid","this","props","data","formatData","shopperEmail","paymentMethod","type","handleRef","ref","componentRef","render","reference","h","CoreProvider","i18n","loadingContext","resources","BankTransferResult","BankTransferInput","onChange","setState","RedirectButton","showPayButton","name","displayName","onSubmit","submit","payButton"],"mappings":"ybASO,MAAMA,UAA4BC,EACrCC,YAAqBC,EAAWC,kBAEhCF,oBAA6B,CACzBG,kBAAkB,GAIfC,MAA2B,CAC9BC,SAAUC,KAAKC,MAAMJ,iBACrBK,KAAM,CAAC,GAGX,WAAIH,GACA,QAASC,KAAKF,MAAMC,OACxB,CAKAI,UAAAA,GACI,MAAMC,aAAEA,GAAiBJ,KAAKF,MAAMI,KAEpC,MAAO,CACHG,cAAe,CACXC,KAAMd,EAAoBc,SAE1BF,GAAgB,CAAEA,gBAE9B,CAEQG,UAAYC,IAChBR,KAAKS,aAAeD,CAAAA,EAGxBE,MAAAA,GACI,OAAIV,KAAKC,MAAMU,UAEPC,EAACC,EAAAA,CAAaC,KAAMd,KAAKC,MAAMa,KAAMC,eAAgBf,KAAKC,MAAMc,eAAgBC,UAAWhB,KAAKgB,WAC5FJ,EAACK,EAAAA,CAAmBT,IAAKR,KAAKO,aAAeP,KAAKC,SAM1DW,EAACC,EAAAA,CAAaC,KAAMd,KAAKC,MAAMa,KAAMC,eAAgBf,KAAKC,MAAMc,eAAgBC,UAAWhB,KAAKgB,WAC3FhB,KAAKC,MAAMJ,kBAAoBe,EAACM,EAAAA,CAAkBV,IAAKR,KAAKO,aAAeP,KAAKC,MAAOkB,SAAUnB,KAAKoB,WACvGR,EAACS,EAAAA,IACOrB,KAAKC,MACTqB,cAAetB,KAAKC,MAAMqB,cAC1BC,KAAMvB,KAAKwB,YACXC,SAAUzB,KAAK0B,OACfC,UAAW3B,KAAK2B,YAIhC"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/BlikInput.js";import s from"../internal/Await/Await.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import i from"./config.js";import n from"../internal/RedirectButton/RedirectButton.js";import p from"../../core/Errors/SRPanelProvider.js";import{TxVariants as a}from"../tx-variants.js";class m extends e{static type=a.blik;formatData(){const t=!!this.props.storedPaymentMethodId;return{paymentMethod:{type:m.type,...!t&&{blikCode:this.state?.data?.blikCode},...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.label?this.props.label:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId&&this.props.label?this.props.name:null}render(){return this.props.paymentData?t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(p,{srPanel:this.props.modules.srPanel},t(s,{ref:t=>{this.componentRef=t},clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.handleError,onComplete:this.onComplete,brandLogo:this.icon,type:i.type,messageText:this.props.i18n.get(i.messageTextId),awaitText:this.props.i18n.get(i.awaitTextId),showCountdownTimer:i.showCountdownTimer,delay:i.STATUS_INTERVAL,countdownTime:i.COUNTDOWN_MINUTES,throttleTime:i.THROTTLE_TIME,throttleInterval:i.THROTTLE_INTERVAL,onActionHandled:this.props.onActionHandled}))):t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.storedPaymentMethodId?t(n,{name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton}))}}export{m as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/BlikInput.js";import s from"../internal/Await/Await.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import i from"./config.js";import n from"../internal/RedirectButton/RedirectButton.js";import p from"../../core/Errors/SRPanelProvider.js";import{TxVariants as a}from"../tx-variants.js";class h extends e{static type=a.blik;formatData(){const t=!!this.props.storedPaymentMethodId;return{paymentMethod:{type:h.type,...!t&&{blikCode:this.state?.data?.blikCode},...t&&{storedPaymentMethodId:this.props.storedPaymentMethodId}}}}get isValid(){return!!this.props.storedPaymentMethodId||!!this.state.isValid}get displayName(){return this.props.storedPaymentMethodId&&this.props.label?this.props.label:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId&&this.props.label?this.props.name:null}render(){return this.props.paymentData?t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(p,{srPanel:this.props.modules.srPanel},t(s,{ref:t=>{this.componentRef=t},clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.handleError,onComplete:this.onComplete,brandLogo:this.icon,type:i.type,messageText:this.props.i18n.get(i.messageTextId),awaitText:this.props.i18n.get(i.awaitTextId),showCountdownTimer:i.showCountdownTimer,delay:i.STATUS_INTERVAL,countdownTime:i.COUNTDOWN_MINUTES,throttleTime:i.THROTTLE_TIME,throttleInterval:i.THROTTLE_INTERVAL,onActionHandled:this.props.onActionHandled}))):t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.storedPaymentMethodId?t(n,{showPayButton:this.props.showPayButton,name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},...this.props,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton}))}}export{h as default};
2
2
  //# sourceMappingURL=Blik.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Blik.js","sources":["../../../../src/components/Blik/Blik.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport BlikInput from '../../components/Blik/components/BlikInput';\nimport Await from '../internal/Await';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport config from './config';\nimport RedirectButton from '../../components/internal/RedirectButton';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\ninterface BlikElementData {\n paymentMethod: {\n type: string;\n blikCode: string;\n };\n}\n\nclass BlikElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.blik;\n\n formatData(): BlikElementData {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n return {\n paymentMethod: {\n type: BlikElement.type,\n ...(!recurringPayment && { blikCode: this.state?.data?.blikCode }),\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n }\n };\n }\n\n get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.label;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.name;\n }\n return null;\n }\n\n /**\n * NOTE: for future reference:\n * this.props.onComplete (which is called from this.onComplete) equates to the merchant defined onAdditionalDetails callback\n * (the initial /payments response defines an \"await\" action, actionTypes.ts translates this to \"onComplete: props.onAdditionalDetails\")\n */\n render() {\n if (this.props.paymentData) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.handleError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.props.onActionHandled}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <BlikInput\n // @ts-ignore Ref is used by preact component\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default BlikElement;\n"],"names":["BlikElement","UIElement","static","TxVariants","blik","formatData","recurringPayment","this","props","storedPaymentMethodId","paymentMethod","type","blikCode","state","data","isValid","displayName","label","name","additionalInfo","render","paymentData","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","Await","ref","componentRef","clientKey","onError","handleError","onComplete","brandLogo","icon","config","messageText","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","RedirectButton","amount","payButton","onSubmit","submit","BlikInput","onChange","setState"],"mappings":"mdAkBA,MAAMA,UAAoBC,EACtBC,YAAqBC,EAAWC,KAEhCC,UAAAA,GACI,MAAMC,IAAqBC,KAAKC,MAAMC,sBAEtC,MAAO,CACHC,cAAe,CACXC,KAAMX,EAAYW,SACbL,GAAoB,CAAEM,SAAUL,KAAKM,OAAOC,MAAMF,aACnDN,GAAoB,CAAEG,sBAAuBF,KAAKC,MAAMC,wBAGxE,CAEA,WAAIM,GACA,QAAIR,KAAKC,MAAMC,yBAINF,KAAKM,MAAME,OACxB,CAEA,eAAIC,GACA,OAAIT,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMS,MAEfV,KAAKC,MAAMU,IACtB,CAEA,kBAAIC,GACA,OAAIZ,KAAKC,MAAMC,uBAAyBF,KAAKC,MAAMS,MACxCV,KAAKC,MAAMU,KAEf,IACX,CAOAE,MAAAA,GACI,OAAIb,KAAKC,MAAMa,YAEPC,EAACC,EAAAA,CAAaC,KAAMjB,KAAKC,MAAMgB,KAAMC,eAAgBlB,KAAKC,MAAMiB,eAAgBC,UAAWnB,KAAKmB,WAC5FJ,EAACK,EAAAA,CAAgBC,QAASrB,KAAKC,MAAMqB,QAAQD,SACzCN,EAACQ,EAAAA,CACGC,IAAKA,IACDxB,KAAKyB,aAAeD,CAAAA,EAExBE,UAAW1B,KAAKC,MAAMyB,UACtBZ,YAAad,KAAKC,MAAMa,YACxBa,QAAS3B,KAAK4B,YACdC,WAAY7B,KAAK6B,WACjBC,UAAW9B,KAAK+B,KAChB3B,KAAM4B,EAAO5B,KACb6B,YAAajC,KAAKC,MAAMgB,KAAKiB,IAAIF,EAAOG,eACxCC,UAAWpC,KAAKC,MAAMgB,KAAKiB,IAAIF,EAAOK,aACtCC,mBAAoBN,EAAOM,mBAC3BC,MAAOP,EAAOQ,gBACdC,cAAeT,EAAOU,kBACtBC,aAAcX,EAAOY,cACrBC,iBAAkBb,EAAOc,kBACzBC,gBAAiB/C,KAAKC,MAAM8C,oBAQ5ChC,EAACC,EAAAA,CAAaC,KAAMjB,KAAKC,MAAMgB,KAAMC,eAAgBlB,KAAKC,MAAMiB,eAAgBC,UAAWnB,KAAKmB,WAC3FnB,KAAKC,MAAMC,sBACRa,EAACiC,EAAAA,CACGrC,KAAMX,KAAKS,YACXwC,OAAQjD,KAAKC,MAAMgD,OACnBC,UAAWlD,KAAKkD,UAChBC,SAAUnD,KAAKoD,OACf5B,IAAKA,IACDxB,KAAKyB,aAAeD,CAAAA,IAI5BT,EAACsC,EAAAA,CAEG7B,IAAKA,IACDxB,KAAKyB,aAAeD,CAAAA,KAEpBxB,KAAKC,MACTqD,SAAUtD,KAAKuD,SACfJ,SAAUnD,KAAKoD,OACfF,UAAWlD,KAAKkD,YAKpC"}
1
+ {"version":3,"file":"Blik.js","sources":["../../../../src/components/Blik/Blik.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport BlikInput from '../../components/Blik/components/BlikInput';\nimport Await from '../internal/Await';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport config from './config';\nimport RedirectButton from '../../components/internal/RedirectButton';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport { AwaitConfiguration } from '../internal/Await/types';\n\ninterface BlikElementData {\n paymentMethod: {\n type: string;\n blikCode: string;\n };\n}\n\nclass BlikElement extends UIElement<AwaitConfiguration> {\n public static type = TxVariants.blik;\n\n formatData(): BlikElementData {\n const recurringPayment = !!this.props.storedPaymentMethodId;\n\n return {\n paymentMethod: {\n type: BlikElement.type,\n ...(!recurringPayment && { blikCode: this.state?.data?.blikCode }),\n ...(recurringPayment && { storedPaymentMethodId: this.props.storedPaymentMethodId })\n }\n };\n }\n\n get isValid(): boolean {\n if (this.props.storedPaymentMethodId) {\n return true;\n }\n\n return !!this.state.isValid;\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.label;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n if (this.props.storedPaymentMethodId && this.props.label) {\n return this.props.name;\n }\n return null;\n }\n\n /**\n * NOTE: for future reference:\n * this.props.onComplete (which is called from this.onComplete) equates to the merchant defined onAdditionalDetails callback\n * (the initial /payments response defines an \"await\" action, actionTypes.ts translates this to \"onComplete: props.onAdditionalDetails\")\n */\n render() {\n if (this.props.paymentData) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onError={this.handleError}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n type={config.type}\n messageText={this.props.i18n.get(config.messageTextId)}\n awaitText={this.props.i18n.get(config.awaitTextId)}\n showCountdownTimer={config.showCountdownTimer}\n delay={config.STATUS_INTERVAL}\n countdownTime={config.COUNTDOWN_MINUTES}\n throttleTime={config.THROTTLE_TIME}\n throttleInterval={config.THROTTLE_INTERVAL}\n onActionHandled={this.props.onActionHandled}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <BlikInput\n // @ts-ignore Ref is used by preact component\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default BlikElement;\n"],"names":["BlikElement","UIElement","static","TxVariants","blik","formatData","recurringPayment","this","props","storedPaymentMethodId","paymentMethod","type","blikCode","state","data","isValid","displayName","label","name","additionalInfo","render","paymentData","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","Await","ref","componentRef","clientKey","onError","handleError","onComplete","brandLogo","icon","config","messageText","get","messageTextId","awaitText","awaitTextId","showCountdownTimer","delay","STATUS_INTERVAL","countdownTime","COUNTDOWN_MINUTES","throttleTime","THROTTLE_TIME","throttleInterval","THROTTLE_INTERVAL","onActionHandled","RedirectButton","showPayButton","amount","payButton","onSubmit","submit","BlikInput","onChange","setState"],"mappings":"mdAkBA,MAAMA,UAAoBC,EACtBC,YAAqBC,EAAWC,KAEhCC,UAAAA,GACI,MAAMC,IAAqBC,KAAKC,MAAMC,sBAEtC,MAAO,CACHC,cAAe,CACXC,KAAMX,EAAYW,SACbL,GAAoB,CAAEM,SAAUL,KAAKM,OAAOC,MAAMF,aACnDN,GAAoB,CAAEG,sBAAuBF,KAAKC,MAAMC,wBAGxE,CAEA,WAAIM,GACA,QAAIR,KAAKC,MAAMC,yBAINF,KAAKM,MAAME,OACxB,CAEA,eAAIC,GACA,OAAIT,KAAKC,MAAMC,uBAAyBF,KAAK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,KAAKyB,aAAeD,CAAAA,KAEpBxB,KAAKC,MACTsD,SAAUvD,KAAKwD,SACfJ,SAAUpD,KAAKqD,OACfF,UAAWnD,KAAKmD,YAKpC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as r}from"../../../../external/preact/dist/preact.js";import{useRef as s,useMemo as t,useState as o,useCallback as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import l from"../../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import i from"./defaultProps.js";import{AddressModeOptions as d}from"./types.js";import{ENCRYPTED_CARD_NUMBER as u,DATE_POLICY_REQUIRED as c,CVC_POLICY_REQUIRED as m}from"../../../internal/SecuredFields/lib/constants.js";import{cardInputFormatters as p,cardInputValidationRules as h,getRuleByNameAndMode as f}from"./validate.js";import y from"../../../internal/SecuredFields/binLookup/extensions.js";import b from"../../../../utils/useForm/useForm.js";import{mapFieldKey as S,handlePartialAddressMode as N,extractPropsForSFP as g,extractPropsForCardFields as A,getLayout as F,lookupBlurBasedErrors as C}from"./utils.js";import{usePrevious as j}from"../../../../utils/hookUtils.js";import k from"../../../internal/Address/Specifications.js";import{StoredCardFieldsWrapper as R}from"./components/StoredCardFieldsWrapper.js";import{CardFieldsWrapper as x}from"./components/CardFieldsWrapper.js";import{getAutoJumpHandler as w,setFocusOnFirstField as P,getFocusHandler as B,getAddressHandler as v}from"./handlers.js";import I from"../../../../external/classnames/index.js";import{getPartialAddressValidationRules as V}from"../../../internal/Address/validate.js";import{ERROR_ACTION_BLUR_SCENARIO as E,ERROR_ACTION_FOCUS_FIELD as M}from"../../../../core/Errors/constants.js";import O from"../../../../core/Errors/useSRPanelContext.js";import q from"../../../../core/Context/useImage.js";import{getArrayDifferences as T}from"../../../../utils/arrayUtils.js";import D from"../../../internal/FormInstruction/FormInstruction.js";import{PREFIX as L}from"../../../internal/Icon/constants.js";const _=i=>{const _=s(null),K=s(!1),H=q(),{setSRMessagesFromObjects:U,setSRMessagesFromStrings:z,clearSRPanel:W,shouldMoveFocusSR:$}=O(),G=U?.({fieldTypeMappingFn:S}),J=s(null),Q=e=>{J.current=e},X=s({});Object.keys(X.current).length||i.setComponentRef(X.current);const Y=s(0),Z=s(!1),ee=t((()=>new k(i.specifications)),[i.specifications]);X.current.sfp=_;const[re,se]=o("ready"),[te,oe]=o({}),[ne,ae]=o({...i.holderNameRequired&&{holderName:!1}}),[le,ie]=o({...i.hasHolderName&&{holderName:i.data.holderName??""}}),[de,ue]=o(null),[ce,me]=o(""),[pe,he]=o(!1),[fe,ye]=o(c),[be,Se]=o(m),[Ne,ge]=o(null),[Ae,Fe]=o([]),[Ce,je]=o(i.storedPaymentMethodId?i.brand:""),ke=i.billingAddressMode!==d.none&&i.billingAddressRequired,Re=N(i.billingAddressMode),xe=s(Re&&i.data?.billingAddress?.country),[we,Pe]=o(!1),[Be,ve]=o(ke?i.data.billingAddress:null),[Ie,Ve]=o(!1),[Ee,Me]=o(""),[Oe,qe]=o({value:null}),[Te,De]=o(null),{handleChangeFor:Le,triggerValidation:_e,data:Ke,valid:He,errors:Ue,setSchema:ze,setData:We,setValid:$e,setErrors:Ge}=b({schema:[],defaultData:i.data,formatters:p,rules:h}),Je=!!Object.keys(i.installmentOptions).length&&"debit"!==i.fundingSource,Qe=i.showInstallmentAmounts??!0,Xe="kr"===(Ne??i.countryCode),Ye=i.configuration.koreanAuthenticationRequired&&Xe,Ze=Ie&&"auto"===i.configuration.socialSecurityNumberMode||"show"===i.configuration.socialSecurityNumberMode,er=(e,r)=>{i.onFocus({fieldType:e,event:r})},rr=(e,r)=>{i.onBlur({fieldType:e,event:r})},sr=B(me,er,rr),tr=()=>F({props:i,showKCP:Ye,showBrazilianSSN:Ze,...i.billingAddressRequired&&{countrySpecificSchemas:ee.getAddressSchemaForCountry(Be?.country),billingAddressRequiredFields:i.billingAddressRequiredFields}}),or=n((e=>{const r="webInternalElement"!==e.fieldType?e.fieldType:e.name;De(r)}),[]),nr=v(We,$e,Ge),ar=w(Z,_,tr()),lr=t((()=>y(i,{sfp:_},{dualBrandSelectElements:Ae,setDualBrandSelectElements:Fe,setSelectedBrandValue:je,issuingCountryCode:Ne,setIssuingCountryCode:ge},Y)),[Ae,Ne]);X.current.showValidation=()=>{K.current=!0,W?.(),_.current.showValidation(),_e(["holderName","socialSecurityNumber","taxNumber"]),J?.current&&J.current.showValidation()},X.current.processBinLookupResponse=(e,r)=>{lr.processBinLookup(e,r)},X.current.setStatus=se,a((()=>(X.current.setFocusOn=_.current.setFocusOn,X.current.updateStyles=_.current.updateStyles,X.current.handleUnsupportedCard=_.current.handleUnsupportedCard,()=>{_.current.destroy()})),[]),a((()=>{const e=[...i.hasHolderName?["holderName"]:[],...Ze?["socialSecurityNumber"]:[],...Ye?["taxNumber"]:[],...ke?["billingAddress"]:[]];ze(e)}),[i.hasHolderName,Ze,Ye]),a((()=>{ie({...le,holderName:Ke.holderName??"",taxNumber:Ke.taxNumber}),Me(Ke.socialSecurityNumber),ke&&ve({...Ke.billingAddress}),ae({...ne,holderName:!i.holderNameRequired||He.holderName,socialSecurityNumber:!!He.socialSecurityNumber&&He.socialSecurityNumber,taxNumber:!!He.taxNumber&&He.taxNumber,billingAddress:!!He.billingAddress&&He.billingAddress});const e=!!Ue.billingAddress&&Object.entries(Ue.billingAddress).reduce(((e,[,r])=>e||null!=r),!1);oe({...te,holderName:i.holderNameRequired&&Ue.holderName?Ue.holderName:null,socialSecurityNumber:Ze&&Ue.socialSecurityNumber?Ue.socialSecurityNumber:null,taxNumber:Ye&&Ue.taxNumber?Ue.taxNumber:null,billingAddress:ke&&e?Ue.billingAddress:null})}),[Ke,He,Ue]);const ir=j(de);a((()=>{const e=ne.holderName,r=pe,s=!ke||ne.billingAddress,t=!Ye||!!ne.taxNumber&&!!ne.encryptedPassword,o=!Ze||!!ne.socialSecurityNumber,n=r&&e&&s&&t&&o,a=_.current.mapErrorsToValidationRuleResult(),l={...te,...a},{billingAddress:d,...u}=l,c={...u,...d},m=G?.({errors:c,isValidating:K.current,layout:tr(),countrySpecificLabels:ee.getAddressLabelsForCountry(Be?.country)??Re?.default?.labels}),p=m?.currentErrorsSortedByLayout;switch(ue(p),m?.action){case M:$&&P(K.current,_,m?.fieldToFocus),setTimeout((()=>{K.current=!1}),300);break;case E:{const e=T(p,ir,"field"),r=e?.[0];if(r){const e=C(r.errorCode)?r.errorMessage:null;z(e)}else W();break}}if(p){const e=T(p,ir,"field");e?.forEach((e=>{const r={fieldType:e.field,errorCode:e.errorCode};i.onValidationErrorAnalytics(r)}))}i.onChange({data:le,valid:ne,errors:l,isValid:n,billingAddress:Be,selectedBrandValue:Ce,storePaymentMethod:we,socialSecurityNumber:Ee,installments:Oe})}),[le,ne,te,Ce,we,Oe]);const dr=i.storedPaymentMethodId?R:x;return e(r,null,e(l,{ref:_,...g(i),styles:{...i.styles},koreanAuthenticationRequired:i.configuration.koreanAuthenticationRequired,hasKoreanFields:!(!i.configuration.koreanAuthenticationRequired||"kr"!==i.countryCode),onChange:(e,r)=>{if(e.autoCompleteName){if(!i.hasHolderName)return;const r=f("holderName","blur")(e.autoCompleteName)?e.autoCompleteName:null;r&&(We("holderName",r),$e("holderName",!0),Ge("holderName",null))}else i.autoFocus&&Y.current>0&&"handleOnFieldValid"===r?.event&&r?.fieldType===u&&e.valid.encryptedCardNumber&&ar(),ie({...le,...e.data}),oe({...te,...e.errors}),ae({...ne,...e.valid}),he(e.isSfpValid),Se(e.cvcPolicy),Ve(e.showSocialSecurityNumber),ye(e.expiryDatePolicy)},onBrand:i.onBrand,onFocus:sr,type:i.brand,disableIOSArrowKeys:i.disableIOSArrowKeys?or:null,render:({setRootNode:r,setFocusOn:s},t)=>e("div",{ref:r,className:I({"adyen-checkout__card-input":!0,"adyen-checkout-card-input__wrapper":!0,[`adyen-checkout__card-input--${i.fundingSource??"credit"}`]:!0,"adyen-checkout__card-input--loading":"loading"===re}),role:"form"},e(D,null),e(dr,{...A(i),data:le,valid:ne,errors:te,handleChangeFor:Le,focusedElement:ce,setFocusOn:s,sfpState:t,cvcPolicy:be,hasInstallments:Je,showAmountsInInstallments:Qe,handleInstallments:qe,brandsIcons:i.brandsIcons,formData:Ke,formErrors:Ue,formValid:He,expiryDatePolicy:fe,dualBrandSelectElements:Ae,extensions:lr,selectedBrandValue:Ce,showKCP:Ye,showBrazilianSSN:Ze,socialSecurityNumber:Ee,handleOnStoreDetails:Pe,setAddressRef:Q,billingAddress:Be,billingAddressValidationRules:Re&&V(xe.current),partialAddressSchema:Re,handleAddress:nr,onAddressLookup:i.onAddressLookup,onAddressSelected:i.onAddressSelected,addressSearchDebounceMs:i.addressSearchDebounceMs,iOSFocusedField:Te,onFieldFocusAnalytics:er,onFieldBlurAnalytics:rr}))}),i.showPayButton&&i.payButton({status:re,variant:i.isPayButtonPrimaryVariant?"primary":"secondary",icon:H({imageFolder:"components/"})(`${L}lock`)}))};_.defaultProps=i;export{_ as default};
1
+ import{createElement as e,Fragment as r}from"../../../../external/preact/dist/preact.js";import{useRef as s,useMemo as t,useState as o,useCallback as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import l from"./defaultProps.js";import{AddressModeOptions as d}from"./types.js";import{ENCRYPTED_CARD_NUMBER as u,DATE_POLICY_REQUIRED as c,CVC_POLICY_REQUIRED as m}from"../../../internal/SecuredFields/lib/constants.js";import{cardInputFormatters as p,cardInputValidationRules as h,getRuleByNameAndMode as f}from"./validate.js";import y from"../../../internal/SecuredFields/binLookup/extensions.js";import b from"../../../../utils/useForm/useForm.js";import{handlePartialAddressMode as N,extractPropsForSFP as S,extractPropsForCardFields as g,getLayout as A}from"./utils.js";import F from"../../../internal/Address/Specifications.js";import{StoredCardFieldsWrapper as C}from"./components/StoredCardFieldsWrapper.js";import{CardFieldsWrapper as j}from"./components/CardFieldsWrapper.js";import{getAutoJumpHandler as k,getFocusHandler as x,getAddressHandler as R}from"./handlers.js";import P from"../../../../external/classnames/index.js";import{getPartialAddressValidationRules as v}from"../../../internal/Address/validate.js";import w from"../../../../core/Context/useImage.js";import{getArrayDifferences as I}from"../../../../utils/arrayUtils.js";import B from"../../../internal/FormInstruction/FormInstruction.js";import{PREFIX as V}from"../../../internal/Icon/constants.js";import E from"./useSRPanelForCardInputErrors.js";const O=l=>{const O=s(null),q=s(!1),M=w(),D=s(null),_=e=>{D.current=e},L=s({});Object.keys(L.current).length||l.setComponentRef(L.current);const T=s(0),K=s(!1),H=t((()=>new F(l.specifications)),[l.specifications]);L.current.sfp=O;const[U,z]=o("ready"),[W,$]=o({}),[G,J]=o({...l.holderNameRequired&&{holderName:!1}}),[Q,X]=o({...l.hasHolderName&&{holderName:l.data.holderName??""}}),[Y,Z]=o(""),[ee,re]=o(!1),[se,te]=o(c),[oe,ne]=o(m),[ae,ie]=o(null),[le,de]=o([]),[ue,ce]=o(l.storedPaymentMethodId?l.brand:""),me=l.billingAddressMode!==d.none&&l.billingAddressRequired,pe=N(l.billingAddressMode),he=s(pe&&l.data?.billingAddress?.country),[fe,ye]=o(!1),[be,Ne]=o(me?l.data.billingAddress:null),[Se,ge]=o(!1),[Ae,Fe]=o(""),[Ce,je]=o({value:null}),[ke,xe]=o(null),{handleChangeFor:Re,triggerValidation:Pe,data:ve,valid:we,errors:Ie,setSchema:Be,setData:Ve,setValid:Ee,setErrors:Oe}=b({schema:[],defaultData:l.data,formatters:p,rules:h}),qe=!!Object.keys(l.installmentOptions).length&&"debit"!==l.fundingSource,Me=l.showInstallmentAmounts??!0,De="kr"===(ae??l.countryCode),_e=l.configuration.koreanAuthenticationRequired&&De,Le=Se&&"auto"===l.configuration.socialSecurityNumberMode||"show"===l.configuration.socialSecurityNumberMode,Te=(e,r)=>{l.onFocus({fieldType:e,event:r})},Ke=(e,r)=>{l.onBlur({fieldType:e,event:r})},He=x(Z,Te,Ke),Ue=()=>A({props:l,showKCP:_e,showBrazilianSSN:Le,...l.billingAddressRequired&&{countrySpecificSchemas:H.getAddressSchemaForCountry(be?.country),billingAddressRequiredFields:l.billingAddressRequiredFields}}),ze=n((e=>{const r="webInternalElement"!==e.fieldType?e.fieldType:e.name;xe(r)}),[]),We=R(Ve,Ee,Oe),$e=k(K,O,Ue()),Ge=t((()=>y(l,{sfp:O},{dualBrandSelectElements:le,setDualBrandSelectElements:de,setSelectedBrandValue:ce,issuingCountryCode:ae,setIssuingCountryCode:ie},T)),[le,ae]);L.current.showValidation=()=>{q.current=!0,Xe?.(),O.current.showValidation(),Pe(["holderName","socialSecurityNumber","taxNumber"]),D?.current&&D.current.showValidation()},L.current.processBinLookupResponse=(e,r)=>{Ge.processBinLookup(e,r)},L.current.setStatus=z,a((()=>(L.current.setFocusOn=O.current.setFocusOn,L.current.updateStyles=O.current.updateStyles,L.current.handleUnsupportedCard=O.current.handleUnsupportedCard,()=>{O.current.destroy()})),[]),a((()=>{const e=[...l.hasHolderName?["holderName"]:[],...Le?["socialSecurityNumber"]:[],..._e?["taxNumber"]:[],...me?["billingAddress"]:[]];Be(e)}),[l.hasHolderName,Le,_e]),a((()=>{X({...Q,holderName:ve.holderName??"",taxNumber:ve.taxNumber}),Fe(ve.socialSecurityNumber),me&&Ne({...ve.billingAddress}),J({...G,holderName:!l.holderNameRequired||we.holderName,socialSecurityNumber:!!we.socialSecurityNumber&&we.socialSecurityNumber,taxNumber:!!we.taxNumber&&we.taxNumber,billingAddress:!!we.billingAddress&&we.billingAddress});const e=!!Ie.billingAddress&&Object.entries(Ie.billingAddress).reduce(((e,[,r])=>e||null!=r),!1);$({...W,holderName:l.holderNameRequired&&Ie.holderName?Ie.holderName:null,socialSecurityNumber:Le&&Ie.socialSecurityNumber?Ie.socialSecurityNumber:null,taxNumber:_e&&Ie.taxNumber?Ie.taxNumber:null,billingAddress:me&&e?Ie.billingAddress:null})}),[ve,we,Ie]);const{sortedErrorList:Je,previousSortedErrors:Qe,clearSRPanel:Xe}=E({errors:W,props:l,isValidating:q,retrieveLayout:Ue,specifications:H,billingAddress:be,sfp:O});a((()=>{const e=G.holderName,r=ee,s=!me||G.billingAddress,t=!_e||!!G.taxNumber&&!!G.encryptedPassword,o=!Le||!!G.socialSecurityNumber,n=r&&e&&s&&t&&o,a=O.current.mapErrorsToValidationRuleResult(),i={...W,...a};if(Je){const e=I(Je,Qe,"field");e?.forEach((e=>{const r={fieldType:e.field,errorCode:e.errorCode};l.onValidationErrorAnalytics(r)}))}l.onChange({data:Q,valid:G,errors:i,isValid:n,billingAddress:be,selectedBrandValue:ue,storePaymentMethod:fe,socialSecurityNumber:Ae,installments:Ce})}),[Q,G,W,ue,fe,Ce]);const Ye=l.storedPaymentMethodId?C:j;return e(r,null,e(i,{ref:O,...S(l),styles:{...l.styles},koreanAuthenticationRequired:l.configuration.koreanAuthenticationRequired,hasKoreanFields:!(!l.configuration.koreanAuthenticationRequired||"kr"!==l.countryCode),onChange:(e,r)=>{if(e.autoCompleteName){if(!l.hasHolderName)return;const r=f("holderName","blur")(e.autoCompleteName)?e.autoCompleteName:null;r&&(Ve("holderName",r),Ee("holderName",!0),Oe("holderName",null))}else l.autoFocus&&T.current>0&&"handleOnFieldValid"===r?.event&&r?.fieldType===u&&e.valid.encryptedCardNumber&&$e(),X({...Q,...e.data}),$({...W,...e.errors}),J({...G,...e.valid}),re(e.isSfpValid),ne(e.cvcPolicy),ge(e.showSocialSecurityNumber),te(e.expiryDatePolicy)},onBrand:l.onBrand,onFocus:He,type:l.brand,disableIOSArrowKeys:l.disableIOSArrowKeys?ze:null,render:({setRootNode:r,setFocusOn:s},t)=>e("div",{ref:r,className:P({"adyen-checkout__card-input":!0,"adyen-checkout-card-input__wrapper":!0,[`adyen-checkout__card-input--${l.fundingSource??"credit"}`]:!0,"adyen-checkout__card-input--loading":"loading"===U}),role:"form"},e(B,null),e(Ye,{...g(l),data:Q,valid:G,errors:W,handleChangeFor:Re,focusedElement:Y,setFocusOn:s,sfpState:t,cvcPolicy:oe,hasInstallments:qe,showAmountsInInstallments:Me,handleInstallments:je,brandsIcons:l.brandsIcons,formData:ve,formErrors:Ie,formValid:we,expiryDatePolicy:se,dualBrandSelectElements:le,extensions:Ge,selectedBrandValue:ue,showKCP:_e,showBrazilianSSN:Le,socialSecurityNumber:Ae,handleOnStoreDetails:ye,setAddressRef:_,billingAddress:be,billingAddressValidationRules:pe&&v(he.current),partialAddressSchema:pe,handleAddress:We,onAddressLookup:l.onAddressLookup,onAddressSelected:l.onAddressSelected,addressSearchDebounceMs:l.addressSearchDebounceMs,iOSFocusedField:ke,onFieldFocusAnalytics:Te,onFieldBlurAnalytics:Ke}))}),l.showPayButton&&l.payButton({status:U,variant:l.isPayButtonPrimaryVariant?"primary":"secondary",icon:M({imageFolder:"components/"})(`${V}lock`)}))};O.defaultProps=l;export{O as default};
2
2
  //# sourceMappingURL=CardInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CardInput.js","sources":["../../../../../../src/components/Card/components/CardInput/CardInput.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useMemo, useCallback } from 'preact/hooks';\nimport SecuredFieldsProvider from '../../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { OnChangeEventDetails, SFPState } from '../../../internal/SecuredFields/SFP/types';\nimport defaultProps from './defaultProps';\nimport './CardInput.scss';\nimport { AddressModeOptions, CardInputDataState, CardInputErrorState, CardInputProps, CardInputRef, CardInputValidState } from './types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, ENCRYPTED_CARD_NUMBER } from '../../../internal/SecuredFields/lib/constants';\nimport { BinLookupResponse } from '../../types';\nimport { cardInputFormatters, cardInputValidationRules, getRuleByNameAndMode } from './validate';\nimport CIExtensions from '../../../internal/SecuredFields/binLookup/extensions';\nimport useForm from '../../../../utils/useForm';\nimport { SetSRMessagesReturnObject, SortedErrorObject } from '../../../../core/Errors/types';\nimport { handlePartialAddressMode, extractPropsForCardFields, extractPropsForSFP, getLayout, lookupBlurBasedErrors, mapFieldKey } from './utils';\nimport { usePrevious } from '../../../../utils/hookUtils';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { StoredCardFieldsWrapper } from './components/StoredCardFieldsWrapper';\nimport { CardFieldsWrapper } from './components/CardFieldsWrapper';\nimport { getAddressHandler, getAutoJumpHandler, getFocusHandler, setFocusOnFirstField } from './handlers';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { TouchStartEventObj } from './components/types';\nimport classNames from 'classnames';\nimport { getPartialAddressValidationRules } from '../../../internal/Address/validate';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../../core/Errors/constants';\nimport useSRPanelContext from '../../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../../core/Errors/SRPanelProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport { getArrayDifferences } from '../../../../utils/arrayUtils';\nimport FormInstruction from '../../../internal/FormInstruction';\nimport { AddressData } from '../../../../types/global-types';\nimport { CbObjOnFocus } from '../../../internal/SecuredFields/lib/types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/types';\nimport { PREFIX } from '../../../internal/Icon/constants';\n\nconst CardInput = (props: CardInputProps) => {\n const sfp = useRef(null);\n const isValidating = useRef(false);\n const getImage = useImage();\n\n /** SR stuff */\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n /** end SR stuff */\n\n const billingAddressRef = useRef(null);\n const setAddressRef = ref => {\n billingAddressRef.current = ref;\n };\n\n const cardInputRef = useRef<CardInputRef>({});\n // Just call once to create the object by which we expose the members expected by the parent Card comp\n if (!Object.keys(cardInputRef.current).length) {\n props.setComponentRef(cardInputRef.current);\n }\n\n const hasPanLengthRef = useRef(0);\n const isAutoJumping = useRef(false);\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n // Store ref to sfp (useful for 'deep' debugging)\n cardInputRef.current.sfp = sfp;\n\n /**\n * STATE HOOKS\n */\n const [status, setStatus] = useState('ready');\n\n const [errors, setErrors] = useState<CardInputErrorState>({});\n const [valid, setValid] = useState<CardInputValidState>({\n ...(props.holderNameRequired && { holderName: false })\n });\n const [data, setData] = useState<CardInputDataState>({\n ...(props.hasHolderName && { holderName: props.data.holderName ?? '' })\n });\n\n const [sortedErrorList, setSortedErrorList] = useState<SortedErrorObject[]>(null);\n\n const [focusedElement, setFocusedElement] = useState('');\n const [isSfpValid, setIsSfpValid] = useState(false);\n const [expiryDatePolicy, setExpiryDatePolicy] = useState(DATE_POLICY_REQUIRED);\n const [cvcPolicy, setCvcPolicy] = useState(CVC_POLICY_REQUIRED);\n const [issuingCountryCode, setIssuingCountryCode] = useState<string>(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState(props.storedPaymentMethodId ? props.brand : ''); // If this is a storedCard comp initialise state with the storedCard's brand\n\n const showBillingAddress = props.billingAddressMode !== AddressModeOptions.none && props.billingAddressRequired;\n\n const partialAddressSchema = handlePartialAddressMode(props.billingAddressMode);\n // Keeps the value of the country set initially by the merchant, before the Address Component mutates it\n const partialAddressCountry = useRef<string>(partialAddressSchema && props.data?.billingAddress?.country);\n\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n const [billingAddress, setBillingAddress] = useState<AddressData>(showBillingAddress ? props.data.billingAddress : null);\n const [showSocialSecurityNumber, setShowSocialSecurityNumber] = useState(false);\n const [socialSecurityNumber, setSocialSecurityNumber] = useState('');\n const [installments, setInstallments] = useState<InstallmentsObj>({ value: null });\n\n // re. Disable arrows for iOS: The name of the element calling for other elements to be disabled\n // - either a securedField type (like 'encryptedCardNumber') when call is coming from SF\n // or else the name of an internal, Adyen-web, element (like 'holderName')\n const [iOSFocusedField, setIOSFocusedField] = useState(null);\n\n /**\n * LOCAL VARS\n */\n const {\n handleChangeFor,\n triggerValidation,\n data: formData,\n valid: formValid,\n errors: formErrors,\n setSchema,\n setData: setFormData,\n setValid: setFormValid,\n setErrors: setFormErrors\n } = useForm<CardInputDataState>({\n schema: [],\n defaultData: props.data,\n formatters: cardInputFormatters,\n rules: cardInputValidationRules\n });\n\n const hasInstallments = !!Object.keys(props.installmentOptions).length && props.fundingSource !== 'debit';\n const showAmountsInInstallments = props.showInstallmentAmounts ?? true;\n\n const cardCountryCode: string = issuingCountryCode ?? props.countryCode;\n const isKorea = cardCountryCode === 'kr'; // If issuingCountryCode or the merchant defined countryCode is set to 'kr'\n const showKCP = props.configuration.koreanAuthenticationRequired && isKorea;\n\n const showBrazilianSSN: boolean =\n (showSocialSecurityNumber && props.configuration.socialSecurityNumberMode === 'auto') ||\n props.configuration.socialSecurityNumberMode === 'show';\n\n /**\n * HANDLERS\n */\n // Handlers for focus & blur on all fields. Can be renamed to onFieldFocus once the onFocusField is renamed in Field.tsx\n const onFieldFocusAnalytics = (who: string, e: Event | CbObjOnFocus) => {\n props.onFocus({ fieldType: who, event: e });\n };\n const onFieldBlurAnalytics = (who: string, e: Event | CbObjOnFocus) => {\n props.onBlur({ fieldType: who, event: e });\n };\n\n // Make SecuredFields aware of the focus & blur handlers\n const handleFocus = getFocusHandler(setFocusedElement, onFieldFocusAnalytics, onFieldBlurAnalytics);\n\n const retrieveLayout = (): string[] => {\n return getLayout({\n props,\n showKCP,\n showBrazilianSSN,\n ...(props.billingAddressRequired && {\n countrySpecificSchemas: specifications.getAddressSchemaForCountry(billingAddress?.country),\n billingAddressRequiredFields: props.billingAddressRequiredFields\n })\n });\n };\n\n /**\n * re. Disabling arrow keys in iOS:\n * Only by disabling all fields in the Card PM except for the active securedField input can we force the iOS soft keyboard arrow keys to disable\n *\n * NOTE: only called if ua.__IS_IOS = true && this.config.disableIOSArrowKeys = true (as referenced in CSF)\n *\n * @param obj - has fieldType prop saying whether this function is being called in response to an securedFields click ('encryptedCardNumber' etc)\n * - in which case we should disable all non-SF fields\n * or,\n * due to an internal action ('webInternalElement') - in which case we can enable all non-SF fields\n */\n const handleTouchstartIOS = useCallback((obj: TouchStartEventObj) => {\n const elementType = obj.fieldType !== 'webInternalElement' ? obj.fieldType : obj.name;\n setIOSFocusedField(elementType);\n }, []);\n\n const handleAddress = getAddressHandler(setFormData, setFormValid, setFormErrors);\n\n const doPanAutoJump = getAutoJumpHandler(isAutoJumping, sfp, retrieveLayout());\n\n const handleSecuredFieldsChange = (sfState: SFPState, eventDetails?: OnChangeEventDetails): void => {\n /**\n * Handling auto complete value for holderName (but only if the component is using a holderName field)\n */\n if (sfState.autoCompleteName) {\n if (!props.hasHolderName) return;\n const holderNameValidationFn = getRuleByNameAndMode('holderName', 'blur');\n const acHolderName = holderNameValidationFn(sfState.autoCompleteName) ? sfState.autoCompleteName : null;\n if (acHolderName) {\n setFormData('holderName', acHolderName);\n setFormValid('holderName', true); // only if holderName is valid does this fny get called - so we know it's valid and w/o error\n setFormErrors('holderName', null);\n }\n return;\n }\n\n /**\n * Decide if we can shift focus to the expiryDate field.\n *\n * We can if... the config prop, autoFocus, is true AND we have a panLength value from binLookup\n * AND we are responding to a handleOnFieldValid message about the PAN that says it is valid\n */\n if (\n props.autoFocus &&\n hasPanLengthRef.current > 0 &&\n eventDetails?.event === 'handleOnFieldValid' &&\n eventDetails?.fieldType === ENCRYPTED_CARD_NUMBER &&\n sfState.valid.encryptedCardNumber\n ) {\n doPanAutoJump();\n }\n\n /**\n * Process SFP state\n */\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n\n // Values relating to /binLookup response\n setCvcPolicy(sfState.cvcPolicy);\n setShowSocialSecurityNumber(sfState.showSocialSecurityNumber);\n setExpiryDatePolicy(sfState.expiryDatePolicy);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n CIExtensions(\n props,\n { sfp },\n {\n dualBrandSelectElements,\n setDualBrandSelectElements,\n setSelectedBrandValue,\n issuingCountryCode,\n setIssuingCountryCode\n },\n hasPanLengthRef\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPOSE METHODS expected by Card.tsx\n */\n cardInputRef.current.showValidation = () => {\n // set flag\n isValidating.current = true;\n\n /**\n * Clear errors prior to validating so that the screenreader will read them *all* again, and in the right order\n * - only using aria-atomic on the error panel will read them in the wrong order\n */\n clearSRPanel?.(); // TODO - recheck if this is still true\n\n // Validate SecuredFields\n sfp.current.showValidation();\n\n // Validate holderName & SSN & KCP (taxNumber) but *not* billingAddress\n triggerValidation(['holderName', 'socialSecurityNumber', 'taxNumber']);\n\n // Validate Address\n if (billingAddressRef?.current) billingAddressRef.current.showValidation();\n };\n\n cardInputRef.current.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n cardInputRef.current.setStatus = setStatus;\n\n /**\n * EFFECT HOOKS\n */\n useEffect(() => {\n // componentDidMount - expose more methods expected by Card.tsx\n cardInputRef.current.setFocusOn = sfp.current.setFocusOn;\n cardInputRef.current.updateStyles = sfp.current.updateStyles;\n cardInputRef.current.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n // componentWillUnmount\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n /**\n * Handle form schema updates\n */\n useEffect(() => {\n const newSchema = [\n ...(props.hasHolderName ? ['holderName'] : []),\n ...(showBrazilianSSN ? ['socialSecurityNumber'] : []),\n ...(showKCP ? ['taxNumber'] : []),\n ...(showBillingAddress ? ['billingAddress'] : [])\n ];\n setSchema(newSchema);\n }, [props.hasHolderName, showBrazilianSSN, showKCP]);\n\n /**\n * Handle updates from useForm\n */\n useEffect(() => {\n setData({ ...data, holderName: formData.holderName ?? '', taxNumber: formData.taxNumber });\n\n setSocialSecurityNumber(formData.socialSecurityNumber);\n\n if (showBillingAddress) setBillingAddress({ ...formData.billingAddress });\n\n setValid({\n ...valid,\n holderName: props.holderNameRequired ? formValid.holderName : true,\n // Setting value to false if it's falsy keeps in line with existing, expected behaviour\n // - but there is an argument to allow 'undefined' as a value to indicate the non-presence of the field\n socialSecurityNumber: formValid.socialSecurityNumber ? formValid.socialSecurityNumber : false,\n taxNumber: formValid.taxNumber ? formValid.taxNumber : false,\n billingAddress: formValid.billingAddress ? formValid.billingAddress : false\n });\n\n // Check if billingAddress errors object has any properties that aren't null or undefined\n const addressHasErrors = formErrors.billingAddress\n ? Object.entries(formErrors.billingAddress).reduce((acc, [, error]) => acc || error != null, false)\n : false;\n\n // Errors\n setErrors({\n ...errors,\n holderName: props.holderNameRequired && !!formErrors.holderName ? formErrors.holderName : null,\n socialSecurityNumber: showBrazilianSSN && !!formErrors.socialSecurityNumber ? formErrors.socialSecurityNumber : null,\n taxNumber: showKCP && !!formErrors.taxNumber ? formErrors.taxNumber : null,\n billingAddress: showBillingAddress && addressHasErrors ? formErrors.billingAddress : null\n });\n }, [formData, formValid, formErrors]);\n\n // Get the previous value\n const previousSortedErrors = usePrevious(sortedErrorList);\n\n /**\n * Main 'componentDidUpdate' handler\n */\n useEffect(() => {\n const holderNameValid: boolean = valid.holderName;\n\n const sfpValid: boolean = isSfpValid;\n const addressValid: boolean = showBillingAddress ? valid.billingAddress : true;\n\n const koreanAuthentication: boolean = showKCP ? !!valid.taxNumber && !!valid.encryptedPassword : true;\n\n const socialSecurityNumberValid: boolean = showBrazilianSSN ? !!valid.socialSecurityNumber : true;\n\n const isValid: boolean = sfpValid && holderNameValid && addressValid && koreanAuthentication && socialSecurityNumberValid;\n\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n const mergedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors AND solves race condition problems for sfp from showValidation\n\n // Extract and then flatten billingAddress errors into a new object with *all* the field errors at top level\n const { billingAddress: extractedAddressErrors, ...errorsWithoutAddress } = mergedErrors;\n\n const errorsForPanel = { ...errorsWithoutAddress, ...extractedAddressErrors };\n\n // Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: retrieveLayout(),\n // If we don't have country specific address labels, we might have a label related to a partialAddressSchema (i.e. zipCode)\n countrySpecificLabels: specifications.getAddressLabelsForCountry(billingAddress?.country) ?? partialAddressSchema?.default?.labels\n });\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout);\n\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n if (shouldMoveFocusSR) setFocusOnFirstField(isValidating.current, sfp, srPanelResp?.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Use the error code to look up whether error is actually a blur based one (most are but some SF ones aren't)\n const isBlurBasedError = lookupBlurBasedErrors(latestErrorMsg.errorCode);\n\n /**\n * ONLY ADD BLUR BASED ERRORS TO THE ERROR PANEL - doing this step prevents the non-blur based errors from being read out twice\n * (once from the aria-live, error panel & once from the aria-describedby element)\n */\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n // console.log('### CardInput2::componentDidUpdate:: #2 (not validating) single error:: latestSRError', latestSRError);\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n // console.log('### CardInput2::componentDidUpdate:: #3(not validating) clearing errors:: NO latestErrorMsg');\n clearSRPanel();\n }\n break;\n }\n default:\n break;\n }\n\n // Analytics\n if (currentErrorsSortedByLayout) {\n const newErrors = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n newErrors?.forEach(errorItem => {\n const aObj: FieldErrorAnalyticsObject = {\n fieldType: errorItem.field,\n errorCode: errorItem.errorCode\n };\n\n props.onValidationErrorAnalytics(aObj);\n });\n }\n\n props.onChange({\n data,\n valid,\n errors: mergedErrors,\n isValid,\n billingAddress,\n selectedBrandValue,\n storePaymentMethod,\n socialSecurityNumber,\n installments\n });\n }, [data, valid, errors, selectedBrandValue, storePaymentMethod, installments]);\n\n /**\n * RENDER\n */\n const FieldToRender = props.storedPaymentMethodId ? StoredCardFieldsWrapper : CardFieldsWrapper;\n\n return (\n <Fragment>\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n styles={{ ...props.styles }}\n koreanAuthenticationRequired={props.configuration.koreanAuthenticationRequired}\n hasKoreanFields={!!(props.configuration.koreanAuthenticationRequired && props.countryCode === 'kr')}\n onChange={handleSecuredFieldsChange}\n onBrand={props.onBrand}\n onFocus={handleFocus}\n type={props.brand}\n disableIOSArrowKeys={props.disableIOSArrowKeys ? handleTouchstartIOS : null}\n render={({ setRootNode, setFocusOn }, sfpState) => (\n <div\n ref={setRootNode}\n className={classNames({\n 'adyen-checkout__card-input': true,\n 'adyen-checkout-card-input__wrapper': true,\n [`adyen-checkout__card-input--${props.fundingSource ?? 'credit'}`]: true,\n 'adyen-checkout__card-input--loading': status === 'loading'\n })}\n role={'form'}\n >\n <FormInstruction />\n\n <FieldToRender\n // Extract exact props that we need to pass down\n {...extractPropsForCardFields(props)}\n // Pass on vars created in CardInput:\n // Base (shared w. StoredCard)\n data={data}\n valid={valid}\n errors={errors}\n handleChangeFor={handleChangeFor}\n focusedElement={focusedElement}\n setFocusOn={setFocusOn}\n sfpState={sfpState}\n cvcPolicy={cvcPolicy}\n hasInstallments={hasInstallments}\n showAmountsInInstallments={showAmountsInInstallments}\n handleInstallments={setInstallments}\n // For Card\n brandsIcons={props.brandsIcons}\n formData={formData}\n formErrors={formErrors}\n formValid={formValid}\n expiryDatePolicy={expiryDatePolicy}\n dualBrandSelectElements={dualBrandSelectElements}\n extensions={extensions}\n selectedBrandValue={selectedBrandValue}\n // For KCP\n showKCP={showKCP}\n // For SSN\n showBrazilianSSN={showBrazilianSSN}\n socialSecurityNumber={socialSecurityNumber}\n // For Store details\n handleOnStoreDetails={setStorePaymentMethod}\n // For Address\n setAddressRef={setAddressRef}\n billingAddress={billingAddress}\n billingAddressValidationRules={partialAddressSchema && getPartialAddressValidationRules(partialAddressCountry.current)}\n partialAddressSchema={partialAddressSchema}\n handleAddress={handleAddress}\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n //\n iOSFocusedField={iOSFocusedField}\n //\n onFieldFocusAnalytics={onFieldFocusAnalytics}\n onFieldBlurAnalytics={onFieldBlurAnalytics}\n />\n </div>\n )}\n />\n {props.showPayButton &&\n props.payButton({\n status,\n variant: props.isPayButtonPrimaryVariant ? 'primary' : 'secondary',\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </Fragment>\n );\n};\n\nCardInput.defaultProps = defaultProps;\n\nexport default CardInput;\n"],"names":["CardInput","props","sfp","useRef","isValidating","getImage","useImage","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressRef","setAddressRef","ref","current","cardInputRef","Object","keys","length","setComponentRef","hasPanLengthRef","isAutoJumping","specifications","useMemo","Specifications","status","setStatus","useState","errors","setErrors","valid","setValid","holderNameRequired","holderName","data","setData","hasHolderName","sortedErrorList","setSortedErrorList","focusedElement","setFocusedElement","isSfpValid","setIsSfpValid","expiryDatePolicy","setExpiryDatePolicy","DATE_POLICY_REQUIRED","cvcPolicy","setCvcPolicy","CVC_POLICY_REQUIRED","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","storedPaymentMethodId","brand","showBillingAddress","billingAddressMode","AddressModeOptions","none","billingAddressRequired","partialAddressSchema","handlePartialAddressMode","partialAddressCountry","billingAddress","country","storePaymentMethod","setStorePaymentMethod","setBillingAddress","showSocialSecurityNumber","setShowSocialSecurityNumber","socialSecurityNumber","setSocialSecurityNumber","installments","setInstallments","value","iOSFocusedField","setIOSFocusedField","handleChangeFor","triggerValidation","formData","formValid","formErrors","setSchema","setFormData","setFormValid","setFormErrors","useForm","schema","defaultData","formatters","cardInputFormatters","rules","cardInputValidationRules","hasInstallments","installmentOptions","fundingSource","showAmountsInInstallments","showInstallmentAmounts","isKorea","countryCode","showKCP","configuration","koreanAuthenticationRequired","showBrazilianSSN","socialSecurityNumberMode","onFieldFocusAnalytics","who","e","onFocus","fieldType","event","onFieldBlurAnalytics","onBlur","handleFocus","getFocusHandler","retrieveLayout","getLayout","countrySpecificSchemas","getAddressSchemaForCountry","billingAddressRequiredFields","handleTouchstartIOS","useCallback","obj","elementType","name","handleAddress","getAddressHandler","doPanAutoJump","getAutoJumpHandler","extensions","CIExtensions","showValidation","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","useEffect","setFocusOn","updateStyles","handleUnsupportedCard","destroy","newSchema","taxNumber","addressHasErrors","entries","reduce","acc","error","previousSortedErrors","usePrevious","holderNameValid","sfpValid","addressValid","koreanAuthentication","encryptedPassword","socialSecurityNumberValid","isValid","sfStateErrorsObj","mapErrorsToValidationRuleResult","mergedErrors","extractedAddressErrors","errorsWithoutAddress","errorsForPanel","srPanelResp","layout","countrySpecificLabels","getAddressLabelsForCountry","default","labels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnFirstField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","lookupBlurBasedErrors","errorCode","errorMessage","newErrors","forEach","errorItem","aObj","field","onValidationErrorAnalytics","onChange","FieldToRender","StoredCardFieldsWrapper","CardFieldsWrapper","h","Fragment","SecuredFieldsProvider","extractPropsForSFP","styles","hasKoreanFields","sfState","eventDetails","autoCompleteName","acHolderName","getRuleByNameAndMode","holderNameValidationFn","autoFocus","ENCRYPTED_CARD_NUMBER","encryptedCardNumber","onBrand","type","disableIOSArrowKeys","render","setRootNode","sfpState","div","className","classNames","role","FormInstruction","extractPropsForCardFields","handleInstallments","brandsIcons","handleOnStoreDetails","billingAddressValidationRules","getPartialAddressValidationRules","onAddressLookup","onAddressSelected","addressSearchDebounceMs","showPayButton","payButton","variant","isPayButtonPrimaryVariant","icon","imageFolder","PREFIX","defaultProps"],"mappings":"s1DAkCA,MAAMA,EAAaC,IACf,MAAMC,EAAMC,EAAO,MACbC,EAAeD,GAAO,GACtBE,EAAWC,KAGXC,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAG1FC,EAAuCL,IAA2B,CACpEM,mBAAoBC,IAIlBC,EAAoBZ,EAAO,MAC3Ba,EAAgBC,IAClBF,EAAkBG,QAAUD,CAAAA,EAG1BE,EAAehB,EAAqB,CAAA,GAErCiB,OAAOC,KAAKF,EAAaD,SAASI,QACnCrB,EAAMsB,gBAAgBJ,EAAaD,SAGvC,MAAMM,EAAkBrB,EAAO,GACzBsB,EAAgBtB,GAAO,GAEvBuB,GAAiBC,GAAQ,IAAM,IAAIC,EAAe3B,EAAMyB,iBAAiB,CAACzB,EAAMyB,iBAGtFP,EAAaD,QAAQhB,IAAMA,EAK3B,MAAO2B,GAAQC,IAAaC,EAAS,UAE9BC,GAAQC,IAAaF,EAA8B,CAAC,IACpDG,GAAOC,IAAYJ,EAA8B,IACh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G,WAAYA,EACZ4E,SAAUA,EACVzK,UAAWA,GACXiD,gBAAiBA,GACjBG,0BAA2BA,GAC3B4H,mBAAoBnJ,GAEpBoJ,YAAalO,EAAMkO,YACnB9I,SAAUA,GACVE,WAAYA,GACZD,UAAWA,GACXvC,iBAAkBA,GAClBQ,wBAAyBA,GACzBgF,WAAYA,GACZ9E,mBAAoBA,GAEpBiD,QAASA,GAETG,iBAAkBA,GAClBjC,qBAAsBA,GAEtBwJ,qBAAsB5J,GAEtBxD,cAAeA,EACfqD,eAAgBA,GAChBgK,8BAA+BnK,IAAwBoK,EAAiClK,GAAsBlD,SAC9GgD,qBAAsBA,GACtBiE,cAAeA,GACfoG,gBAAiBtO,EAAMsO,gBACvBC,kBAAmBvO,EAAMuO,kBACzBC,wBAAyBxO,EAAMwO,wBAE/BxJ,gBAAiBA,GAEjB8B,sBAAuBA,GACvBM,qBAAsBA,QAKrCpH,EAAMyO,eACHzO,EAAM0O,UAAU,CACZ9M,UACA+M,QAAS3O,EAAM4O,0BAA4B,UAAY,YACvDC,KAAMzO,EAAS,CAAE0O,YAAa,eAAxB1O,CAAyC,GAAG2O,WACtD,EAKhBhP,EAAUiP,aAAeA"}
1
+ {"version":3,"file":"CardInput.js","sources":["../../../../../../src/components/Card/components/CardInput/CardInput.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useMemo, useCallback } from 'preact/hooks';\nimport SecuredFieldsProvider from '../../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { OnChangeEventDetails, SFPState } from '../../../internal/SecuredFields/SFP/types';\nimport defaultProps from './defaultProps';\nimport './CardInput.scss';\nimport { AddressModeOptions, CardInputDataState, CardInputErrorState, CardInputProps, CardInputRef, CardInputValidState } from './types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, ENCRYPTED_CARD_NUMBER } from '../../../internal/SecuredFields/lib/constants';\nimport { BinLookupResponse } from '../../types';\nimport { cardInputFormatters, cardInputValidationRules, getRuleByNameAndMode } from './validate';\nimport CIExtensions from '../../../internal/SecuredFields/binLookup/extensions';\nimport useForm from '../../../../utils/useForm';\nimport { SortedErrorObject } from '../../../../core/Errors/types';\nimport { handlePartialAddressMode, extractPropsForCardFields, extractPropsForSFP, getLayout } from './utils';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { StoredCardFieldsWrapper } from './components/StoredCardFieldsWrapper';\nimport { CardFieldsWrapper } from './components/CardFieldsWrapper';\nimport { getAddressHandler, getAutoJumpHandler, getFocusHandler } from './handlers';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { TouchStartEventObj } from './components/types';\nimport classNames from 'classnames';\nimport { getPartialAddressValidationRules } from '../../../internal/Address/validate';\nimport useImage from '../../../../core/Context/useImage';\nimport { getArrayDifferences } from '../../../../utils/arrayUtils';\nimport FormInstruction from '../../../internal/FormInstruction';\nimport { AddressData } from '../../../../types/global-types';\nimport { CbObjOnFocus } from '../../../internal/SecuredFields/lib/types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/types';\nimport { PREFIX } from '../../../internal/Icon/constants';\nimport useSRPanelForCardInputErrors from './useSRPanelForCardInputErrors';\n\nconst CardInput = (props: CardInputProps) => {\n const sfp = useRef(null);\n const isValidating = useRef(false);\n const getImage = useImage();\n\n const billingAddressRef = useRef(null);\n const setAddressRef = ref => {\n billingAddressRef.current = ref;\n };\n\n const cardInputRef = useRef<CardInputRef>({});\n // Just call once to create the object by which we expose the members expected by the parent Card comp\n if (!Object.keys(cardInputRef.current).length) {\n props.setComponentRef(cardInputRef.current);\n }\n\n const hasPanLengthRef = useRef(0);\n const isAutoJumping = useRef(false);\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n // Store ref to sfp (useful for 'deep' debugging)\n cardInputRef.current.sfp = sfp;\n\n /**\n * STATE HOOKS\n */\n const [status, setStatus] = useState('ready');\n\n const [errors, setErrors] = useState<CardInputErrorState>({});\n const [valid, setValid] = useState<CardInputValidState>({\n ...(props.holderNameRequired && { holderName: false })\n });\n const [data, setData] = useState<CardInputDataState>({\n ...(props.hasHolderName && { holderName: props.data.holderName ?? '' })\n });\n\n const [focusedElement, setFocusedElement] = useState('');\n const [isSfpValid, setIsSfpValid] = useState(false);\n const [expiryDatePolicy, setExpiryDatePolicy] = useState(DATE_POLICY_REQUIRED);\n const [cvcPolicy, setCvcPolicy] = useState(CVC_POLICY_REQUIRED);\n const [issuingCountryCode, setIssuingCountryCode] = useState<string>(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState(props.storedPaymentMethodId ? props.brand : ''); // If this is a storedCard comp initialise state with the storedCard's brand\n\n const showBillingAddress = props.billingAddressMode !== AddressModeOptions.none && props.billingAddressRequired;\n\n const partialAddressSchema = handlePartialAddressMode(props.billingAddressMode);\n // Keeps the value of the country set initially by the merchant, before the Address Component mutates it\n const partialAddressCountry = useRef<string>(partialAddressSchema && props.data?.billingAddress?.country);\n\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n const [billingAddress, setBillingAddress] = useState<AddressData>(showBillingAddress ? props.data.billingAddress : null);\n const [showSocialSecurityNumber, setShowSocialSecurityNumber] = useState(false);\n const [socialSecurityNumber, setSocialSecurityNumber] = useState('');\n const [installments, setInstallments] = useState<InstallmentsObj>({ value: null });\n\n // re. Disable arrows for iOS: The name of the element calling for other elements to be disabled\n // - either a securedField type (like 'encryptedCardNumber') when call is coming from SF\n // or else the name of an internal, Adyen-web, element (like 'holderName')\n const [iOSFocusedField, setIOSFocusedField] = useState(null);\n\n /**\n * LOCAL VARS\n */\n const {\n handleChangeFor,\n triggerValidation,\n data: formData,\n valid: formValid,\n errors: formErrors,\n setSchema,\n setData: setFormData,\n setValid: setFormValid,\n setErrors: setFormErrors\n } = useForm<CardInputDataState>({\n schema: [],\n defaultData: props.data,\n formatters: cardInputFormatters,\n rules: cardInputValidationRules\n });\n\n const hasInstallments = !!Object.keys(props.installmentOptions).length && props.fundingSource !== 'debit';\n const showAmountsInInstallments = props.showInstallmentAmounts ?? true;\n\n const cardCountryCode: string = issuingCountryCode ?? props.countryCode;\n const isKorea = cardCountryCode === 'kr'; // If issuingCountryCode or the merchant defined countryCode is set to 'kr'\n const showKCP = props.configuration.koreanAuthenticationRequired && isKorea;\n\n const showBrazilianSSN: boolean =\n (showSocialSecurityNumber && props.configuration.socialSecurityNumberMode === 'auto') ||\n props.configuration.socialSecurityNumberMode === 'show';\n\n /**\n * HANDLERS\n */\n // Handlers for focus & blur on all fields. Can be renamed to onFieldFocus once the onFocusField is renamed in Field.tsx\n const onFieldFocusAnalytics = (who: string, e: Event | CbObjOnFocus) => {\n props.onFocus({ fieldType: who, event: e });\n };\n const onFieldBlurAnalytics = (who: string, e: Event | CbObjOnFocus) => {\n props.onBlur({ fieldType: who, event: e });\n };\n\n // Make SecuredFields aware of the focus & blur handlers\n const handleFocus = getFocusHandler(setFocusedElement, onFieldFocusAnalytics, onFieldBlurAnalytics);\n\n const retrieveLayout = (): string[] => {\n return getLayout({\n props,\n showKCP,\n showBrazilianSSN,\n ...(props.billingAddressRequired && {\n countrySpecificSchemas: specifications.getAddressSchemaForCountry(billingAddress?.country),\n billingAddressRequiredFields: props.billingAddressRequiredFields\n })\n });\n };\n\n /**\n * re. Disabling arrow keys in iOS:\n * Only by disabling all fields in the Card PM except for the active securedField input can we force the iOS soft keyboard arrow keys to disable\n *\n * NOTE: only called if ua.__IS_IOS = true && this.config.disableIOSArrowKeys = true (as referenced in CSF)\n *\n * @param obj - has fieldType prop saying whether this function is being called in response to an securedFields click ('encryptedCardNumber' etc)\n * - in which case we should disable all non-SF fields\n * or,\n * due to an internal action ('webInternalElement') - in which case we can enable all non-SF fields\n */\n const handleTouchstartIOS = useCallback((obj: TouchStartEventObj) => {\n const elementType = obj.fieldType !== 'webInternalElement' ? obj.fieldType : obj.name;\n setIOSFocusedField(elementType);\n }, []);\n\n const handleAddress = getAddressHandler(setFormData, setFormValid, setFormErrors);\n\n const doPanAutoJump = getAutoJumpHandler(isAutoJumping, sfp, retrieveLayout());\n\n const handleSecuredFieldsChange = (sfState: SFPState, eventDetails?: OnChangeEventDetails): void => {\n /**\n * Handling auto complete value for holderName (but only if the component is using a holderName field)\n */\n if (sfState.autoCompleteName) {\n if (!props.hasHolderName) return;\n const holderNameValidationFn = getRuleByNameAndMode('holderName', 'blur');\n const acHolderName = holderNameValidationFn(sfState.autoCompleteName) ? sfState.autoCompleteName : null;\n if (acHolderName) {\n setFormData('holderName', acHolderName);\n setFormValid('holderName', true); // only if holderName is valid does this fny get called - so we know it's valid and w/o error\n setFormErrors('holderName', null);\n }\n return;\n }\n\n /**\n * Decide if we can shift focus to the expiryDate field.\n *\n * We can if... the config prop, autoFocus, is true AND we have a panLength value from binLookup\n * AND we are responding to a handleOnFieldValid message about the PAN that says it is valid\n */\n if (\n props.autoFocus &&\n hasPanLengthRef.current > 0 &&\n eventDetails?.event === 'handleOnFieldValid' &&\n eventDetails?.fieldType === ENCRYPTED_CARD_NUMBER &&\n sfState.valid.encryptedCardNumber\n ) {\n doPanAutoJump();\n }\n\n /**\n * Process SFP state\n */\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n\n // Values relating to /binLookup response\n setCvcPolicy(sfState.cvcPolicy);\n setShowSocialSecurityNumber(sfState.showSocialSecurityNumber);\n setExpiryDatePolicy(sfState.expiryDatePolicy);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n CIExtensions(\n props,\n { sfp },\n {\n dualBrandSelectElements,\n setDualBrandSelectElements,\n setSelectedBrandValue,\n issuingCountryCode,\n setIssuingCountryCode\n },\n hasPanLengthRef\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPOSE METHODS expected by Card.tsx\n */\n cardInputRef.current.showValidation = () => {\n // set flag\n isValidating.current = true;\n\n /**\n * Clear errors prior to validating so that the screenreader will read them *all* again, and in the right order\n * - only using aria-atomic on the error panel will read them in the wrong order\n */\n clearSRPanel?.(); // TODO - recheck if this is still true\n\n // Validate SecuredFields\n sfp.current.showValidation();\n\n // Validate holderName & SSN & KCP (taxNumber) but *not* billingAddress\n triggerValidation(['holderName', 'socialSecurityNumber', 'taxNumber']);\n\n // Validate Address\n if (billingAddressRef?.current) billingAddressRef.current.showValidation();\n };\n\n cardInputRef.current.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n cardInputRef.current.setStatus = setStatus;\n\n /**\n * EFFECT HOOKS\n */\n useEffect(() => {\n // componentDidMount - expose more methods expected by Card.tsx\n cardInputRef.current.setFocusOn = sfp.current.setFocusOn;\n cardInputRef.current.updateStyles = sfp.current.updateStyles;\n cardInputRef.current.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n // componentWillUnmount\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n /**\n * Handle form schema updates\n */\n useEffect(() => {\n const newSchema = [\n ...(props.hasHolderName ? ['holderName'] : []),\n ...(showBrazilianSSN ? ['socialSecurityNumber'] : []),\n ...(showKCP ? ['taxNumber'] : []),\n ...(showBillingAddress ? ['billingAddress'] : [])\n ];\n setSchema(newSchema);\n }, [props.hasHolderName, showBrazilianSSN, showKCP]);\n\n /**\n * Handle updates from useForm\n */\n useEffect(() => {\n setData({ ...data, holderName: formData.holderName ?? '', taxNumber: formData.taxNumber });\n\n setSocialSecurityNumber(formData.socialSecurityNumber);\n\n if (showBillingAddress) setBillingAddress({ ...formData.billingAddress });\n\n setValid({\n ...valid,\n holderName: props.holderNameRequired ? formValid.holderName : true,\n // Setting value to false if it's falsy keeps in line with existing, expected behaviour\n // - but there is an argument to allow 'undefined' as a value to indicate the non-presence of the field\n socialSecurityNumber: formValid.socialSecurityNumber ? formValid.socialSecurityNumber : false,\n taxNumber: formValid.taxNumber ? formValid.taxNumber : false,\n billingAddress: formValid.billingAddress ? formValid.billingAddress : false\n });\n\n // Check if billingAddress errors object has any properties that aren't null or undefined\n const addressHasErrors = formErrors.billingAddress\n ? Object.entries(formErrors.billingAddress).reduce((acc, [, error]) => acc || error != null, false)\n : false;\n\n // Errors\n setErrors({\n ...errors,\n holderName: props.holderNameRequired && !!formErrors.holderName ? formErrors.holderName : null,\n socialSecurityNumber: showBrazilianSSN && !!formErrors.socialSecurityNumber ? formErrors.socialSecurityNumber : null,\n taxNumber: showKCP && !!formErrors.taxNumber ? formErrors.taxNumber : null,\n billingAddress: showBillingAddress && addressHasErrors ? formErrors.billingAddress : null\n });\n }, [formData, formValid, formErrors]);\n\n // Use the custom hook to set (or clear) errors in the SRPanel\n const {\n sortedErrorList: currentErrorsSortedByLayout,\n previousSortedErrors,\n clearSRPanel\n } = useSRPanelForCardInputErrors({\n errors,\n props,\n isValidating,\n retrieveLayout,\n specifications,\n billingAddress,\n sfp\n });\n\n /**\n * Main 'componentDidUpdate' handler\n */\n useEffect(() => {\n const holderNameValid: boolean = valid.holderName;\n\n const sfpValid: boolean = isSfpValid;\n const addressValid: boolean = showBillingAddress ? valid.billingAddress : true;\n\n const koreanAuthentication: boolean = showKCP ? !!valid.taxNumber && !!valid.encryptedPassword : true;\n\n const socialSecurityNumberValid: boolean = showBrazilianSSN ? !!valid.socialSecurityNumber : true;\n\n const isValid: boolean = sfpValid && holderNameValid && addressValid && koreanAuthentication && socialSecurityNumberValid;\n\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n const mergedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors AND solves race condition problems for sfp from showValidation\n\n // Analytics\n if (currentErrorsSortedByLayout) {\n const newErrors = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n newErrors?.forEach(errorItem => {\n const aObj: FieldErrorAnalyticsObject = {\n fieldType: errorItem.field,\n errorCode: errorItem.errorCode\n };\n\n props.onValidationErrorAnalytics(aObj);\n });\n }\n\n props.onChange({\n data,\n valid,\n errors: mergedErrors,\n isValid,\n billingAddress,\n selectedBrandValue,\n storePaymentMethod,\n socialSecurityNumber,\n installments\n });\n }, [data, valid, errors, selectedBrandValue, storePaymentMethod, installments]);\n\n /**\n * RENDER\n */\n const FieldToRender = props.storedPaymentMethodId ? StoredCardFieldsWrapper : CardFieldsWrapper;\n\n return (\n <Fragment>\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n styles={{ ...props.styles }}\n koreanAuthenticationRequired={props.configuration.koreanAuthenticationRequired}\n hasKoreanFields={!!(props.configuration.koreanAuthenticationRequired && props.countryCode === 'kr')}\n onChange={handleSecuredFieldsChange}\n onBrand={props.onBrand}\n onFocus={handleFocus}\n type={props.brand}\n disableIOSArrowKeys={props.disableIOSArrowKeys ? handleTouchstartIOS : null}\n render={({ setRootNode, setFocusOn }, sfpState) => (\n <div\n ref={setRootNode}\n className={classNames({\n 'adyen-checkout__card-input': true,\n 'adyen-checkout-card-input__wrapper': true,\n [`adyen-checkout__card-input--${props.fundingSource ?? 'credit'}`]: true,\n 'adyen-checkout__card-input--loading': status === 'loading'\n })}\n role={'form'}\n >\n <FormInstruction />\n\n <FieldToRender\n // Extract exact props that we need to pass down\n {...extractPropsForCardFields(props)}\n // Pass on vars created in CardInput:\n // Base (shared w. StoredCard)\n data={data}\n valid={valid}\n errors={errors}\n handleChangeFor={handleChangeFor}\n focusedElement={focusedElement}\n setFocusOn={setFocusOn}\n sfpState={sfpState}\n cvcPolicy={cvcPolicy}\n hasInstallments={hasInstallments}\n showAmountsInInstallments={showAmountsInInstallments}\n handleInstallments={setInstallments}\n // For Card\n brandsIcons={props.brandsIcons}\n formData={formData}\n formErrors={formErrors}\n formValid={formValid}\n expiryDatePolicy={expiryDatePolicy}\n dualBrandSelectElements={dualBrandSelectElements}\n extensions={extensions}\n selectedBrandValue={selectedBrandValue}\n // For KCP\n showKCP={showKCP}\n // For SSN\n showBrazilianSSN={showBrazilianSSN}\n socialSecurityNumber={socialSecurityNumber}\n // For Store details\n handleOnStoreDetails={setStorePaymentMethod}\n // For Address\n setAddressRef={setAddressRef}\n billingAddress={billingAddress}\n billingAddressValidationRules={partialAddressSchema && getPartialAddressValidationRules(partialAddressCountry.current)}\n partialAddressSchema={partialAddressSchema}\n handleAddress={handleAddress}\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n //\n iOSFocusedField={iOSFocusedField}\n //\n onFieldFocusAnalytics={onFieldFocusAnalytics}\n onFieldBlurAnalytics={onFieldBlurAnalytics}\n />\n </div>\n )}\n />\n {props.showPayButton &&\n props.payButton({\n status,\n variant: props.isPayButtonPrimaryVariant ? 'primary' : 'secondary',\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </Fragment>\n );\n};\n\nCardInput.defaultProps = defaultProps;\n\nexport default CardInput;\n"],"names":["CardInput","props","sfp","useRef","isValidating","getImage","useImage","billingAddressRef","setAddressRef","ref","current","cardInputRef","Object","keys","length","setComponentRef","hasPanLengthRef","isAutoJumping","specifications","useMemo","Specifications","status","setStatus","useState","errors","setErrors","valid","setValid","holderNameRequired","holderName","data","setData","hasHolderName","focusedElement","setFocusedElement","isSfpValid","setIsSfpValid","expiryDatePolicy","setExpiryDatePolicy","DATE_POLICY_REQUIRED","cvcPolicy","setCvcPolicy","CVC_POLICY_REQUIRED","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","storedPaymentMethodId","brand","showBillingAddress","billingAddressMode","AddressModeOptions","none","billingAddressRequired","partialAddressSchema","handlePartialAddressMode","partialAddressCountry","billingAddress","country","storePaymentMethod","setStorePaymentMethod","setBillingAddress","showSocialSecurityNumber","setShowSocialSecurityNumber","socialSecurityNumber","setSocialSecurityNumber","installments","setInstallments","value","iOSFocusedField","setIOSFocusedField","handleChangeFor","triggerValidation","formData","formValid","formErrors","setSchema","setFormData","setFormValid","setFormErrors","useForm","schema","defaultData","formatters","cardInputFormatters","rules","cardInputValidationRules","hasInstallments","installmentOptions","fundingSource","showAmountsInInstallments","showInstallmentAmounts","isKorea","countryCode","showKCP","configuration","koreanAuthenticationRequired","showBrazilianSSN","socialSecurityNumberMode","onFieldFocusAnalytics","who","e","onFocus","fieldType","event","onFieldBlurAnalytics","onBlur","handleFocus","getFocusHandler","retrieveLayout","getLayout","countrySpecificSchemas","getAddressSchemaForCountry","billingAddressRequiredFields","handleTouchstartIOS","useCallback","obj","elementType","name","handleAddress","getAddressHandler","doPanAutoJump","getAutoJumpHandler","extensions","CIExtensions","showValidation","clearSRPanel","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","useEffect","setFocusOn","updateStyles","handleUnsupportedCard","destroy","newSchema","taxNumber","addressHasErrors","entries","reduce","acc","error","sortedErrorList","currentErrorsSortedByLayout","previousSortedErrors","useSRPanelForCardInputErrors","holderNameValid","sfpValid","addressValid","koreanAuthentication","encryptedPassword","socialSecurityNumberValid","isValid","sfStateErrorsObj","mapErrorsToValidationRuleResult","mergedErrors","newErrors","getArrayDifferences","forEach","errorItem","aObj","field","errorCode","onValidationErrorAnalytics","onChange","FieldToRender","StoredCardFieldsWrapper","CardFieldsWrapper","h","Fragment","SecuredFieldsProvider","extractPropsForSFP","styles","hasKoreanFields","sfState","eventDetails","autoCompleteName","acHolderName","getRuleByNameAndMode","holderNameValidationFn","autoFocus","ENCRYPTED_CARD_NUMBER","encryptedCardNumber","onBrand","type","disableIOSArrowKeys","render","setRootNode","sfpState","div","className","classNames","role","FormInstruction","extractPropsForCardFields","handleInstallments","brandsIcons","handleOnStoreDetails","billingAddressValidationRules","getPartialAddressValidationRules","onAddressLookup","onAddressSelected","addressSearchDebounceMs","showPayButton","payButton","variant","isPayButtonPrimaryVariant","icon","imageFolder","PREFIX","defaultProps"],"mappings":"wlDA+BA,MAAMA,EAAaC,IACf,MAAMC,EAAMC,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EpBkI,YAAatM,EAAMsM,YACnB5H,SAAUA,GACVE,WAAYA,GACZD,UAAWA,GACXvC,iBAAkBA,GAClBQ,wBAAyBA,GACzBgF,WAAYA,GACZ9E,mBAAoBA,GAEpBiD,QAASA,GAETG,iBAAkBA,GAClBjC,qBAAsBA,GAEtBsI,qBAAsB1I,GAEtBtD,cAAeA,EACfmD,eAAgBA,GAChB8I,8BAA+BjJ,IAAwBkJ,EAAiChJ,GAAsBhD,SAC9G8C,qBAAsBA,GACtBiE,cAAeA,GACfkF,gBAAiB1M,EAAM0M,gBACvBC,kBAAmB3M,EAAM2M,kBACzBC,wBAAyB5M,EAAM4M,wBAE/BtI,gBAAiBA,GAEjB8B,sBAAuBA,GACvBM,qBAAsBA,QAKrC1G,EAAM6M,eACH7M,EAAM8M,UAAU,CACZ1L,SACA2L,QAAS/M,EAAMgN,0BAA4B,UAAY,YACvDC,KAAM7M,EAAS,CAAE8M,YAAa,eAAxB9M,CAAyC,GAAG+M,WACtD,EAKhBpN,EAAUqN,aAAeA"}
@@ -1,2 +1,2 @@
1
- import{CREDIT_CARD_SF_FIELDS as e,ENCRYPTED_CARD_NUMBER as r}from"../../../internal/SecuredFields/lib/constants.js";import{selectOne as t}from"../../../internal/SecuredFields/lib/utilities/dom.js";const n=(r,t,n)=>{r&&(e.includes(n)?t.current.setFocusOn(n):o(n,t))},s=(e,r,t)=>n=>{e("billingAddress",n.data),r("billingAddress",n.isValid),t("billingAddress",n.errors)},i=(e,r,t)=>n=>{e(n.currentFocusObject),!0===n.focus?r(n.fieldType,n):t(n.fieldType,n)},c=(t,n,s)=>()=>{t.current||(t.current=!0,Promise.resolve().then((()=>{const i=s.findIndex((e=>e===r)),c=s.slice(i+1);for(const r of c){if(!e.includes(r)){o(r,n);break}if(!n.current.sfIsOptionalOrHidden(r)){n.current.setFocusOn(r);break}}t.current=!1})))},o=(e,r)=>{let n=e;if("taxNumber"===n&&(n="kcpTaxNumberOrDOB"),"country"===n||"stateOrProvince"===n){const e=t(r.current.rootNode,`.adyen-checkout__field--${n} .adyen-checkout__filter-input`);e?.focus()}else{const e=t(r.current.rootNode,`[name="${n}"]`);e?.focus()}};export{s as getAddressHandler,c as getAutoJumpHandler,i as getFocusHandler,n as setFocusOnFirstField};
1
+ import{ENCRYPTED_CARD_NUMBER as e,CREDIT_CARD_SF_FIELDS as r}from"../../../internal/SecuredFields/lib/constants.js";import{selectOne as t}from"../../../internal/SecuredFields/lib/utilities/dom.js";const n=(e,t,n)=>{e&&(r.includes(n)?t.current.setFocusOn(n):o(n,t))},s=(e,r,t)=>n=>{e("billingAddress",n.data),r("billingAddress",n.isValid),t("billingAddress",n.errors)},i=(e,r,t)=>n=>{e(n.currentFocusObject),!0===n.focus?r(n.fieldType,n):t(n.fieldType,n)},c=(t,n,s)=>()=>{t.current||(t.current=!0,Promise.resolve().then((()=>{const i=s.findIndex((r=>r===e)),c=s.slice(i+1);for(const e of c){if(!r.includes(e)){o(e,n);break}if(!n.current.sfIsOptionalOrHidden(e)){n.current.setFocusOn(e);break}}t.current=!1})))},o=(e,r)=>{let n=e;if("taxNumber"===n&&(n="kcpTaxNumberOrDOB"),"country"===n||"stateOrProvince"===n){const e=t(r.current.rootNode,`.adyen-checkout__field--${n} .adyen-checkout__filter-input`);e?.focus()}else{const e=t(r.current.rootNode,`[name="${n}"]`);e?.focus()}};export{s as getAddressHandler,c as getAutoJumpHandler,i as getFocusHandler,n as setFocusOnFirstField};
2
2
  //# sourceMappingURL=handlers.js.map
@@ -0,0 +1,2 @@
1
+ import{useState as r,useEffect as s}from"../../../../external/preact/hooks/dist/hooks.js";import e from"../../../../core/Errors/useSRPanelContext.js";import{mapFieldKey as o,handlePartialAddressMode as t,lookupBlurBasedErrors as i}from"./utils.js";import{usePrevious as a}from"../../../../utils/hookUtils.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as n}from"../../../../core/Errors/constants.js";import{setFocusOnFirstField as c}from"./handlers.js";import{getArrayDifferences as u}from"../../../../utils/arrayUtils.js";const d=({errors:d,props:p,isValidating:f,retrieveLayout:m,specifications:g,billingAddress:S,sfp:y})=>{const{setSRMessagesFromObjects:b,setSRMessagesFromStrings:j,clearSRPanel:R,shouldMoveFocusSR:h}=e(),E=b?.({fieldTypeMappingFn:o}),F=t(p.billingAddressMode),[M,k]=r(null),L=a(M),A=y.current?.mapErrorsToValidationRuleResult(),T={...d,...A};return s((()=>{try{const{billingAddress:r,...s}=T,e={...s,...r},o=E?.({errors:e,isValidating:f.current,layout:m(),countrySpecificLabels:g.getAddressLabelsForCountry(S?.country)??F?.default?.labels}),t=o?.currentErrorsSortedByLayout;switch(k(t),o?.action){case n:h&&c(f.current,y,o?.fieldToFocus),setTimeout((()=>{f.current=!1}),300);break;case l:{const r=u(t,L,"field"),s=r?.[0];if(s){const r=i(s.errorCode)?s.errorMessage:null;j(r)}else R();break}}}catch(r){}}),[d]),{sortedErrorList:M,previousSortedErrors:L,clearSRPanel:R}};export{d as default};
2
+ //# sourceMappingURL=useSRPanelForCardInputErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSRPanelForCardInputErrors.js","sources":["../../../../../../src/components/Card/components/CardInput/useSRPanelForCardInputErrors.ts"],"sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport useSRPanelContext from '../../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../../core/Errors/SRPanelProvider';\nimport { handlePartialAddressMode, lookupBlurBasedErrors, mapFieldKey } from './utils';\nimport { usePrevious } from '../../../../utils/hookUtils';\nimport { SetSRMessagesReturnObject, SortedErrorObject } from '../../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../../core/Errors/constants';\nimport { setFocusOnFirstField } from './handlers';\nimport { getArrayDifferences } from '../../../../utils/arrayUtils';\n\nconst useSRPanelForCardInputErrors = ({ errors, props, isValidating, retrieveLayout, specifications, billingAddress, sfp }) => {\n // Extract fns from context\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const partialAddressSchema = handlePartialAddressMode(props.billingAddressMode);\n\n const [sortedErrorList, setSortedErrorList] = useState<SortedErrorObject[]>(null);\n\n // Get the previous list of errors\n const previousSortedErrors = usePrevious(sortedErrorList);\n\n const sfStateErrorsObj = sfp.current?.mapErrorsToValidationRuleResult();\n const mergedErrors = { ...errors, ...sfStateErrorsObj };\n\n useEffect(() => {\n try {\n // Extract and then flatten billingAddress errors into a new object with *all* the field errors at top level\n const { billingAddress: extractedAddressErrors, ...errorsWithoutAddress } = mergedErrors;\n\n const errorsForPanel = { ...errorsWithoutAddress, ...extractedAddressErrors };\n\n // Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: retrieveLayout(),\n // If we don't have country specific address labels, we might have a label related to a partialAddressSchema (i.e. zipCode)\n countrySpecificLabels: specifications.getAddressLabelsForCountry(billingAddress?.country) ?? partialAddressSchema?.default?.labels\n });\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n setSortedErrorList(currentErrorsSortedByLayout);\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n if (shouldMoveFocusSR) setFocusOnFirstField(isValidating.current, sfp, srPanelResp?.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Use the error code to look up whether error is actually a blur based one (most are but some SF ones aren't)\n const isBlurBasedError = lookupBlurBasedErrors(latestErrorMsg.errorCode);\n\n /**\n * ONLY ADD BLUR BASED ERRORS TO THE ERROR PANEL - doing this step prevents the non-blur based errors from being read out twice\n * (once from the aria-live, error panel & once from the aria-describedby element)\n */\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n // console.log('### CardInput2::componentDidUpdate:: #2 (not validating) single error:: latestSRError', latestSRError);\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n // console.log('### CardInput2::componentDidUpdate:: #3(not validating) clearing errors:: NO latestErrorMsg');\n clearSRPanel();\n }\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors]);\n\n return { sortedErrorList, previousSortedErrors, clearSRPanel };\n};\n\nexport default useSRPanelForCardInputErrors;\n"],"names":["useSRPanelForCardInputErrors","errors","props","isValidating","retrieveLayout","specifications","billingAddress","sfp","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","partialAddressSchema","handlePartialAddressMode","billingAddressMode","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","sfStateErrorsObj","current","mapErrorsToValidationRuleResult","mergedErrors","useEffect","extractedAddressErrors","errorsWithoutAddress","errorsForPanel","srPanelResp","layout","countrySpecificLabels","getAddressLabelsForCountry","country","default","labels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnFirstField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","lookupBlurBasedErrors","errorCode","errorMessage","_"],"mappings":"giBAUA,MAAMA,EAA+B,EAAGC,SAAQC,QAAOC,eAAcC,iBAAgBC,iBAAgBC,iBAAgBC,UAEjH,MAAMC,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAG1FC,EAAuCL,IAA2B,CACpEM,mBAAoBC,IAGlBC,EAAuBC,EAAyBf,EAAMgB,qBAErDC,EAAiBC,GAAsBC,EAA8B,MAGtEC,EAAuBC,EAAYJ,GAEnCK,EAAmBjB,EAAIkB,SAASC,kCAChCC,EAAe,IAAK1B,KAAWuB,GAkErC,OAhEAI,GAAU,KACN,IAEI,MAAQtB,eAAgBuB,KAA2BC,GAAyBH,EAEtEI,EAAiB,IAAKD,KAAyBD,GAG/CG,EAAyCnB,IAAgB,CAC3DZ,OAAQ8B,EACR5B,aAAcA,EAAasB,QAC3BQ,OAAQ7B,IAER8B,sBAAuB7B,EAAe8B,2BAA2B7B,GAAgB8B,UAAYpB,GAAsBqB,SAASC,SAI1HC,EAA8BP,GAAaO,4BAMjD,OALAnB,EAAmBmB,GAKXP,GAAaQ,QAEjB,KAAKC,EACG9B,GAAmB+B,EAAqBvC,EAAasB,QAASlB,EAAKyB,GAAaW,cAEpFC,YAAW,KACPzC,EAAasB,SAAU,CAAA,GACxB,KACH,MAEJ,KAAKoB,EAA4B,CAC7B,MAAMC,EAAaC,EAA+CR,EAA6BjB,EAAsB,SAE/G0B,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAMMC,EANmBC,EAAsBF,EAAeG,WAMrBH,EAAeI,aAAe,KAEvE3C,EAAyBwC,QAIzBvC,IAEJ,KACJ,EAIR,CAAE,MAAO2C,GAET,IACD,CAACpD,IAEG,CAAEkB,kBAAiBG,uBAAsBZ,eAAa"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import{CoreProvider as s}from"../../core/Context/CoreProvider.js";import{CashAppComponent as o}from"./components/CashAppComponent.js";import r from"./services/CashAppService.js";import{CashAppSdkLoader as a}from"./services/CashAppSdkLoader.js";import n from"./defaultProps.js";import i from"../internal/RedirectButton/RedirectButton.js";import"../../external/classnames/index.js";import{payAmountLabel as p}from"../internal/PayButton/utils.js";import{TxVariants as h}from"../tx-variants.js";import{PREFIX as d}from"../internal/Icon/constants.js";class c extends e{static type=h.cashapp;cashAppService;static defaultProps=n;constructor(t,e){super(t,e),this.props.enableStoreDetails&&this.props.storePaymentMethod&&console.warn("CashAppPay: enableStoreDetails AND storePaymentMethod configuration properties should not be used together. That can lead to undesired behavior."),this.props.storedPaymentMethodId||(this.cashAppService=new r(new a,{storePaymentMethod:this.props.storePaymentMethod,useCashAppButtonUi:this.props.showPayButton,environment:this.props.environment,amount:this.props.amount,redirectURL:this.props.redirectURL,clientId:this.props.configuration?.clientId,scopeId:this.props.configuration?.scopeId,button:this.props.button,referenceId:this.props.referenceId}))}formatProps(t){return{...t,enableStoreDetails:t.session?.configuration?.enableStoreDetails||t.enableStoreDetails}}formatData(){const{shopperWantsToStore:t,grantId:e,onFileGrantId:s,cashTag:o,customerId:r}=this.state.data||{},{storePaymentMethod:a,storedPaymentMethodId:n}=this.props,i=this.props.enableStoreDetails||!this.props.session&&a;if(n)return{paymentMethod:{type:c.type,storedPaymentMethodId:n}};return{paymentMethod:{type:c.type,...e&&{grantId:e},...r&&{customerId:r},...s&&o&&{onFileGrantId:s,cashtag:o}},...i&&{storePaymentMethod:a||t}}}get displayName(){return this.props.storedPaymentMethodId&&this.props.cashtag?this.props.cashtag:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?"Cash App Pay":""}submit=()=>{const{onClick:t,storedPaymentMethodId:e}=this.props;if(e)return void super.submit();let s=!1;new Promise(((e,s)=>t({resolve:e,reject:s}))).catch((()=>{throw s=!0,Error("onClick rejected")})).then((()=>this.cashAppService.createCustomerRequest())).then((()=>{this.cashAppService.begin()})).catch((t=>{s||this.handleError(t)}))};get isValid(){return!0}handleOnChangeStoreDetails=t=>{const e={...this.state.data,shopperWantsToStore:t};this.setState({data:e})};handleAuthorize=t=>{const e={...this.state.data,...t};this.setState({data:e,valid:{},errors:{},isValid:!0}),super.submit()};render(){return t(s,{i18n:this.props.i18n,resources:this.resources,loadingContext:this.props.loadingContext},this.props.storedPaymentMethodId?t(i,{label:p(this.props.i18n,this.props.amount),icon:this.resources?.getImage({imageFolder:"components/"})(`${d}lock`),name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},enableStoreDetails:this.props.enableStoreDetails,cashAppService:this.cashAppService,onChangeStoreDetails:this.handleOnChangeStoreDetails,onError:this.handleError,onClick:this.submit,onAuthorize:this.handleAuthorize}))}}export{c as CashAppPay,c as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import{CoreProvider as s}from"../../core/Context/CoreProvider.js";import{CashAppComponent as o}from"./components/CashAppComponent.js";import r from"./services/CashAppService.js";import{CashAppSdkLoader as a}from"./services/CashAppSdkLoader.js";import n from"./defaultProps.js";import i from"../internal/RedirectButton/RedirectButton.js";import"../../external/classnames/index.js";import{payAmountLabel as p}from"../internal/PayButton/utils.js";import{TxVariants as h}from"../tx-variants.js";import{PREFIX as d}from"../internal/Icon/constants.js";class c extends e{static type=h.cashapp;cashAppService;static defaultProps=n;constructor(t,e){super(t,e),this.props.enableStoreDetails&&this.props.storePaymentMethod&&console.warn("CashAppPay: enableStoreDetails AND storePaymentMethod configuration properties should not be used together. That can lead to undesired behavior."),this.props.storedPaymentMethodId||(this.cashAppService=new r(new a,{storePaymentMethod:this.props.storePaymentMethod,useCashAppButtonUi:this.props.showPayButton,environment:this.props.environment,amount:this.props.amount,redirectURL:this.props.redirectURL,clientId:this.props.configuration?.clientId,scopeId:this.props.configuration?.scopeId,button:this.props.button,referenceId:this.props.referenceId}))}formatProps(t){return{...t,enableStoreDetails:t.session?.configuration?.enableStoreDetails||t.enableStoreDetails}}formatData(){const{shopperWantsToStore:t,grantId:e,onFileGrantId:s,cashTag:o,customerId:r}=this.state.data||{},{storePaymentMethod:a,storedPaymentMethodId:n}=this.props,i=this.props.enableStoreDetails||!this.props.session&&a;if(n)return{paymentMethod:{type:c.type,storedPaymentMethodId:n}};return{paymentMethod:{type:c.type,...e&&{grantId:e},...r&&{customerId:r},...s&&o&&{onFileGrantId:s,cashtag:o}},...i&&{storePaymentMethod:a||t}}}get displayName(){return this.props.storedPaymentMethodId&&this.props.cashtag?this.props.cashtag:this.props.name}get additionalInfo(){return this.props.storedPaymentMethodId?"Cash App Pay":""}submit=()=>{const{onClick:t,storedPaymentMethodId:e}=this.props;if(e)return void super.submit();let s=!1;new Promise(((e,s)=>t({resolve:e,reject:s}))).catch((()=>{throw s=!0,Error("onClick rejected")})).then((()=>this.cashAppService.createCustomerRequest())).then((()=>{this.cashAppService.begin()})).catch((t=>{s||this.handleError(t)}))};get isValid(){return!0}handleOnChangeStoreDetails=t=>{const e={...this.state.data,shopperWantsToStore:t};this.setState({data:e})};handleAuthorize=t=>{const e={...this.state.data,...t};this.setState({data:e,valid:{},errors:{},isValid:!0}),super.submit()};render(){return t(s,{i18n:this.props.i18n,resources:this.resources,loadingContext:this.props.loadingContext},this.props.storedPaymentMethodId?t(i,{showPayButton:this.props.showPayButton,label:p(this.props.i18n,this.props.amount),icon:this.resources?.getImage({imageFolder:"components/"})(`${d}lock`),name:this.displayName,amount:this.props.amount,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(o,{ref:t=>{this.componentRef=t},enableStoreDetails:this.props.enableStoreDetails,cashAppService:this.cashAppService,onChangeStoreDetails:this.handleOnChangeStoreDetails,onError:this.handleError,onClick:this.submit,onAuthorize:this.handleAuthorize}))}}export{c as CashAppPay,c as default};
2
2
  //# sourceMappingURL=CashAppPay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CashAppPay.js","sources":["../../../../src/components/CashAppPay/CashAppPay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { CashAppComponent } from './components/CashAppComponent';\nimport CashAppService from './services/CashAppService';\nimport { CashAppSdkLoader } from './services/CashAppSdkLoader';\nimport { CashAppPayElementData, CashAppPayConfiguration, CashAppPayEventData } from './types';\nimport { ICashAppService } from './services/types';\nimport defaultProps from './defaultProps';\nimport RedirectButton from '../internal/RedirectButton';\nimport { payAmountLabel } from '../internal/PayButton';\nimport { TxVariants } from '../tx-variants';\nimport type { ICore } from '../../core/types';\nimport { PREFIX } from '../internal/Icon/constants';\n\nexport class CashAppPay extends UIElement<CashAppPayConfiguration> {\n public static type = TxVariants.cashapp;\n\n private readonly cashAppService: ICashAppService | undefined;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: CashAppPayConfiguration) {\n super(checkout, props);\n\n if (this.props.enableStoreDetails && this.props.storePaymentMethod) {\n console.warn(\n 'CashAppPay: enableStoreDetails AND storePaymentMethod configuration properties should not be used together. That can lead to undesired behavior.'\n );\n }\n\n if (this.props.storedPaymentMethodId) {\n return;\n }\n\n this.cashAppService = new CashAppService(new CashAppSdkLoader(), {\n storePaymentMethod: this.props.storePaymentMethod,\n useCashAppButtonUi: this.props.showPayButton,\n environment: this.props.environment,\n amount: this.props.amount,\n redirectURL: this.props.redirectURL,\n clientId: this.props.configuration?.clientId,\n scopeId: this.props.configuration?.scopeId,\n button: this.props.button,\n referenceId: this.props.referenceId\n });\n }\n\n public formatProps(props: CashAppPayConfiguration) {\n return {\n ...props,\n enableStoreDetails: props.session?.configuration?.enableStoreDetails || props.enableStoreDetails\n };\n }\n\n public formatData(): CashAppPayElementData {\n const { shopperWantsToStore, grantId, onFileGrantId, cashTag, customerId } = this.state.data || {};\n const { storePaymentMethod: storePaymentMethodSetByMerchant, storedPaymentMethodId } = this.props;\n\n /**\n * We include 'storePaymentMethod' flag if we either Display the Checkbox OR if it is non-sessions flow AND the merchant wants to store the payment method\n */\n const includeStorePaymentMethod = this.props.enableStoreDetails || (!this.props.session && storePaymentMethodSetByMerchant);\n\n if (storedPaymentMethodId) {\n return {\n paymentMethod: {\n type: CashAppPay.type,\n storedPaymentMethodId\n }\n };\n }\n\n const shouldAddOnFileProperties = onFileGrantId && cashTag;\n\n return {\n paymentMethod: {\n type: CashAppPay.type,\n ...(grantId && { grantId }),\n ...(customerId && { customerId }),\n ...(shouldAddOnFileProperties && { onFileGrantId, cashtag: cashTag })\n },\n ...(includeStorePaymentMethod && { storePaymentMethod: storePaymentMethodSetByMerchant || shopperWantsToStore })\n };\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.cashtag) {\n return this.props.cashtag;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n return this.props.storedPaymentMethodId ? 'Cash App Pay' : '';\n }\n\n public submit = () => {\n const { onClick, storedPaymentMethodId } = this.props;\n\n if (storedPaymentMethodId) {\n super.submit();\n return;\n }\n\n let onClickPromiseRejected = false;\n\n new Promise<void>((resolve, reject) => onClick({ resolve, reject }))\n .catch(() => {\n onClickPromiseRejected = true;\n throw Error('onClick rejected');\n })\n .then(() => {\n return this.cashAppService.createCustomerRequest();\n })\n .then(() => {\n this.cashAppService.begin();\n })\n .catch(error => {\n if (onClickPromiseRejected) {\n // Swallow exception triggered by onClick reject\n return;\n }\n this.handleError(error);\n });\n };\n\n public get isValid(): boolean {\n return true;\n }\n\n private handleOnChangeStoreDetails = (storePayment: boolean) => {\n const data = { ...this.state.data, shopperWantsToStore: storePayment };\n this.setState({ data });\n };\n\n private handleAuthorize = (cashAppPaymentData: CashAppPayEventData): void => {\n const data = { ...this.state.data, ...cashAppPaymentData };\n this.setState({ data, valid: {}, errors: {}, isValid: true });\n super.submit();\n };\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} resources={this.resources} loadingContext={this.props.loadingContext}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n label={payAmountLabel(this.props.i18n, this.props.amount)}\n icon={this.resources?.getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <CashAppComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n enableStoreDetails={this.props.enableStoreDetails}\n cashAppService={this.cashAppService}\n onChangeStoreDetails={this.handleOnChangeStoreDetails}\n onError={this.handleError}\n onClick={this.submit}\n onAuthorize={this.handleAuthorize}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default CashAppPay;\n"],"names":["CashAppPay","UIElement","static","TxVariants","cashapp","cashAppService","defaultProps","constructor","checkout","props","super","this","enableStoreDetails","storePaymentMethod","console","warn","storedPaymentMethodId","CashAppService","CashAppSdkLoader","useCashAppButtonUi","showPayButton","environment","amount","redirectURL","clientId","configuration","scopeId","button","referenceId","formatProps","session","formatData","shopperWantsToStore","grantId","onFileGrantId","cashTag","customerId","state","data","storePaymentMethodSetByMerchant","includeStorePaymentMethod","paymentMethod","type","cashtag","displayName","name","additionalInfo","submit","onClick","onClickPromiseRejected","Promise","resolve","reject","catch","Error","then","createCustomerRequest","begin","error","handleError","isValid","handleOnChangeStoreDetails","storePayment","setState","handleAuthorize","cashAppPaymentData","valid","errors","render","h","CoreProvider","i18n","resources","loadingContext","RedirectButton","label","payAmountLabel","icon","getImage","imageFolder","PREFIX","payButton","onSubmit","ref","componentRef","CashAppComponent","onChangeStoreDetails","onError","onAuthorize"],"mappings":"sqBAeO,MAAMA,UAAmBC,EAC5BC,YAAqBC,EAAWC,QAEfC,eAEjBH,oBAAgCI,EAEhCC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAE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D,KAAKF,MAAMG,mBAC/BP,eAAgBM,KAAKN,eACrBiF,qBAAsB3E,KAAKkD,2BAC3B0B,QAAS5E,KAAKgD,YACdX,QAASrC,KAAKoC,OACdyC,YAAa7E,KAAKqD,kBAKtC"}
1
+ {"version":3,"file":"CashAppPay.js","sources":["../../../../src/components/CashAppPay/CashAppPay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport { CashAppComponent } from './components/CashAppComponent';\nimport CashAppService from './services/CashAppService';\nimport { CashAppSdkLoader } from './services/CashAppSdkLoader';\nimport { CashAppPayElementData, CashAppPayConfiguration, CashAppPayEventData } from './types';\nimport { ICashAppService } from './services/types';\nimport defaultProps from './defaultProps';\nimport RedirectButton from '../internal/RedirectButton';\nimport { payAmountLabel } from '../internal/PayButton';\nimport { TxVariants } from '../tx-variants';\nimport type { ICore } from '../../core/types';\nimport { PREFIX } from '../internal/Icon/constants';\n\nexport class CashAppPay extends UIElement<CashAppPayConfiguration> {\n public static type = TxVariants.cashapp;\n\n private readonly cashAppService: ICashAppService | undefined;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: CashAppPayConfiguration) {\n super(checkout, props);\n\n if (this.props.enableStoreDetails && this.props.storePaymentMethod) {\n console.warn(\n 'CashAppPay: enableStoreDetails AND storePaymentMethod configuration properties should not be used together. That can lead to undesired behavior.'\n );\n }\n\n if (this.props.storedPaymentMethodId) {\n return;\n }\n\n this.cashAppService = new CashAppService(new CashAppSdkLoader(), {\n storePaymentMethod: this.props.storePaymentMethod,\n useCashAppButtonUi: this.props.showPayButton,\n environment: this.props.environment,\n amount: this.props.amount,\n redirectURL: this.props.redirectURL,\n clientId: this.props.configuration?.clientId,\n scopeId: this.props.configuration?.scopeId,\n button: this.props.button,\n referenceId: this.props.referenceId\n });\n }\n\n public formatProps(props: CashAppPayConfiguration) {\n return {\n ...props,\n enableStoreDetails: props.session?.configuration?.enableStoreDetails || props.enableStoreDetails\n };\n }\n\n public formatData(): CashAppPayElementData {\n const { shopperWantsToStore, grantId, onFileGrantId, cashTag, customerId } = this.state.data || {};\n const { storePaymentMethod: storePaymentMethodSetByMerchant, storedPaymentMethodId } = this.props;\n\n /**\n * We include 'storePaymentMethod' flag if we either Display the Checkbox OR if it is non-sessions flow AND the merchant wants to store the payment method\n */\n const includeStorePaymentMethod = this.props.enableStoreDetails || (!this.props.session && storePaymentMethodSetByMerchant);\n\n if (storedPaymentMethodId) {\n return {\n paymentMethod: {\n type: CashAppPay.type,\n storedPaymentMethodId\n }\n };\n }\n\n const shouldAddOnFileProperties = onFileGrantId && cashTag;\n\n return {\n paymentMethod: {\n type: CashAppPay.type,\n ...(grantId && { grantId }),\n ...(customerId && { customerId }),\n ...(shouldAddOnFileProperties && { onFileGrantId, cashtag: cashTag })\n },\n ...(includeStorePaymentMethod && { storePaymentMethod: storePaymentMethodSetByMerchant || shopperWantsToStore })\n };\n }\n\n get displayName() {\n if (this.props.storedPaymentMethodId && this.props.cashtag) {\n return this.props.cashtag;\n }\n return this.props.name;\n }\n\n get additionalInfo() {\n return this.props.storedPaymentMethodId ? 'Cash App Pay' : '';\n }\n\n public submit = () => {\n const { onClick, storedPaymentMethodId } = this.props;\n\n if (storedPaymentMethodId) {\n super.submit();\n return;\n }\n\n let onClickPromiseRejected = false;\n\n new Promise<void>((resolve, reject) => onClick({ resolve, reject }))\n .catch(() => {\n onClickPromiseRejected = true;\n throw Error('onClick rejected');\n })\n .then(() => {\n return this.cashAppService.createCustomerRequest();\n })\n .then(() => {\n this.cashAppService.begin();\n })\n .catch(error => {\n if (onClickPromiseRejected) {\n // Swallow exception triggered by onClick reject\n return;\n }\n this.handleError(error);\n });\n };\n\n public get isValid(): boolean {\n return true;\n }\n\n private handleOnChangeStoreDetails = (storePayment: boolean) => {\n const data = { ...this.state.data, shopperWantsToStore: storePayment };\n this.setState({ data });\n };\n\n private handleAuthorize = (cashAppPaymentData: CashAppPayEventData): void => {\n const data = { ...this.state.data, ...cashAppPaymentData };\n this.setState({ data, valid: {}, errors: {}, isValid: true });\n super.submit();\n };\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} resources={this.resources} loadingContext={this.props.loadingContext}>\n {this.props.storedPaymentMethodId ? (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n label={payAmountLabel(this.props.i18n, this.props.amount)}\n icon={this.resources?.getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)}\n name={this.displayName}\n amount={this.props.amount}\n payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <CashAppComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n enableStoreDetails={this.props.enableStoreDetails}\n cashAppService={this.cashAppService}\n onChangeStoreDetails={this.handleOnChangeStoreDetails}\n onError={this.handleError}\n onClick={this.submit}\n onAuthorize={this.handleAuthorize}\n />\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default CashAppPay;\n"],"names":["CashAppPay","UIElement","static","TxVariants","cashapp","cashAppService","defaultProps","constructor","checkout","props","super","this","enableStoreDetails","storePaymentMethod","console","warn","storedPaymentMethodId","CashAppService","CashAppSdkLoader","useCashAppButtonUi","showPayButton","environment","amount","redirectURL","clientId","configuration","scopeId","button","referenceId","formatProps","session","formatData","shopperWantsToStore","grantId","onFileGrantId","cashTag","customerId","state","data","storePaymentMethodSetByMerchant","includeStorePaymentMethod","paymentMethod","type","cashtag","displayName","name","additionalInfo","submit","onClick","onClickPromiseRejected","Promise","resolve","reject","catch","Error","then","createCustomerRequest","begin","error","handleError","isValid","handleOnChangeStoreDetails","storePayment","setState","handleAuthorize","cashAppPaymentData","valid","errors","render","h","CoreProvider","i18n","resources","loadingContext","RedirectButton","label","payAmountLabel","icon","getImage","imageFolder","PREFIX","payButton","onSubmit","ref","componentRef","CashAppComponent","onChangeStoreDetails","onError","onAuthorize"],"mappings":"sqBAeO,MAAMA,UAAmBC,EAC5BC,YAAq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foC,IAAKA,IACDxE,KAAKyE,aAAeD,CAAAA,IAI5Bd,EAACgB,EAAAA,CACGF,IAAKA,IACDxE,KAAKyE,aAAeD,CAAAA,EAExBvE,mBAAoBD,KAAKF,MAAMG,mBAC/BP,eAAgBM,KAAKN,eACrBiF,qBAAsB3E,KAAKkD,2BAC3B0B,QAAS5E,KAAKgD,YACdX,QAASrC,KAAKoC,OACdyC,YAAa7E,KAAKqD,kBAKtC"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./defaultProps.js";import{DropinComponent as s}from"./components/DropinComponent.js";import{CoreProvider as i}from"../../core/Context/CoreProvider.js";import{getCommonProps as n}from"./components/utils.js";import r from"./elements/createElements.js";import a from"./elements/createStoredElements.js";import h from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as m}from"../../utils/hasOwnProperty.js";import p from"../../core/Errors/SRPanelProvider.js";import d from"./elements/splitPaymentMethods.js";import{TxVariants as c}from"../tx-variants.js";const l=["paywithgoogle","googlepay","applepay"];class y extends e{static type=c.dropin;static defaultProps=o;dropinRef=null;paymentMethodsConfiguration;componentFromAction;constructor(t,e){super(t,e),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach((t=>this.core.register(t))),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return{type:"dropin",...super.formatProps(t),instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter((t=>l.includes(t)))}}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){return this.dropinRef?.setStatus(t,e),this}get activePaymentMethod(){return this.dropinRef?.state||this.dropinRef?.state.activePaymentMethod?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}displayFinalAnimation(t){this.props.disableFinalAnimation||this.dropinRef.setStatus(t)}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleCreate=()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:o,instantPaymentTypes:s}=this.props,{paymentMethods:i,storedPaymentMethods:m,instantPaymentMethods:p}=d(this.core.paymentMethodsResponse,s),c=n({...this.props,elementRef:this.elementRef});return[e?a(m,t,c,this.core):[],o?r(i,t,c,this.core):[],h(p,t,c,this.core)]};handleAction(t,e={}){if(!t||!t.type){if(m(t,"action")&&m(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&this.activePaymentMethod?.updateWithAction)return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof y&&(e={...this.elementRef.activePaymentMethod?.props,...e});const o=this.core.createFromAction(t,{...e,elementRef:this.elementRef,onAdditionalDetails:this.handleAdditionalDetails,isDropin:!0});return o?(this.setStatus(o.props.statusType,{component:o}),this.componentFromAction=o,this):null}handleOrder=({order:t})=>{this.updateParent({order:t})};closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}render(){return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(p,{srPanel:this.props.modules.srPanel},t(s,{...this.props,core:this.core,onChange:this.setState,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}})))}}export{y as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./defaultProps.js";import{DropinComponent as s}from"./components/DropinComponent.js";import{CoreProvider as i}from"../../core/Context/CoreProvider.js";import{getCommonProps as n}from"./components/utils.js";import r from"./elements/createElements.js";import a from"./elements/createStoredElements.js";import h from"./elements/createInstantPaymentElements.js";import{hasOwnProperty as m}from"../../utils/hasOwnProperty.js";import p from"../../core/Errors/SRPanelProvider.js";import d from"./elements/splitPaymentMethods.js";import{TxVariants as c}from"../tx-variants.js";const l=["paywithgoogle","googlepay","applepay"];class y extends e{static type=c.dropin;static defaultProps=o;dropinRef=null;paymentMethodsConfiguration;componentFromAction;constructor(t,e){super(t,e),this.submit=this.submit.bind(this),this.handleAction=this.handleAction.bind(this),this.props.paymentMethodComponents.forEach((t=>this.core.register(t))),this.paymentMethodsConfiguration=this.props.paymentMethodsConfiguration||{}}storeElementRefOnCore(){this.core.storeElementReference(this)}formatProps(t){return{type:"dropin",...super.formatProps(t),instantPaymentTypes:Array.from(new Set(t.instantPaymentTypes)).filter((t=>l.includes(t)))}}get isValid(){return!!this.dropinRef&&!!this.dropinRef.state.activePaymentMethod&&!!this.dropinRef.state.activePaymentMethod.isValid}showValidation(){return this.dropinRef.state.activePaymentMethod&&this.dropinRef.state.activePaymentMethod.showValidation(),this}setStatus(t,e={}){return this.dropinRef?.setStatus(t,e),this}get activePaymentMethod(){return this.dropinRef?.state||this.dropinRef?.state.activePaymentMethod?this.dropinRef.state.activePaymentMethod:null}get data(){return this.activePaymentMethod?this.dropinRef.state.activePaymentMethod.data:null}displayFinalAnimation(t){this.props.disableFinalAnimation||this.dropinRef.setStatus(t)}submit(){if(!this.activePaymentMethod)throw new Error("No active payment method.");this.activePaymentMethod.isValid||this.activePaymentMethod.showValidation(),this.activePaymentMethod.isInstantPayment&&this.closeActivePaymentMethod(),this.activePaymentMethod.submit()}handleCreate=()=>{const{paymentMethodsConfiguration:t,showStoredPaymentMethods:e,showPaymentMethods:o,instantPaymentTypes:s}=this.props,{paymentMethods:i,storedPaymentMethods:m,instantPaymentMethods:p}=d(this.core.paymentMethodsResponse,s),c=n({...this.props,elementRef:this.elementRef});return[e?a(m,t,c,this.core):[],o?r(i,t,c,this.core):[],h(p,t,c,this.core)]};handleAction(t,e={}){if(!t||!t.type){if(m(t,"action")&&m(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}if("redirect"!==t.type&&this.activePaymentMethod?.updateWithAction)return this.activePaymentMethod.updateWithAction(t);this.elementRef instanceof y&&(e={...this.elementRef.activePaymentMethod?.props,...e});const o=this.core.createFromAction(t,{...e,elementRef:this.elementRef,onAdditionalDetails:this.handleAdditionalDetails,isDropin:!0});return o?(this.setStatus(o.props.statusType,{component:o}),this.componentFromAction=o,this):null}handleOrder=({order:t})=>{this.updateParent({order:t})};closeActivePaymentMethod(){this.dropinRef.closeActivePaymentMethod()}render(){return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(p,{srPanel:this.props.modules.srPanel},t(s,{...this.props,core:this.core,elementRef:this.elementRef,onCreateElements:this.handleCreate,ref:t=>{this.dropinRef=t}})))}}export{y as default};
2
2
  //# sourceMappingURL=Dropin.js.map