@adyen/adyen-web 6.0.3 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +13 -4
  4. package/dist/es/components/Card/Card.js +1 -1
  5. package/dist/es/components/Card/Card.js.map +1 -1
  6. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  7. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  8. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  9. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  10. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  11. package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
  12. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
  13. package/dist/es/core/Analytics/utils.js +1 -1
  14. package/dist/es/core/Analytics/utils.js.map +1 -1
  15. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  16. package/dist/es/core/core.js +1 -1
  17. package/dist/es/index.d.ts +13 -4
  18. package/dist/es/utils/constants/currency-decimals.js +1 -1
  19. package/dist/es/utils/constants/currency-decimals.js.map +1 -1
  20. package/dist/es-legacy/components/Card/Card.js +1 -1
  21. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  22. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  23. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  24. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  25. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  26. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  27. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
  28. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
  29. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  30. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  31. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  32. package/dist/es-legacy/core/core.js +1 -1
  33. package/dist/es-legacy/utils/constants/currency-decimals.js +1 -1
  34. package/dist/es-legacy/utils/constants/currency-decimals.js.map +1 -1
  35. package/package.json +8 -8
@@ -767,6 +767,11 @@ interface CardConfiguration extends UIElementProps {
767
767
  * - merchant set config option
768
768
  */
769
769
  hasHolderName?: boolean;
770
+ /**
771
+ * holderName coming from a stored card in /paymentMethods response
772
+ * @internal
773
+ */
774
+ holderName?: string;
770
775
  /**
771
776
  * Show/hide the Security Code field
772
777
  * - merchant set config option
@@ -818,7 +823,7 @@ interface CardConfiguration extends UIElementProps {
818
823
  *
819
824
  * - merchant set config option
820
825
  */
821
- minimumExpiryDate?: string[];
826
+ minimumExpiryDate?: string;
822
827
  /**
823
828
  * When in Dropin this is the name shown in the paymentMethods list
824
829
  * @defaultValue - derived from PaymentMethods response
@@ -3278,6 +3283,7 @@ declare class BancontactElement extends CardElement {
3278
3283
  fundingSource?: "debit" | "credit";
3279
3284
  hasCVC?: boolean;
3280
3285
  hasHolderName?: boolean;
3286
+ holderName?: string;
3281
3287
  hideCVC?: boolean;
3282
3288
  holderNameRequired?: boolean;
3283
3289
  id?: string;
@@ -3286,7 +3292,7 @@ declare class BancontactElement extends CardElement {
3286
3292
  lastFour?: string;
3287
3293
  legacyInputMode?: boolean;
3288
3294
  maskSecurityCode?: boolean;
3289
- minimumExpiryDate?: string[];
3295
+ minimumExpiryDate?: string;
3290
3296
  name?: string;
3291
3297
  onAddressLookup?: OnAddressLookupType;
3292
3298
  onBinLookup?: (event: CbObjOnBinLookup) => void;
@@ -3551,6 +3557,7 @@ declare class CustomCard extends UIElement<CustomCardConfiguration> {
3551
3557
  onLoad?: (event: CbObjOnLoad) => void;
3552
3558
  placeholders?: Placeholders$1;
3553
3559
  onAddressLookup?: OnAddressLookupType;
3560
+ holderName?: string;
3554
3561
  expiryMonth?: string;
3555
3562
  billingAddressMode?: "full" | "partial" | "none";
3556
3563
  brands?: string[];
@@ -3563,7 +3570,7 @@ declare class CustomCard extends UIElement<CustomCardConfiguration> {
3563
3570
  lastFour?: string;
3564
3571
  legacyInputMode?: boolean;
3565
3572
  maskSecurityCode?: boolean;
3566
- minimumExpiryDate?: string[];
3573
+ minimumExpiryDate?: string;
3567
3574
  onBinLookup?: (event: CbObjOnBinLookup) => void;
3568
3575
  onBinValue?: (event: CbObjOnBinValue) => void;
3569
3576
  onBrand?: (event: CbObjOnBrand) => void;
@@ -5718,8 +5725,10 @@ interface OrderStatus {
5718
5725
  expiresAt: string;
5719
5726
  paymentMethods: {
5720
5727
  amount?: PaymentAmount;
5721
- lastFour: string;
5728
+ lastFour?: string;
5722
5729
  type: string;
5730
+ name?: string;
5731
+ label?: string;
5723
5732
  }[];
5724
5733
  pspReference: string;
5725
5734
  reference: string;
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import o from"./components/CardInput/CardInput.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import s from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import p from"../internal/ClickToPay/services/create-clicktopay-service.js";import c from"./components/ClickToPayWrapper.js";import l from"../../core/Errors/SRPanelProvider.js";import{TxVariants as d}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import{ANALYTICS_RENDERED_STR as m,ANALYTICS_CONFIGURED_STR as y,ANALYTICS_FOCUS_STR as f,ANALYTICS_UNFOCUS_STR as b,ANALYTICS_VALIDATION_ERROR_STR as g}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as C}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as P}from"../../utils/hasOwnProperty.js";import S,{IMPLEMENTATION_ERROR as k}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as T}from"../../core/Errors/utils.js";import{SF_ErrorCodes as R}from"../../core/Errors/constants.js";import B from"./components/CardInput/defaultProps.js";class I extends u{static type=d.scheme;clickToPayService;clickToPayRef=null;constructor(t,o){super(t,o),o&&!o._disableClickToPay&&(this.clickToPayService=p(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),this.clickToPayService?.initialize())}static defaultProps={showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...n(["type","setComponentRef"]).from(B)};setStatus(t,o){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,o),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,o),this}setClickToPayRef=t=>{this.clickToPayRef=t};formatProps(t){const o=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,e=!(0===t.amount?.value)&&o,s=t.storedPaymentMethodId||t.id,r=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!r)throw new S(k,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?B.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:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:o,showStoreDetailsCheckbox:e,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:I.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...a(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}onBrand=t=>{this.props.onBrand?.(t)};processBinLookupResponse(t,o=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,o),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}handleClickToPaySubmit=t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()};onBinLookup(t){if(!t.isReset){const o=n("supportedBrandsRaw").from(t);this.props.onBinLookup(o)}}submitAnalytics(t){const{type:o}=t;o!==m&&o!==y||"scheme"===this.constructor.type&&P(this.props,"supportedShopperInteractions")&&(t.isStoredPaymentMethod=!0,t.brand=this.props.brand),super.submitAnalytics(t,this.props)}onConfigSuccess=t=>{this.submitAnalytics({type:y}),this.props.onConfigSuccess?.(t)};onFocus=t=>{this.submitAnalytics({type:f,target:i(t.fieldType)}),C.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)};onBlur=t=>{this.submitAnalytics({type:b,target:i(t.fieldType)}),C.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)};onValidationErrorAnalytics=t=>{this.submitAnalytics({type:g,target:i(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:T(t.errorCode,R)})};onBinValue=r(this);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:o}=this.props;return t?t.map((t=>({icon:o[t]?.icon??this.props.modules.resources.getImage()(t),name:t}))):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||I.type}get accessibleName(){return(this.props.name||I.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return s()}payButton=o=>{const e=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...o,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:e&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})};renderCardInput(e=!0){return t(o,{setComponentRef:this.setComponentRef,...this.props,...this.state,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:e,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onValidationErrorAnalytics:this.onValidationErrorAnalytics,onConfigSuccess:this.onConfigSuccess})}render(){return t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(l,{srPanel:this.props.modules.srPanel},t(c,{amount:this.props.amount,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)))))}}export{I as CardElement,I as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import o from"./components/CardInput/CardInput.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import s from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import p from"../internal/ClickToPay/services/create-clicktopay-service.js";import c from"./components/ClickToPayWrapper.js";import l from"../../core/Errors/SRPanelProvider.js";import{TxVariants as d}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import{ANALYTICS_RENDERED_STR as m,ANALYTICS_CONFIGURED_STR as y,ANALYTICS_FOCUS_STR as f,ANALYTICS_UNFOCUS_STR as b,ANALYTICS_VALIDATION_ERROR_STR as g}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as C}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as P}from"../../utils/hasOwnProperty.js";import S,{IMPLEMENTATION_ERROR as k}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as T}from"../../core/Errors/utils.js";import{SF_ErrorCodes as R}from"../../core/Errors/constants.js";import B from"./components/CardInput/defaultProps.js";class I extends u{static type=d.scheme;clickToPayService;clickToPayRef=null;constructor(t,o){super(t,o),o&&!o._disableClickToPay&&(this.clickToPayService=p(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),this.clickToPayService?.initialize())}static defaultProps={showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...n(["type","setComponentRef"]).from(B)};setStatus(t,o){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,o),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,o),this}setClickToPayRef=t=>{this.clickToPayRef=t};formatProps(t){const o=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,e=!(0===t.amount?.value)&&o,s=t.storedPaymentMethodId||t.id,r=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!r)throw new S(k,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?B.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:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:o,showStoreDetailsCheckbox:e,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:I.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.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...a(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}onBrand=t=>{this.props.onBrand?.(t)};processBinLookupResponse(t,o=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,o),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}handleClickToPaySubmit=t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()};onBinLookup(t){if(!t.isReset){const o=n("supportedBrandsRaw").from(t);this.props.onBinLookup(o)}}submitAnalytics(t){const{type:o}=t;o!==m&&o!==y||"scheme"===this.constructor.type&&P(this.props,"supportedShopperInteractions")&&(t.isStoredPaymentMethod=!0,t.brand=this.props.brand),super.submitAnalytics(t,this.props)}onConfigSuccess=t=>{this.submitAnalytics({type:y}),this.props.onConfigSuccess?.(t)};onFocus=t=>{this.submitAnalytics({type:f,target:i(t.fieldType)}),C.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)};onBlur=t=>{this.submitAnalytics({type:b,target:i(t.fieldType)}),C.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)};onValidationErrorAnalytics=t=>{this.submitAnalytics({type:g,target:i(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:T(t.errorCode,R)})};onBinValue=r(this);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:o}=this.props;return t?t.map((t=>({icon:o[t]?.icon??this.props.modules.resources.getImage()(t),name:t}))):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||I.type}get accessibleName(){return(this.props.name||I.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return s()}payButton=o=>{const e=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...o,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:e&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})};renderCardInput(e=!0){return t(o,{setComponentRef:this.setComponentRef,...this.props,...this.state,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:e,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onValidationErrorAnalytics:this.onValidationErrorAnalytics,onConfigSuccess:this.onConfigSuccess})}render(){return t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(l,{srPanel:this.props.modules.srPanel},t(c,{amount:this.props.amount,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)))))}}export{I as CardElement,I 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 { CoreProvider } from '../../core/Context/CoreProvider';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CbObjOnBinLookup, CbObjOnConfigSuccess, CbObjOnFocus } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } 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 } from '../../types/global-types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport {\n ANALYTICS_FOCUS_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_RENDERED_STR\n} from '../../core/Analytics/constants';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../core/Analytics/types';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { getErrorMessageFromCode } from '../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../core/Errors/constants';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(this.props.configuration, this.props.clickToPayConfiguration, this.props.environment);\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static 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, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\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 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 of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\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 && { storedPaymentMethodId: this.props.storedPaymentMethodId }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\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(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, 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 handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CbObjOnBinLookup) {\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 protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n const { type } = analyticsObj;\n\n if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) {\n // Check if it's a storedCard\n if (this.constructor['type'] === 'scheme') {\n if (hasOwnProperty(this.props, 'supportedShopperInteractions')) {\n analyticsObj.isStoredPaymentMethod = true;\n analyticsObj.brand = this.props.brand;\n }\n }\n }\n\n super.submitAnalytics(analyticsObj, this.props);\n }\n\n private onConfigSuccess = (obj: CbObjOnConfigSuccess) => {\n this.submitAnalytics({\n type: ANALYTICS_CONFIGURED_STR\n });\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_FOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CbObjOnFocus);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_UNFOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CbObjOnFocus);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n private onValidationErrorAnalytics = (obj: FieldErrorAnalyticsObject) => {\n this.submitAnalytics({\n type: ANALYTICS_VALIDATION_ERROR_STR,\n target: fieldTypeToSnakeCase(obj.fieldType),\n validationErrorCode: obj.errorCode,\n validationErrorMessage: getErrorMessageFromCode(obj.errorCode, SF_ErrorCodes)\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.enableStoreDetails && typeof this.state.storePaymentMethod !== 'undefined';\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(): { icon: any; name: string }[] {\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: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\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 onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\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 onValidationErrorAnalytics={this.onValidationErrorAnalytics}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <ClickToPayWrapper\n amount={this.props.amount}\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 </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","static","TxVariants","scheme","clickToPayService","clickToPayRef","constructor","checkout","props","super","_disableClickToPay","this","createClickToPayService","configuration","clickToPayConfiguration","environment","initialize","showFormInstruction","doBinLookup","reject","from","CardInputDefaultProps","setStatus","status","componentRef","setClickToPayRef","ref","formatProps","enableStoreDetails","session","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","fundingSource","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","updateStyles","stylesObj","setFocusOn","fieldName","onBrand","event","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","handleClickToPaySubmit","payload","setState","valid","errors","isValid","submit","onBinLookup","obj","nuObj","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","hasOwnProperty","isStoredPaymentMethod","onConfigSuccess","onFocus","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","onBlur","ANALYTICS_UNFOCUS_STR","onValidationErrorAnalytics","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","onBinValue","triggerBinLookUp","length","storePaymentMethod","Boolean","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","payButton","isZeroAuth","isStoredCard","h","PayButton","secondaryAmount","label","onClick","renderCardInput","isCardPrimaryInput","CardInput","setComponentRef","onChange","onSubmit","handleKeyPress","brandsIcons","isPayButtonPrimaryVariant","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","isStandaloneComponent","onSetStatus","setElementStatus","onError","handleError"],"mappings":"m6CAmCO,MAAMA,UAAoBC,EAC7BC,YAAqBC,EAAWC,OAEfC,kBAKTC,cAAgB,KAExBC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAEZA,IAAUA,EAAME,qBAChBC,KAAKP,kBAAoBQ,EAAwBD,KAAKH,MAAMK,cAAeF,KAAKH,MAAMM,wBAAyBH,KAAKH,MAAMO,aACrHJ,KAAKP,mBAAmBY,aAErC,CAEAf,oBAAgC,CAC5BgB,qBAAqB,EACrBP,oBAAoB,EACpBQ,aAAa,KAEVC,EAAO,CAAC,OAAQ,oBAAoBC,KAAKC,IAGzCC,SAAAA,CAAUC,EAAyBf,GAOtC,OANIG,KAAKa,cAAcF,WACnBX,KAAKa,aAAaF,UAAUC,EAAQf,GAEpCG,KAAKN,eAAeiB,WACpBX,KAAKN,cAAciB,UAAUC,EAAQf,GAElCG,IACX,CAEQc,iBAAmBC,IACvBf,KAAKN,cAAgBqB,CAAAA,EAGzBC,WAAAA,CAAYnB,GAER,MAAMoB,EAAqBpB,EAAMqB,SAAShB,eAAee,oBAAsBpB,EAAMoB,mBAG/EE,IADqC,IAAxBtB,EAAMuB,QAAQC,QACqBJ,EAEhDK,EAAezB,EAAM0B,uBAAyB1B,EAAM2B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AYjH,KAAKiH,WACjBhF,MAAOjC,KAAKH,MAAMoC,MAClB+G,YAAahJ,KAAKwH,OAClByB,0BAA2BP,EAC3BpB,UAAWtH,KAAKsH,UAChBpB,QAASlG,KAAKkG,QACdM,OAAQxG,KAAKwG,OACbE,2BAA4B1G,KAAK0G,2BACjCT,gBAAiBjG,KAAKiG,iBAGlC,CAEAiD,MAAAA,GACI,OACId,EAACe,EAAAA,CAAahG,KAAMnD,KAAKH,MAAMsD,KAAMiG,eAAgBpJ,KAAKH,MAAMuJ,eAAgB9B,UAAWtH,KAAKsH,WAC5Fc,EAACiB,EAAAA,CAAgBC,QAAStJ,KAAKH,MAAM6H,QAAQ4B,SACzClB,EAACmB,EAAAA,CACGnI,OAAQpB,KAAKH,MAAMuB,OACnBlB,cAAeF,KAAKH,MAAMM,wBAC1BV,kBAAmBO,KAAKP,kBACxB+J,uBAAuB,EACvB1I,iBAAkBd,KAAKc,iBACvB2I,YAAazJ,KAAK0J,iBAClBZ,SAAU9I,KAAKiF,uBACf0E,QAAS3J,KAAK4J,cAEblB,GAAsB1I,KAAKyI,gBAAgBC,MAKhE"}
1
+ {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CbObjOnBinLookup, CbObjOnConfigSuccess, CbObjOnFocus } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } 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 } from '../../types/global-types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport {\n ANALYTICS_FOCUS_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_RENDERED_STR\n} from '../../core/Analytics/constants';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../core/Analytics/types';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { getErrorMessageFromCode } from '../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../core/Errors/constants';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(this.props.configuration, this.props.clickToPayConfiguration, this.props.environment);\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static 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, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\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 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 of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\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 },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\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(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, 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 handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CbObjOnBinLookup) {\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 protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n const { type } = analyticsObj;\n\n if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) {\n // Check if it's a storedCard\n if (this.constructor['type'] === 'scheme') {\n if (hasOwnProperty(this.props, 'supportedShopperInteractions')) {\n analyticsObj.isStoredPaymentMethod = true;\n analyticsObj.brand = this.props.brand;\n }\n }\n }\n\n super.submitAnalytics(analyticsObj, this.props);\n }\n\n private onConfigSuccess = (obj: CbObjOnConfigSuccess) => {\n this.submitAnalytics({\n type: ANALYTICS_CONFIGURED_STR\n });\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_FOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CbObjOnFocus);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_UNFOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CbObjOnFocus);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n private onValidationErrorAnalytics = (obj: FieldErrorAnalyticsObject) => {\n this.submitAnalytics({\n type: ANALYTICS_VALIDATION_ERROR_STR,\n target: fieldTypeToSnakeCase(obj.fieldType),\n validationErrorCode: obj.errorCode,\n validationErrorMessage: getErrorMessageFromCode(obj.errorCode, SF_ErrorCodes)\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.enableStoreDetails && typeof this.state.storePaymentMethod !== 'undefined';\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(): { icon: any; name: string }[] {\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: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\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 onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\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 onValidationErrorAnalytics={this.onValidationErrorAnalytics}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <ClickToPayWrapper\n amount={this.props.amount}\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 </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","static","TxVariants","scheme","clickToPayService","clickToPayRef","constructor","checkout","props","super","_disableClickToPay","this","createClickToPayService","configuration","clickToPayConfiguration","environment","initialize","showFormInstruction","doBinLookup","reject","from","CardInputDefaultProps","setStatus","status","componentRef","setClickToPayRef","ref","formatProps","enableStoreDetails","session","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","holderName","fundingSource","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","updateStyles","stylesObj","setFocusOn","fieldName","onBrand","event","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","handleClickToPaySubmit","payload","setState","valid","errors","isValid","submit","onBinLookup","obj","nuObj","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","hasOwnProperty","isStoredPaymentMethod","onConfigSuccess","onFocus","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","onBlur","ANALYTICS_UNFOCUS_STR","onValidationErrorAnalytics","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","onBinValue","triggerBinLookUp","length","storePaymentMethod","Boolean","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","payButton","isZeroAuth","isStoredCard","h","PayButton","secondaryAmount","label","onClick","renderCardInput","isCardPrimaryInput","CardInput","setComponentRef","onChange","onSubmit","handleKeyPress","brandsIcons","isPayButtonPrimaryVariant","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","isStandaloneComponent","onSetStatus","setElementStatus","onError","handleError"],"mappings":"m6CAmCO,MAAMA,UAAoBC,EAC7BC,YAAqBC,EAAWC,OAEfC,kBAKTC,cAAgB,KAExBC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAEZA,IAAUA,EAAME,qBAChBC,KAAKP,kBAAoBQ,EAAwBD,KAAKH,MAAMK,cAAeF,KAAKH,MAAMM,wBAAyBH,KAAKH,MAAMO,aACrHJ,KAAKP,mBAAmBY,aAErC,CAEAf,oBAAgC,CAC5BgB,qBAAqB,EACrBP,oBAAoB,EACpBQ,aAAa,KAEVC,EAAO,CAAC,OAAQ,oBAAoBC,KAAKC,IAGzCC,SAAAA,CAAUC,EAAyBf,GAOtC,OANIG,KAAKa,cAAcF,WACnBX,KAAKa,aAAaF,UAAUC,EAAQf,GAEpCG,KAAKN,eAAeiB,WACpBX,KAAKN,cAAciB,UAAUC,EAAQf,GAElCG,IACX,CAEQc,iBAAmBC,IACvBf,KAAKN,cAAgBqB,CAAAA,EAGzBC,WAAAA,CAAYnB,GAER,MAAMoB,EAAqBpB,EAAMqB,SAAShB,eAAee,oBAAsBpB,EAAMoB,mBAG/EE,IADqC,IAAxBtB,EAAMuB,QAAQC,QACqBJ,EAEhDK,EAAezB,EAAM0B,uBAAyB1B,EAAM2B,GACpDC,EAAwBH,GAAgBzB,GAAO6B,8BAA8BC,SAAS,aAG5F,GAAIL,IAAiBG,EAEjB,MAAM,IAAIG,EACNC,EACA,uGAIR,MAAO,IACAhC,EAEHiC,qBAAqBjC,EAAMkC,eAAwBlC,EAAMiC,mBAEzDE,SAAUnC,EAAOoC,OAAyB,SAAhBpC,EAAMoC,OAAqB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AK2G,2BACjCT,gBAAiBlG,KAAKkG,iBAGlC,CAEAiD,MAAAA,GACI,OACId,EAACe,EAAAA,CAAajG,KAAMnD,KAAKH,MAAMsD,KAAMkG,eAAgBrJ,KAAKH,MAAMwJ,eAAgB9B,UAAWvH,KAAKuH,WAC5Fc,EAACiB,EAAAA,CAAgBC,QAASvJ,KAAKH,MAAM8H,QAAQ4B,SACzClB,EAACmB,EAAAA,CACGpI,OAAQpB,KAAKH,MAAMuB,OACnBlB,cAAeF,KAAKH,MAAMM,wBAC1BV,kBAAmBO,KAAKP,kBACxBgK,uBAAuB,EACvB3I,iBAAkBd,KAAKc,iBACvB4I,YAAa1J,KAAK2J,iBAClBZ,SAAU/I,KAAKkF,uBACf0E,QAAS5J,KAAK6J,cAEblB,GAAsB3I,KAAK0I,gBAAgBC,MAKhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { BinLookupResponse, BrandConfiguration, CardBrandsConfiguration, CardBackendConfiguration, DualBrandSelectElement } from '../../types';\nimport { InstallmentOptions } from './components/types';\nimport { ValidationResult } from '../../../internal/PersonalDetails/types';\nimport { CVCPolicyType, DatePolicyType } from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CbObjOnError, 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, PaymentAmount } from '../../../../types/global-types';\nimport { AnalyticsModule } from '../../../../types/global-types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/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;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\ntype PlaceholderKeys =\n | 'holderName'\n | 'cardNumber'\n | 'expiryDate'\n | 'expiryMonth'\n | 'expiryYear'\n | 'securityCodeThreeDigits'\n | 'securityCodeFourDigits'\n | 'password';\nexport type Placeholders = Partial<Record<PlaceholderKeys, string>>;\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 amount?: PaymentAmount;\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 forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: string;\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: AnalyticsModule;\n risk: RiskElement;\n resources: Resources;\n };\n onAdditionalSFConfig?: () => {};\n onAdditionalSFRemoved?: () => {};\n onAllValid?: () => {};\n onAutoComplete?: () => {};\n onBinValue?: () => {};\n onBlur?: (e) => {};\n onBrand?: () => {};\n onConfigSuccess?: () => {};\n onChange?: (state) => {};\n onError?: () => {};\n onFieldValid?: () => {};\n onFocus?: (e) => {};\n onLoad?: () => {};\n handleKeyPress?: (obj: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n addressSearchDebounceMs?: number;\n payButton?: (obj) => {};\n placeholders?: Placeholders;\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 onValidationErrorAnalytics?: (obj: FieldErrorAnalyticsObject) => {};\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?: any;\n setFocusOn?: (who) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CbObjOnError) => 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"],"names":["AddressModeOptions"],"mappings":"OAkMYA,SAAAA,mDAAAA,CAAAA,IAAAA,EAAAA,CAAAA"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { BinLookupResponse, BrandConfiguration, CardBrandsConfiguration, CardBackendConfiguration, DualBrandSelectElement } from '../../types';\nimport { InstallmentOptions } from './components/types';\nimport { ValidationResult } from '../../../internal/PersonalDetails/types';\nimport { CVCPolicyType, DatePolicyType } from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CbObjOnError, 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, PaymentAmount } from '../../../../types/global-types';\nimport { AnalyticsModule } from '../../../../types/global-types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/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;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\ntype PlaceholderKeys =\n | 'holderName'\n | 'cardNumber'\n | 'expiryDate'\n | 'expiryMonth'\n | 'expiryYear'\n | 'securityCodeThreeDigits'\n | 'securityCodeFourDigits'\n | 'password';\nexport type Placeholders = Partial<Record<PlaceholderKeys, string>>;\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 amount?: PaymentAmount;\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 forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderName?: string;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: string;\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: AnalyticsModule;\n risk: RiskElement;\n resources: Resources;\n };\n onAdditionalSFConfig?: () => {};\n onAdditionalSFRemoved?: () => {};\n onAllValid?: () => {};\n onAutoComplete?: () => {};\n onBinValue?: () => {};\n onBlur?: (e) => {};\n onBrand?: () => {};\n onConfigSuccess?: () => {};\n onChange?: (state) => {};\n onError?: () => {};\n onFieldValid?: () => {};\n onFocus?: (e) => {};\n onLoad?: () => {};\n handleKeyPress?: (obj: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n addressSearchDebounceMs?: number;\n payButton?: (obj) => {};\n placeholders?: Placeholders;\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 onValidationErrorAnalytics?: (obj: FieldErrorAnalyticsObject) => {};\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?: any;\n setFocusOn?: (who) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CbObjOnError) => 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"],"names":["AddressModeOptions"],"mappings":"OAmMYA,SAAAA,mDAAAA,CAAAA,IAAAA,EAAAA,CAAAA"}
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import s from"./PaymentMethod/PaymentMethodList.js";import o from"./status/index.js";import n from"../../../core/Services/order-status.js";import{sanitizeOrder as a}from"../../internal/UIElement/utils.js";import{ANALYTICS_RENDERED_STR as r}from"../../../core/Analytics/constants.js";import i from"../../../core/Errors/AdyenCheckoutError.js";class d extends t{state={elements:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{}};componentDidMount(){this.prepareDropinData()}prepareDropinData=()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[o,a,i]=this.props.onCreateElements(),d=t?n({clientKey:e,loadingContext:s},t):null;Promise.all([o,a,i,d]).then((([t,e,s,o])=>{this.setState({instantPaymentElements:s,elements:e,storedPaymentElements:t,orderStatus:o}),this.setStatus("ready"),this.props.modules?.analytics.sendAnalytics("dropin",{type:r})})),this.onOrderCancel=this.getOnOrderCancel()};setStatus=(t,e={})=>{this.setState({status:{type:t,props:e}})};setActivePaymentMethod=t=>{this.setState((e=>({activePaymentMethod:t,cachedPaymentMethods:{...e.cachedPaymentMethods,[t._id]:!0}})))};componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}handleOnSelectPaymentMethod=t=>{const{activePaymentMethod:e}=this.state;this.setActivePaymentMethod(t),(e&&e._id!==t._id||!e)&&(this.props.onSelect?.(t),t.submitAnalytics({type:r}))};handleDisableStoredPaymentMethod=t=>{this.setState({isDisabling:!0}),new Promise(((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s))).then((()=>{this.setState((e=>({storedPaymentElements:e.storedPaymentElements.filter((e=>e._id!==t._id))}))),this.setState({isDisabling:!1})})).catch((()=>{this.setState({isDisabling:!1})}))};closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}getOnOrderCancel=()=>this.props.onOrderCancel?t=>{const e=a(t.order);new Promise(((t,s)=>{this.props.onOrderCancel({order:e},{resolve:t,reject:s})})).then((({amount:t})=>this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null,t))).catch((t=>{throw new i("NETWORK_ERROR",t)}))}:this.props.session?t=>this.props.session.cancelOrder(t).then((()=>this.props.core.update({order:null}))).catch((t=>{console.error(t),this.setStatus(t?.message||"error")})):null;onOrderCancel;render(t,{elements:n,instantPaymentElements:a,storedPaymentElements:r,status:i,activePaymentMethod:d,cachedPaymentMethods:h}){const p="loading"===i.type,m="redirect"===i.type,c=n?.length||a?.length||r?.length;switch(i.type){case"success":return e(o.Success,{message:0===t?.amount?.value?"resultMessages.preauthorized":i.props?.message});case"error":return e(o.Error,{message:i.props?.message});case"custom":return i.props?.component?.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${i.type}`},m&&i.props.component&&i.props.component.render(),p&&i.props&&i.props.component&&i.props.component.render(),!!c&&e(s,{isLoading:p||m,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:n,instantPaymentMethods:a,storedPaymentMethods:r,activePaymentMethod:d,cachedPaymentMethods:h,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openPaymentMethod:this.props.openPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}}export{d as DropinComponent,d as default};
1
+ import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import s from"./PaymentMethod/PaymentMethodList.js";import o from"./status/index.js";import n from"../../../core/Services/order-status.js";import{sanitizeOrder as a}from"../../internal/UIElement/utils.js";import{ANALYTICS_RENDERED_STR as r}from"../../../core/Analytics/constants.js";import i from"../../../core/Errors/AdyenCheckoutError.js";class d extends t{state={elements:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{}};componentDidMount(){this.prepareDropinData()}prepareDropinData=()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[o,a,i]=this.props.onCreateElements(),d=t?n({clientKey:e,loadingContext:s},t):null;Promise.all([o,a,i,d]).then((([t,e,s,o])=>{this.setState({instantPaymentElements:s,elements:e,storedPaymentElements:t,orderStatus:o}),this.setStatus("ready"),this.props.modules?.analytics.sendAnalytics("dropin",{type:r,configData:this.analyticConfigData})})),this.onOrderCancel=this.getOnOrderCancel()};get analyticConfigData(){return{openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,showStoredPaymentMethods:this.props.showStoredPaymentMethods}}setStatus=(t,e={})=>{this.setState({status:{type:t,props:e}})};setActivePaymentMethod=t=>{this.setState((e=>({activePaymentMethod:t,cachedPaymentMethods:{...e.cachedPaymentMethods,[t._id]:!0}})))};componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}handleOnSelectPaymentMethod=t=>{const{activePaymentMethod:e}=this.state;this.setActivePaymentMethod(t),(e&&e._id!==t._id||!e)&&(this.props.onSelect?.(t),t.submitAnalytics({type:r}))};handleDisableStoredPaymentMethod=t=>{this.setState({isDisabling:!0}),new Promise(((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s))).then((()=>{this.setState((e=>({storedPaymentElements:e.storedPaymentElements.filter((e=>e._id!==t._id))}))),this.setState({isDisabling:!1})})).catch((()=>{this.setState({isDisabling:!1})}))};closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}getOnOrderCancel=()=>this.props.onOrderCancel?t=>{const e=a(t.order);new Promise(((t,s)=>{this.props.onOrderCancel({order:e},{resolve:t,reject:s})})).then((({amount:t})=>this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null,t))).catch((t=>{throw new i("NETWORK_ERROR",t)}))}:this.props.session?t=>this.props.session.cancelOrder(t).then((()=>this.props.core.update({order:null}))).catch((t=>{console.error(t),this.setStatus(t?.message||"error")})):null;onOrderCancel;render(t,{elements:n,instantPaymentElements:a,storedPaymentElements:r,status:i,activePaymentMethod:d,cachedPaymentMethods:h}){const p="loading"===i.type,m="redirect"===i.type,c=n?.length||a?.length||r?.length;switch(i.type){case"success":return e(o.Success,{message:0===t?.amount?.value?"resultMessages.preauthorized":i.props?.message});case"error":return e(o.Error,{message:i.props?.message});case"custom":return i.props?.component?.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${i.type}`},m&&i.props.component&&i.props.component.render(),p&&i.props&&i.props.component&&i.props.component.render(),!!c&&e(s,{isLoading:p||m,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:n,instantPaymentMethods:a,storedPaymentMethods:r,activePaymentMethod:d,cachedPaymentMethods:h,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openPaymentMethod:this.props.openPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}}export{d as DropinComponent,d as default};
2
2
  //# sourceMappingURL=DropinComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DropinComponent.js","sources":["../../../../../src/components/Dropin/components/DropinComponent.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport PaymentMethodList from './PaymentMethod/PaymentMethodList';\nimport Status from './status';\nimport getOrderStatus from '../../../core/Services/order-status';\nimport { DropinComponentProps, DropinComponentState, DropinStatusProps, onOrderCancelData } from '../types';\nimport './DropinComponent.scss';\nimport { UIElementStatus } from '../../internal/UIElement/types';\nimport { sanitizeOrder } from '../../internal/UIElement/utils';\nimport { PaymentAmount } from '../../../types/global-types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nexport class DropinComponent extends Component<DropinComponentProps, DropinComponentState> {\n public state: DropinComponentState = {\n elements: [],\n instantPaymentElements: [],\n storedPaymentElements: [],\n orderStatus: null,\n isDisabling: false,\n status: { type: 'loading', props: undefined },\n activePaymentMethod: null,\n cachedPaymentMethods: {}\n };\n\n componentDidMount() {\n this.prepareDropinData();\n }\n\n public prepareDropinData = () => {\n const { order, clientKey, loadingContext } = this.props;\n const [storedElementsPromises, elementsPromises, instantPaymentsPromises] = this.props.onCreateElements();\n const orderStatusPromise = order ? getOrderStatus({ clientKey, loadingContext }, order) : null;\n\n void Promise.all([storedElementsPromises, elementsPromises, instantPaymentsPromises, orderStatusPromise]).then(\n ([storedPaymentElements, elements, instantPaymentElements, orderStatus]) => {\n this.setState({ instantPaymentElements, elements, storedPaymentElements, orderStatus });\n this.setStatus('ready');\n\n this.props.modules?.analytics.sendAnalytics('dropin', { type: ANALYTICS_RENDERED_STR });\n }\n );\n\n this.onOrderCancel = this.getOnOrderCancel();\n };\n\n public setStatus = (status: UIElementStatus, props: DropinStatusProps = {}) => {\n this.setState({ status: { type: status, props } });\n };\n\n private setActivePaymentMethod = paymentMethod => {\n this.setState(prevState => ({\n activePaymentMethod: paymentMethod,\n cachedPaymentMethods: { ...prevState.cachedPaymentMethods, [paymentMethod._id]: true }\n }));\n };\n\n componentDidUpdate(prevProps, prevState) {\n if (prevState.status.type !== this.state.status.type && this.state.activePaymentMethod) {\n this.state.activePaymentMethod.setStatus(this.state.status.type);\n }\n\n if (this.state.status.type === 'ready' && prevState.status.type !== 'ready' && this.props.onReady) {\n this.props.onReady();\n }\n }\n\n private handleOnSelectPaymentMethod = paymentMethod => {\n const { activePaymentMethod } = this.state;\n\n this.setActivePaymentMethod(paymentMethod);\n\n // onSelect event\n if ((activePaymentMethod && activePaymentMethod._id !== paymentMethod._id) || !activePaymentMethod) {\n this.props.onSelect?.(paymentMethod);\n\n paymentMethod.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n };\n\n private handleDisableStoredPaymentMethod = storedPaymentMethod => {\n this.setState({ isDisabling: true });\n\n new Promise((resolve, reject) => this.props.onDisableStoredPaymentMethod(storedPaymentMethod.props.storedPaymentMethodId, resolve, reject))\n .then(() => {\n this.setState(prevState => ({\n storedPaymentElements: prevState.storedPaymentElements.filter(pm => pm._id !== storedPaymentMethod._id)\n }));\n this.setState({ isDisabling: false });\n })\n .catch(() => {\n this.setState({ isDisabling: false });\n });\n };\n\n closeActivePaymentMethod() {\n this.setState({ activePaymentMethod: null });\n }\n\n /**\n * getOnOrderCancel decides which onOrderCancel logic should be used, manual or sessions\n */\n private getOnOrderCancel = () => {\n if (this.props.onOrderCancel) {\n return (data: onOrderCancelData) => {\n const order = sanitizeOrder(data.order);\n new Promise<{ amount: PaymentAmount }>((resolve, reject) => {\n this.props.onOrderCancel({ order }, { resolve, reject });\n })\n .then(({ amount }) => this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null, amount))\n .catch(error => {\n throw new AdyenCheckoutError('NETWORK_ERROR', error);\n });\n };\n }\n if (this.props.session) {\n return (data: onOrderCancelData) =>\n this.props.session\n .cancelOrder(data)\n .then(() => this.props.core.update({ order: null }))\n .catch(error => {\n console.error(error);\n this.setStatus(error?.message || 'error');\n });\n }\n return null;\n };\n\n private onOrderCancel: (data: onOrderCancelData) => void;\n\n render(props, { elements, instantPaymentElements, storedPaymentElements, status, activePaymentMethod, cachedPaymentMethods }) {\n const isLoading = status.type === 'loading';\n const isRedirecting = status.type === 'redirect';\n const hasPaymentMethodsToBeDisplayed = elements?.length || instantPaymentElements?.length || storedPaymentElements?.length;\n\n switch (status.type) {\n case 'success':\n return <Status.Success message={props?.amount?.value === 0 ? 'resultMessages.preauthorized' : status.props?.message} />;\n\n case 'error':\n return <Status.Error message={status.props?.message} />;\n\n case 'custom':\n return status.props?.component?.render();\n\n default:\n return (\n <div className={`adyen-checkout__dropin adyen-checkout__dropin--${status.type}`}>\n {isRedirecting && status.props.component && status.props.component.render()}\n {isLoading && status.props && status.props.component && status.props.component.render()}\n {!!hasPaymentMethodsToBeDisplayed && (\n <PaymentMethodList\n isLoading={isLoading || isRedirecting}\n isDisablingPaymentMethod={this.state.isDisabling}\n paymentMethods={elements}\n instantPaymentMethods={instantPaymentElements}\n storedPaymentMethods={storedPaymentElements}\n activePaymentMethod={activePaymentMethod}\n cachedPaymentMethods={cachedPaymentMethods}\n order={this.props.order}\n orderStatus={this.state.orderStatus}\n onOrderCancel={this.onOrderCancel}\n onSelect={this.handleOnSelectPaymentMethod}\n openPaymentMethod={this.props.openPaymentMethod}\n openFirstPaymentMethod={this.props.openFirstPaymentMethod}\n openFirstStoredPaymentMethod={this.props.openFirstStoredPaymentMethod}\n onDisableStoredPaymentMethod={this.handleDisableStoredPaymentMethod}\n showRemovePaymentMethodButton={this.props.showRemovePaymentMethodButton}\n showRadioButton={this.props.showRadioButton}\n />\n )}\n </div>\n );\n }\n }\n}\n\nexport default DropinComponent;\n"],"names":["DropinComponent","Component","state","elements","instantPaymentElements","storedPaymentElements","orderStatus","isDisabling","status","type","props","undefined","activePaymentMethod","cachedPaymentMethods","componentDidMount","this","prepareDropinData","order","clientKey","loadingContext","storedElementsPromises","elementsPromises","instantPaymentsPromises","onCreateElements","orderStatusPromise","getOrderStatus","Promise","all","then","setState","setStatus","modules","analytics","sendAnalytics","ANALYTICS_RENDERED_STR","onOrderCancel","getOnOrderCancel","setActivePaymentMethod","paymentMethod","prevState","_id","componentDidUpdate","prevProps","onReady","handleOnSelectPaymentMethod","onSelect","submitAnalytics","handleDisableStoredPaymentMethod","storedPaymentMethod","resolve","reject","onDisableStoredPaymentMethod","storedPaymentMethodId","filter","pm","catch","closeActivePaymentMethod","data","sanitizeOrder","amount","elementRef","handleAdvanceFlowPaymentMethodsUpdate","error","AdyenCheckoutError","session","cancelOrder","core","update","console","message","render","isLoading","isRedirecting","hasPaymentMethodsToBeDisplayed","length","h","Status","Success","value","Error","component","div","className","PaymentMethodList","isDisablingPaymentMethod","paymentMethods","instantPaymentMethods","storedPaymentMethods","openPaymentMethod","openFirstPaymentMethod","openFirstStoredPaymentMethod","showRemovePaymentMethodButton","showRadioButton"],"mappings":"4aAYO,MAAMA,UAAwBC,EAC1BC,MAA8B,CACjCC,SAAU,GACVC,uBAAwB,GACxBC,sBAAuB,GACvBC,YAAa,KACbC,aAAa,EACbC,OAAQ,CAAEC,KAAM,UAAWC,WAAOC,GAClCC,oBAAqB,KACrBC,qBAAsB,CAAC,GAG3BC,iBAAAA,GACIC,KAAKC,mBACT,CAEOA,kBAAoB,KACvB,MAAMC,MAAEA,EAAKC,UAAEA,EAASC,eAAEA,GAAmBJ,KAAKL,OAC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iD,QAAQmB,MAAc,+BAAiCtE,EAAOE,OAAO2D,UAEhH,IAAK,QACD,OAAOM,EAACC,EAAOG,MAAK,CAACV,QAAS7D,EAAOE,OAAO2D,UAEhD,IAAK,SACD,OAAO7D,EAAOE,OAAOsE,WAAWV,SAEpC,QACI,OACIK,EAACM,MAAAA,CAAIC,UAAW,kDAAkD1E,EAAOC,QACpE+D,GAAiBhE,EAAOE,MAAMsE,WAAaxE,EAAOE,MAAMsE,UAAUV,SAClEC,GAAa/D,EAAOE,OAASF,EAAOE,MAAMsE,WAAaxE,EAAOE,MAAMsE,UAAUV,WAC5EG,GACCE,EAACQ,EAAAA,CACGZ,UAAWA,GAAaC,EACxBY,yBAA0BrE,KAAKb,MAAMK,YACrC8E,eAAgBlF,EAChBmF,sBAAuBlF,EACvBmF,qBAAsBlF,EACtBO,oBAAqBA,EACrBC,qBAAsBA,EACtBI,MAAOF,KAAKL,MAAMO,MAClBX,YAAaS,KAAKb,MAAMI,YACxB6B,cAAepB,KAAKoB,cACpBU,SAAU9B,KAAK6B,4BACf4C,kBAAmBzE,KAAKL,MAAM8E,kBAC9BC,uBAAwB1E,KAAKL,MAAM+E,uBACnCC,6BAA8B3E,KAAKL,MAAMgF,6BACzCvC,6BAA8BpC,KAAKgC,iCACnC4C,8BAA+B5E,KAAKL,MAAMiF,8BAC1CC,gBAAiB7E,KAAKL,MAAMkF,mBAMxD"}
