@adyen/adyen-web 6.45.1 → 6.45.2

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 (205) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +1846 -1889
  4. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  5. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  6. package/dist/es/components/Ach/Ach.js +1 -1
  7. package/dist/es/components/Ach/Ach.js.map +1 -1
  8. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  9. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  10. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  11. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  12. package/dist/es/components/BacsDD/BacsDD.js +1 -1
  13. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  14. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  15. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  16. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  17. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  18. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  19. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  20. package/dist/es/components/Blik/Blik.js +1 -1
  21. package/dist/es/components/Blik/Blik.js.map +1 -1
  22. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  23. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  24. package/dist/es/components/Card/Card.js +1 -1
  25. package/dist/es/components/Card/Card.js.map +1 -1
  26. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  27. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  28. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  29. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  30. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  31. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  32. package/dist/es/components/Donation/Donation.js +1 -1
  33. package/dist/es/components/Donation/Donation.js.map +1 -1
  34. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  35. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  36. package/dist/es/components/Dropin/Dropin.js +1 -1
  37. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  38. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  39. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  40. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  41. package/dist/es/components/Giropay/Giropay.js +1 -1
  42. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  43. package/dist/es/components/MBWay/MBWay.js +1 -1
  44. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  45. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  46. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  47. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  48. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  49. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  50. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  51. package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
  52. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  53. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  54. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  55. package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
  56. package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
  57. package/dist/es/components/PayTo/components/PayToPhone.js +1 -1
  58. package/dist/es/components/PayTo/components/PayToPhone.js.map +1 -1
  59. package/dist/es/components/Pix/Pix.js +1 -1
  60. package/dist/es/components/Pix/Pix.js.map +1 -1
  61. package/dist/es/components/Pix/components/PixInput/PixInput.js +1 -1
  62. package/dist/es/components/Pix/components/PixInput/PixInput.js.map +1 -1
  63. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  64. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  65. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  66. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  67. package/dist/es/components/Redirect/Redirect.js +1 -1
  68. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  69. package/dist/es/components/Sepa/Sepa.js.map +1 -1
  70. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  71. package/dist/es/components/Trustly/Trustly.js +1 -1
  72. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  73. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  74. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  75. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  76. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  77. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  78. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  79. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  80. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  81. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  82. package/dist/es/components/internal/IbanInput/validate.js +1 -1
  83. package/dist/es/components/internal/IbanInput/validate.js.map +1 -1
  84. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  85. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  86. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  87. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  88. package/dist/es/components/internal/RedirectButton/RedirectButton.js +1 -1
  89. package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  90. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  91. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  92. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  93. package/dist/es/components/internal/UIElement/utils.js +1 -1
  94. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  95. package/dist/es/core/config.js +1 -1
  96. package/dist/es/index.d.ts +1846 -1889
  97. package/dist/es/utils/Validator/Validator.js +1 -1
  98. package/dist/es/utils/Validator/Validator.js.map +1 -1
  99. package/dist/es/utils/useForm/reducer.js +1 -1
  100. package/dist/es/utils/useForm/reducer.js.map +1 -1
  101. package/dist/es/utils/useForm/useForm.js +1 -1
  102. package/dist/es/utils/useForm/useForm.js.map +1 -1
  103. package/dist/es/utils/useForm/useFormWithA11y.js +1 -1
  104. package/dist/es/utils/useForm/useFormWithA11y.js.map +1 -1
  105. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  106. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  107. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  108. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  109. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  110. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  111. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  112. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  113. package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
  114. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  115. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  116. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  117. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  118. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  119. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  120. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  121. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  122. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  123. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  124. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  125. package/dist/es-legacy/components/Card/Card.js +1 -1
  126. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  127. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  128. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  129. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  130. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  131. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  133. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  134. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  135. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  136. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  137. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  138. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  139. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  140. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  141. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  142. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  143. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  144. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  145. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  146. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  147. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  148. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  149. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  150. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  151. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  152. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
  153. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  154. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  155. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  156. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
  157. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
  158. package/dist/es-legacy/components/PayTo/components/PayToPhone.js +1 -1
  159. package/dist/es-legacy/components/PayTo/components/PayToPhone.js.map +1 -1
  160. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  161. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  162. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js +1 -1
  163. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js.map +1 -1
  164. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  165. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  166. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  167. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  168. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  169. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  170. package/dist/es-legacy/components/Sepa/Sepa.js.map +1 -1
  171. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  172. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  173. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  174. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  175. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  176. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  177. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  178. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  179. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  180. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  181. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  182. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  183. package/dist/es-legacy/components/internal/IbanInput/validate.js +1 -1
  184. package/dist/es-legacy/components/internal/IbanInput/validate.js.map +1 -1
  185. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  186. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  187. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  188. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  189. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  190. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  191. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  192. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  193. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  194. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  195. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  196. package/dist/es-legacy/core/config.js +1 -1
  197. package/dist/es-legacy/utils/Validator/Validator.js +1 -1
  198. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  199. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  200. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  201. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  202. package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
  203. package/dist/es-legacy/utils/useForm/useFormWithA11y.js +1 -1
  204. package/dist/es-legacy/utils/useForm/useFormWithA11y.js.map +1 -1
  205. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as o,useState as r,useRef as t}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as s}from"../../../core/Context/CoreProvider.js";import i from"../../internal/FormFields/Field/Field.js";import a from"../../../utils/useForm/useForm.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import{digitsOnlyFormatter as l}from"../../../utils/Formatters/formatters.js";import n from"../../../core/Context/useImage.js";import d from"../../internal/FormFields/InputText.js";import{PREFIX as m}from"../../internal/Icon/constants.js";function u(u){const{i18n:c}=s(),p=n(),{handleChangeFor:f,triggerValidation:k,data:b,valid:C,errors:h,isValid:g}=a({schema:["blikCode"],rules:{blikCode:{validate:e=>6===e?.length,errorMessage:"blik.invalid",modes:["blur"]}},formatters:{blikCode:l}});o(()=>{u.onChange?.({data:b,errors:h,valid:C,isValid:Boolean(g)},this)},[b,C,h,g]);const[F,j]=r("ready"),v=t({setStatus:j,showValidation:()=>{k()}});return o(()=>{u.setComponentRef(v.current)},[u.setComponentRef]),e("div",{className:"adyen-checkout__blik"},e("p",{className:"adyen-checkout__blik__helper"},c.get("blik.help")),e(i,{errorMessage:"string"==typeof h.blikCode?.errorMessage&&c.get(h.blikCode.errorMessage),label:c.get("blik.code"),classNameModifiers:["blikCode","50"],isValid:C.blikCode,dir:"ltr",name:"blikCode"},e(d,{value:b.blikCode,name:"blikCode",spellcheck:!1,required:!0,autocorrect:"off",autocomplete:"off",onInput:f("blikCode","input"),onBlur:f("blikCode","blur"),placeholder:u?.placeholders?.blikCode,inputMode:"numeric",maxLength:6})),u.showPayButton&&u.payButton?.({status:F,icon:p({imageFolder:"components/"})(`${m}lock`)}))}u.defaultProps={data:{blikCode:""}};export{u as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as o,useState as t}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import i from"../../internal/FormFields/Field/Field.js";import s from"../../../utils/useForm/useForm.js";import"../../internal/SecuredFields/lib/CSF/utils/userAgent.js";import{digitsOnlyFormatter as a}from"../../../utils/Formatters/formatters.js";import l from"../../../core/Context/useImage.js";import d from"../../internal/FormFields/InputText.js";import{PREFIX as n}from"../../internal/Icon/constants.js";function m(m){const{i18n:c}=r(),u=l(),{handleChangeFor:p,triggerValidation:k,data:b,valid:f,errors:h,isValid:C}=s({schema:["blikCode"],rules:{blikCode:{validate:e=>6===e?.length,errorMessage:"blik.invalid",modes:["blur"]}},formatters:{blikCode:a}});o(()=>{m.onChange({data:b,errors:h,valid:f,isValid:C},this)},[b,f,h,C]);const[g,F]=t("ready");return this.setStatus=F,this.showValidation=k,e("div",{className:"adyen-checkout__blik"},e("p",{className:"adyen-checkout__blik__helper"},c.get("blik.help")),e(i,{errorMessage:!!h.blikCode&&c.get(h.blikCode.errorMessage),label:c.get("blik.code"),classNameModifiers:["blikCode","50"],isValid:f.blikCode,dir:"ltr",name:"blikCode"},e(d,{value:b.blikCode,name:"blikCode",spellcheck:!1,required:!0,autocorrect:"off",autocomplete:"off",onInput:p("blikCode","input"),onBlur:p("blikCode","blur"),placeholder:m?.placeholders?.blikCode,inputMode:"numeric",maxLength:6})),m.showPayButton&&m.payButton({status:g,icon:u({imageFolder:"components/"})(`${n}lock`)}))}m.defaultProps={data:{blikCode:""}};export{m as default};
2
2
  //# sourceMappingURL=BlikInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlikInput.js","sources":["../../../../../src/components/Blik/components/BlikInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../../internal/FormFields/Field';\nimport './BlikInput.scss';\nimport useForm from '../../../utils/useForm';\nimport { digitsOnlyFormatter } from '../../../utils/Formatters/formatters';\nimport useImage from '../../../core/Context/useImage';\nimport InputText from '../../internal/FormFields/InputText';\nimport { ComponentMethodsRef, UIElementProps } from '../../internal/UIElement/types';\nimport { PREFIX } from '../../internal/Icon/constants';\nimport { OnChangeDataErrors, PaymentData } from '../../../types';\n\ninterface BlikInputProps extends UIElementProps {\n data?: BlikInputDataState;\n placeholders?: BlikInputDataState;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\ninterface BlikInputDataState {\n blikCode: string;\n}\n\nfunction BlikInput(props: Readonly<BlikInputProps>) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<BlikInputDataState>({\n schema: ['blikCode'],\n rules: {\n blikCode: {\n validate: code => code?.length === 6,\n errorMessage: 'blik.invalid',\n modes: ['blur']\n }\n },\n formatters: {\n blikCode: digitsOnlyFormatter\n }\n });\n\n useEffect(() => {\n props.onChange?.({ data: data as unknown as PaymentData, errors: errors as OnChangeDataErrors, valid, isValid: Boolean(isValid) }, this);\n }, [data, valid, errors, isValid]);\n\n const [status, setStatus] = useState('ready');\n\n const blikComponentRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(blikComponentRef.current);\n }, [props.setComponentRef]);\n\n return (\n <div className=\"adyen-checkout__blik\">\n <p className=\"adyen-checkout__blik__helper\">{i18n.get('blik.help')}</p>\n <Field\n errorMessage={typeof errors.blikCode?.errorMessage === 'string' ? i18n.get(errors.blikCode.errorMessage) : false}\n label={i18n.get('blik.code')}\n classNameModifiers={['blikCode', '50']}\n isValid={valid.blikCode}\n dir={'ltr'}\n name={'blikCode'}\n >\n <InputText\n value={data.blikCode}\n name={'blikCode'}\n spellcheck={false}\n required={true}\n autocorrect={'off'}\n autocomplete={'off'}\n onInput={handleChangeFor('blikCode', 'input')}\n onBlur={handleChangeFor('blikCode', 'blur')}\n placeholder={props?.placeholders?.blikCode}\n inputMode={'numeric'}\n maxLength={6}\n />\n </Field>\n\n {props.showPayButton &&\n props.payButton?.({\n status,\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </div>\n );\n}\n\nBlikInput.defaultProps = { data: { blikCode: '' } };\n\nexport default BlikInput;\n"],"names":["BlikInput","props","i18n","useCoreContext","getImage","useImage","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","blikCode","validate","code","length","errorMessage","modes","formatters","digitsOnlyFormatter","useEffect","onChange","Boolean","this","status","setStatus","useState","blikComponentRef","useRef","showValidation","setComponentRef","current","h","div","className","p","get","Field","label","classNameModifiers","dir","name","InputText","value","spellcheck","required","autocorrect","autocomplete","onInput","onBlur","placeholder","placeholders","inputMode","maxLength","showPayButton","payButton","icon","imageFolder","PREFIX","defaultProps"],"mappings":"0oBAuBA,SAASA,EAAUC,GACf,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA4B,CACrGC,OAAQ,CAAC,YACTC,MAAO,CACHC,SAAU,CACNC,SAAUC,GAAyB,IAAjBA,GAAMC,OACxBC,aAAc,eACdC,MAAO,CAAC,UAGhBC,WAAY,CACRN,SAAUO,KAIlBC,EAAU,KACNtB,EAAMuB,WAAW,CAAEhB,KAAMA,EAAgCE,OAAQA,EAA8BD,QAAOE,QAASc,QAAQd,IAAYe,OACpI,CAAClB,EAAMC,EAAOC,EAAQC,IAEzB,MAAOgB,EAAQC,GAAaC,EAAS,SAE/BC,EAAmBC,EAA4B,CACjDH,UAAWA,EACXI,eAAgB,KACZzB,OAQR,OAJAgB,EAAU,KACNtB,EAAMgC,gBAAgBH,EAAiBI,UACxC,CAACjC,EAAMgC,kBAGNE,EAACC,MAAAA,CAAIC,UAAU,wBACXF,EAACG,IAAAA,CAAED,UAAU,gCAAgCnC,EAAKqC,IAAI,cACtDJ,EAACK,EAAAA,CACGrB,aAAuD,iBAAlCT,EAAOK,UAAUI,cAA4BjB,EAAKqC,IAAI7B,EAAOK,SAASI,cAC3FsB,MAAOvC,EAAKqC,IAAI,aAChBG,mBAAoB,CAAC,WAAY,MACjC/B,QAASF,EAAMM,SACf4B,IAAK,MACLC,KAAM,YAENT,EAACU,EAAAA,CACGC,MAAOtC,EAAKO,SACZ6B,KAAM,WACNG,YAAY,EACZC,UAAU,EACVC,YAAa,MACbC,aAAc,MACdC,QAAS7C,EAAgB,WAAY,SACrC8C,OAAQ9C,EAAgB,WAAY,QACpC+C,YAAapD,GAAOqD,cAAcvC,SAClCwC,UAAW,UACXC,UAAW,KAIlBvD,EAAMwD,eACHxD,EAAMyD,YAAY,CACd/B,SACAgC,KAAMvD,EAAS,CAAEwD,YAAa,eAAxBxD,CAAyC,GAAGyD,WAItE,CAEA7D,EAAU8D,aAAe,CAAEtD,KAAM,CAAEO,SAAU"}