1
+ {"version":3,"file":"DropinComponent.js","sources":["../../../../../src/components/Dropin/components/DropinComponent.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport PaymentMethodList from './PaymentMethod/PaymentMethodList';\nimport Status from './status';\nimport getOrderStatus from '../../../core/Services/order-status';\nimport { DropinComponentProps, DropinComponentState, DropinStatusProps, onOrderCancelData } from '../types';\nimport './DropinComponent.scss';\nimport { UIElementStatus } from '../../internal/UIElement/types';\nimport { sanitizeOrder } from '../../internal/UIElement/utils';\nimport { PaymentAmount } from '../../../types/global-types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nexport class DropinComponent extends Component<DropinComponentProps, DropinComponentState> {\n public state: DropinComponentState = {\n elements: [],\n instantPaymentElements: [],\n storedPaymentElements: [],\n orderStatus: null,\n isDisabling: false,\n status: { type: 'loading', props: undefined },\n activePaymentMethod: null,\n cachedPaymentMethods: {}\n };\n\n componentDidMount() {\n this.prepareDropinData();\n }\n\n public prepareDropinData = () => {\n const { order, clientKey, loadingContext } = this.props;\n const [storedElementsPromises, elementsPromises, instantPaymentsPromises] = this.props.onCreateElements();\n const orderStatusPromise = order ? getOrderStatus({ clientKey, loadingContext }, order) : null;\n\n void Promise.all([storedElementsPromises, elementsPromises, instantPaymentsPromises, orderStatusPromise]).then(\n ([storedPaymentElements, elements, instantPaymentElements, orderStatus]) => {\n this.setState({ instantPaymentElements, elements, storedPaymentElements, orderStatus });\n this.setStatus('ready');\n\n this.props.modules?.analytics.sendAnalytics('dropin', {\n type: ANALYTICS_RENDERED_STR,\n configData: this.analyticConfigData\n });\n }\n );\n\n this.onOrderCancel = this.getOnOrderCancel();\n };\n\n get analyticConfigData() {\n return {\n openFirstStoredPaymentMethod: this.props.openFirstStoredPaymentMethod,\n showStoredPaymentMethods: this.props.showStoredPaymentMethods\n };\n }\n\n public setStatus = (status: UIElementStatus, props: DropinStatusProps = {}) => {\n this.setState({ status: { type: status, props } });\n };\n\n private setActivePaymentMethod = paymentMethod => {\n this.setState(prevState => ({\n activePaymentMethod: paymentMethod,\n cachedPaymentMethods: { ...prevState.cachedPaymentMethods, [paymentMethod._id]: true }\n }));\n };\n\n componentDidUpdate(prevProps, prevState) {\n if (prevState.status.type !== this.state.status.type && this.state.activePaymentMethod) {\n this.state.activePaymentMethod.setStatus(this.state.status.type);\n }\n\n if (this.state.status.type === 'ready' && prevState.status.type !== 'ready' && this.props.onReady) {\n this.props.onReady();\n }\n }\n\n private handleOnSelectPaymentMethod = paymentMethod => {\n const { activePaymentMethod } = this.state;\n\n this.setActivePaymentMethod(paymentMethod);\n\n // onSelect event\n if ((activePaymentMethod && activePaymentMethod._id !== paymentMethod._id) || !activePaymentMethod) {\n this.props.onSelect?.(paymentMethod);\n\n paymentMethod.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n };\n\n private handleDisableStoredPaymentMethod = storedPaymentMethod => {\n this.setState({ isDisabling: true });\n\n new Promise((resolve, reject) => this.props.onDisableStoredPaymentMethod(storedPaymentMethod.props.storedPaymentMethodId, resolve, reject))\n .then(() => {\n this.setState(prevState => ({\n storedPaymentElements: prevState.storedPaymentElements.filter(pm => pm._id !== storedPaymentMethod._id)\n }));\n this.setState({ isDisabling: false });\n })\n .catch(() => {\n this.setState({ isDisabling: false });\n });\n };\n\n closeActivePaymentMethod() {\n this.setState({ activePaymentMethod: null });\n }\n\n /**\n * getOnOrderCancel decides which onOrderCancel logic should be used, manual or sessions\n */\n private getOnOrderCancel = () => {\n if (this.props.onOrderCancel) {\n return (data: onOrderCancelData) => {\n const order = sanitizeOrder(data.order);\n new Promise<{ amount: PaymentAmount }>((resolve, reject) => {\n this.props.onOrderCancel({ order }, { resolve, reject });\n })\n .then(({ amount }) => this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null, amount))\n .catch(error => {\n throw new AdyenCheckoutError('NETWORK_ERROR', error);\n });\n };\n }\n if (this.props.session) {\n return (data: onOrderCancelData) =>\n this.props.session\n .cancelOrder(data)\n .then(() => this.props.core.update({ order: null }))\n .catch(error => {\n console.error(error);\n this.setStatus(error?.message || 'error');\n });\n }\n return null;\n };\n\n private onOrderCancel: (data: onOrderCancelData) => void;\n\n render(props, { elements, instantPaymentElements, storedPaymentElements, status, activePaymentMethod, cachedPaymentMethods }) {\n const isLoading = status.type === 'loading';\n const isRedirecting = status.type === 'redirect';\n const hasPaymentMethodsToBeDisplayed = elements?.length || instantPaymentElements?.length || storedPaymentElements?.length;\n\n switch (status.type) {\n case 'success':\n return <Status.Success message={props?.amount?.value === 0 ? 'resultMessages.preauthorized' : status.props?.message} />;\n\n case 'error':\n return <Status.Error message={status.props?.message} />;\n\n case 'custom':\n return status.props?.component?.render();\n\n default:\n return (\n <div className={`adyen-checkout__dropin adyen-checkout__dropin--${status.type}`}>\n {isRedirecting && status.props.component && status.props.component.render()}\n {isLoading && status.props && status.props.component && status.props.component.render()}\n {!!hasPaymentMethodsToBeDisplayed && (\n <PaymentMethodList\n isLoading={isLoading || isRedirecting}\n isDisablingPaymentMethod={this.state.isDisabling}\n paymentMethods={elements}\n instantPaymentMethods={instantPaymentElements}\n storedPaymentMethods={storedPaymentElements}\n activePaymentMethod={activePaymentMethod}\n cachedPaymentMethods={cachedPaymentMethods}\n order={this.props.order}\n orderStatus={this.state.orderStatus}\n onOrderCancel={this.onOrderCancel}\n onSelect={this.handleOnSelectPaymentMethod}\n openPaymentMethod={this.props.openPaymentMethod}\n openFirstPaymentMethod={this.props.openFirstPaymentMethod}\n openFirstStoredPaymentMethod={this.props.openFirstStoredPaymentMethod}\n onDisableStoredPaymentMethod={this.handleDisableStoredPaymentMethod}\n showRemovePaymentMethodButton={this.props.showRemovePaymentMethodButton}\n showRadioButton={this.props.showRadioButton}\n />\n )}\n </div>\n );\n }\n }\n}\n\nexport default DropinComponent;\n"],"names":["DropinComponent","Component","state","elements","instantPaymentElements","storedPaymentElements","orderStatus","isDisabling","status","type","props","undefined","activePaymentMethod","cachedPaymentMethods","componentDidMount","this","prepareDropinData","order","clientKey","loadingContext","storedElementsPromises","elementsPromises","instantPaymentsPromises","onCreateElements","orderStatusPromise","getOrderStatus","Promise","all","then","setState","setStatus","modules","analytics","sendAnalytics","ANALYTICS_RENDERED_STR","configData","analyticConfigData","onOrderCancel","getOnOrderCancel","openFirstStoredPaymentMethod","showStoredPaymentMethods","setActivePaymentMethod","paymentMethod","prevState","_id","componentDidUpdate","prevProps","onReady","handleOnSelectPaymentMethod","onSelect","submitAnalytics","handleDisableStoredPaymentMethod","storedPaymentMethod","resolve","reject","onDisableStoredPaymentMethod","storedPaymentMethodId","filter","pm","catch","closeActivePaymentMethod","data","sanitizeOrder","amount","elementRef","handleAdvanceFlowPaymentMethodsUpdate","error","AdyenCheckoutError","session","cancelOrder","core","update","console","message","render","isLoading","isRedirecting","hasPaymentMethodsToBeDisplayed","length","h","Status","Success","value","Error","component","div","className","PaymentMethodList","isDisablingPaymentMethod","paymentMethods","instantPaymentMethods","storedPaymentMethods","openPaymentMethod","openFirstPaymentMethod","showRemovePaymentMethodButton","showRadioButton"],"mappings":"4aAYO,MAAMA,UAAwBC,EAC1BC,MAA8B,CACjCC,SAAU,GACVC,uBAAwB,GACxBC,sBAAuB,GACvBC,YAAa,KACbC,aAAa,EACbC,OAAQ,CAAEC,KAAM,UAAWC,WAAOC,GAClCC,oBAAqB,KACrBC,qBAAsB,CAAC,GAG3BC,iBAAAA,GACIC,KAAKC,mBACT,CAEOA,kBAAoB,KACvB,MAAMC,MAAEA,EAAKC,UAAEA,EAASC,eAAEA,GAAmBJ,KAAKL,OAC3CU,EAAwBC,EAAkBC,GAA2BP,KAAKL,MAAMa,mBACjFC,EAAqBP,EAAQQ,EAAe,CAAEP,YAAWC,kBAAkBF,GAAS,KAErFS,QAAQC,IAAI,CAACP,EAAwBC,EAAkBC,EAAyBE,IAAqBI,MACtG,EAAEvB,EAAuBF,EAAUC,EAAwBE,MACvDS,KAAKc,SAAS,CAAEzB,yBAAwBD,WAAUE,wBAAuBC,gBACzES,KAAKe,UAAU,SAEff,KAAKL,MAAMqB,SAASC,UAAUC,cAAc,SAAU,CAClDxB,KAAMyB,EACNC,WAAYpB,KAAKqB,oBACrB,IAIRrB,KAAKsB,cAAgBtB,KAAKuB,kBAAgB,EAG9C,sBAAIF,GACA,MAAO,CACHG,6BAA8BxB,KAAKL,MAAM6B,6BACzCC,yBAA0BzB,KAAKL,MAAM8B,yBAE7C,CAEOV,UAAY,CAACtB,EAAyBE,EAA2B,MACpEK,KAAKc,SAAS,CAAErB,OAAQ,CAAEC,KA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AChBuF,sBAAuBtF,EACvBuF,qBAAsBtF,EACtBO,oBAAqBA,EACrBC,qBAAsBA,EACtBI,MAAOF,KAAKL,MAAMO,MAClBX,YAAaS,KAAKb,MAAMI,YACxB+B,cAAetB,KAAKsB,cACpBY,SAAUlC,KAAKiC,4BACf4C,kBAAmB7E,KAAKL,MAAMkF,kBAC9BC,uBAAwB9E,KAAKL,MAAMmF,uBACnCtD,6BAA8BxB,KAAKL,MAAM6B,6BACzCgB,6BAA8BxC,KAAKoC,iCACnC2C,8BAA+B/E,KAAKL,MAAMoF,8BAC1CC,gBAAiBhF,KAAKL,MAAMqF,mBAMxD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";import o from"../../../../core/Context/useImage.js";const n=({order:n,orderStatus:d,onOrderCancel:r,brandLogoConfiguration:m})=>{const{i18n:c}=a(),u=o();return e("div",null,e("ul",{className:"adyen-checkout__order-payment-methods-list"},d?.paymentMethods?.map(((a,o)=>e("li",{key:`${a.type}-${o}`,className:"adyen-checkout__order-payment-method"},e("div",{className:"adyen-checkout__order-payment-method__header"},e("div",{className:"adyen-checkout__payment-method__header__title"},e(t,{altDescription:a.name,type:a.type,src:m[a.type]||u()(a.type)}),"•••• ",a.lastFour),r&&e("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link",onClick:()=>{r({order:n})}},c.get("storedPaymentMethod.disable.button"))),e("div",{className:"adyen-checkout__order-payment-method__details"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount__label"},c.get("deductedBalance")),e("div",{className:"adyen-checkout__order-payment-method__deducted-amount__value"},c.amount(a.amount.value,a.amount.currency)))))))),d.remainingAmount&&e("div",{className:"adyen-checkout__order-remaining-amount"},c.get("partialPayment.warning")," ",e("strong",null,c.amount(d.remainingAmount.value,d.remainingAmount.currency))))};export{n as OrderPaymentMethods,n as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"./PaymentMethodIcon.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";import o from"../../../../core/Context/useImage.js";const n=({order:n,orderStatus:d,onOrderCancel:r,brandLogoConfiguration:m})=>{const{i18n:c}=a(),u=o();return e("div",null,e("ul",{className:"adyen-checkout__order-payment-methods-list"},d?.paymentMethods?.map(((a,o)=>e("li",{key:`${a.type}-${o}`,className:"adyen-checkout__order-payment-method"},e("div",{className:"adyen-checkout__order-payment-method__header"},e("div",{className:"adyen-checkout__payment-method__header__title"},e(t,{altDescription:a.name,type:a.type,src:m[a.type]||u()(a.type)}),a.label?`${a.label}`:`•••• ${a.lastFour}`),r&&e("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link",onClick:()=>{r({order:n})}},c.get("storedPaymentMethod.disable.button"))),e("div",{className:"adyen-checkout__order-payment-method__details"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount"},e("div",{className:"adyen-checkout__order-payment-method__deducted-amount__label"},c.get("deductedBalance")),e("div",{className:"adyen-checkout__order-payment-method__deducted-amount__value"},c.amount(a.amount.value,a.amount.currency)))))))),d.remainingAmount&&e("div",{className:"adyen-checkout__order-remaining-amount"},c.get("partialPayment.warning")," ",e("strong",null,c.amount(d.remainingAmount.value,d.remainingAmount.currency))))};export{n as OrderPaymentMethods,n as default};
2
2
  //# sourceMappingURL=OrderPaymentMethods.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div className=\"adyen-checkout__payment-method__header__title\">\n <PaymentMethodIcon\n altDescription={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n •••• {orderPaymentMethod.lastFour}\n </div>\n\n {onOrderCancel && (\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link\"\n onClick={() => {\n onOrderCancel({ order });\n }}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </button>\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</div>\n <div className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </div>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <div className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </div>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","PaymentMethodIcon","altDescription","name","src","lastFour","button","onClick","get","amount","value","currency","remainingAmount","strong"],"mappings":"+OAMO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BACrE,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,GAAaW,gBAAgBC,KAAI,CAACC,EAAoBC,IACnDP,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACW,EAAAA,CACGC,eAAgBN,EAAmBO,KACnCH,KAAMJ,EAAmBI,KACzBI,IAAKnB,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QACxF,QACIJ,EAAmBS,UAG5BrB,GACGM,EAACgB,SAAAA,CACGN,KAAK,SACLP,UAAU,qFACVc,QAAS,KACLvB,EAAc,CAAEF,SAAM,GAGzBI,EAAKsB,IAAI,wCAItBlB,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACC,MAAAA,CAAIE,UAAU,gEAAgEP,EAAKsB,IAAI,oBACxFlB,EAACC,MAAAA,CAAIE,UAAU,gEACVP,EAAKuB,OAAOb,EAAmBa,OAAOC,MAAOd,EAAmBa,OAAOE,iBAQ/F5B,EAAY6B,iBACTtB,EAACC,MAAAA,CAAIE,UAAU,0CACVP,EAAKsB,IAAI,0BAA2B,IACrClB,EAACuB,cAAQ3B,EAAKuB,OAAO1B,EAAY6B,gBAAgBF,MAAO3B,EAAY6B,gBAAgBD,YAAQ"}