1
+ {"version":3,"file":"BlikInput.js","sources":["../../../../../src/components/Blik/components/BlikInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../../internal/FormFields/Field';\nimport './BlikInput.scss';\nimport useForm from '../../../utils/useForm';\nimport { digitsOnlyFormatter } from '../../../utils/Formatters/formatters';\nimport useImage from '../../../core/Context/useImage';\nimport InputText from '../../internal/FormFields/InputText';\nimport { UIElementProps } from '../../internal/UIElement/types';\nimport { PREFIX } from '../../internal/Icon/constants';\n\ninterface BlikInputProps extends UIElementProps {\n data?: BlikInputDataState;\n placeholders?: BlikInputDataState;\n}\n\ninterface BlikInputDataState {\n blikCode: string;\n}\n\nfunction BlikInput(props: Readonly<BlikInputProps>) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<BlikInputDataState>({\n schema: ['blikCode'],\n rules: {\n blikCode: {\n validate: code => code?.length === 6,\n errorMessage: 'blik.invalid',\n modes: ['blur']\n }\n },\n formatters: {\n blikCode: digitsOnlyFormatter\n }\n });\n\n useEffect(() => {\n // @ts-ignore TODO: Fix this. Preact component types should not inherit from UIElementProps.\n props.onChange({ data, errors, valid, isValid }, this);\n }, [data, valid, errors, isValid]);\n\n const [status, setStatus] = useState('ready');\n this.setStatus = setStatus;\n this.showValidation = triggerValidation;\n\n return (\n <div className=\"adyen-checkout__blik\">\n <p className=\"adyen-checkout__blik__helper\">{i18n.get('blik.help')}</p>\n <Field\n errorMessage={!!errors.blikCode && i18n.get(errors.blikCode.errorMessage)}\n label={i18n.get('blik.code')}\n classNameModifiers={['blikCode', '50']}\n isValid={valid.blikCode}\n dir={'ltr'}\n name={'blikCode'}\n >\n <InputText\n value={data.blikCode}\n name={'blikCode'}\n spellcheck={false}\n required={true}\n autocorrect={'off'}\n autocomplete={'off'}\n onInput={handleChangeFor('blikCode', 'input')}\n onBlur={handleChangeFor('blikCode', 'blur')}\n placeholder={props?.placeholders?.blikCode}\n inputMode={'numeric'}\n maxLength={6}\n />\n </Field>\n\n {props.showPayButton &&\n props.payButton({\n status,\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </div>\n );\n}\n\nBlikInput.defaultProps = { data: { blikCode: '' } };\n\nexport default BlikInput;\n"],"names":["BlikInput","props","i18n","useCoreContext","getImage","useImage","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","blikCode","validate","code","length","errorMessage","modes","formatters","digitsOnlyFormatter","useEffect","onChange","this","status","setStatus","useState","showValidation","h","div","className","p","get","Field","label","classNameModifiers","dir","name","InputText","value","spellcheck","required","autocorrect","autocomplete","onInput","onBlur","placeholder","placeholders","inputMode","maxLength","showPayButton","payButton","icon","imageFolder","PREFIX","defaultProps"],"mappings":"8nBAqBA,SAASA,EAAUC,GACf,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA4B,CACrGC,OAAQ,CAAC,YACTC,MAAO,CACHC,SAAU,CACNC,SAAUC,GAAyB,IAAjBA,GAAMC,OACxBC,aAAc,eACdC,MAAO,CAAC,UAGhBC,WAAY,CACRN,SAAUO,KAIlBC,EAAU,KAENtB,EAAMuB,SAAS,CAAEhB,OAAME,SAAQD,QAAOE,WAAWc,OAClD,CAACjB,EAAMC,EAAOC,EAAQC,IAEzB,MAAOe,EAAQC,GAAaC,EAAS,SAIrC,OAHAH,KAAKE,UAAYA,EACjBF,KAAKI,eAAiBtB,EAGlBuB,EAACC,MAAAA,CAAIC,UAAU,wBACXF,EAACG,IAAAA,CAAED,UAAU,gCAAgC9B,EAAKgC,IAAI,cACtDJ,EAACK,EAAAA,CACGhB,eAAgBT,EAAOK,UAAYb,EAAKgC,IAAIxB,EAAOK,SAASI,cAC5DiB,MAAOlC,EAAKgC,IAAI,aAChBG,mBAAoB,CAAC,WAAY,MACjC1B,QAASF,EAAMM,SACfuB,IAAK,MACLC,KAAM,YAENT,EAACU,EAAAA,CACGC,MAAOjC,EAAKO,SACZwB,KAAM,WACNG,YAAY,EACZC,UAAU,EACVC,YAAa,MACbC,aAAc,MACdC,QAASxC,EAAgB,WAAY,SACrCyC,OAAQzC,EAAgB,WAAY,QACpC0C,YAAa/C,GAAOgD,cAAclC,SAClCmC,UAAW,UACXC,UAAW,KAIlBlD,EAAMmD,eACHnD,EAAMoD,UAAU,CACZ3B,SACA4B,KAAMlD,EAAS,CAAEmD,YAAa,eAAxBnD,CAAyC,GAAGoD,WAItE,CAEAxD,EAAUyD,aAAe,CAAEjD,KAAM,CAAEO,SAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import e from"./components/CardInput/CardInput.js";import o from"../../utils/browserInfo.js";import{triggerBinLookUp as s}from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as n,isSecuredField as i}from"../internal/SecuredFields/utils.js";import{reject as r,notFalsy as a}from"../../utils/commonUtils.js";import{shouldIncludeInstallmentsInPaymentData as p}from"./components/CardInput/utils.js";import c from"../internal/ClickToPay/services/create-clicktopay-service.js";import d from"./components/ClickToPayWrapper.js";import{TxVariants as l}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import m,{IMPLEMENTATION_ERROR as y}from"../../core/Errors/AdyenCheckoutError.js";import f from"./components/CardInput/defaultProps.js";import{AnalyticsInfoEvent as g,InfoEventType as b}from"../../core/Analytics/events/AnalyticsInfoEvent.js";function C(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class P extends u{setStatus(t){return this.componentRef?.setStatus&&this.componentRef.setStatus(t),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t),this}getPaymentMethodConfigFromResponse(t){return t?.fundingSource?this.core.paymentMethodsResponse?.findByFundingSource(t.type,t.fundingSource):super.getPaymentMethodConfigFromResponse(t)}formatProps(t){const e=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,o=!(0===t.amount?.value)&&e,s=t.storedPaymentMethodId||t.id,n=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!n)throw new m(y,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");const i=t.installmentOptions;t.session&&a(i)&&console.warn("WARNING: You have defined installments configuration on the Card component, but you are using a /sessions integration.\nWith this integration, installments configuration must be defined when you create the session. Any configuration defined elsewhere will be ignored.\n\n");const r=t.session?t.session?.configuration?.installmentOptions??f.installmentOptions:i;return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?f.billingAddressMode:t.billingAddressMode,brand:t.brand??l.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:r,enableStoreDetails:e,showStoreDetailsCheckbox:o,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:P.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource},...this.state.fastlaneData&&{fastlaneData:btoa(JSON.stringify(this.state.fastlaneData))}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...p(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}beforeRender(t){if(t?.originalAction)return;const e=new g({type:b.rendered,component:this.type,configData:{...t,showPayButton:this.props.showPayButton},...t?.oneClick&&{isStoredPaymentMethod:!0,brand:t.brand}});this.analytics.sendAnalytics(e)}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,e=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,e),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const e=r("supportedBrandsRaw").from(t);this.props.onBinLookup?.(e)}}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:e}=this.props;return t?t.map(t=>({icon:e?.[t]?.icon??this.props.modules.resources.getImage()(t),name:t})):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||P.type}get accessibleName(){return(this.props.name||P.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return o()}renderCardInput(o=!0){return t(e,{setComponentRef:this.setComponentRef,...this.props,...this.state,billingAddressMode:this.props.billingAddressMode,onSubmitAnalytics:this.submitAnalytics,onChange:this.setState,onSubmit:this.submit,handleKeyDown:this.handleKeyDown,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:o,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onConfigSuccess:this.onConfigSuccess})}componentToRender(){return t(d,{configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},t=>this.renderCardInput(t))}constructor(e,o){super(e,o),C(this,"clickToPayService",void 0),C(this,"componentRef",void 0),C(this,"clickToPayRef",null),C(this,"setClickToPayRef",t=>{this.clickToPayRef=t}),C(this,"onBrand",t=>{this.props.onBrand?.(t)}),C(this,"handleClickToPaySubmit",t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()}),C(this,"onConfigSuccess",t=>{const e=new g({component:this.type,type:b.configured});this.submitAnalytics(e),this.props.onConfigSuccess?.(t)}),C(this,"onFocus",t=>{const e=new g({component:this.type,type:b.focus,target:n(t.fieldType)});this.submitAnalytics(e),i(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)}),C(this,"onBlur",t=>{const e=new g({component:this.type,type:b.unfocus,target:n(t.fieldType)});this.submitAnalytics(e),i(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)}),C(this,"onBinValue",s(this)),C(this,"payButton",e=>{const o=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...e,label:o&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit,showReview:!!this.props.onReview})}),o&&!o._disableClickToPay&&"prepaid"!==this.props.fundingSource&&(this.clickToPayService=c(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment,this.analytics),this.clickToPayService?.initialize())}}C(P,"type",l.scheme),C(P,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...r(["type","setComponentRef"]).from(f)});export{P as CardElement,P as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import e from"./components/CardInput/CardInput.js";import o from"../../utils/browserInfo.js";import{triggerBinLookUp as s}from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as n,isSecuredField as i}from"../internal/SecuredFields/utils.js";import{reject as r,notFalsy as a}from"../../utils/commonUtils.js";import{shouldIncludeInstallmentsInPaymentData as p}from"./components/CardInput/utils.js";import c from"../internal/ClickToPay/services/create-clicktopay-service.js";import u from"./components/ClickToPayWrapper.js";import{TxVariants as d}from"../tx-variants.js";import{UIElement as l}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import m,{IMPLEMENTATION_ERROR as y}from"../../core/Errors/AdyenCheckoutError.js";import f from"./components/CardInput/defaultProps.js";import{AnalyticsInfoEvent as g,InfoEventType as b}from"../../core/Analytics/events/AnalyticsInfoEvent.js";function C(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class P extends l{setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t),this}getPaymentMethodConfigFromResponse(t){return t?.fundingSource?this.core.paymentMethodsResponse?.findByFundingSource(t.type,t.fundingSource):super.getPaymentMethodConfigFromResponse(t)}formatProps(t){const e=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,o=!(0===t.amount?.value)&&e,s=t.storedPaymentMethodId||t.id,n=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!n)throw new m(y,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");const i=t.installmentOptions;t.session&&a(i)&&console.warn("WARNING: You have defined installments configuration on the Card component, but you are using a /sessions integration.\nWith this integration, installments configuration must be defined when you create the session. Any configuration defined elsewhere will be ignored.\n\n");const r=t.session?t.session?.configuration?.installmentOptions??f.installmentOptions:i;return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?f.billingAddressMode:t.billingAddressMode,brand:t.brand??d.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:r,enableStoreDetails:e,showStoreDetailsCheckbox:o,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:P.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource},...this.state.fastlaneData&&{fastlaneData:btoa(JSON.stringify(this.state.fastlaneData))}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...p(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}beforeRender(t){if(t?.originalAction)return;const e=new g({type:b.rendered,component:this.type,configData:{...t,showPayButton:this.props.showPayButton},...t?.oneClick&&{isStoredPaymentMethod:!0,brand:t.brand}});this.analytics.sendAnalytics(e)}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,e=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,e),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const e=r("supportedBrandsRaw").from(t);this.props.onBinLookup?.(e)}}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:e}=this.props;return t?t.map(t=>({icon:e?.[t]?.icon??this.props.modules.resources.getImage()(t),name:t})):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||P.type}get accessibleName(){return(this.props.name||P.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return o()}renderCardInput(o=!0){return t(e,{setComponentRef:this.setComponentRef,...this.props,...this.state,onSubmitAnalytics:this.submitAnalytics,onChange:this.setState,onSubmit:this.submit,handleKeyDown:this.handleKeyDown,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:o,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onConfigSuccess:this.onConfigSuccess})}componentToRender(){return t(u,{configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},t=>this.renderCardInput(t))}constructor(e,o){super(e,o),C(this,"clickToPayService",void 0),C(this,"clickToPayRef",null),C(this,"setClickToPayRef",t=>{this.clickToPayRef=t}),C(this,"onBrand",t=>{this.props.onBrand?.(t)}),C(this,"handleClickToPaySubmit",t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()}),C(this,"onConfigSuccess",t=>{const e=new g({component:this.type,type:b.configured});this.submitAnalytics(e),this.props.onConfigSuccess?.(t)}),C(this,"onFocus",t=>{const e=new g({component:this.type,type:b.focus,target:n(t.fieldType)});this.submitAnalytics(e),i(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)}),C(this,"onBlur",t=>{const e=new g({component:this.type,type:b.unfocus,target:n(t.fieldType)});this.submitAnalytics(e),i(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)}),C(this,"onBinValue",s(this)),C(this,"payButton",e=>{const o=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...e,label:o&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit,showReview:!!this.props.onReview})}),o&&!o._disableClickToPay&&"prepaid"!==this.props.fundingSource&&(this.clickToPayService=c(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment,this.analytics),this.clickToPayService?.initialize())}}C(P,"type",d.scheme),C(P,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...r(["type","setComponentRef"]).from(f)});export{P as CardElement,P as default};
2
2
  //# sourceMappingURL=Card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport { triggerBinLookUp } from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport {\n CardBinLookupData,\n CardBrandData,\n CardConfigSuccessData,\n CardErrorData,\n CardFocusData,\n StylesObject\n} from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase, isSecuredField } from '../internal/SecuredFields/utils';\nimport { notFalsy, reject } from '../../utils/commonUtils';\nimport { shouldIncludeInstallmentsInPaymentData } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject, PaymentMethodBrand } from '../../types/global-types';\nimport { TxVariants } from '../tx-variants';\nimport type { ComponentMethodsRef, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { InstallmentOptions } from './components/CardInput/components/Installments/Installments';\nimport { AddressModeOptions, CardInputRef } from './components/CardInput/types';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static readonly type: TxVariants = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n protected componentRef: CardInputRef | undefined;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef: ComponentMethodsRef | null = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay && this.props.fundingSource !== 'prepaid') {\n this.clickToPayService = createClickToPayService(\n this.props.configuration,\n this.props.clickToPayConfiguration,\n this.props.environment,\n this.analytics\n );\n\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static readonly defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status);\n }\n return this;\n }\n\n private readonly setClickToPayRef = (ref: ComponentMethodsRef) => {\n this.clickToPayRef = ref;\n };\n\n // This is the most self contained way of handling funding source matching\n // Alternatives would be to override getPaymentMethodConfigFromResponse and change it's signature\n protected override getPaymentMethodConfigFromResponse(componentProps: CardConfiguration) {\n if (componentProps?.fundingSource) {\n return this.core.paymentMethodsResponse?.findByFundingSource(componentProps.type, componentProps.fundingSource);\n }\n\n return super.getPaymentMethodConfigFromResponse(componentProps);\n }\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n // Take the configuration set on the card component - which is either merchant defined or default (empty object)\n // @ts-ignore 'installmentOptions' is optional on CardConfiguration (the merchant-facing type), but by this point\n // UIElement.buildElementProps has already merged CardInputDefaultProps.installmentOptions ({}) into props\n // before formatProps() is called, so the value is always defined here.\n const merchantInstallmentOptions: InstallmentOptions = props.installmentOptions;\n\n if (props.session && notFalsy(merchantInstallmentOptions)) {\n console.warn(\n 'WARNING: You have defined installments configuration on the Card component, but you are using a /sessions integration.\\nWith this integration, installments configuration must be defined when you create the session. Any configuration defined elsewhere will be ignored.\\n\\n'\n );\n }\n\n // In a session scenario, only the session's own installments configuration is used; otherwise fall back to the merchant configuration / default\n const shownInstallmentOptions: InstallmentOptions = props.session\n ? (props.session?.configuration?.installmentOptions ?? CardInputDefaultProps.installmentOptions)\n : merchantInstallmentOptions;\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n installmentOptions: shownInstallmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource }),\n ...(this.state.fastlaneData && { fastlaneData: btoa(JSON.stringify(this.state.fastlaneData)) })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(shouldIncludeInstallmentsInPaymentData(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n protected override beforeRender(configSetByMerchant?: CardConfiguration): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && {\n isStoredPaymentMethod: true,\n brand: configSetByMerchant.brand\n })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n updateStyles(stylesObj: StylesObject) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName: string) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = (event: CardBrandData) => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse | null, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj: CardErrorData) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private readonly handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n private readonly onConfigSuccess = (obj: CardConfigSuccessData) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.configured });\n this.submitAnalytics(event);\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private readonly onFocus = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.focus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (isSecuredField(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private readonly onBlur = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.unfocus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (isSecuredField(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): PaymentMethodBrand[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration?.[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonProps): h.JSX.Element => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n showReview={!!this.props.onReview}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n billingAddressMode={this.props.billingAddressMode as AddressModeOptions}\n onSubmitAnalytics={this.submitAnalytics}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyDown={this.handleKeyDown}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <ClickToPayWrapper\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","this","componentRef","clickToPayRef","getPaymentMethodConfigFromResponse","componentProps","fundingSource","core","paymentMethodsResponse","findByFundingSource","type","super","formatProps","props","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","merchantInstallmentOptions","installmentOptions","notFalsy","console","warn","shownInstallmentOptions","CardInputDefaultProps","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","data","holderName","fastlaneData","btoa","JSON","stringify","billingAddress","socialSecurityNumber","storePaymentMethodPayload","shouldIncludeInstallmentsInPaymentData","installments","browserInfo","origin","window","location","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onSubmitAnalytics","submitAnalytics","onChange","setState","onSubmit","submit","handleKeyDown","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onConfigSuccess","componentToRender","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","constructor","checkout","_define_property","ref","payload","valid","errors","configured","focus","target","fieldTypeToSnakeCase","fieldType","isSecuredField","unfocus","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","label","onClick","showReview","onReview","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"6nCAgCO,MAAMA,UAAoBC,EAmCtBC,SAAAA,CAAUC,GAOb,OANIC,KAAKC,cAAcH,WACnBE,KAAKC,aAAaH,UAAUC,GAE5BC,KAAKE,eAAeJ,WACpBE,KAAKE,cAAcJ,UAAUC,GAE1BC,IACX,CAQmBG,kCAAAA,CAAmCC,GAClD,OAAIA,GAAgBC,cACTL,KAAKM,KAAKC,wBAAwBC,oBAAoBJ,EAAeK,KAAML,EAAeC,eAG9FK,MAAMP,mCAAmCC,EACpD,CAEAO,WAAAA,CAAYC,GAER,MAAMC,EAAqBD,EAAME,SAASC,eAAeF,oBAAsBD,EAAMC,mBAG/EG,IADqC,IAAxBJ,EAAMK,QAAQC,QACqBL,EAEhDM,EAAeP,EAAMQ,uBAAyBR,EAAMS,GACpDC,EAAwBH,GAAgBP,GAAOW,8BAA8BC,SAAS,a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Y,MAAMkK,YACX9K,KAAKyF,WAGJzF,KAAK8I,mBAAmBiC,aAErC,EAxBAvB,EADS5J,EACca,OAAmBiC,EAAWsI,QA0BrDxB,EA3BS5J,EA2BiBqL,eAAe,CACrCC,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,KAEV5E,EAAO,CAAC,OAAQ,oBAAoBC,KAAKvE"}
1
+ {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport { triggerBinLookUp } from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardConfigSuccessData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase, isSecuredField } from '../internal/SecuredFields/utils';\nimport { notFalsy, reject } from '../../utils/commonUtils';\nimport { shouldIncludeInstallmentsInPaymentData } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject, PaymentMethodBrand } from '../../types/global-types';\nimport { TxVariants } from '../tx-variants';\nimport type { ComponentMethodsRef, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { InstallmentOptions } from './components/CardInput/components/Installments/Installments';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static readonly type: TxVariants = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef: ComponentMethodsRef | null = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay && this.props.fundingSource !== 'prepaid') {\n this.clickToPayService = createClickToPayService(\n this.props.configuration,\n this.props.clickToPayConfiguration,\n this.props.environment,\n this.analytics\n );\n\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static readonly defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status);\n }\n return this;\n }\n\n private readonly setClickToPayRef = (ref: ComponentMethodsRef) => {\n this.clickToPayRef = ref;\n };\n\n // This is the most self contained way of handling funding source matching\n // Alternatives would be to override getPaymentMethodConfigFromResponse and change it's signature\n protected override getPaymentMethodConfigFromResponse(componentProps: CardConfiguration) {\n if (componentProps?.fundingSource) {\n return this.core.paymentMethodsResponse?.findByFundingSource(componentProps.type, componentProps.fundingSource);\n }\n\n return super.getPaymentMethodConfigFromResponse(componentProps);\n }\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n // Take the configuration set on the card component - which is either merchant defined or default (empty object)\n // @ts-ignore 'installmentOptions' is optional on CardConfiguration (the merchant-facing type), but by this point\n // UIElement.buildElementProps has already merged CardInputDefaultProps.installmentOptions ({}) into props\n // before formatProps() is called, so the value is always defined here.\n const merchantInstallmentOptions: InstallmentOptions = props.installmentOptions;\n\n if (props.session && notFalsy(merchantInstallmentOptions)) {\n console.warn(\n 'WARNING: You have defined installments configuration on the Card component, but you are using a /sessions integration.\\nWith this integration, installments configuration must be defined when you create the session. Any configuration defined elsewhere will be ignored.\\n\\n'\n );\n }\n\n // In a session scenario, only the session's own installments configuration is used; otherwise fall back to the merchant configuration / default\n const shownInstallmentOptions: InstallmentOptions = props.session\n ? (props.session?.configuration?.installmentOptions ?? CardInputDefaultProps.installmentOptions)\n : merchantInstallmentOptions;\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n installmentOptions: shownInstallmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource }),\n ...(this.state.fastlaneData && { fastlaneData: btoa(JSON.stringify(this.state.fastlaneData)) })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(shouldIncludeInstallmentsInPaymentData(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n protected override beforeRender(configSetByMerchant?: CardConfiguration): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && {\n isStoredPaymentMethod: true,\n brand: configSetByMerchant.brand\n })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = event => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse | null, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private readonly handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n private readonly onConfigSuccess = (obj: CardConfigSuccessData) => {\n const event = new AnalyticsInfoEvent({ component: this.type, type: InfoEventType.configured });\n this.submitAnalytics(event);\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private readonly onFocus = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.focus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (isSecuredField(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private readonly onBlur = (obj: ComponentFocusObject) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.unfocus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n if (isSecuredField(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): PaymentMethodBrand[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration?.[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonProps): h.JSX.Element => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n showReview={!!this.props.onReview}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onSubmitAnalytics={this.submitAnalytics}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyDown={this.handleKeyDown}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <ClickToPayWrapper\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","props","this","componentRef","clickToPayRef","getPaymentMethodConfigFromResponse","componentProps","fundingSource","core","paymentMethodsResponse","findByFundingSource","type","super","formatProps","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","merchantInstallmentOptions","installmentOptions","notFalsy","console","warn","shownInstallmentOptions","CardInputDefaultProps","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","data","holderName","fastlaneData","btoa","JSON","stringify","billingAddress","socialSecurityNumber","storePaymentMethodPayload","shouldIncludeInstallmentsInPaymentData","installments","browserInfo","origin","window","location","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onSubmitAnalytics","submitAnalytics","onChange","setState","onSubmit","submit","handleKeyDown","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onConfigSuccess","componentToRender","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","constructor","checkout","_define_property","ref","payload","valid","errors","configured","focus","target","fieldTypeToSnakeCase","fieldType","isSecuredField","unfocus","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","label","onClick","showReview","onReview","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","do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KD,MAAM0I,SAASrC,KAI5BmD,OAAOlB,aAAa8B,EAAiBnK,OAoErCuJ,EAAAvJ,KAAmBmI,YAAapI,IAC5B,MAAMqK,EAA0C,IAA7BpK,KAAKD,MAAMiB,QAAQC,MAChCoJ,EAAerK,KAAKD,MAAMoB,uBAAuBqF,OAAS,EAChE,OACIiB,EAAC6C,EAAAA,IACOvK,EACJwK,MAAOH,IAAeC,EAAerK,KAAKD,MAAMuD,KAAK+D,IAAI,yBAA2B,GACpFmD,QAASxK,KAAKiI,OACdwC,aAAczK,KAAKD,MAAM2K,aAnU7B3K,IAAUA,EAAM4K,oBAAmD,YAA7B3K,KAAKD,MAAMM,gBACjDL,KAAK6I,kBAAoB+B,EACrB5K,KAAKD,MAAMe,cACXd,KAAKD,MAAMiD,wBACXhD,KAAKD,MAAM8K,YACX7K,KAAKwF,WAGJxF,KAAK6I,mBAAmBiC,aAErC,EAtBAvB,EADS5J,EACcc,OAAmBgC,EAAWsI,QAwBrDxB,EAzBS5J,EAyBiBqL,eAAe,CACrCC,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,KAEV5E,EAAO,CAAC,OAAQ,oBAAoBC,KAAKvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport type {\n BinLookupResponse,\n BrandConfiguration,\n CardBrandsConfiguration,\n CardBackendConfiguration,\n DualBrandSelectElement,\n CardPlaceholders\n} from '../../types';\nimport {\n CardAllValidData,\n CardAutoCompleteData,\n CardBinValueData,\n CardBrandData,\n CardConfigSuccessData,\n CardFieldValidData,\n CardFocusData,\n CardLoadData,\n CVCPolicyType,\n DatePolicyType\n} from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CardErrorData, StylesObject } from '../../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../../core/Context/Resources';\nimport { SRPanel } from '../../../../core/Errors/SRPanel';\nimport RiskElement from '../../../../core/RiskModule';\nimport { DisclaimerMsgObject } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { OnAddressLookupType, OnAddressSelectedType } from '../../../internal/Address/components/AddressSearch';\nimport { ComponentMethodsRef } from '../../../internal/UIElement/types';\nimport { AddressData } from '../../../../types/global-types';\nimport type { FastlaneSignupConfiguration } from '../../../PayPalFastlane/types';\nimport type { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { IAnalytics } from '../../../../core/Analytics/Analytics';\nimport { PayButtonProps } from '../../../internal/PayButton/PayButton';\nimport { h } from 'preact';\nimport { InstallmentOptions } from './components/Installments/Installments';\nimport type { Form } from '../../../../utils/useForm/types';\nimport type { SecuredFieldsProviderRef } from '../../../internal/SecuredFields/SFP/types';\nimport { AdyenCheckoutError } from '../../../../types';\nimport { ValidationRuleResult } from '../../../../utils/Validator/ValidationRuleResult';\n\nexport interface CardInputValidState {\n holderName?: boolean;\n billingAddress?: boolean;\n socialSecurityNumber?: boolean;\n encryptedCardNumber?: boolean;\n encryptedExpiryMonth?: boolean;\n encryptedExpiryYear?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: boolean;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputErrorState {\n holderName?: ValidationRuleResult;\n billingAddress?: ValidationRuleResult;\n socialSecurityNumber?: ValidationRuleResult;\n encryptedCardNumber?: boolean;\n encryptedExpiryDate?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: ValidationRuleResult;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputDataState {\n holderName?: string;\n billingAddress?: AddressData | null;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\n/**\n * Should be the subset of the props sent to CardInput that are *actually* used by CardInput\n * - either in the comp itself or are passed on to its children\n */\nexport interface CardInputProps {\n isPayButtonPrimaryVariant?: boolean;\n autoFocus?: boolean;\n billingAddressAllowedCountries?: string[];\n billingAddressRequired?: boolean;\n billingAddressRequiredFields?: string[];\n billingAddressMode?: AddressModeOptions;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n brandsIcons: Array<BrandConfiguration>;\n clientKey?: string;\n configuration: CardBackendConfiguration;\n countryCode?: string;\n cvcPolicy?: CVCPolicyType;\n data?: CardInputDataState;\n disableIOSArrowKeys?: boolean;\n enableStoreDetails?: boolean;\n expiryMonth?: string;\n expiryYear?: string;\n fastlaneConfiguration?: FastlaneSignupConfiguration;\n forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit' | 'prepaid';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderName?: string;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: 'components' | 'custom';\n installmentOptions?: InstallmentOptions;\n keypadFix?: boolean;\n lastFour?: string;\n loadingContext?: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n modules?: {\n srPanel?: SRPanel;\n analytics?: IAnalytics;\n risk?: RiskElement;\n resources?: Resources;\n };\n onAdditionalSFConfig?: () => void;\n onAdditionalSFRemoved?: () => void;\n onAllValid?: (o: CardAllValidData) => void;\n onAutoComplete?: (o: CardAutoCompleteData) => void;\n onBinValue?: (o: CardBinValueData) => void;\n onBlur?: (e) => void;\n onBrand?: (o: CardBrandData) => void;\n onConfigSuccess?: (O: CardConfigSuccessData) => void;\n onChange: (state) => void;\n onError?: (e: AdyenCheckoutError) => void;\n onFieldValid?: (o: CardFieldValidData) => void;\n onFocus?: (e) => void;\n onLoad?: (o: CardLoadData) => void;\n onSubmitAnalytics: (event: AbstractAnalyticsEvent) => void;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n onSubmit?: () => void;\n addressSearchDebounceMs?: number;\n payButton?: (props: PayButtonProps) => h.JSX.Element;\n placeholders?: CardPlaceholders;\n positionHolderNameOnTop?: boolean;\n resources: Resources;\n setComponentRef?: (ref) => void;\n showBrandIcon?: boolean;\n showInstallmentAmounts?: boolean;\n showPayButton?: boolean;\n showStoreDetailsCheckbox?: boolean;\n showWarnings?: boolean;\n showContextualElement?: boolean;\n specifications?: Specifications;\n storedPaymentMethodId?: string;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type: string;\n maskSecurityCode?: boolean;\n exposeExpiryDate?: boolean;\n disclaimerMessage?: DisclaimerMsgObject;\n}\n\nexport interface CardInputState {\n dualBrandSelectElements: DualBrandSelectElement[];\n selectedBrandValue: string;\n billingAddress: object;\n brand?: string;\n data?: object;\n errors?: object;\n focusedElement: string;\n cvcPolicy: CVCPolicyType;\n expiryDatePolicy: DatePolicyType;\n isValid: boolean;\n status: string;\n valid?: object;\n issuingCountryCode: string;\n showSocialSecurityNumber?: boolean;\n}\n\n// An interface for the members exposed by CardInput to its parent Card/UIElement\nexport interface CardInputRef extends ComponentMethodsRef {\n sfp?: SecuredFieldsProviderRef;\n setFocusOn?: (field: string) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CardErrorData) => boolean;\n}\n\nexport interface FieldError {\n errorMessage?: string;\n errorI18n?: string;\n}\n\nexport interface SFError {\n isValid?: boolean;\n errorMessage?: string;\n errorI18n?: string;\n error: string;\n rootNode: HTMLElement;\n detectedBrands?: string[];\n}\n\nexport interface SFStateErrorObj {\n [key: string]: SFError;\n}\n\nexport interface LayoutObj {\n props: CardInputProps;\n showKCP: boolean;\n showBrazilianSSN: boolean;\n countrySpecificSchemas: AddressSchema;\n billingAddressRequiredFields?: string[];\n}\n\nexport enum AddressModeOptions {\n full = 'full',\n partial = 'partial',\n none = 'none'\n}\n\nexport type CardSetFormData = Form<CardInputDataState>['setData'];\nexport type CardSetFormValid = Form<CardInputDataState>['setValid'];\nexport type CardSetFormErrors = Form<CardInputDataState>['setErrors'];\n\nexport type OnFieldFocus = (who: string, e: Event | CardFocusData) => void;\n"],"names":["AddressModeOptions"],"mappings":"AAiNO,IAAAA,EAAKA,SAAAA,GAAAA,uDAAAA,CAIX,CAJWA,CAIX,CAAA"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport type {\n BinLookupResponse,\n BrandConfiguration,\n CardBrandsConfiguration,\n CardBackendConfiguration,\n DualBrandSelectElement,\n CardPlaceholders\n} from '../../types';\nimport { ValidationResult } from '../../../internal/PersonalDetails/types';\nimport {\n CardAllValidData,\n CardAutoCompleteData,\n CardBinValueData,\n CardBrandData,\n CardConfigSuccessData,\n CardFieldValidData,\n CardFocusData,\n CardLoadData,\n CVCPolicyType,\n DatePolicyType\n} from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CardErrorData, StylesObject } from '../../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../../core/Context/Resources';\nimport { SRPanel } from '../../../../core/Errors/SRPanel';\nimport RiskElement from '../../../../core/RiskModule';\nimport { DisclaimerMsgObject } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { OnAddressLookupType, OnAddressSelectedType } from '../../../internal/Address/components/AddressSearch';\nimport { ComponentMethodsRef } from '../../../internal/UIElement/types';\nimport { AddressData } from '../../../../types/global-types';\nimport type { FastlaneSignupConfiguration } from '../../../PayPalFastlane/types';\nimport type { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { IAnalytics } from '../../../../core/Analytics/Analytics';\nimport { PayButtonProps } from '../../../internal/PayButton/PayButton';\nimport { h } from 'preact';\nimport { InstallmentOptions } from './components/Installments/Installments';\nimport type { Form } from '../../../../utils/useForm/types';\nimport type { SecuredFieldsProviderRef } from '../../../internal/SecuredFields/SFP/types';\n\nexport interface CardInputValidState {\n holderName?: boolean;\n billingAddress?: boolean;\n socialSecurityNumber?: boolean;\n encryptedCardNumber?: boolean;\n encryptedExpiryMonth?: boolean;\n encryptedExpiryYear?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: boolean;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputErrorState {\n holderName?: ValidationResult;\n billingAddress?: ValidationResult;\n socialSecurityNumber?: ValidationResult;\n encryptedCardNumber?: boolean;\n encryptedExpiryDate?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: ValidationResult;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputDataState {\n holderName?: string;\n billingAddress?: AddressData | null;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\n/**\n * Should be the subset of the props sent to CardInput that are *actually* used by CardInput\n * - either in the comp itself or are passed on to its children\n */\nexport interface CardInputProps {\n isPayButtonPrimaryVariant?: boolean;\n autoFocus?: boolean;\n billingAddressAllowedCountries?: string[];\n billingAddressRequired?: boolean;\n billingAddressRequiredFields?: string[];\n billingAddressMode?: AddressModeOptions;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n brandsIcons: Array<BrandConfiguration>;\n clientKey: string;\n configuration: CardBackendConfiguration;\n countryCode?: string;\n cvcPolicy?: CVCPolicyType;\n data?: CardInputDataState;\n disableIOSArrowKeys?: boolean;\n enableStoreDetails?: boolean;\n expiryMonth?: string;\n expiryYear?: string;\n fastlaneConfiguration?: FastlaneSignupConfiguration;\n forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit' | 'prepaid';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderName?: string;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: 'components' | 'custom';\n installmentOptions?: InstallmentOptions;\n keypadFix?: boolean;\n lastFour?: string;\n loadingContext: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n modules?: {\n srPanel: SRPanel;\n analytics: IAnalytics;\n risk: RiskElement;\n resources: Resources;\n };\n onAdditionalSFConfig?: () => void;\n onAdditionalSFRemoved?: () => void;\n onAllValid?: (o: CardAllValidData) => void;\n onAutoComplete?: (o: CardAutoCompleteData) => void;\n onBinValue?: (o: CardBinValueData) => void;\n onBlur?: (e) => void;\n onBrand?: (o: CardBrandData) => void;\n onConfigSuccess?: (O: CardConfigSuccessData) => void;\n onChange: (state) => void;\n onError?: () => void;\n onFieldValid?: (o: CardFieldValidData) => void;\n onFocus?: (e) => void;\n onLoad?: (o: CardLoadData) => void;\n onSubmitAnalytics: (event: AbstractAnalyticsEvent) => void;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n addressSearchDebounceMs?: number;\n payButton?: (props: PayButtonProps) => h.JSX.Element;\n placeholders?: CardPlaceholders;\n positionHolderNameOnTop?: boolean;\n resources: Resources;\n setComponentRef?: (ref) => void;\n showBrandIcon?: boolean;\n showInstallmentAmounts?: boolean;\n showPayButton: boolean;\n showStoreDetailsCheckbox?: boolean;\n showWarnings?: boolean;\n showContextualElement?: boolean;\n specifications?: Specifications;\n storedPaymentMethodId?: string;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type: string;\n maskSecurityCode?: boolean;\n exposeExpiryDate?: boolean;\n disclaimerMessage?: DisclaimerMsgObject;\n}\n\nexport interface CardInputState {\n dualBrandSelectElements: DualBrandSelectElement[];\n selectedBrandValue: string;\n billingAddress: object;\n brand?: string;\n data?: object;\n errors?: object;\n focusedElement: string;\n cvcPolicy: CVCPolicyType;\n expiryDatePolicy: DatePolicyType;\n isValid: boolean;\n status: string;\n valid?: object;\n issuingCountryCode: string;\n showSocialSecurityNumber?: boolean;\n}\n\n// An interface for the members exposed by CardInput to its parent Card/UIElement\nexport interface CardInputRef extends ComponentMethodsRef {\n sfp?: SecuredFieldsProviderRef;\n setFocusOn?: (who) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CardErrorData) => boolean;\n}\n\nexport interface FieldError {\n errorMessage?: string;\n errorI18n?: string;\n}\n\nexport interface SFError {\n isValid?: boolean;\n errorMessage?: string;\n errorI18n?: string;\n error: string;\n rootNode: HTMLElement;\n detectedBrands?: string[];\n}\n\nexport interface SFStateErrorObj {\n [key: string]: SFError;\n}\n\nexport interface LayoutObj {\n props: CardInputProps;\n showKCP: boolean;\n showBrazilianSSN: boolean;\n countrySpecificSchemas: AddressSchema;\n billingAddressRequiredFields?: string[];\n}\n\nexport enum AddressModeOptions {\n full = 'full',\n partial = 'partial',\n none = 'none'\n}\n\nexport type CardSetFormData = Form<CardInputDataState>['setData'];\nexport type CardSetFormValid = Form<CardInputDataState>['setValid'];\nexport type CardSetFormErrors = Form<CardInputDataState>['setErrors'];\n\nexport type OnFieldFocus = (who: string, e: Event | CardFocusData) => void;\n"],"names":["AddressModeOptions"],"mappings":"AA+MO,IAAAA,EAAKA,SAAAA,GAAAA,uDAAAA,CAIX,CAJWA,CAIX,CAAA"}
@@ -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{CashAppComponent as s}from"./components/CashAppComponent.js";import o from"./services/CashAppService.js";import{CashAppSdkLoader as r}from"./services/CashAppSdkLoader.js";import n from"./defaultProps.js";import i from"../internal/RedirectButton/RedirectButton.js";import{payAmountLabel as a}from"../internal/PayButton/utils.js";import{TxVariants as p}from"../tx-variants.js";import{PREFIX as h}from"../internal/Icon/constants.js";function d(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class c extends e{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:n,storedPaymentMethodId:i}=this.props,a=this.props.enableStoreDetails||!this.props.session&&n;if(i)return{paymentMethod:{type:c.type,storedPaymentMethodId:i}};return{paymentMethod:{type:c.type,...e&&{grantId:e},...r&&{customerId:r},...s&&o&&{onFileGrantId:s,cashtag:o}},...a&&{storePaymentMethod:n||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":""}get isValid(){return!0}componentToRender(){return this.props.storedPaymentMethodId?t(i,{showPayButton:this.props.showPayButton,label:a(this.props.i18n,this.props.amount),icon:this.resources?.getImage({imageFolder:"components/"})(`${h}lock`),name:this.displayName,payButton:this.payButton,onSubmit:this.submit,setComponentRef:this.setComponentRef}):t(s,{setComponentRef:this.setComponentRef,enableStoreDetails:this.props.enableStoreDetails,cashAppService:this.cashAppService,onChangeStoreDetails:this.handleOnChangeStoreDetails,onError:this.handleError,onClick:this.submit,onAuthorize:this.handleAuthorize})}constructor(t,e){if(super(t,e),d(this,"cashAppService",void 0),d(this,"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,new Error("onClick rejected")}).then(()=>this.cashAppService.createCustomerRequest(this.props.amount)).then(()=>{this.cashAppService.begin()}).catch(t=>{s||this.handleError(t)})}),d(this,"handleOnChangeStoreDetails",t=>{const e={...this.state.data,shopperWantsToStore:t};this.setState({data:e})}),d(this,"handleAuthorize",t=>{const e={...this.state.data,...t};this.setState({data:e,valid:{},errors:{},isValid:!0}),super.submit()}),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)return;const s=new r({environment:this.props.environment,analytics:this.analytics});this.cashAppService=new o(s,{storePaymentMethod:this.props.storePaymentMethod,useCashAppButtonUi:this.props.showPayButton,environment:this.props.environment,redirectURL:this.props.redirectURL,clientId:this.props.configuration?.clientId,scopeId:this.props.configuration?.scopeId,button:this.props.button,referenceId:this.props.referenceId})}}d(c,"type",p.cashapp),d(c,"defaultProps",n);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{CashAppComponent as s}from"./components/CashAppComponent.js";import o from"./services/CashAppService.js";import{CashAppSdkLoader as r}from"./services/CashAppSdkLoader.js";import n from"./defaultProps.js";import i from"../internal/RedirectButton/RedirectButton.js";import{payAmountLabel as a}from"../internal/PayButton/utils.js";import{TxVariants as p}from"../tx-variants.js";import{PREFIX as h}from"../internal/Icon/constants.js";function d(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class c extends e{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:n,storedPaymentMethodId:i}=this.props,a=this.props.enableStoreDetails||!this.props.session&&n;if(i)return{paymentMethod:{type:c.type,storedPaymentMethodId:i}};return{paymentMethod:{type:c.type,...e&&{grantId:e},...r&&{customerId:r},...s&&o&&{onFileGrantId:s,cashtag:o}},...a&&{storePaymentMethod:n||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":""}get isValid(){return!0}componentToRender(){return this.props.storedPaymentMethodId?t(i,{showPayButton:this.props.showPayButton,label:a(this.props.i18n,this.props.amount),icon:this.resources?.getImage({imageFolder:"components/"})(`${h}lock`),name:this.displayName,payButton:this.payButton,onSubmit:this.submit,ref:t=>{this.componentRef=t}}):t(s,{setComponentRef:this.setComponentRef,enableStoreDetails:this.props.enableStoreDetails,cashAppService:this.cashAppService,onChangeStoreDetails:this.handleOnChangeStoreDetails,onError:this.handleError,onClick:this.submit,onAuthorize:this.handleAuthorize})}constructor(t,e){if(super(t,e),d(this,"cashAppService",void 0),d(this,"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,new Error("onClick rejected")}).then(()=>this.cashAppService.createCustomerRequest(this.props.amount)).then(()=>{this.cashAppService.begin()}).catch(t=>{s||this.handleError(t)})}),d(this,"handleOnChangeStoreDetails",t=>{const e={...this.state.data,shopperWantsToStore:t};this.setState({data:e})}),d(this,"handleAuthorize",t=>{const e={...this.state.data,...t};this.setState({data:e,valid:{},errors:{},isValid:!0}),super.submit()}),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)return;const s=new r({environment:this.props.environment,analytics:this.analytics});this.cashAppService=new o(s,{storePaymentMethod:this.props.storePaymentMethod,useCashAppButtonUi:this.props.showPayButton,environment:this.props.environment,redirectURL:this.props.redirectURL,clientId:this.props.configuration?.clientId,scopeId:this.props.configuration?.scopeId,button:this.props.button,referenceId:this.props.referenceId})}}d(c,"type",p.cashapp),d(c,"defaultProps",n);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 { 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/utils';\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 readonly type = TxVariants.cashapp;\n\n private readonly cashAppService: ICashAppService | undefined;\n\n protected static readonly 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 const sdkLoader = new CashAppSdkLoader({\n environment: this.props.environment,\n analytics: this.analytics\n });\n\n this.cashAppService = new CashAppService(sdkLoader, {\n storePaymentMethod: this.props.storePaymentMethod,\n useCashAppButtonUi: this.props.showPayButton,\n environment: this.props.environment,\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 new Error('onClick rejected');\n })\n .then(() => {\n return this.cashAppService.createCustomerRequest(this.props.amount);\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 readonly handleOnChangeStoreDetails = (storePayment: boolean) => {\n const data = { ...this.state.data, shopperWantsToStore: storePayment };\n this.setState({ data });\n };\n\n private readonly 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 protected override componentToRender(): h.JSX.Element {\n return 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 payButton={this.payButton}\n onSubmit={this.submit}\n setComponentRef={this.setComponentRef}\n />\n ) : (\n <CashAppComponent\n setComponentRef={this.setComponentRef}\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 }\n}\n\nexport default CashAppPay;\n"],"names":["CashAppPay","UIElement","formatProps","props","enableStoreDetails","session","configuration","formatData","shopperWantsToStore","grantId","onFileGrantId","cashTag","customerId","this","state","data","storePaymentMethod","storePaymentMethodSetByMerchant","storedPaymentMethodId","includeStorePaymentMethod","paymentMethod","type","cashtag","displayName","name","additionalInfo","isValid","componentToRender","h","RedirectButton","showPayButton","label","payAmountLabel","i18n","amount","icon","resources","getImage","imageFolder","PREFIX","payButton","onSubmit","submit","setComponentRef","CashAppComponent","cashAppService","onChangeStoreDetails","handleOnChangeStoreDetails","onError","handleError","onClick","onAuthorize","handleAuthorize","constructor","checkout","super","_define_property","onClickPromiseRejected","Promise","resolve","reject","catch","Error","then","createCustomerRequest","begin","error","storePayment","setState","cashAppPaymentData","valid","errors","console","warn","sdkLoader","CashAppSdkLoader","environment","analytics","CashAppService","useCashAppButtonUi","redirectURL","clientId","scopeId","button","referenceId","TxVariants","cashapp","defaultProps"],"mappings":"irBAcO,MAAMA,UAAmBC,EAqCrBC,WAAAA,CAAYC,GACf,MAAO,IACAA,EACHC,mBAAoBD,EAAME,SAASC,eAAeF,oBAAsBD,EAAMC,mBAEtF,CAEOG,UAAAA,GACH,MAAMC,oBAAEA,EAAmBC,QAAEA,EAAOC,cAAEA,EAAaC,QAAEA,EAAOC,WAAEA,GAAeC,KAAKC,MAAMC,MAAQ,CAAA,GACxFC,mBAAoBC,EAA+BC,sBAAEA,GAA0BL,KAAKV,MAKtFgB,EAA4BN,KAAKV,MAAMC,qBAAwBS,KAAKV,MAAME,SAAWY,EAE3F,GAAIC,EACA,MAAO,CACHE,cAAe,CACXC,KAAMrB,EAAWqB,KACjBH,0BAOZ,MAAO,CACHE,cAAe,CACXC,KAAMrB,EAAWqB,QACbZ,GAAW,CAAEA,cACbG,GAAc,CAAEA,iBANMF,GAAiBC,GAOV,CAAED,gBAAeY,QAASX,OAE3DQ,GAA6B,CAAEH,mBAAoBC,GAAmCT,GAElG,CAEA,eAAIe,GACA,OAAIV,KAAKV,MAAMe,uBAAyBL,KAAK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AC3C,MAAMpD,EAAO,IAAKF,KAAKC,MAAMC,KAAMP,oBAAqB2D,GACxDtD,KAAKuD,SAAS,CAAErD,WAGpByC,EAAA3C,KAAiBuC,kBAAmBiB,IAChC,MAAMtD,EAAO,IAAKF,KAAKC,MAAMC,QAASsD,GACtCxD,KAAKuD,SAAS,CAAErD,OAAMuD,MAAO,CAAA,EAAIC,OAAQ,CAAA,EAAI7C,SAAS,IACtD6B,MAAMb,WAtHF7B,KAAKV,MAAMC,oBAAsBS,KAAKV,MAAMa,oBAC5CwD,QAAQC,KACJ,oJAIJ5D,KAAKV,MAAMe,sBACX,OAGJ,MAAMwD,EAAY,IAAIC,EAAiB,CACnCC,YAAa/D,KAAKV,MAAMyE,YACxBC,UAAWhE,KAAKgE,YAGpBhE,KAAKgC,eAAiB,IAAIiC,EAAeJ,EAAW,CAChD1D,mBAAoBH,KAAKV,MAAMa,mBAC/B+D,mBAAoBlE,KAAKV,MAAM2B,cAC/B8C,YAAa/D,KAAKV,MAAMyE,YACxBI,YAAanE,KAAKV,MAAM6E,YACxBC,SAAUpE,KAAKV,MAAMG,eAAe2E,SACpCC,QAASrE,KAAKV,MAAMG,eAAe4E,QACnCC,OAAQtE,KAAKV,MAAMgF,OACnBC,YAAavE,KAAKV,MAAMiF,aAEhC,EAlCA5B,EADSxD,EACcqB,OAAOgE,EAAWC,SAIzC9B,EALSxD,EAKiBuF,eAAeA"}
1
+ {"version":3,"file":"CashAppPay.js","sources":["../../../../src/components/CashAppPay/CashAppPay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\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/utils';\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 readonly type = TxVariants.cashapp;\n\n private readonly cashAppService: ICashAppService | undefined;\n\n protected static readonly 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 const sdkLoader = new CashAppSdkLoader({\n environment: this.props.environment,\n analytics: this.analytics\n });\n\n this.cashAppService = new CashAppService(sdkLoader, {\n storePaymentMethod: this.props.storePaymentMethod,\n useCashAppButtonUi: this.props.showPayButton,\n environment: this.props.environment,\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 new Error('onClick rejected');\n })\n .then(() => {\n return this.cashAppService.createCustomerRequest(this.props.amount);\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 readonly handleOnChangeStoreDetails = (storePayment: boolean) => {\n const data = { ...this.state.data, shopperWantsToStore: storePayment };\n this.setState({ data });\n };\n\n private readonly 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 protected override componentToRender(): h.JSX.Element {\n return 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 payButton={this.payButton}\n onSubmit={this.submit}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n ) : (\n <CashAppComponent\n setComponentRef={this.setComponentRef}\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 }\n}\n\nexport default CashAppPay;\n"],"names":["CashAppPay","UIElement","formatProps","props","enableStoreDetails","session","configuration","formatData","shopperWantsToStore","grantId","onFileGrantId","cashTag","customerId","this","state","data","storePaymentMethod","storePaymentMethodSetByMerchant","storedPaymentMethodId","includeStorePaymentMethod","paymentMethod","type","cashtag","displayName","name","additionalInfo","isValid","componentToRender","h","RedirectButton","showPayButton","label","payAmountLabel","i18n","amount","icon","resources","getImage","imageFolder","PREFIX","payButton","onSubmit","submit","ref","componentRef","CashAppComponent","setComponentRef","cashAppService","onChangeStoreDetails","handleOnChangeStoreDetails","onError","handleError","onClick","onAuthorize","handleAuthorize","constructor","checkout","super","_define_property","onClickPromiseRejected","Promise","resolve","reject","catch","Error","then","createCustomerRequest","begin","error","storePayment","setState","cashAppPaymentData","valid","errors","console","warn","sdkLoader","CashAppSdkLoader","environment","analytics","CashAppService","useCashAppButtonUi","redirectURL","clientId","scopeId","button","referenceId","TxVariants","cashapp","defaultProps"],"mappings":"irBAcO,MAAMA,UAAmBC,EAqCrBC,WAAAA,CAAYC,GACf,MAAO,IACAA,EACHC,mBAAoBD,EAAME,SAASC,eAAeF,oBAAsBD,EAAMC,mBAEtF,CAEOG,UAAAA,GACH,MAAMC,oBAAEA,EAAmBC,QAAEA,EAAOC,cAAEA,EAAaC,QAAEA,EAAOC,WAAEA,GAAeC,KAAKC,MAAMC,MAAQ,CAAA,GACxFC,mBAAoBC,EAA+BC,sBAAEA,GAA0BL,KAAKV,MAKtFgB,EAA4BN,KAAKV,MAAMC,qBAAwBS,KAAKV,MAAME,SAAWY,EAE3F,GAAIC,EACA,MAAO,CACHE,cAAe,CACXC,KAAMrB,EAAWqB,KACjBH,0BAOZ,MAAO,CACHE,cAAe,CACXC,KAAMrB,EAAWqB,QACbZ,GAAW,CAAEA,cACbG,GAAc,CAAEA,iBANMF,GAAiBC,GAOV,CAAED,gBAAeY,QAASX,OAE3DQ,GAA6B,CA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eoB,UAEvBJ,MAAMK,IACCT,GAIJ9C,KAAKsC,YAAYiB,OAQ7BV,EAAA7C,KAAiBoC,6BAA8BoB,IAC3C,MAAMtD,EAAO,IAAKF,KAAKC,MAAMC,KAAMP,oBAAqB6D,GACxDxD,KAAKyD,SAAS,CAAEvD,WAGpB2C,EAAA7C,KAAiByC,kBAAmBiB,IAChC,MAAMxD,EAAO,IAAKF,KAAKC,MAAMC,QAASwD,GACtC1D,KAAKyD,SAAS,CAAEvD,OAAMyD,MAAO,CAAA,EAAIC,OAAQ,CAAA,EAAI/C,SAAS,IACtD+B,MAAMf,WAtHF7B,KAAKV,MAAMC,oBAAsBS,KAAKV,MAAMa,oBAC5C0D,QAAQC,KACJ,oJAIJ9D,KAAKV,MAAMe,sBACX,OAGJ,MAAM0D,EAAY,IAAIC,EAAiB,CACnCC,YAAajE,KAAKV,MAAM2E,YACxBC,UAAWlE,KAAKkE,YAGpBlE,KAAKkC,eAAiB,IAAIiC,EAAeJ,EAAW,CAChD5D,mBAAoBH,KAAKV,MAAMa,mBAC/BiE,mBAAoBpE,KAAKV,MAAM2B,cAC/BgD,YAAajE,KAAKV,MAAM2E,YACxBI,YAAarE,KAAKV,MAAM+E,YACxBC,SAAUtE,KAAKV,MAAMG,eAAe6E,SACpCC,QAASvE,KAAKV,MAAMG,eAAe8E,QACnCC,OAAQxE,KAAKV,MAAMkF,OACnBC,YAAazE,KAAKV,MAAMmF,aAEhC,EAlCA5B,EADS1D,EACcqB,OAAOkE,EAAWC,SAIzC9B,EALS1D,EAKiByF,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./CustomCardInput/CustomCardInput.js";import o from"../../utils/browserInfo.js";import{triggerBinLookUp as s}from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{getCardImageUrl as r,fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{TxVariants as a}from"../tx-variants.js";import{AnalyticsInfoEvent as d,InfoEventType as p}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as u}from"../Card/constants.js";function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class l extends t{formatProps(e){return{...e,type:a.customCard}}formatData(){const e=this.state.selectedBrandValue;return{paymentMethod:{type:"scheme",...this.state.data,...e&&{brand:e}},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(e){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(e),this}setFocusOn(e){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(e),this}processBinLookupResponse(e){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(e),this}dualBrandingChangeHandler(e){return this.componentRef?.dualBrandingChangeHandler&&this.componentRef.dualBrandingChangeHandler(e),this}handleUnsupportedCard(e){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(e),this}onBinLookup(e){const t={...e};if(t.rootNode=this._node,!t.isReset){t.supportedBrandsRaw=e.supportedBrandsRaw?.map(e=>(e.brandImageUrl=this.props.brandsConfiguration[e.brand]?.icon??r(e.brand,this.resources),e));let n=!1,o=!1;e.supportedBrandsRaw?.length>1&&(n=!0,o=e.detectedBrands.some(e=>u.includes(e))),t.dualBrandingType=null,n&&(t.dualBrandingType=o?"Dual Branded (Selectable): Regulation mandates that you must provide a brand selection mechanism":"Dual Branded (Display-only): No selection mechanism required")}this.props.onBinLookup(t)}get isValid(){return!!this.state.isValid}get browserInfo(){return o()}componentToRender(){return e(n,{ref:e=>{this.componentRef=e},...this.props,...this.state,handleKeyDown:this.handleKeyDown,rootNode:this._node,onChange:this.setState,onBinValue:this.onBinValue,implementationType:"custom",resources:this.resources,brand:this.brand,onFocus:this.onFocus,onSubmitAnalytics:this.submitAnalytics})}constructor(...e){super(...e),c(this,"componentRef",void 0),c(this,"brand",a.card),c(this,"onBinValue",s(this)),c(this,"onFocus",e=>{const t=new d({component:this.type,type:!0===e.focus?p.focus:p.unfocus,target:i(e.fieldType)});this.submitAnalytics(t),this.props.onFocus?.(e)}),c(this,"onEnterKeyPressed",(e,t)=>{this.props.onEnterKeyPressed?.(e,t)})}}c(l,"type",a.customCard),c(l,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{l as CustomCard,l as default};
1
+ import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./CustomCardInput/CustomCardInput.js";import o from"../../utils/browserInfo.js";import{triggerBinLookUp as s}from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{getCardImageUrl as r,fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{TxVariants as a}from"../tx-variants.js";import{AnalyticsInfoEvent as d,InfoEventType as p}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as u}from"../Card/constants.js";function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class l extends t{formatProps(e){return{...e,type:a.customCard}}formatData(){const e=this.state.selectedBrandValue;return{paymentMethod:{type:"scheme",...this.state.data,...e&&{brand:e}},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(e){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(e),this}setFocusOn(e){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(e),this}processBinLookupResponse(e){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(e),this}dualBrandingChangeHandler(e){return this.componentRef?.dualBrandingChangeHandler&&this.componentRef.dualBrandingChangeHandler(e),this}handleUnsupportedCard(e){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(e),this}onBinLookup(e){const t={...e};if(t.rootNode=this._node,!t.isReset){t.supportedBrandsRaw=e.supportedBrandsRaw?.map(e=>(e.brandImageUrl=this.props.brandsConfiguration[e.brand]?.icon??r(e.brand,this.resources),e));let n=!1,o=!1;e.supportedBrandsRaw?.length>1&&(n=!0,o=e.detectedBrands.some(e=>u.includes(e))),t.dualBrandingType=null,n&&(t.dualBrandingType=o?"Dual Branded (Selectable): Regulation mandates that you must provide a brand selection mechanism":"Dual Branded (Display-only): No selection mechanism required")}this.props.onBinLookup(t)}get isValid(){return!!this.state.isValid}get browserInfo(){return o()}componentToRender(){return e(n,{ref:e=>{this.componentRef=e},...this.props,...this.state,handleKeyDown:this.handleKeyDown,rootNode:this._node,onChange:this.setState,onBinValue:this.onBinValue,implementationType:"custom",resources:this.resources,brand:this.brand,onFocus:this.onFocus,onSubmitAnalytics:this.submitAnalytics})}constructor(...e){super(...e),c(this,"brand",a.card),c(this,"onBinValue",s(this)),c(this,"onFocus",e=>{const t=new d({component:this.type,type:!0===e.focus?p.focus:p.unfocus,target:i(e.fieldType)});this.submitAnalytics(t),this.props.onFocus?.(e)}),c(this,"onEnterKeyPressed",(e,t)=>{this.props.onEnterKeyPressed?.(e,t)})}}c(l,"type",a.customCard),c(l,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{l as CustomCard,l as default};
2
2
  //# sourceMappingURL=CustomCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomCard.js","sources":["../../../../src/components/CustomCard/CustomCard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement';\nimport CustomCardInput from './CustomCardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { triggerBinLookUp } from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { BrandObject } from '../Card/types';\nimport { getCardImageUrl, fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { TxVariants } from '../tx-variants';\nimport { CustomCardConfiguration } from './types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM } from '../Card/constants';\nimport type { CustomCardInputRef } from './CustomCardInput';\n\nconst SELECTABLE_DUAL_BRANDED_SCENARIO = 'Dual Branded (Selectable): Regulation mandates that you must provide a brand selection mechanism';\nconst DISPLAY_ONLY_DUAL_BRANDED_SCENARIO = 'Dual Branded (Display-only): No selection mechanism required';\n\nexport class CustomCard extends UIElement<CustomCardConfiguration> {\n public static readonly type = TxVariants.customCard;\n\n protected componentRef: CustomCardInputRef | undefined;\n\n protected static readonly defaultProps = {\n onBinLookup: () => {},\n brandsConfiguration: {}\n };\n\n private readonly brand = TxVariants.card;\n\n formatProps(props: CustomCardConfiguration) {\n return {\n ...props,\n type: TxVariants.customCard\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const sfBrand = this.state.selectedBrandValue;\n const securedFieldsData = this.state.data as Record<string, string>;\n return {\n paymentMethod: {\n type: 'scheme',\n ...securedFieldsData,\n ...(sfBrand && { brand: sfBrand })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(frame) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(frame);\n return this;\n }\n\n processBinLookupResponse(binLookupResponse) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse);\n return this;\n }\n\n dualBrandingChangeHandler(e: Event | string) {\n if (this.componentRef?.dualBrandingChangeHandler) this.componentRef.dualBrandingChangeHandler(e);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n onBinLookup(obj: CardBinLookupData) {\n const nuObj = { ...obj };\n nuObj.rootNode = this._node;\n\n if (!nuObj.isReset) {\n // Add brandImage urls, first checking if the merchant has configured their own one for the brand\n nuObj.supportedBrandsRaw = obj.supportedBrandsRaw?.map((item: BrandObject) => {\n item.brandImageUrl = this.props.brandsConfiguration[item.brand]?.icon ?? getCardImageUrl(item.brand, this.resources);\n return item;\n });\n\n // Check for dual branded scenario and, if so, discern which type\n let isDualBrandedScenario = false;\n let isSelectableDualBrandedScenario = false;\n\n if (obj.supportedBrandsRaw?.length > 1) {\n isDualBrandedScenario = true;\n isSelectableDualBrandedScenario = obj.detectedBrands.some(item =>\n (DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as readonly string[]).includes(item)\n );\n }\n\n // Set the dual branding type\n nuObj.dualBrandingType = null;\n\n if (isDualBrandedScenario) {\n nuObj.dualBrandingType = isSelectableDualBrandedScenario ? SELECTABLE_DUAL_BRANDED_SCENARIO : DISPLAY_ONLY_DUAL_BRANDED_SCENARIO;\n }\n }\n\n this.props.onBinLookup(nuObj);\n }\n\n public onBinValue = triggerBinLookUp(this);\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n private readonly onFocus = (obj: CardFocusData) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: obj.focus === true ? InfoEventType.focus : InfoEventType.unfocus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n this.props.onFocus?.(obj);\n };\n\n protected onEnterKeyPressed = (activeElement: Element, component: UIElement) => {\n this.props.onEnterKeyPressed?.(activeElement, component);\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <CustomCardInput\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n {...this.state}\n handleKeyDown={this.handleKeyDown}\n rootNode={this._node}\n onChange={this.setState}\n onBinValue={this.onBinValue}\n implementationType={'custom'}\n resources={this.resources}\n brand={this.brand}\n onFocus={this.onFocus}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default CustomCard;\n"],"names":["CustomCard","UIElement","formatProps","props","type","TxVariants","customCard","formatData","sfBrand","this","state","selectedBrandValue","paymentMethod","data","brand","browserInfo","origin","window","location","updateStyles","stylesObj","componentRef","setFocusOn","frame","processBinLookupResponse","binLookupResponse","dualBrandingChangeHandler","e","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","rootNode","_node","isReset","supportedBrandsRaw","map","item","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","isDualBrandedScenario","isSelectableDualBrandedScenario","length","detectedBrands","some","DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM","includes","dualBrandingType","isValid","collectBrowserInfo","componentToRender","h","CustomCardInput","ref","handleKeyDown","onChange","setState","onBinValue","implementationType","onFocus","onSubmitAnalytics","submitAnalytics","super","args","_define_property","card","triggerBinLookUp","event","AnalyticsInfoEvent","component","focus","InfoEventType","unfocus","target","fieldTypeToSnakeCase","fieldType","onEnterKeyPressed","activeElement","defaultProps"],"mappings":"8vBAiBO,MAAMA,UAAmBC,EAY5BC,WAAAA,CAAYC,GACR,MAAO,IACAA,EACHC,KAAMC,EAAWC,WAEzB,CAKAC,UAAAA,GACI,MAAMC,EAAUC,KAAKC,MAAMC,mBAE3B,MAAO,CACHC,cAAe,CACXR,KAAM,YAHYK,KAAKC,MAAMG,QAKzBL,GAAW,CAAEM,MAAON,IAE5BO,YAAaN,KAAKM,YAClBC,SAAUC,QAAUA,OAAOC,SAASF,OAE5C,CAEAG,YAAAA,CAAaC,GAET,OADIX,KAAKY,cAAcF,cAAcV,KAAKY,aAAaF,aAAaC,GAC7DX,IACX,CAEAa,UAAAA,CAAWC,GAEP,OADId,KAAKY,cAAcC,YAAYb,KAAKY,aAAaC,WAAWC,GACzDd,IACX,CAEAe,wBAAAA,CAAyBC,GAErB,OADIhB,KAAKY,cAAcG,0BAA0Bf,KAAKY,aAAaG,yBAAyBC,GACrFhB,IACX,CAEAiB,yBAAAA,CAA0BC,GAEtB,OADIlB,KAAKY,cAAcK,2BAA2BjB,KAAKY,aAAaK,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AMwC,EAAQ,IAAIC,EAAmB,CACjCC,UAAWhE,KAAKL,KAChBA,MAAoB,IAAd2B,EAAI2C,MAAiBC,EAAcD,MAAQC,EAAcC,QAC/DC,OAAQC,EAAqB/C,EAAIgD,aAGrCtE,KAAKwD,gBAAgBM,GAGrB9D,KAAKN,MAAM4D,UAAUhC,KAGzBqC,EAAA3D,KAAUuE,oBAAoB,CAACC,EAAwBR,KACnDhE,KAAKN,MAAM6E,oBAAoBC,EAAeR,MArHlDL,EADSpE,EACcI,OAAOC,EAAWC,YAIzC8D,EALSpE,EAKiBkF,eAAe,CACrCpD,YAAa,OACbU,oBAAqB,CAAA"}
1
+ {"version":3,"file":"CustomCard.js","sources":["../../../../src/components/CustomCard/CustomCard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement';\nimport CustomCardInput from './CustomCardInput';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { triggerBinLookUp } from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { BrandObject } from '../Card/types';\nimport { getCardImageUrl, fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { TxVariants } from '../tx-variants';\nimport { CustomCardConfiguration } from './types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM } from '../Card/constants';\n\nconst SELECTABLE_DUAL_BRANDED_SCENARIO = 'Dual Branded (Selectable): Regulation mandates that you must provide a brand selection mechanism';\nconst DISPLAY_ONLY_DUAL_BRANDED_SCENARIO = 'Dual Branded (Display-only): No selection mechanism required';\n\nexport class CustomCard extends UIElement<CustomCardConfiguration> {\n public static readonly type = TxVariants.customCard;\n\n protected static readonly defaultProps = {\n onBinLookup: () => {},\n brandsConfiguration: {}\n };\n\n private brand = TxVariants.card;\n\n formatProps(props: CustomCardConfiguration) {\n return {\n ...props,\n type: TxVariants.customCard\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const sfBrand = this.state.selectedBrandValue;\n return {\n paymentMethod: {\n type: 'scheme',\n ...this.state.data,\n ...(sfBrand && { brand: sfBrand })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(frame) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(frame);\n return this;\n }\n\n processBinLookupResponse(binLookupResponse) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse);\n return this;\n }\n\n dualBrandingChangeHandler(e: Event | string) {\n if (this.componentRef?.dualBrandingChangeHandler) this.componentRef.dualBrandingChangeHandler(e);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n onBinLookup(obj: CardBinLookupData) {\n const nuObj = { ...obj };\n nuObj.rootNode = this._node;\n\n if (!nuObj.isReset) {\n // Add brandImage urls, first checking if the merchant has configured their own one for the brand\n nuObj.supportedBrandsRaw = obj.supportedBrandsRaw?.map((item: BrandObject) => {\n item.brandImageUrl = this.props.brandsConfiguration[item.brand]?.icon ?? getCardImageUrl(item.brand, this.resources);\n return item;\n });\n\n // Check for dual branded scenario and, if so, discern which type\n let isDualBrandedScenario = false;\n let isSelectableDualBrandedScenario = false;\n\n if (obj.supportedBrandsRaw?.length > 1) {\n isDualBrandedScenario = true;\n isSelectableDualBrandedScenario = obj.detectedBrands.some(item =>\n (DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as readonly string[]).includes(item)\n );\n }\n\n // Set the dual branding type\n nuObj.dualBrandingType = null;\n\n if (isDualBrandedScenario) {\n nuObj.dualBrandingType = isSelectableDualBrandedScenario ? SELECTABLE_DUAL_BRANDED_SCENARIO : DISPLAY_ONLY_DUAL_BRANDED_SCENARIO;\n }\n }\n\n this.props.onBinLookup(nuObj);\n }\n\n public onBinValue = triggerBinLookUp(this);\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n private onFocus = (obj: CardFocusData) => {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: obj.focus === true ? InfoEventType.focus : InfoEventType.unfocus,\n target: fieldTypeToSnakeCase(obj.fieldType) as UiTarget\n });\n\n this.submitAnalytics(event);\n\n // Call merchant defined callback\n this.props.onFocus?.(obj);\n };\n\n protected onEnterKeyPressed = (activeElement: Element, component: UIElement) => {\n this.props.onEnterKeyPressed?.(activeElement, component);\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <CustomCardInput\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n {...this.state}\n handleKeyDown={this.handleKeyDown}\n rootNode={this._node}\n onChange={this.setState}\n onBinValue={this.onBinValue}\n implementationType={'custom'}\n resources={this.resources}\n brand={this.brand}\n onFocus={this.onFocus}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default CustomCard;\n"],"names":["CustomCard","UIElement","formatProps","props","type","TxVariants","customCard","formatData","sfBrand","this","state","selectedBrandValue","paymentMethod","data","brand","browserInfo","origin","window","location","updateStyles","stylesObj","componentRef","setFocusOn","frame","processBinLookupResponse","binLookupResponse","dualBrandingChangeHandler","e","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","rootNode","_node","isReset","supportedBrandsRaw","map","item","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","isDualBrandedScenario","isSelectableDualBrandedScenario","length","detectedBrands","some","DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM","includes","dualBrandingType","isValid","collectBrowserInfo","componentToRender","h","CustomCardInput","ref","handleKeyDown","onChange","setState","onBinValue","implementationType","onFocus","onSubmitAnalytics","submitAnalytics","super","args","_define_property","card","triggerBinLookUp","event","AnalyticsInfoEvent","component","focus","InfoEventType","unfocus","target","fieldTypeToSnakeCase","fieldType","onEnterKeyPressed","activeElement","defaultProps"],"mappings":"8vBAgBO,MAAMA,UAAmBC,EAU5BC,WAAAA,CAAYC,GACR,MAAO,IACAA,EACHC,KAAMC,EAAWC,WAEzB,CAKAC,UAAAA,GACI,MAAMC,EAAUC,KAAKC,MAAMC,mBAC3B,MAAO,CACHC,cAAe,CACXR,KAAM,YACHK,KAAKC,MAAMG,QACVL,GAAW,CAAEM,MAAON,IAE5BO,YAAaN,KAAKM,YAClBC,SAAUC,QAAUA,OAAOC,SAASF,OAE5C,CAEAG,YAAAA,CAAaC,GAET,OADIX,KAAKY,cAAcF,cAAcV,KAAKY,aAAaF,aAAaC,GAC7DX,IACX,CAEAa,UAAAA,CAAWC,GAEP,OADId,KAAKY,cAAcC,YAAYb,KAAKY,aAAaC,WAAWC,GACzDd,IACX,CAEAe,wBAAAA,CAAyBC,GAErB,OADIhB,KAAKY,cAAcG,0BAA0Bf,KAAKY,aAAaG,yBAAyBC,GACrFhB,IACX,CAEAiB,yBAAAA,CAA0BC,GAEtB,OADIlB,KAAKY,cAAcK,2BAA2BjB,KAAKY,aAAaK,0BAA0BC,GACvFlB,IACX,CAEAmB,qBAAAA,CAAsBC,GAElB,OADIpB,KAAKY,cAAcO,uBAAuBnB,KAAKY,aAAaO,sBAAsBC,GAC/EpB,IACX,CAEAqB,WAAAA,CAAYC,GACR,MAAMC,EAAQ,IAAKD,GAGnB,GAFAC,EAAMC,SAAWxB,KAAKyB,OAEjBF,EAAMG,QAAS,CAEhBH,EAAMI,mBAAqBL,EAAIK,oBAAoBC,IAAKC,IACpDA,EAAKC,cAAgB9B,KAAKN,MAAMqC,oBAAoBF,EAAKxB,QAAQ2B,MAAQC,EAAgBJ,EAAKxB,MAAOL,KAAKkC,WACnGL,IAIX,IAAIM,GAAwB,EACxBC,GAAkC,EAElCd,EAAIK,oBAAoBU,OAAS,IACjCF,GAAwB,EACxBC,EAAkCd,EAAIgB,eAAeC,KAAKV,GACrDW,EAAgEC,SAASZ,KAKlFN,EAAMmB,iBAAmB,KAErBP,IACAZ,EAAMmB,iBAAmBN,EAvFA,mGACE,+DAwFnC,CAEApC,KAAKN,MAAM2B,YAAYE,EAC3B,CAIA,WAAIoB,GACA,QAAS3C,KAAKC,MAAM0C,OACxB,CAEA,eAAIrC,GACA,OAAOsC,GACX,CAmBmBC,iBAAAA,GACf,OACIC,EAACC,EAAAA,CACGC,IAAKA,IACDhD,KAAKY,aAAeoC,MAEpBhD,KAAKN,SACLM,KAAKC,MACTgD,cAAejD,KAAKiD,cACpBzB,SAAUxB,KAAKyB,MACfyB,SAAUlD,KAAKmD,SACfC,WAAYpD,KAAKoD,WACjBC,mBAAoB,SACpBnB,UAAWlC,KAAKkC,UAChB7B,MAAOL,KAAKK,MACZiD,QAAStD,KAAKsD,QACdC,kBAAmBvD,KAAKwD,iBAGpC,mBAzIGC,SAAAC,GAQHC,EAAA3D,KAAQK,QAAQT,EAAWgE,MAmF3BD,EAAA3D,KAAOoD,aAAaS,EAAiB7D,OAUrC2D,EAAA3D,KAAQsD,UAAWhC,IACf,MAAMwC,EAAQ,IAAIC,EAAmB,CACjCC,UAAWhE,KAAKL,KAChBA,MAAoB,IAAd2B,EAAI2C,MAAiBC,EAAcD,MAAQC,EAAcC,QAC/DC,OAAQC,EAAqB/C,EAAIgD,aAGrCtE,KAAKwD,gBAAgBM,GAGrB9D,KAAKN,MAAM4D,UAAUhC,KAGzBqC,EAAA3D,KAAUuE,oBAAoB,CAACC,EAAwBR,KACnDhE,KAAKN,MAAM6E,oBAAoBC,EAAeR,MAlHlDL,EADSpE,EACcI,OAAOC,EAAWC,YAEzC8D,EAHSpE,EAGiBkF,eAAe,CACrCpD,YAAa,OACbU,oBAAqB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomCardInput.js","sources":["../../../../../src/components/CustomCard/CustomCardInput/CustomCardInput.tsx"],"sourcesContent":["import { h, Ref } from 'preact';\nimport { useState, useEffect, useRef, useMemo } from 'preact/hooks';\nimport Language from '../../../language/Language';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { SFPState } from '../../internal/SecuredFields/SFP/types';\nimport { BinLookupResponse, CardBrandsConfiguration, CardPlaceholders } from '../../Card/types';\nimport SFExtensions from '../../internal/SecuredFields/binLookup/extensions';\nimport {\n CardAllValidData,\n CardAutoCompleteData,\n CardBinValueData,\n CardBrandData,\n CardConfigSuccessData,\n CardFieldValidData,\n CardFocusData,\n CardLoadData,\n CardErrorData,\n SFFieldType,\n StylesObject\n} from '../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../core/Context/Resources';\nimport { SFError } from '../../Card/components/CardInput/types';\nimport { ValidationError } from '../types';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport type UIElement from '../../internal/UIElement';\nimport type { ComponentMethodsRef } from '../../internal/UIElement/types';\n\n/**\n * Methods that CustomCardInput exposes to the CustomCard element through the ref\n */\nexport interface CustomCardInputRef extends ComponentMethodsRef {\n processBinLookupResponse(binLookupResponse: BinLookupResponse, isReset?: boolean): void;\n dualBrandingChangeHandler(event: Event | string): void;\n setFocusOn(frame: SFFieldType): void;\n updateStyles(stylesObj: StylesObject): void;\n handleUnsupportedCard(errObj: CardErrorData): boolean;\n}\n\ninterface SecuredFieldsProps {\n autoFocus?: boolean;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n clientKey?: string;\n countryCode?: string;\n forceCompat?: boolean;\n i18n?: Language;\n implementationType?: 'components' | 'custom';\n keypadFix?: boolean;\n loadingContext?: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n onAdditionalSFConfig?: () => void;\n onAdditionalSFRemoved?: () => void;\n onAllValid?: (data: CardAllValidData) => void;\n onAutoComplete?: (data: CardAutoCompleteData) => void;\n onBinValue?: (data: CardBinValueData) => void;\n onBrand?: (data: CardBrandData) => void;\n onConfigSuccess?: (data: CardConfigSuccessData) => void;\n onChange?: (data) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onError?: (error: AdyenCheckoutError, component?: UIElement) => void;\n onFieldValid?: (data: CardFieldValidData) => void;\n onFocus?: (data: CardFocusData) => void;\n onLoad?: (data: CardLoadData) => void;\n placeholders?: CardPlaceholders;\n rootNode?: HTMLElement;\n resources?: Resources;\n showWarnings?: boolean;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type?: string;\n maskSecurityCode?: boolean;\n ref?: Ref<CustomCardInputRef>;\n}\n\nconst defaultProps = {\n onChange: () => {},\n onError: () => {},\n onValidationError: () => {}\n};\n\nfunction CustomCardInput(props: Readonly<SecuredFieldsProps>) {\n const sfp = useRef(null);\n\n const [errors, setErrors] = useState({});\n const [valid, setValid] = useState({});\n const [data, setData] = useState({});\n\n const [isSfpValid, setIsSfpValid] = useState(false);\n\n const [issuingCountryCode, setIssuingCountryCode] = useState(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState('');\n\n const handleSecuredFieldsChange = (sfState: SFPState): void => {\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n SFExtensions(\n props,\n { sfp },\n { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode }\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPECTED METHODS ON SecuredFields.this\n */\n this.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n this.dualBrandingChangeHandler = extensions.handleDualBrandSelection;\n\n useEffect(() => {\n this.setFocusOn = sfp.current.setFocusOn;\n this.updateStyles = sfp.current.updateStyles;\n this.showValidation = sfp.current.showValidation;\n this.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n useEffect(() => {\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n\n const mappedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors\n\n props.onChange({\n data,\n valid,\n errors: mappedErrors,\n isValid: isSfpValid,\n selectedBrandValue\n });\n\n // Create an array of Validation error objects and send to callback\n if (Object.keys(mappedErrors).length) {\n const validationErrors: ValidationError[] = Object.entries(mappedErrors).map(([fieldType, error]) => {\n const valErr: ValidationError = {\n fieldType,\n ...(error ? (error as SFError) : { error: '', rootNode: this.props.rootNode })\n };\n return valErr;\n });\n this.props.onValidationError?.(validationErrors);\n }\n }, [data, valid, errors, selectedBrandValue]);\n\n return (\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n type={props.brand}\n componentType={props.type}\n onChange={handleSecuredFieldsChange}\n onSubmitAnalytics={props.onSubmitAnalytics}\n exposeExpiryDate={false}\n disableIOSArrowKeys={null}\n render={() => null}\n />\n );\n}\n\nCustomCardInput.defaultProps = defaultProps;\n\nexport default CustomCardInput;\n\nconst extractPropsForSFP = (props: SecuredFieldsProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onBrand: props.onBrand,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyDown: props.handleKeyDown,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onFocus: props.onFocus,\n onLoad: props.onLoad,\n rootNode: props.rootNode,\n showWarnings: props.showWarnings,\n styles: props.styles,\n trimTrailingSeparator: props.trimTrailingSeparator,\n resources: props.resources,\n maskSecurityCode: props.maskSecurityCode,\n placeholders: props.placeholders\n };\n};\n"],"names":["CustomCardInput","props","sfp","useRef","errors","setErrors","useState","valid","setValid","data","setData","isSfpValid","setIsSfpValid","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","extensions","useMemo","SFExtensions","this","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","dualBrandingChangeHandler","handleDualBrandSelection","useEffect","setFocusOn","current","updateStyles","showValidation","handleUnsupportedCard","destroy","sfStateErrorsObj","mapErrorsToValidationRuleResult","mappedErrors","onChange","isValid","Object","keys","length","validationErrors","entries","map","fieldType","error","rootNode","onValidationError","h","SecuredFieldsProvider","ref","extractPropsForSFP","type","brand","componentType","sfState","onSubmitAnalytics","exposeExpiryDate","disableIOSArrowKeys","render","defaultProps","onError","autoFocus","brands","brandsConfiguration","clientKey","forceCompat","i18n","implementationType","keypadFix","legacyInputMode","loadingContext","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onBrand","onConfigSuccess","handleKeyDown","onFieldValid","onFocus","onLoad","showWarnings","styles","trimTrailingSeparator","resources","maskSecurityCode","placeholders"],"mappings":"qUAoFA,SAASA,EAAgBC,GACrB,MAAMC,EAAMC,EAAO,OAEZC,EAAQC,GAAaC,EAAS,CAAA,IAC9BC,EAAOC,GAAYF,EAAS,CAAA,IAC5BG,EAAMC,GAAWJ,EAAS,CAAA,IAE1BK,EAAYC,GAAiBN,GAAS,IAEtCO,EAAoBC,GAAyBR,EAAS,OAEtDS,EAAyBC,G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,OAAQ,IAAM,MAG1B,CAEA9D,EAAgB+D,aApGK,CACjBxB,SAAU,OACVyB,QAAS,OACTd,kBAAmB,QAqGvB,MAAMI,EAAsBrD,IACjB,CACHgE,UAAWhE,EAAMgE,UACjBC,OAAQjE,EAAMiE,OACdC,oBAAqBlE,EAAMkE,oBAC3BC,UAAWnE,EAAMmE,UACjBC,YAAapE,EAAMoE,YACnBC,KAAMrE,EAAMqE,KACZC,mBAAoBtE,EAAMsE,mBAC1BC,UAAWvE,EAAMuE,UACjBC,gBAAiBxE,EAAMwE,gBACvBC,eAAgBzE,EAAMyE,eACtBC,kBAAmB1E,EAAM0E,kBACzBC,qBAAsB3E,EAAM2E,qBAC5BC,sBAAuB5E,EAAM4E,sBAC7BC,WAAY7E,EAAM6E,WAClBC,eAAgB9E,EAAM8E,eACtBC,WAAY/E,EAAM+E,WAClBC,QAAShF,EAAMgF,QACfC,gBAAiBjF,EAAMiF,gBACvBC,cAAelF,EAAMkF,cACrBnB,QAAS/D,EAAM+D,QACfoB,aAAcnF,EAAMmF,aACpBC,QAASpF,EAAMoF,QACfC,OAAQrF,EAAMqF,OACdrC,SAAUhD,EAAMgD,SAChBsC,aAActF,EAAMsF,aACpBC,OAAQvF,EAAMuF,OACdC,sBAAuBxF,EAAMwF,sBAC7BC,UAAWzF,EAAMyF,UACjBC,iBAAkB1F,EAAM0F,iBACxBC,aAAc3F,EAAM2F"}
1
+ {"version":3,"file":"CustomCardInput.js","sources":["../../../../../src/components/CustomCard/CustomCardInput/CustomCardInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useRef, useMemo } from 'preact/hooks';\nimport Language from '../../../language/Language';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { SFPState } from '../../internal/SecuredFields/SFP/types';\nimport { BinLookupResponse, CardBrandsConfiguration, CardPlaceholders } from '../../Card/types';\nimport SFExtensions from '../../internal/SecuredFields/binLookup/extensions';\nimport { StylesObject } from '../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../core/Context/Resources';\nimport { SFError } from '../../Card/components/CardInput/types';\nimport { ValidationError } from '../types';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\n\ninterface SecuredFieldsProps {\n autoFocus?: boolean;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n clientKey: string;\n countryCode?: string;\n forceCompat?: boolean;\n i18n: Language;\n implementationType?: 'components' | 'custom';\n keypadFix?: boolean;\n loadingContext?: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n onAdditionalSFConfig?: () => {};\n onAdditionalSFRemoved?: () => {};\n onAllValid?: () => {};\n onAutoComplete?: () => {};\n onBinValue?: () => {};\n onBrand?: () => {};\n onConfigSuccess?: () => {};\n onChange: (data) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onError?: () => {};\n onFieldValid?: () => {};\n onFocus?: (e) => {};\n onLoad?: () => {};\n placeholders?: CardPlaceholders;\n rootNode: HTMLElement;\n resources: Resources;\n showWarnings?: boolean;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type: string;\n maskSecurityCode?: boolean;\n}\n\nconst defaultProps = {\n onChange: () => {},\n onError: () => {},\n onValidationError: () => {}\n};\n\nfunction CustomCardInput(props: Readonly<SecuredFieldsProps>) {\n const sfp = useRef(null);\n\n const [errors, setErrors] = useState({});\n const [valid, setValid] = useState({});\n const [data, setData] = useState({});\n\n const [isSfpValid, setIsSfpValid] = useState(false);\n\n const [issuingCountryCode, setIssuingCountryCode] = useState(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState('');\n\n const handleSecuredFieldsChange = (sfState: SFPState): void => {\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n SFExtensions(\n props,\n { sfp },\n { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode }\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPECTED METHODS ON SecuredFields.this\n */\n this.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n this.dualBrandingChangeHandler = extensions.handleDualBrandSelection;\n\n /**\n * EFFECT HOOKS\n */\n useEffect(() => {\n // componentDidMount\n this.setFocusOn = sfp.current.setFocusOn;\n this.updateStyles = sfp.current.updateStyles;\n this.showValidation = sfp.current.showValidation;\n this.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n // componentWillUnmount\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n /**\n * Main 'componentDidUpdate' handler\n */\n useEffect(() => {\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n\n const mappedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors\n\n props.onChange({\n data,\n valid,\n errors: mappedErrors,\n isValid: isSfpValid,\n selectedBrandValue\n });\n\n // Create an array of Validation error objects and send to callback\n if (Object.keys(mappedErrors).length) {\n const validationErrors: ValidationError[] = Object.entries(mappedErrors).map(([fieldType, error]) => {\n const valErr: ValidationError = {\n fieldType,\n ...(error ? (error as SFError) : { error: '', rootNode: this.props.rootNode })\n };\n return valErr;\n });\n this.props.onValidationError?.(validationErrors);\n }\n }, [data, valid, errors, selectedBrandValue]);\n\n /**\n * RENDER\n */\n // prettier-ignore\n return (\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n type={props.brand}\n componentType={props.type}\n onChange={handleSecuredFieldsChange}\n onSubmitAnalytics={props.onSubmitAnalytics}\n exposeExpiryDate={false}\n disableIOSArrowKeys={null}\n render={() => null}\n />\n );\n}\n\nCustomCardInput.defaultProps = defaultProps;\n\nexport default CustomCardInput;\n\nconst extractPropsForSFP = (props: SecuredFieldsProps) => {\n return {\n autoFocus: props.autoFocus,\n brands: props.brands,\n brandsConfiguration: props.brandsConfiguration,\n clientKey: props.clientKey,\n forceCompat: props.forceCompat,\n i18n: props.i18n,\n implementationType: props.implementationType,\n keypadFix: props.keypadFix,\n legacyInputMode: props.legacyInputMode,\n loadingContext: props.loadingContext,\n minimumExpiryDate: props.minimumExpiryDate,\n onAdditionalSFConfig: props.onAdditionalSFConfig,\n onAdditionalSFRemoved: props.onAdditionalSFRemoved,\n onAllValid: props.onAllValid,\n onAutoComplete: props.onAutoComplete,\n onBinValue: props.onBinValue,\n onBrand: props.onBrand,\n onConfigSuccess: props.onConfigSuccess,\n handleKeyDown: props.handleKeyDown,\n onError: props.onError,\n onFieldValid: props.onFieldValid,\n onFocus: props.onFocus,\n onLoad: props.onLoad,\n rootNode: props.rootNode,\n showWarnings: props.showWarnings,\n styles: props.styles,\n trimTrailingSeparator: props.trimTrailingSeparator,\n resources: props.resources,\n maskSecurityCode: props.maskSecurityCode,\n placeholders: props.placeholders\n };\n};\n"],"names":["CustomCardInput","props","sfp","useRef","errors","setErrors","useState","valid","setValid","data","setData","isSfpValid","setIsSfpValid","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","extensions","useMemo","SFExtensions","this","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","dualBrandingChangeHandler","handleDualBrandSelection","useEffect","setFocusOn","current","updateStyles","showValidation","handleUnsupportedCard","destroy","sfStateErrorsObj","mapErrorsToValidationRuleResult","mappedErrors","onChange","isValid","Object","keys","length","validationErrors","entries","map","fieldType","error","rootNode","onValidationError","h","SecuredFieldsProvider","ref","extractPropsForSFP","type","brand","componentType","sfState","onSubmitAnalytics","exposeExpiryDate","disableIOSArrowKeys","render","defaultProps","onError","autoFocus","brands","brandsConfiguration","clientKey","forceCompat","i18n","implementationType","keypadFix","legacyInputMode","loadingContext","minimumExpiryDate","onAdditionalSFConfig","onAdditionalSFRemoved","onAllValid","onAutoComplete","onBinValue","onBrand","onConfigSuccess","handleKeyDown","onFieldValid","onFocus","onLoad","showWarnings","styles","trimTrailingSeparator","resources","maskSecurityCode","placeholders"],"mappings":"qUAyDA,SAASA,EAAgBC,GACrB,MAAMC,EAAMC,EAAO,OAEZC,EAAQC,GAAaC,EAAS,CAAA,IAC9BC,EAAOC,GAAYF,EAAS,CAAA,IAC5BG,EAAMC,GAAWJ,EAAS,CAAA,IAE1BK,EAAYC,GAAiBN,GAAS,IAEtCO,EAAoBC,GAAyBR,EAAS,OAEtDS,EAAyBC,GAA8BV,EAAS,KAChEW,EAAoBC,GAAyBZ,EAAS,IAWvDa,EAAaC,EACf,IACIC,EACIpB,EACA,CAAEC,OACF,CAAEa,0BAAyBC,6BAA4BE,wBAAuBL,qBAAoBC,0BAE1G,CAACC,EAAyBF,IA6D9B,OAvDAS,KAAKC,yBAA2B,CAACC,EAAsCC,KACnEN,EAAWO,iBAAiBF,EAAmBC,IAGnDH,KAAKK,0BAA4BR,EAAWS,yBAK5CC,EAAU,KAENP,KAAKQ,WAAa5B,EAAI6B,QAAQD,WAC9BR,KAAKU,aAAe9B,EAAI6B,QAAQC,aAChCV,KAAKW,eAAiB/B,EAAI6B,QAAQE,eAClCX,KAAKY,sBAAwBhC,EAAI6B,QAAQG,sBAGlC,KACHhC,EAAI6B,QAAQI,YAEjB,IAKHN,EAAU,KACN,MAAMO,EAAmBlC,EAAI6B,QAAQM,kCAE/BC,EAAe,IAAKlC,KAAWgC,GAWrC,GATAnC,EAAMsC,SAAS,CACX9B,OACAF,QACAH,OAAQkC,EACRE,QAAS7B,EACTM,uBAIAwB,OAAOC,KAAKJ,GAAcK,OAAQ,CAClC,MAAMC,EAAsCH,OAAOI,QAAQP,GAAcQ,IAAI,EAAEC,EAAWC,MACtD,CAC5BD,eACIC,GAA6B,CAAE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F,EAAMwF,sBAC7BC,UAAWzF,EAAMyF,UACjBC,iBAAkB1F,EAAM0F,iBACxBC,aAAc3F,EAAM2F"}
@@ -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 n from"./components/DonationComponent.js";import{TxVariants as o}from"../tx-variants.js";import{AnalyticsLogEvent as s,LogEventSubtype as i,LogEventType as a}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsInfoEvent as r,UiTarget as c,InfoEventType as d}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import l,{REPARENT_WITHOUT_AUTO_START_ERROR_MSG as m}from"./DonationCampaignService.js";function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}class h extends e{static isServiceMode(t){return"rootNode"in t&&!!t.rootNode}async initialiseServiceMode(t,e){if(t.session)if(t.session.sessionsDonationInitiated)console.error(m);else{t.session.sessionsDonationInitiated=!0;try{const n=await new l(t,e).initialise();n&&(this.props={...this.props,...n},this.mount(e.rootNode))}catch(e){t.options.donation?.onDonationFailure?.(e)}}}get data(){return this.state.data}get isValid(){return this.state.isValid}setState(t){this.state={...this.state,...t}}donate(){const t=new s({component:h.type,type:a.submit,subType:i.donation,message:"Making donation"});this.core.modules.analytics.sendAnalytics(t);const{data:e,isValid:n}=this;this.props.onDonate({data:e,isValid:n},this)}cancel(){const t=new s({component:h.type,type:a.closed,subType:i.donation,message:"Opting to not make donation"});this.core.modules.analytics.sendAnalytics(t);const{data:e,isValid:n}=this;this.isInServiceMode&&this.unmount(),this.props.onCancel({data:e,isValid:n})}amountSelected(t){const e=new r({component:h.type,type:d.selected,selectedValue:JSON.stringify(t.data.amount),target:c.donationAmountButton});this.core.modules.analytics.sendAnalytics(e)}componentToRender(){return t(n,{...this.props,setComponentRef:this.setComponentRef,onChange:this.setState,onDonate:this.donate,onCancel:this.cancel,onAmountSelected:this.amountSelected})}constructor(t,e){const n=h.isServiceMode(e);super(t,n?void 0:e),p(this,"isInServiceMode",!1),this.donate=this.donate.bind(this),this.cancel=this.cancel.bind(this),this.amountSelected=this.amountSelected.bind(this),this.isInServiceMode=n,t.session&&n&&this.initialiseServiceMode(t,e)}}p(h,"type",o.donation),p(h,"defaultProps",{onCancel:()=>{},onDonate:()=>{}});export{h as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/DonationComponent.js";import{TxVariants as o}from"../tx-variants.js";import{AnalyticsLogEvent as s,LogEventSubtype as i,LogEventType as a}from"../../core/Analytics/events/AnalyticsLogEvent.js";import{AnalyticsInfoEvent as r,UiTarget as c,InfoEventType as d}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import l,{REPARENT_WITHOUT_AUTO_START_ERROR_MSG as m}from"./DonationCampaignService.js";function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}class h extends e{static isServiceMode(t){return"rootNode"in t&&!!t.rootNode}async initialiseServiceMode(t,e){if(t.session)if(t.session.sessionsDonationInitiated)console.error(m);else{t.session.sessionsDonationInitiated=!0;try{const n=await new l(t,e).initialise();n&&(this.props={...this.props,...n},this.mount(e.rootNode))}catch(e){t.options.donation?.onDonationFailure?.(e)}}}get data(){return this.state.data}get isValid(){return this.state.isValid}setState(t){this.state={...this.state,...t}}donate(){const t=new s({component:h.type,type:a.submit,subType:i.donation,message:"Making donation"});this.core.modules.analytics.sendAnalytics(t);const{data:e,isValid:n}=this;this.props.onDonate({data:e,isValid:n},this)}cancel(){const t=new s({component:h.type,type:a.closed,subType:i.donation,message:"Opting to not make donation"});this.core.modules.analytics.sendAnalytics(t);const{data:e,isValid:n}=this;this.isInServiceMode&&this.unmount(),this.props.onCancel({data:e,isValid:n})}amountSelected(t){const e=new r({component:h.type,type:d.selected,selectedValue:JSON.stringify(t.data.amount),target:c.donationAmountButton});this.core.modules.analytics.sendAnalytics(e)}componentToRender(){return t(n,{...this.props,ref:t=>{this.componentRef=t},onChange:this.setState,onDonate:this.donate,onCancel:this.cancel,onAmountSelected:this.amountSelected})}constructor(t,e){const n=h.isServiceMode(e);super(t,n?void 0:e),p(this,"isInServiceMode",!1),this.donate=this.donate.bind(this),this.cancel=this.cancel.bind(this),this.amountSelected=this.amountSelected.bind(this),this.isInServiceMode=n,t.session&&n&&this.initialiseServiceMode(t,e)}}p(h,"type",o.donation),p(h,"defaultProps",{onCancel:()=>{},onDonate:()=>{}});export{h as default};
2
2
  //# sourceMappingURL=Donation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Donation.js","sources":["../../../../src/components/Donation/Donation.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport DonationComponent from './components/DonationComponent';\nimport { TxVariants } from '../tx-variants';\nimport type { ICore } from '../../core/types';\nimport { DonationCampaignOptions, DonationConfiguration, DonationProps } from './types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { DonationPayload } from './components/types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport DonationCampaignService, { REPARENT_WITHOUT_AUTO_START_ERROR_MSG } from './DonationCampaignService';\n\nclass DonationElement extends UIElement<DonationConfiguration> {\n public static readonly type = TxVariants.donation;\n\n private readonly isInServiceMode: boolean = false;\n\n constructor(checkout: ICore, props: DonationProps) {\n const isServiceMode = DonationElement.isServiceMode(props);\n const initialConfig = isServiceMode ? undefined : props;\n\n super(checkout, initialConfig);\n\n this.donate = this.donate.bind(this);\n this.cancel = this.cancel.bind(this);\n this.amountSelected = this.amountSelected.bind(this);\n\n this.isInServiceMode = isServiceMode;\n\n if (checkout.session && isServiceMode) {\n void this.initialiseServiceMode(checkout, props); // NOSONAR - async in constructor is intentional for fire-and-forget service mode initialization\n }\n }\n\n /**\n * Type guard to determine if props are for \"service\" mode.\n *\n * The \"service\" mode is used in the /sessions flow:\n * - if the /payments response mandates it, we consult the /sessions/donationCampaigns endpoint on behalf of the merchant, and mount any found Donation Campaigns.\n *\n * The opposite of this mode is the \"direct\" mode, used in the Advanced flow:\n * - the merchant makes their own call to the /donationCampaigns endpoint and provides the Donation Campaign directly to the component.\n */\n private static isServiceMode(props: DonationProps): props is DonationCampaignOptions {\n return 'rootNode' in props && !!props.rootNode;\n }\n\n public static readonly defaultProps = {\n onCancel: () => {},\n onDonate: () => {}\n };\n\n private async initialiseServiceMode(checkout: ICore, props: DonationCampaignOptions) {\n if (!checkout.session) {\n return;\n }\n\n if (checkout.session.sessionsDonationInitiated) {\n console.error(REPARENT_WITHOUT_AUTO_START_ERROR_MSG);\n return;\n }\n\n checkout.session.sessionsDonationInitiated = true;\n try {\n const donationCampaign = await new DonationCampaignService(checkout, props).initialise();\n if (donationCampaign) {\n this.props = { ...this.props, ...donationCampaign };\n this.mount(props.rootNode);\n }\n // If no campaigns found (response is null), don't mount - silently do nothing\n } catch (error: unknown) {\n // Call merchant defined callback\n // e.g. when the merchant wants to reparent the component and donation type = roundup but no commercialTxAmount has been set\n checkout.options.donation?.onDonationFailure?.(error);\n }\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n */\n get data() {\n return this.state.data;\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n return this.state.isValid;\n }\n\n setState(newState) {\n this.state = { ...this.state, ...newState };\n }\n\n donate() {\n // Send analytics\n const event = new AnalyticsLogEvent({\n component: DonationElement.type,\n type: LogEventType.submit,\n subType: LogEventSubtype.donation,\n message: 'Making donation'\n });\n this.core.modules.analytics.sendAnalytics(event);\n\n // Call callback\n const { data, isValid } = this;\n this.props.onDonate({ data, isValid }, this);\n }\n\n cancel() {\n // Send analytics\n const event = new AnalyticsLogEvent({\n component: DonationElement.type,\n type: LogEventType.closed,\n subType: LogEventSubtype.donation,\n message: 'Opting to not make donation'\n });\n this.core.modules.analytics.sendAnalytics(event);\n\n // Call callback\n const { data, isValid } = this;\n\n // If running in service mode, unmount the component\n if (this.isInServiceMode) {\n this.unmount();\n }\n\n this.props.onCancel({ data, isValid });\n }\n\n amountSelected(state: DonationPayload) {\n // Send analytics\n const event = new AnalyticsInfoEvent({\n component: DonationElement.type,\n type: InfoEventType.selected,\n selectedValue: JSON.stringify(state.data.amount),\n target: UiTarget.donationAmountButton\n });\n this.core.modules.analytics.sendAnalytics(event);\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <DonationComponent\n {...this.props}\n setComponentRef={this.setComponentRef}\n onChange={this.setState}\n onDonate={this.donate}\n onCancel={this.cancel}\n onAmountSelected={this.amountSelected}\n />\n );\n }\n}\n\nexport default DonationElement;\n"],"names":["DonationElement","UIElement","isServiceMode","props","rootNode","initialiseServiceMode","checkout","session","sessionsDonationInitiated","console","error","REPARENT_WITHOUT_AUTO_START_ERROR_MSG","donationCampaign","DonationCampaignService","initialise","this","mount","options","donation","onDonationFailure","data","state","isValid","setState","newState","donate","event","AnalyticsLogEvent","component","type","LogEventType","submit","subType","LogEventSubtype","message","core","modules","analytics","sendAnalytics","onDonate","cancel","closed","isInServiceMode","unmount","onCancel","amountSelected","AnalyticsInfoEvent","InfoEventType","selected","selectedValue","JSON","stringify","amount","target","UiTarget","donationAmountButton","componentToRender","h","DonationComponent","setComponentRef","onChange","onAmountSelected","constructor","super","undefined","_define_property","bind","TxVariants","defaultProps"],"mappings":"wqBAWA,MAAMA,UAAwBC,EA+B1B,oBAAeC,CAAcC,GACzB,MAAO,aAAcA,KAAWA,EAAMC,QAC1C,CAOA,2BAAcC,CAAsBC,EAAiBH,GACjD,GAAKG,EAASC,QAId,GAAID,EAASC,QAAQC,0BACjBC,QAAQC,MAAMC,OADlB,CAKAL,EAASC,QAAQC,2BAA4B,EAC7C,IACI,MAAMI,QAAyB,IAAIC,EAAwBP,EAAUH,GAAOW,aACxEF,IACAG,KAAKZ,MAAQ,IAAKY,KAAKZ,SAA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mB,SAAU7B,KAAKyB,OACfqB,iBAAkB9C,KAAK8B,gBAGnC,CAxIA,WAAAiB,CAAYxD,EAAiBH,GACzB,MAAMD,EAAgBF,EAAgBE,cAAcC,GAGpD4D,MAAMzD,EAFgBJ,OAAgB8D,EAAY7D,GAJtD8D,EAAAlD,KAAiB2B,mBAA2B,GAQxC3B,KAAKU,OAASV,KAAKU,OAAOyC,KAAKnD,MAC/BA,KAAKyB,OAASzB,KAAKyB,OAAO0B,KAAKnD,MAC/BA,KAAK8B,eAAiB9B,KAAK8B,eAAeqB,KAAKnD,MAE/CA,KAAK2B,gBAAkBxC,EAEnBI,EAASC,SAAWL,GACfa,KAAKV,sBAAsBC,EAAUH,EAElD,EAnBA8D,EADEjE,EACqB6B,OAAOsC,EAAWjD,UAkCzC+C,EAnCEjE,EAmCqBoE,eAAe,CAClCxB,SAAU,OACVL,SAAU"}
1
+ {"version":3,"file":"Donation.js","sources":["../../../../src/components/Donation/Donation.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport DonationComponent from './components/DonationComponent';\nimport { TxVariants } from '../tx-variants';\nimport type { ICore } from '../../core/types';\nimport { DonationCampaignOptions, DonationConfiguration, DonationProps } from './types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../core/Analytics/events/AnalyticsLogEvent';\nimport { DonationPayload } from './components/types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport DonationCampaignService, { REPARENT_WITHOUT_AUTO_START_ERROR_MSG } from './DonationCampaignService';\n\nclass DonationElement extends UIElement<DonationConfiguration> {\n public static readonly type = TxVariants.donation;\n\n private readonly isInServiceMode: boolean = false;\n\n constructor(checkout: ICore, props: DonationProps) {\n const isServiceMode = DonationElement.isServiceMode(props);\n const initialConfig = isServiceMode ? undefined : props;\n\n super(checkout, initialConfig);\n\n this.donate = this.donate.bind(this);\n this.cancel = this.cancel.bind(this);\n this.amountSelected = this.amountSelected.bind(this);\n\n this.isInServiceMode = isServiceMode;\n\n if (checkout.session && isServiceMode) {\n void this.initialiseServiceMode(checkout, props); // NOSONAR - async in constructor is intentional for fire-and-forget service mode initialization\n }\n }\n\n /**\n * Type guard to determine if props are for \"service\" mode.\n *\n * The \"service\" mode is used in the /sessions flow:\n * - if the /payments response mandates it, we consult the /sessions/donationCampaigns endpoint on behalf of the merchant, and mount any found Donation Campaigns.\n *\n * The opposite of this mode is the \"direct\" mode, used in the Advanced flow:\n * - the merchant makes their own call to the /donationCampaigns endpoint and provides the Donation Campaign directly to the component.\n */\n private static isServiceMode(props: DonationProps): props is DonationCampaignOptions {\n return 'rootNode' in props && !!props.rootNode;\n }\n\n public static readonly defaultProps = {\n onCancel: () => {},\n onDonate: () => {}\n };\n\n private async initialiseServiceMode(checkout: ICore, props: DonationCampaignOptions) {\n if (!checkout.session) {\n return;\n }\n\n if (checkout.session.sessionsDonationInitiated) {\n console.error(REPARENT_WITHOUT_AUTO_START_ERROR_MSG);\n return;\n }\n\n checkout.session.sessionsDonationInitiated = true;\n try {\n const donationCampaign = await new DonationCampaignService(checkout, props).initialise();\n if (donationCampaign) {\n this.props = { ...this.props, ...donationCampaign };\n this.mount(props.rootNode);\n }\n // If no campaigns found (response is null), don't mount - silently do nothing\n } catch (error: unknown) {\n // Call merchant defined callback\n // e.g. when the merchant wants to reparent the component and donation type = roundup but no commercialTxAmount has been set\n checkout.options.donation?.onDonationFailure?.(error);\n }\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n */\n get data() {\n return this.state.data;\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n return this.state.isValid;\n }\n\n setState(newState) {\n this.state = { ...this.state, ...newState };\n }\n\n donate() {\n // Send analytics\n const event = new AnalyticsLogEvent({\n component: DonationElement.type,\n type: LogEventType.submit,\n subType: LogEventSubtype.donation,\n message: 'Making donation'\n });\n this.core.modules.analytics.sendAnalytics(event);\n\n // Call callback\n const { data, isValid } = this;\n this.props.onDonate({ data, isValid }, this);\n }\n\n cancel() {\n // Send analytics\n const event = new AnalyticsLogEvent({\n component: DonationElement.type,\n type: LogEventType.closed,\n subType: LogEventSubtype.donation,\n message: 'Opting to not make donation'\n });\n this.core.modules.analytics.sendAnalytics(event);\n\n // Call callback\n const { data, isValid } = this;\n\n // If running in service mode, unmount the component\n if (this.isInServiceMode) {\n this.unmount();\n }\n\n this.props.onCancel({ data, isValid });\n }\n\n amountSelected(state: DonationPayload) {\n // Send analytics\n const event = new AnalyticsInfoEvent({\n component: DonationElement.type,\n type: InfoEventType.selected,\n selectedValue: JSON.stringify(state.data.amount),\n target: UiTarget.donationAmountButton\n });\n this.core.modules.analytics.sendAnalytics(event);\n }\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <DonationComponent\n {...this.props}\n // @ts-ignore ref is internal from the Component\n ref={ref => {\n this.componentRef = ref;\n }}\n onChange={this.setState}\n onDonate={this.donate}\n onCancel={this.cancel}\n onAmountSelected={this.amountSelected}\n />\n );\n }\n}\n\nexport default DonationElement;\n"],"names":["DonationElement","UIElement","isServiceMode","props","rootNode","initialiseServiceMode","checkout","session","sessionsDonationInitiated","console","error","REPARENT_WITHOUT_AUTO_START_ERROR_MSG","donationCampaign","DonationCampaignService","initialise","this","mount","options","donation","onDonationFailure","data","state","isValid","setState","newState","donate","event","AnalyticsLogEvent","component","type","LogEventType","submit","subType","LogEventSubtype","message","core","modules","analytics","sendAnalytics","onDonate","cancel","closed","isInServiceMode","unmount","onCancel","amountSelected","AnalyticsInfoEvent","InfoEventType","selected","selectedValue","JSON","stringify","amount","target","UiTarget","donationAmountButton","componentToRender","h","DonationComponent","ref","componentRef","onChange","onAmountSelected","constructor","super","undefined","_define_property","bind","TxVariants","defaultProps"],"mappings":"wqBAWA,MAAMA,UAAwBC,EA+B1B,oBAAeC,CAAcC,GACzB,MAAO,aAAcA,KAAWA,EAAMC,QAC1C,CAOA,2BAAcC,CAAsBC,EAAiBH,GACjD,GAAKG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