1
+ {"version":3,"file":"OrderPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/OrderPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport PaymentMethodIcon from './PaymentMethodIcon';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport './OrderPaymentMethods.scss';\nimport { Order, OrderStatus } from '../../../../types';\n\ntype OrderPaymentMethodsProps = {\n order: Order;\n orderStatus: OrderStatus;\n onOrderCancel: (order) => void;\n brandLogoConfiguration: any;\n};\n\nexport const OrderPaymentMethods = ({ order, orderStatus, onOrderCancel, brandLogoConfiguration }: OrderPaymentMethodsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div>\n <ul className={'adyen-checkout__order-payment-methods-list'}>\n {orderStatus?.paymentMethods?.map((orderPaymentMethod, index) => (\n <li key={`${orderPaymentMethod.type}-${index}`} className=\"adyen-checkout__order-payment-method\">\n <div className=\"adyen-checkout__order-payment-method__header\">\n <div className=\"adyen-checkout__payment-method__header__title\">\n <PaymentMethodIcon\n altDescription={orderPaymentMethod.name}\n type={orderPaymentMethod.type}\n src={brandLogoConfiguration[orderPaymentMethod.type] || getImage()(orderPaymentMethod.type)}\n />\n {orderPaymentMethod.label ? `${orderPaymentMethod.label}` : `•••• ${orderPaymentMethod.lastFour}`}\n </div>\n\n {onOrderCancel && (\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link\"\n onClick={() => {\n onOrderCancel({ order });\n }}\n >\n {i18n.get('storedPaymentMethod.disable.button')}\n </button>\n )}\n </div>\n <div className=\"adyen-checkout__order-payment-method__details\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount\">\n <div className=\"adyen-checkout__order-payment-method__deducted-amount__label\">{i18n.get('deductedBalance')}</div>\n <div className=\"adyen-checkout__order-payment-method__deducted-amount__value\">\n {i18n.amount(orderPaymentMethod.amount.value, orderPaymentMethod.amount.currency)}\n </div>\n </div>\n </div>\n </li>\n ))}\n </ul>\n\n {orderStatus.remainingAmount && (\n <div className=\"adyen-checkout__order-remaining-amount\">\n {i18n.get('partialPayment.warning')}{' '}\n <strong>{i18n.amount(orderStatus.remainingAmount.value, orderStatus.remainingAmount.currency)}</strong>\n </div>\n )}\n </div>\n );\n};\n\nexport default OrderPaymentMethods;\n"],"names":["OrderPaymentMethods","order","orderStatus","onOrderCancel","brandLogoConfiguration","i18n","useCoreContext","getImage","useImage","h","div","ul","className","paymentMethods","map","orderPaymentMethod","index","li","key","type","PaymentMethodIcon","altDescription","name","src","label","lastFour","button","onClick","get","amount","value","currency","remainingAmount","strong"],"mappings":"+OAcO,MAAMA,EAAsB,EAAGC,QAAOC,cAAaC,gBAAeC,6BACrE,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,WACGD,EAACE,KAAAA,CAAGC,UAAW,8CACVV,GAAaW,gBAAgBC,KAAI,CAACC,EAAoBC,IACnDP,EAACQ,KAAAA,CAAGC,IAAK,GAAGH,EAAmBI,QAAQH,IAASJ,UAAU,wCACtDH,EAACC,MAAAA,CAAIE,UAAU,gDACXH,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACW,EAAAA,CACGC,eAAgBN,EAAmBO,KACnCH,KAAMJ,EAAmBI,KACzBI,IAAKnB,EAAuBW,EAAmBI,OAASZ,IAAWQ,EAAmBI,QAEzFJ,EAAmBS,MAAQ,GAAGT,EAAmBS,QAAU,QAAQT,EAAmBU,YAG1FtB,GACGM,EAACiB,SAAAA,CACGP,KAAK,SACLP,UAAU,qFACVe,QAAS,KACLxB,EAAc,CAAEF,SAAM,GAGzBI,EAAKuB,IAAI,wCAItBnB,EAACC,MAAAA,CAAIE,UAAU,iDACXH,EAACC,MAAAA,CAAIE,UAAU,yDACXH,EAACC,MAAAA,CAAIE,UAAU,gEAAgEP,EAAKuB,IAAI,oBACxFnB,EAACC,MAAAA,CAAIE,UAAU,gEACVP,EAAKwB,OAAOd,EAAmBc,OAAOC,MAAOf,EAAmBc,OAAOE,iBAQ/F7B,EAAY8B,iBACTvB,EAACC,MAAAA,CAAIE,UAAU,0CACVP,EAAKuB,IAAI,0BAA2B,IACrCnB,EAACwB,cAAQ5B,EAAKwB,OAAO3B,EAAY8B,gBAAgBF,MAAO5B,EAAY8B,gBAAgBD,YAAQ"}
@@ -1,2 +1,2 @@
1
- import{ANALYTICS_EVENT_ERROR as e,ANALYTICS_EVENT_LOG as t,ANALYTICS_ACTION_STR as a,ANALYTICS_SUBMIT_STR as s,ANALYTICS_VALIDATION_ERROR_STR as n,ANALYTICS_EVENT_INFO as o,ANALYTICS_SELECTED_STR as r,ANALYTICS_DOWNLOAD_STR as c,ANALYTICS_INPUT_STR as p,ANALYTICS_DISPLAYED_STR as i,ANALYTICS_UNFOCUS_STR as y,ANALYTICS_FOCUS_STR as d,ANALYTICS_CONFIGURED_STR as m,ANALYTICS_RENDERED_STR as l,ANALYTICS_EXPRESS_PAGES_ARRAY as v}from"./constants.js";import{THREEDS2_ERROR as b,THREEDS2_FULL as E}from"../../components/ThreeDS2/constants.js";import g,{SDK_ERROR as u}from"../Errors/AdyenCheckoutError.js";import{getCardConfigData as h}from"./utils.js";const k=k=>(A,f,M={})=>{const{type:P,target:S}=f;if(!P)throw new g(u,"You are trying to create an analytics event without a type");switch(P){case l:{const{isStoredPaymentMethod:e,brand:t}=f,{isExpress:a,expressPage:s}=M,n=s&&v.includes(s),{type:r}=M;let c=null;"scheme"!==r&&"bcmc"!==r&&"customcard"!==r||(c=h(M));const p={component:A,type:P,..."boolean"==typeof e&&{isStoredPaymentMethod:e},...t&&{brand:t},..."boolean"==typeof a&&{isExpress:a},...!0===a&&n&&{expressPage:s},...c&&{configData:c}};k.createAnalyticsEvent({event:o,data:p});break}case m:{const{isStoredPaymentMethod:e,brand:t}=f,a={component:A,type:P,isStoredPaymentMethod:e,brand:t};k.createAnalyticsEvent({event:o,data:a});break}case d:case y:case i:case p:case c:k.createAnalyticsEvent({event:o,data:{component:A,type:P,target:S}});break;case r:{const{issuer:e}=f;k.createAnalyticsEvent({event:o,data:{component:A,type:P,target:S,issuer:e}});break}case n:{const{validationErrorCode:e,validationErrorMessage:t}=f;k.createAnalyticsEvent({event:o,data:{component:A,type:P,target:S,validationErrorCode:e,validationErrorMessage:t}});break}case s:k.createAnalyticsEvent({event:t,data:{component:A,type:P,message:"Shopper clicked pay"}});break;case a:{const{subtype:e,message:a}=f;k.createAnalyticsEvent({event:t,data:{component:A,type:P,subtype:e,message:a}});break}case E:{const{message:e,metadata:a,subtype:s,result:n}=f;k.createAnalyticsEvent({event:t,data:{component:A,type:P,message:e,metadata:a,subtype:s,result:n}});break}case b:{const{message:t,code:a,errorType:s}=f;k.createAnalyticsEvent({event:e,data:{component:A,type:P,message:t,code:a,errorType:s}});break}default:k.createAnalyticsEvent(f)}};export{k as analyticsPreProcessor};
1
+ import{ANALYTICS_EVENT_ERROR as e,ANALYTICS_EVENT_LOG as t,ANALYTICS_ACTION_STR as a,ANALYTICS_SUBMIT_STR as s,ANALYTICS_VALIDATION_ERROR_STR as n,ANALYTICS_EVENT_INFO as o,ANALYTICS_SELECTED_STR as r,ANALYTICS_DOWNLOAD_STR as c,ANALYTICS_INPUT_STR as p,ANALYTICS_DISPLAYED_STR as i,ANALYTICS_UNFOCUS_STR as y,ANALYTICS_FOCUS_STR as d,ANALYTICS_CONFIGURED_STR as m,ANALYTICS_RENDERED_STR as l,ANALYTICS_EXPRESS_PAGES_ARRAY as v}from"./constants.js";import{THREEDS2_ERROR as b,THREEDS2_FULL as g}from"../../components/ThreeDS2/constants.js";import E,{SDK_ERROR as u}from"../Errors/AdyenCheckoutError.js";import{getCardConfigData as f}from"./utils.js";const h=h=>(k,A,M={})=>{const{type:P,target:S}=A;if(!P)throw new E(u,"You are trying to create an analytics event without a type");switch(P){case l:{const{isStoredPaymentMethod:e,brand:t,configData:a}=A,{isExpress:s,expressPage:n}=M,r=n&&v.includes(n),{type:c}=M;let p=null;"scheme"!==c&&"bcmc"!==c&&"customcard"!==c||(p=f(M));const i={component:k,type:P,..."boolean"==typeof e&&{isStoredPaymentMethod:e},...t&&{brand:t},..."boolean"==typeof s&&{isExpress:s},...!0===s&&r&&{expressPage:n},...p&&{configData:p},...a&&{configData:a}};h.createAnalyticsEvent({event:o,data:i});break}case m:{const{isStoredPaymentMethod:e,brand:t}=A,a={component:k,type:P,isStoredPaymentMethod:e,brand:t};h.createAnalyticsEvent({event:o,data:a});break}case d:case y:case i:case p:case c:h.createAnalyticsEvent({event:o,data:{component:k,type:P,target:S}});break;case r:{const{issuer:e}=A;h.createAnalyticsEvent({event:o,data:{component:k,type:P,target:S,issuer:e}});break}case n:{const{validationErrorCode:e,validationErrorMessage:t}=A;h.createAnalyticsEvent({event:o,data:{component:k,type:P,target:S,validationErrorCode:e,validationErrorMessage:t}});break}case s:h.createAnalyticsEvent({event:t,data:{component:k,type:P,message:"Shopper clicked pay"}});break;case a:{const{subtype:e,message:a}=A;h.createAnalyticsEvent({event:t,data:{component:k,type:P,subtype:e,message:a}});break}case g:{const{message:e,metadata:a,subtype:s,result:n}=A;h.createAnalyticsEvent({event:t,data:{component:k,type:P,message:e,metadata:a,subtype:s,result:n}});break}case b:{const{message:t,code:a,errorType:s}=A;h.createAnalyticsEvent({event:e,data:{component:k,type:P,message:t,code:a,errorType:s}});break}default:h.createAnalyticsEvent(A)}};export{h as analyticsPreProcessor};
2
2
  //# sourceMappingURL=analyticsPreProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyticsPreProcessor.js","sources":["../../../../src/core/Analytics/analyticsPreProcessor.ts"],"sourcesContent":["import { AnalyticsModule } from '../../types/global-types';\nimport { ConfigData, CreateAnalyticsEventObject, SendAnalyticsObject } from './types';\nimport {\n ANALYTICS_ACTION_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_DOWNLOAD_STR,\n ANALYTICS_EVENT_ERROR,\n ANALYTICS_EVENT_INFO,\n ANALYTICS_EVENT_LOG,\n ANALYTICS_FOCUS_STR,\n ANALYTICS_INPUT_STR,\n ANALYTICS_RENDERED_STR,\n ANALYTICS_SELECTED_STR,\n ANALYTICS_SUBMIT_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_EXPRESS_PAGES_ARRAY\n} from './constants';\nimport { THREEDS2_ERROR, THREEDS2_FULL } from '../../components/ThreeDS2/constants';\nimport AdyenCheckoutError, { SDK_ERROR } from '../Errors/AdyenCheckoutError';\nimport { getCardConfigData } from './utils';\n\nexport const analyticsPreProcessor = (analyticsModule: AnalyticsModule) => {\n // return function with an analyticsModule reference\n return (component: string, analyticsObj: SendAnalyticsObject, uiElementProps = {} as any) => {\n const { type, target } = analyticsObj;\n\n if (!type) {\n throw new AdyenCheckoutError(SDK_ERROR, 'You are trying to create an analytics event without a type');\n }\n\n switch (type) {\n /**\n * INFO\n */\n // Called from BaseElement (when component mounted) or, from DropinComponent (after mounting, when it has finished resolving all the PM promises)\n // &/or, from DropinComponent when a PM is selected\n case ANALYTICS_RENDERED_STR: {\n const { isStoredPaymentMethod, brand } = analyticsObj;\n\n // Expected from Wallet PMs\n const { isExpress, expressPage } = uiElementProps;\n\n const hasExpressPage = expressPage && ANALYTICS_EXPRESS_PAGES_ARRAY.includes(expressPage);\n\n const { type: componentType } = uiElementProps;\n let configData: ConfigData = null;\n\n if (componentType === 'scheme' || componentType === 'bcmc' || componentType === 'customcard') {\n // Expected from Card related PMs\n configData = getCardConfigData(uiElementProps);\n }\n\n const data = {\n component,\n type,\n ...(typeof isStoredPaymentMethod === 'boolean' && { isStoredPaymentMethod }), // if defined and a boolean...\n ...(brand && { brand }),\n ...(typeof isExpress === 'boolean' && { isExpress }),\n ...(isExpress === true && hasExpressPage && { expressPage }), // We only care about the expressPage value if isExpress is true\n ...(configData && { configData })\n };\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data\n });\n\n break;\n }\n\n case ANALYTICS_CONFIGURED_STR: {\n const { isStoredPaymentMethod, brand } = analyticsObj;\n const data = { component, type, isStoredPaymentMethod, brand };\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data\n });\n break;\n }\n\n case ANALYTICS_FOCUS_STR:\n case ANALYTICS_UNFOCUS_STR:\n case ANALYTICS_DISPLAYED_STR: // issuerList\n case ANALYTICS_INPUT_STR: // issuerList\n case ANALYTICS_DOWNLOAD_STR: // QR codes\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target }\n });\n break;\n\n // - ApplePay & GooglePay when instant PMs\n // - issuerList buttons\n case ANALYTICS_SELECTED_STR: {\n const { issuer } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target, issuer }\n });\n break;\n }\n\n case ANALYTICS_VALIDATION_ERROR_STR: {\n const { validationErrorCode, validationErrorMessage } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target, validationErrorCode, validationErrorMessage }\n });\n break;\n }\n\n /**\n * LOGS\n */\n case ANALYTICS_SUBMIT_STR:\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, message: 'Shopper clicked pay' }\n });\n break;\n\n case ANALYTICS_ACTION_STR: {\n const { subtype, message } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, subtype, message }\n });\n break;\n }\n\n // General 3DS2 log events: \"action handled\" (i.e. iframe loaded), data sent, process completed\n case THREEDS2_FULL: {\n const { message, metadata, subtype, result } = analyticsObj;\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, message, metadata, subtype, result }\n });\n break;\n }\n\n /**\n * ERRORS\n */\n case THREEDS2_ERROR: {\n const { message, code, errorType } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_ERROR,\n data: { component, type, message, code, errorType }\n });\n break;\n }\n\n default: {\n analyticsModule.createAnalyticsEvent(analyticsObj as CreateAnalyticsEventObject);\n }\n }\n };\n};\n"],"names":["analyticsPreProcessor","analyticsModule","component","analyticsObj","uiElementProps","type","target","AdyenCheckoutError","SDK_ERROR","ANALYTICS_RENDERED_STR","isStoredPaymentMethod","brand","isExpress","expressPage","hasExpressPage","ANALYTICS_EXPRESS_PAGES_ARRAY","includes","componentType","configData","getCardConfigData","data","createAnalyticsEvent","event","ANALYTICS_EVENT_INFO","ANALYTICS_CONFIGURED_STR","ANALYTICS_FOCUS_STR","ANALYTICS_UNFOCUS_STR","ANALYTICS_DISPLAYED_STR","ANALYTICS_INPUT_STR","ANALYTICS_DOWNLOAD_STR","ANALYTICS_SELECTED_STR","issuer","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","validationErrorMessage","ANALYTICS_SUBMIT_STR","ANALYTICS_EVENT_LOG","message","ANALYTICS_ACTION_STR","subtype","THREEDS2_FULL","metadata","result","THREEDS2_ERROR","code","errorType","ANALYTICS_EVENT_ERROR"],"mappings":"0oBAuBO,MAAMA,EAAyBC,GAE3B,CAACC,EAAmBC,EAAmCC,EAAiB,CAAA,KAC3E,MAAMC,KAAEA,EAAIC,OAAEA,GAAWH,EAEzB,IAAKE,EACD,MAAM,IAAIE,EAAmBC,EAAW,8DAG5C,OAAQH,GAMJ,KAAKI,EAAwB,CACzB,MAAMC,sBAAEA,EAAqBC,MAAEA,GAAUR,GAGnCS,UAAEA,EAASC,YAAEA,GAAgBT,EAE7BU,EAAiBD,GAAeE,EAA8BC,SAASH,IAErER,KAAMY,GAAkBb,EAChC,IAAIc,EAAyB,KAEP,WAAlBD,GAAgD,SAAlBA,GAA8C,eAAlBA,IAE1DC,EAAaC,EAAkBf,IAGnC,MAAMgB,EAAO,CACTlB,YACAG,UACqC,kBAA1BK,GAAuC,CAAEA,4BAChDC,GAAS,CAAEA,YACU,kBAAdC,GAA2B,CAAEA,iBACtB,IAAdA,GAAsBE,GAAkB,CAAED,kBAC1CK,GAAc,CAAEA,eAGxBjB,EAAgBoB,qBAAqB,CACjCC,MAAOC,EACPH,SAGJ,KACJ,CAEA,KAAKI,EAA0B,CAC3B,MAAMd,sBAAEA,EAAqBC,MAAEA,GAAUR,EACnCiB,EAAO,CAAElB,YAAWG,OAAMK,wBAAuBC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analyticsPreProcessor.js","sources":["../../../../src/core/Analytics/analyticsPreProcessor.ts"],"sourcesContent":["import { AnalyticsModule } from '../../types/global-types';\nimport { ConfigData, CreateAnalyticsEventObject, SendAnalyticsObject } from './types';\nimport {\n ANALYTICS_ACTION_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_DOWNLOAD_STR,\n ANALYTICS_EVENT_ERROR,\n ANALYTICS_EVENT_INFO,\n ANALYTICS_EVENT_LOG,\n ANALYTICS_FOCUS_STR,\n ANALYTICS_INPUT_STR,\n ANALYTICS_RENDERED_STR,\n ANALYTICS_SELECTED_STR,\n ANALYTICS_SUBMIT_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_EXPRESS_PAGES_ARRAY\n} from './constants';\nimport { THREEDS2_ERROR, THREEDS2_FULL } from '../../components/ThreeDS2/constants';\nimport AdyenCheckoutError, { SDK_ERROR } from '../Errors/AdyenCheckoutError';\nimport { getCardConfigData } from './utils';\n\nexport const analyticsPreProcessor = (analyticsModule: AnalyticsModule) => {\n // return function with an analyticsModule reference\n return (component: string, analyticsObj: SendAnalyticsObject, uiElementProps = {} as any) => {\n const { type, target } = analyticsObj;\n\n if (!type) {\n throw new AdyenCheckoutError(SDK_ERROR, 'You are trying to create an analytics event without a type');\n }\n\n switch (type) {\n /**\n * INFO\n */\n // Called from BaseElement (when component mounted) or, from DropinComponent (after mounting, when it has finished resolving all the PM promises)\n // &/or, from DropinComponent when a PM is selected\n // Only Drop-in sends the configData directly, if it happens the configData from the component(drop-in atm) will take over the internal configData below.\n case ANALYTICS_RENDERED_STR: {\n const { isStoredPaymentMethod, brand, configData: originalConfigData } = analyticsObj;\n\n // Expected from Wallet PMs\n const { isExpress, expressPage } = uiElementProps;\n\n const hasExpressPage = expressPage && ANALYTICS_EXPRESS_PAGES_ARRAY.includes(expressPage);\n\n const { type: componentType } = uiElementProps;\n let configData: ConfigData = null;\n\n if (componentType === 'scheme' || componentType === 'bcmc' || componentType === 'customcard') {\n // Expected from Card related PMs\n configData = getCardConfigData(uiElementProps);\n }\n\n const data = {\n component,\n type,\n ...(typeof isStoredPaymentMethod === 'boolean' && { isStoredPaymentMethod }), // if defined and a boolean...\n ...(brand && { brand }),\n ...(typeof isExpress === 'boolean' && { isExpress }),\n ...(isExpress === true && hasExpressPage && { expressPage }), // We only care about the expressPage value if isExpress is true\n ...(configData && { configData }),\n ...(originalConfigData && { configData: originalConfigData })\n };\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data\n });\n\n break;\n }\n\n case ANALYTICS_CONFIGURED_STR: {\n const { isStoredPaymentMethod, brand } = analyticsObj;\n const data = { component, type, isStoredPaymentMethod, brand };\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data\n });\n break;\n }\n\n case ANALYTICS_FOCUS_STR:\n case ANALYTICS_UNFOCUS_STR:\n case ANALYTICS_DISPLAYED_STR: // issuerList\n case ANALYTICS_INPUT_STR: // issuerList\n case ANALYTICS_DOWNLOAD_STR: // QR codes\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target }\n });\n break;\n\n // - ApplePay & GooglePay when instant PMs\n // - issuerList buttons\n case ANALYTICS_SELECTED_STR: {\n const { issuer } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target, issuer }\n });\n break;\n }\n\n case ANALYTICS_VALIDATION_ERROR_STR: {\n const { validationErrorCode, validationErrorMessage } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_INFO,\n data: { component, type, target, validationErrorCode, validationErrorMessage }\n });\n break;\n }\n\n /**\n * LOGS\n */\n case ANALYTICS_SUBMIT_STR:\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, message: 'Shopper clicked pay' }\n });\n break;\n\n case ANALYTICS_ACTION_STR: {\n const { subtype, message } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, subtype, message }\n });\n break;\n }\n\n // General 3DS2 log events: \"action handled\" (i.e. iframe loaded), data sent, process completed\n case THREEDS2_FULL: {\n const { message, metadata, subtype, result } = analyticsObj;\n\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_LOG,\n data: { component, type, message, metadata, subtype, result }\n });\n break;\n }\n\n /**\n * ERRORS\n */\n case THREEDS2_ERROR: {\n const { message, code, errorType } = analyticsObj;\n analyticsModule.createAnalyticsEvent({\n event: ANALYTICS_EVENT_ERROR,\n data: { component, type, message, code, errorType }\n });\n break;\n }\n\n default: {\n analyticsModule.createAnalyticsEvent(analyticsObj as CreateAnalyticsEventObject);\n }\n }\n };\n};\n"],"names":["analyticsPreProcessor","analyticsModule","component","analyticsObj","uiElementProps","type","target","AdyenCheckoutError","SDK_ERROR","ANALYTICS_RENDERED_STR","isStoredPaymentMethod","brand","configData","originalConfigData","isExpress","expressPage","hasExpressPage","ANALYTICS_EXPRESS_PAGES_ARRAY","includes","componentType","getCardConfigData","data","createAnalyticsEvent","event","ANALYTICS_EVENT_INFO","ANALYTICS_CONFIGURED_STR","ANALYTICS_FOCUS_STR","ANALYTICS_UNFOCUS_STR","ANALYTICS_DISPLAYED_STR","ANALYTICS_INPUT_STR","ANALYTICS_DOWNLOAD_STR","ANALYTICS_SELECTED_STR","issuer","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","validationErrorMessage","ANALYTICS_SUBMIT_STR","ANALYTICS_EVENT_LOG","message","ANALYTICS_ACTION_STR","subtype","THREEDS2_FULL","metadata","result","THREEDS2_ERROR","code","errorType","ANALYTICS_EVENT_ERROR"],"mappings":"0oBAuBO,MAAMA,EAAyBC,GAE3B,CAACC,EAAmBC,EAAmCC,EAAiB,CAAA,KAC3E,MAAMC,KAAEA,EAAIC,OAAEA,GAAWH,EA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,KACJ,CAKA,KAAKC,EACDnC,EAAgBqB,qBAAqB,CACjCC,MAAOc,EACPhB,KAAM,CAAEnB,YAAWG,OAAMiC,QAAS,yBAEtC,MAEJ,KAAKC,EAAsB,CACvB,MAAMC,QAAEA,EAAOF,QAAEA,GAAYnC,EAC7BF,EAAgBqB,qBAAqB,CACjCC,MAAOc,EACPhB,KAAM,CAAEnB,YAAWG,OAAMmC,UAASF,aAEtC,KACJ,CAGA,KAAKG,EAAe,CAChB,MAAMH,QAAEA,EAAOI,SAAEA,EAAQF,QAAEA,EAAOG,OAAEA,GAAWxC,EAE/CF,EAAgBqB,qBAAqB,CACjCC,MAAOc,EACPhB,KAAM,CAAEnB,YAAWG,OAAMiC,UAASI,WAAUF,UAASG,YAEzD,KACJ,CAKA,KAAKC,EAAgB,CACjB,MAAMN,QAAEA,EAAOO,KAAEA,EAAIC,UAAEA,GAAc3C,EACrCF,EAAgBqB,qBAAqB,CACjCC,MAAOwB,EACP1B,KAAM,CAAEnB,YAAWG,OAAMiC,UAASO,OAAMC,eAE5C,KACJ,CAEA,QACI7C,EAAgBqB,qBAAqBnB,GAE7C"}
@@ -1,2 +1,2 @@
1
- import{ANALYTICS_ACTION_STR as e,ANALYTICS_VALIDATION_ERROR_STR as o,errorCodeMapping as s,ALLOWED_ANALYTICS_DATA as n}from"./constants.js";import t from"../../utils/uuid.js";import{digitsOnlyFormatter as r}from"../../utils/Formatters/formatters.js";import{ERROR_FIELD_REQUIRED as a,ERROR_INVALID_FORMAT_EXPECTS as i}from"../Errors/constants.js";import{THREEDS2_FULL as d,DEFAULT_CHALLENGE_WINDOW_SIZE as l}from"../../components/ThreeDS2/constants.js";import u from"../../components/Card/components/CardInput/defaultProps.js";import{DEFAULT_CARD_GROUP_TYPES as m}from"../../components/internal/SecuredFields/lib/constants.js";import{notFalsy as p}from"../../utils/commonUtils.js";const c=()=>Date.now(),g=s=>({timestamp:String(c()),component:s.component,id:t(),..."error"===s.event&&{code:s.code,errorType:s.errorType,message:s.message},..."log"===s.event&&{type:s.type,message:s.message},..."log"===s.event&&(s.type===e||s.type===d)&&{subType:s.subtype},..."log"===s.event&&s.type===d&&{result:s.result},..."info"===s.event&&{type:s.type,target:s.target},..."info"===s.event&&s.issuer&&{issuer:s.issuer},..."info"===s.event&&{isExpress:s.isExpress,expressPage:s.expressPage},..."info"===s.event&&s.isStoredPaymentMethod&&{isStoredPaymentMethod:s.isStoredPaymentMethod,brand:s.brand},..."info"===s.event&&s.type===o&&{validationErrorCode:y(s.validationErrorCode,s.target),validationErrorMessage:s.validationErrorMessage},...s.configData&&{configData:s.configData},...s.metadata&&{metadata:s.metadata}}),y=(e,o)=>{if(e===a||e===i)return s[`${e}.${o}`]??e;let n=s[e]??e;return isNaN(Number(n))&&(n=r(n)),n},h=e=>Object.keys(e).reduce(((o,s)=>(n.includes(s)&&(o[s]=e[s]),o)),{}),f=e=>{const{autoFocus:o,billingAddressAllowedCountries:s,billingAddressMode:n,billingAddressRequired:t,billingAddressRequiredFields:r,brands:a=m,brandsConfiguration:i,challengeWindowSize:d=l,configuration:c,countryCode:g,data:y,disclaimerMessage:h,disableIOSArrowKeys:f,doBinLookup:b,enableStoreDetails:S,exposeExpiryDate:O,forceCompat:C,hasHolderName:A,hideCVC:B,holderNameRequired:k,installmentOptions:P,keypadFix:E,legacyInputMode:F,maskSecurityCode:N,minimumExpiryDate:v,name:w,placeholders:M,positionHolderNameOnTop:x,showBrandIcon:D,showInstallmentAmounts:j,showPayButton:V=!1,styles:I,onAllValid:L,onBinLookup:q,onBinValue:R,onBlur:T,onBrand:K,onConfigSuccess:J,onEnterKeyPressed:H,onFieldValid:z,onFocus:W,onLoad:$}=e,U=JSON.stringify(u.data),G=e.modules?.srPanel?.enabled,Q=e.modules?.srPanel?.moveFocus,X=e.modules?.risk?.enabled,Y=e.onAddressLookup?"lookup":n;let Z="none";!0===c?.koreanAuthenticationRequired&&(Z="kr"===g?.toLowerCase()?"atStart":"auto");let _=JSON.stringify(a);_.length>128&&(_=_.substring(0,124)+"...]");const ee={autoFocus:o,billingAddressAllowedCountries:JSON.stringify(s),billingAddressMode:Y,billingAddressRequired:t,billingAddressRequiredFields:JSON.stringify(r),brands:_,challengeWindowSize:d,disableIOSArrowKeys:f,doBinLookup:b,enableStoreDetails:S,exposeExpiryDate:O,forceCompat:C,hasBrandsConfiguration:p(i),hasData:y&&JSON.stringify(e.data)!==U,hasDisclaimerMessage:!!h,hasHolderName:A,hasInstallmentOptions:p(P),hasPlaceholders:p(M),hasStylesConfigured:p(I),hideCVC:B,holderNameRequired:k,keypadFix:E,legacyInputMode:F,maskSecurityCode:N,minimumExpiryDate:!!v,name:w,positionHolderNameOnTop:x,riskEnabled:X,showBrandIcon:D,showInstallmentAmounts:!!j,showKCPType:Z,showPayButton:V,socialSecurityNumberMode:c?.socialSecurityNumberMode,srPanelEnabled:G,srPanelMoveFocus:Q,hasOnAllValid:L!==u.onAllValid,hasOnBinLookup:q!==u.onBinLookup,hasOnBinValue:R!==u.onBinValue,hasOnBlur:T!==u.onBlur,hasOnBrand:K!==u.onBrand,hasOnConfigSuccess:J!==u.onConfigSuccess,hasOnEnterKeyPressed:H!==u.onEnterKeyPressed,hasOnFieldValid:z!==u.onFieldValid,hasOnFocus:W!==u.onFocus,hasOnLoad:$!==u.onLoad};if(Object.keys(ee).length>32){return Object.entries(ee).reduce(((e,[o,s],n)=>(n<32&&(e[o]=s),e)),{})}return ee};export{g as createAnalyticsObject,f as getCardConfigData,c as getUTCTimestamp,h as processAnalyticsData};
1
+ import{ANALYTICS_ACTION_STR as e,ANALYTICS_VALIDATION_ERROR_STR as o,errorCodeMapping as s,ALLOWED_ANALYTICS_DATA as n}from"./constants.js";import t from"../../utils/uuid.js";import{digitsOnlyFormatter as r}from"../../utils/Formatters/formatters.js";import{ERROR_FIELD_REQUIRED as a,ERROR_INVALID_FORMAT_EXPECTS as i}from"../Errors/constants.js";import{THREEDS2_FULL as d,DEFAULT_CHALLENGE_WINDOW_SIZE as l}from"../../components/ThreeDS2/constants.js";import u from"../../components/Card/components/CardInput/defaultProps.js";import{DEFAULT_CARD_GROUP_TYPES as m}from"../../components/internal/SecuredFields/lib/constants.js";import{notFalsy as p}from"../../utils/commonUtils.js";const c=()=>Date.now(),g=s=>({timestamp:String(c()),component:s.component,id:t(),..."error"===s.event&&{code:s.code,errorType:s.errorType,message:s.message},..."log"===s.event&&{type:s.type,message:s.message},..."log"===s.event&&(s.type===e||s.type===d)&&{subType:s.subtype},..."log"===s.event&&s.type===d&&{result:s.result},..."info"===s.event&&{type:s.type,target:s.target},..."info"===s.event&&s.issuer&&{issuer:s.issuer},..."info"===s.event&&{isExpress:s.isExpress,expressPage:s.expressPage},..."info"===s.event&&s.isStoredPaymentMethod&&{isStoredPaymentMethod:s.isStoredPaymentMethod,brand:s.brand},..."info"===s.event&&s.type===o&&{validationErrorCode:y(s.validationErrorCode,s.target),validationErrorMessage:s.validationErrorMessage},...s.configData&&{configData:s.configData},...s.metadata&&{metadata:s.metadata}}),y=(e,o)=>{if(e===a||e===i)return s[`${e}.${o}`]??e;let n=s[e]??e;return isNaN(Number(n))&&(n=r(n)),n},h=e=>Object.keys(e).reduce(((o,s)=>(n.includes(s)&&(o[s]=e[s]),o)),{}),b=e=>{const{autoFocus:o,billingAddressAllowedCountries:s,billingAddressMode:n,billingAddressRequired:t,billingAddressRequiredFields:r,brands:a=m,brandsConfiguration:i,challengeWindowSize:d=l,configuration:c,countryCode:g,data:y,disclaimerMessage:h,disableIOSArrowKeys:b,doBinLookup:f,enableStoreDetails:S,exposeExpiryDate:C,forceCompat:O,hasHolderName:A,hideCVC:B,holderNameRequired:k,installmentOptions:P,keypadFix:E,legacyInputMode:F,maskSecurityCode:v,minimumExpiryDate:w,name:M,placeholders:x,positionHolderNameOnTop:D,showBrandIcon:N,showInstallmentAmounts:j,showPayButton:V=!1,styles:I,onAllValid:L,onBinLookup:q,onBinValue:R,onBlur:T,onBrand:K,onConfigSuccess:H,onEnterKeyPressed:z,onFieldValid:J,onFocus:W,onLoad:$}=e,U=JSON.stringify(u.data),G=e.modules?.srPanel?.enabled,Q=e.modules?.srPanel?.moveFocus,X=e.modules?.risk?.enabled,Y=e.onAddressLookup?"lookup":n;let Z="none";!0===c?.koreanAuthenticationRequired&&(Z="kr"===g?.toLowerCase()?"atStart":"auto");const _={autoFocus:o,...s?.length>0&&{billingAddressAllowedCountries:s.toString().substring(0,128)},billingAddressMode:Y,billingAddressRequired:t,billingAddressRequiredFields:r?.toString()?.substring(0,128),brands:a?.toString()?.substring(0,128),challengeWindowSize:d,disableIOSArrowKeys:b,doBinLookup:f,enableStoreDetails:S,exposeExpiryDate:C,forceCompat:O,hasBrandsConfiguration:p(i),hasData:y&&JSON.stringify(e.data)!==U,hasDisclaimerMessage:!!h,hasHolderName:A,hasInstallmentOptions:p(P),hasPlaceholders:p(x),hasStylesConfigured:p(I),hideCVC:B,holderNameRequired:k,keypadFix:E,legacyInputMode:F,maskSecurityCode:v,minimumExpiryDate:!!w,name:M,positionHolderNameOnTop:D,riskEnabled:X,showBrandIcon:N,showInstallmentAmounts:!!j,showKCPType:Z,showPayButton:V,socialSecurityNumberMode:c?.socialSecurityNumberMode,srPanelEnabled:G,srPanelMoveFocus:Q,hasOnAllValid:L!==u.onAllValid,hasOnBinLookup:q!==u.onBinLookup,hasOnBinValue:R!==u.onBinValue,hasOnBlur:T!==u.onBlur,hasOnBrand:K!==u.onBrand,hasOnConfigSuccess:H!==u.onConfigSuccess,hasOnEnterKeyPressed:z!==u.onEnterKeyPressed,hasOnFieldValid:J!==u.onFieldValid,hasOnFocus:W!==u.onFocus,hasOnLoad:$!==u.onLoad};if(Object.keys(_).length>32){return Object.entries(_).reduce(((e,[o,s],n)=>(n<32&&(e[o]=s),e)),{})}return _};export{g as createAnalyticsObject,b as getCardConfigData,c as getUTCTimestamp,h as processAnalyticsData};
2
2
  //# sourceMappingURL=utils.js.map