@adyen/adyen-web 6.0.2 → 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.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +13 -4
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Riverty/Riverty.js +1 -1
- package/dist/es/components/Riverty/Riverty.js.map +1 -1
- package/dist/es/components/Riverty/config.js +1 -1
- package/dist/es/components/Riverty/config.js.map +1 -1
- package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
- package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
- package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
- package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
- package/dist/es/core/Analytics/utils.js +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/index.d.ts +13 -4
- package/dist/es/utils/constants/currency-decimals.js +1 -1
- package/dist/es/utils/constants/currency-decimals.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
- package/dist/es-legacy/components/Riverty/Riverty.js.map +1 -1
- package/dist/es-legacy/components/Riverty/config.js +1 -1
- package/dist/es-legacy/components/Riverty/config.js.map +1 -1
- package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
- package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
- package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
- package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/utils/constants/currency-decimals.js +1 -1
- package/dist/es-legacy/utils/constants/currency-decimals.js.map +1 -1
- package/package.json +8 -8
|
@@ -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","
|
|
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 // 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,M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C,EACxDF,EAAgBqB,qBAAqB,CACjCC,MAAOC,EACPH,KAAM,CAAEnB,YAAWG,OAAMC,SAAQ4B,sBAAqBC,4BAE1D,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)),{}),
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsObject, CreateAnalyticsObject, CardConfigData, AnalyticsData } from './types';\nimport { ANALYTICS_ACTION_STR, ANALYTICS_VALIDATION_ERROR_STR, errorCodeMapping, ALLOWED_ANALYTICS_DATA } from './constants';\nimport uuid from '../../utils/uuid';\nimport { digitsOnlyFormatter } from '../../utils/Formatters/formatters';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../Errors/constants';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_FULL } from '../../components/ThreeDS2/constants';\nimport { CardConfiguration } from '../../components/Card/types';\nimport CardInputDefaultProps from '../../components/Card/components/CardInput/defaultProps';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../../components/internal/SecuredFields/lib/constants';\nimport { notFalsy } from '../../utils/commonUtils';\n\nexport const getUTCTimestamp = () => Date.now();\n\n/**\n * All objects for the /checkoutanalytics endpoint have base props:\n * \"timestamp\" & \"component\"\n *\n * Error objects have, in addition to the base props:\n * \"code\", \"errorType\" & \"message\"\n *\n * Log objects have, in addition to the base props:\n * \"message\" & \"type\" &\n * \"subtype\" (e.g. when an action is handled)\n *\n * Info objects have, in addition to the base props:\n * \"type\" & \"target\" &\n * \"isStoredPaymentMethod\" & \"brand\" (when a storedCard is \"selected\"), or,\n * \"validationErrorCode\" & \"validationErrorMessage\" (when the event is describing a validation error)\n *\n * All objects can also have a \"metadata\" object of key-value pairs\n */\nexport const createAnalyticsObject = (aObj: CreateAnalyticsObject): AnalyticsObject => ({\n timestamp: String(getUTCTimestamp()),\n component: aObj.component,\n id: uuid(),\n /** ERROR */\n ...(aObj.event === 'error' && { code: aObj.code, errorType: aObj.errorType, message: aObj.message }), // error event\n /** LOG */\n ...(aObj.event === 'log' && { type: aObj.type, message: aObj.message }), // log event\n ...(aObj.event === 'log' && (aObj.type === ANALYTICS_ACTION_STR || aObj.type === THREEDS2_FULL) && { subType: aObj.subtype }), // only added if we have a log event of Action type or ThreeDS2\n ...(aObj.event === 'log' && aObj.type === THREEDS2_FULL && { result: aObj.result }), // only added if we have a log event of ThreeDS2 type\n /** INFO */\n ...(aObj.event === 'info' && { type: aObj.type, target: aObj.target }), // info event\n ...(aObj.event === 'info' && aObj.issuer && { issuer: aObj.issuer }), // relates to issuerLists\n ...(aObj.event === 'info' && { isExpress: aObj.isExpress, expressPage: aObj.expressPage }), // relates to Plugins & detecting Express PMs\n ...(aObj.event === 'info' && aObj.isStoredPaymentMethod && { isStoredPaymentMethod: aObj.isStoredPaymentMethod, brand: aObj.brand }), // only added if we have an info event about a storedPM\n ...(aObj.event === 'info' &&\n aObj.type === ANALYTICS_VALIDATION_ERROR_STR && {\n validationErrorCode: mapErrorCodesForAnalytics(aObj.validationErrorCode, aObj.target),\n validationErrorMessage: aObj.validationErrorMessage\n }), // only added if we have an info event describing a validation error\n ...(aObj.configData && { configData: aObj.configData }),\n /** All */\n ...(aObj.metadata && { metadata: aObj.metadata })\n});\n\nconst mapErrorCodesForAnalytics = (errorCode: string, target: string) => {\n // Some of the more generic error codes required combination with target to retrieve a specific code\n if (errorCode === ERROR_FIELD_REQUIRED || errorCode === ERROR_INVALID_FORMAT_EXPECTS) {\n return errorCodeMapping[`${errorCode}.${target}`] ?? errorCode;\n }\n\n let errCode = errorCodeMapping[errorCode] ?? errorCode;\n\n // If errCode isn't now a number - then we just need to remove any non-digits\n // since the correct error code is already contained within the string e.g. securedField related errors\n if (isNaN(Number(errCode))) {\n errCode = digitsOnlyFormatter(errCode);\n }\n\n return errCode;\n};\n\nexport const processAnalyticsData = (analyticsData: AnalyticsData): AnalyticsData => {\n return Object.keys(analyticsData).reduce((acc, prop) => {\n if (ALLOWED_ANALYTICS_DATA.includes(prop)) acc[prop] = analyticsData[prop];\n return acc;\n }, {});\n};\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n let brandsStr = JSON.stringify(brands);\n if (brandsStr.length > 128) {\n brandsStr = brandsStr.substring(0, 124) + '...]';\n }\n\n // @ts-ignore commenting out props until endpoint is ready\n const configData: CardConfigData = {\n autoFocus,\n billingAddressAllowedCountries: JSON.stringify(billingAddressAllowedCountries),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: JSON.stringify(billingAddressRequiredFields),\n brands: brandsStr,\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinLookup: onBinLookup !== CardInputDefaultProps.onBinLookup,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnEnterKeyPressed: onEnterKeyPressed !== CardInputDefaultProps.onEnterKeyPressed,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad\n };\n\n // TODO - keep until endpoint can accept more entries in the configData object (current limit: 32);\n if (Object.keys(configData).length > 32) {\n const strippedConfigData = Object.entries(configData).reduce((acc, [key, value], index) => {\n if (index < 32) {\n acc[key] = value;\n }\n return acc;\n }, {});\n\n return strippedConfigData as CardConfigData;\n }\n\n return configData;\n};\n"],"names":["getUTCTimestamp","Date","now","createAnalyticsObject","aObj","timestamp","String","component","id","uuid","event","code","errorType","message","type","ANALYTICS_ACTION_STR","THREEDS2_FULL","subType","subtype","result","target","issuer","isExpress","expressPage","isStoredPaymentMethod","brand","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","mapErrorCodesForAnalytics","validationErrorMessage","configData","metadata","errorCode","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","errorCodeMapping","errCode","isNaN","Number","digitsOnlyFormatter","processAnalyticsData","analyticsData","Object","keys","reduce","acc","prop","ALLOWED_ANALYTICS_DATA","includes","getCardConfigData","cardProps","autoFocus","billingAddressAllowedCountries","billingAddressMode","billingAddressRequired","billingAddressRequiredFields","brands","DEFAULT_CARD_GROUP_TYPES","brandsConfiguration","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","countryCode","data","disclaimerMessage","disableIOSArrowKeys","doBinLookup","enableStoreDetails","exposeExpiryDate","forceCompat","hasHolderName","hideCVC","holderNameRequired","installmentOptions","keypadFix","legacyInputMode","maskSecurityCode","minimumExpiryDate","name","placeholders","positionHolderNameOnTop","showBrandIcon","showInstallmentAmounts","showPayButton","styles","onAllValid","onBinLookup","onBinValue","onBlur","onBrand","onConfigSuccess","onEnterKeyPressed","onFieldValid","onFocus","onLoad","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","brandsStr","length","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinLookup","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnEnterKeyPressed","hasOnFieldValid","hasOnFocus","hasOnLoad","entries","key","value","index"],"mappings":"wqBAWaA,MAAAA,EAAkB,IAAMC,KAAKC,MAoB7BC,EAAyBC,IAAkD,CACpFC,UAAWC,OAAON,KAClBO,UAAWH,EAAKG,UAChBC,GAAIC,OAEe,UAAfL,EAAKM,OAAqB,CAAEC,KAAMP,EAAKO,KAAMC,UAAWR,EAAKQ,UAAWC,QAAST,EAAKS,YAEvE,QAAfT,EAAKM,OAAmB,CAAEI,KAAMV,EAAKU,KAAMD,QAAST,EAAKS,YAC1C,QAAfT,EAAKM,QAAoBN,EAAKU,OAASC,GAAwBX,EA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ACAE,YACAC,kBACAC,mBACAC,oBAAqBA,EACrBC,OACAE,0BACAyB,cACAxB,gBACAC,yBAA0BA,EAC1B2B,cACA1B,gBACAuC,yBAA0B7D,GAAe6D,yBACzCvB,iBACAI,mBAGAoB,cAAetC,IAAea,EAAsBb,WACpDuC,eAAgBtC,IAAgBY,EAAsBZ,YACtDuC,cAAetC,IAAeW,EAAsBX,WACpDuC,UAAWtC,IAAWU,EAAsBV,OAC5CuC,WAAYtC,IAAYS,EAAsBT,QAC9CuC,mBAAoBtC,IAAoBQ,EAAsBR,gBAC9DuC,qBAAsBtC,IAAsBO,EAAsBP,kBAClEuC,gBAAiBtC,IAAiBM,EAAsBN,aACxDuC,WAAYtC,IAAYK,EAAsBL,QAC9CuC,UAAWtC,IAAWI,EAAsBJ,QAIhD,GAAIpD,OAAOC,KAAKb,IAAYmF,OAAS,GAAI,CAQrC,OAP2BvE,OAAO2F,QAAQvG,IAAYc,QAAO,CAACC,GAAMyF,EAAKC,GAAQC,KACzEA,EAAQ,KACR3F,EAAIyF,GAAOC,GAER1F,IACR,CAAC,EAGR,CAEA,OAAOf,EAAAA"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsObject, CreateAnalyticsObject, CardConfigData, AnalyticsData } from './types';\nimport { ANALYTICS_ACTION_STR, ANALYTICS_VALIDATION_ERROR_STR, errorCodeMapping, ALLOWED_ANALYTICS_DATA } from './constants';\nimport uuid from '../../utils/uuid';\nimport { digitsOnlyFormatter } from '../../utils/Formatters/formatters';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../Errors/constants';\nimport { DEFAULT_CHALLENGE_WINDOW_SIZE, THREEDS2_FULL } from '../../components/ThreeDS2/constants';\nimport { CardConfiguration } from '../../components/Card/types';\nimport CardInputDefaultProps from '../../components/Card/components/CardInput/defaultProps';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../../components/internal/SecuredFields/lib/constants';\nimport { notFalsy } from '../../utils/commonUtils';\n\nconst MAX_LENGTH = 128;\nexport const getUTCTimestamp = () => Date.now();\n\n/**\n * All objects for the /checkoutanalytics endpoint have base props:\n * \"timestamp\" & \"component\"\n *\n * Error objects have, in addition to the base props:\n * \"code\", \"errorType\" & \"message\"\n *\n * Log objects have, in addition to the base props:\n * \"message\" & \"type\" &\n * \"subtype\" (e.g. when an action is handled)\n *\n * Info objects have, in addition to the base props:\n * \"type\" & \"target\" &\n * \"isStoredPaymentMethod\" & \"brand\" (when a storedCard is \"selected\"), or,\n * \"validationErrorCode\" & \"validationErrorMessage\" (when the event is describing a validation error)\n *\n * All objects can also have a \"metadata\" object of key-value pairs\n */\nexport const createAnalyticsObject = (aObj: CreateAnalyticsObject): AnalyticsObject => ({\n timestamp: String(getUTCTimestamp()),\n component: aObj.component,\n id: uuid(),\n /** ERROR */\n ...(aObj.event === 'error' && { code: aObj.code, errorType: aObj.errorType, message: aObj.message }), // error event\n /** LOG */\n ...(aObj.event === 'log' && { type: aObj.type, message: aObj.message }), // log event\n ...(aObj.event === 'log' && (aObj.type === ANALYTICS_ACTION_STR || aObj.type === THREEDS2_FULL) && { subType: aObj.subtype }), // only added if we have a log event of Action type or ThreeDS2\n ...(aObj.event === 'log' && aObj.type === THREEDS2_FULL && { result: aObj.result }), // only added if we have a log event of ThreeDS2 type\n /** INFO */\n ...(aObj.event === 'info' && { type: aObj.type, target: aObj.target }), // info event\n ...(aObj.event === 'info' && aObj.issuer && { issuer: aObj.issuer }), // relates to issuerLists\n ...(aObj.event === 'info' && { isExpress: aObj.isExpress, expressPage: aObj.expressPage }), // relates to Plugins & detecting Express PMs\n ...(aObj.event === 'info' && aObj.isStoredPaymentMethod && { isStoredPaymentMethod: aObj.isStoredPaymentMethod, brand: aObj.brand }), // only added if we have an info event about a storedPM\n ...(aObj.event === 'info' &&\n aObj.type === ANALYTICS_VALIDATION_ERROR_STR && {\n validationErrorCode: mapErrorCodesForAnalytics(aObj.validationErrorCode, aObj.target),\n validationErrorMessage: aObj.validationErrorMessage\n }), // only added if we have an info event describing a validation error\n ...(aObj.configData && { configData: aObj.configData }),\n /** All */\n ...(aObj.metadata && { metadata: aObj.metadata })\n});\n\nconst mapErrorCodesForAnalytics = (errorCode: string, target: string) => {\n // Some of the more generic error codes required combination with target to retrieve a specific code\n if (errorCode === ERROR_FIELD_REQUIRED || errorCode === ERROR_INVALID_FORMAT_EXPECTS) {\n return errorCodeMapping[`${errorCode}.${target}`] ?? errorCode;\n }\n\n let errCode = errorCodeMapping[errorCode] ?? errorCode;\n\n // If errCode isn't now a number - then we just need to remove any non-digits\n // since the correct error code is already contained within the string e.g. securedField related errors\n if (isNaN(Number(errCode))) {\n errCode = digitsOnlyFormatter(errCode);\n }\n\n return errCode;\n};\n\nexport const processAnalyticsData = (analyticsData: AnalyticsData): AnalyticsData => {\n return Object.keys(analyticsData).reduce((acc, prop) => {\n if (ALLOWED_ANALYTICS_DATA.includes(prop)) acc[prop] = analyticsData[prop];\n return acc;\n }, {});\n};\n\nexport const getCardConfigData = (cardProps: CardConfiguration): CardConfigData => {\n // Extract props from cardProps - mostly setting a default value, if prop not found\n const {\n autoFocus,\n billingAddressAllowedCountries,\n billingAddressMode,\n billingAddressRequired,\n billingAddressRequiredFields,\n brands = DEFAULT_CARD_GROUP_TYPES,\n brandsConfiguration,\n challengeWindowSize = DEFAULT_CHALLENGE_WINDOW_SIZE,\n configuration,\n countryCode,\n data,\n disclaimerMessage,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasHolderName,\n hideCVC,\n holderNameRequired,\n installmentOptions,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate,\n name, // = 'none',\n placeholders,\n positionHolderNameOnTop,\n showBrandIcon,\n showInstallmentAmounts,\n showPayButton = false, // hard coded default\n styles,\n onAllValid,\n onBinLookup,\n onBinValue,\n onBlur,\n onBrand,\n onConfigSuccess,\n onEnterKeyPressed,\n onFieldValid,\n onFocus,\n onLoad\n } = cardProps;\n\n const dataString = JSON.stringify(CardInputDefaultProps.data);\n\n const srPanelEnabled = cardProps.modules?.srPanel?.enabled;\n const srPanelMoveFocus = cardProps.modules?.srPanel?.moveFocus;\n\n const riskEnabled = cardProps.modules?.risk?.enabled;\n\n const billingAddressModeValue = cardProps.onAddressLookup ? 'lookup' : billingAddressMode;\n\n let showKCPType: 'none' | 'auto' | 'atStart' = 'none';\n if (configuration?.koreanAuthenticationRequired === true) {\n showKCPType = countryCode?.toLowerCase() === 'kr' ? 'atStart' : 'auto';\n }\n\n // @ts-ignore commenting out props until endpoint is ready\n const configData: CardConfigData = {\n autoFocus,\n ...(billingAddressAllowedCountries?.length > 0 && {\n billingAddressAllowedCountries: billingAddressAllowedCountries.toString().substring(0, MAX_LENGTH)\n }),\n billingAddressMode: billingAddressModeValue,\n billingAddressRequired,\n billingAddressRequiredFields: billingAddressRequiredFields?.toString()?.substring(0, MAX_LENGTH),\n // Probably just for development - in real life we wouldn't expect the number of supported brands to push the endpoint limit on 128 chars\n brands: brands?.toString()?.substring(0, MAX_LENGTH),\n challengeWindowSize,\n disableIOSArrowKeys,\n doBinLookup,\n enableStoreDetails,\n exposeExpiryDate,\n forceCompat,\n hasBrandsConfiguration: notFalsy(brandsConfiguration),\n hasData: data && JSON.stringify(cardProps.data) !== dataString,\n hasDisclaimerMessage: !!disclaimerMessage,\n hasHolderName,\n hasInstallmentOptions: notFalsy(installmentOptions),\n hasPlaceholders: notFalsy(placeholders), // has merchant defined placeholders\n hasStylesConfigured: notFalsy(styles),\n hideCVC,\n holderNameRequired,\n keypadFix,\n legacyInputMode,\n maskSecurityCode,\n minimumExpiryDate: !!minimumExpiryDate, // Potentially, in the future, we can send the actual string value\n name,\n positionHolderNameOnTop,\n riskEnabled,\n showBrandIcon,\n showInstallmentAmounts: !!showInstallmentAmounts,\n showKCPType,\n showPayButton,\n socialSecurityNumberMode: configuration?.socialSecurityNumberMode,\n srPanelEnabled,\n srPanelMoveFocus,\n /** callbacks */\n // We need to detect if the merchant themselves has defined these, not if we've set them as a default\n hasOnAllValid: onAllValid !== CardInputDefaultProps.onAllValid,\n hasOnBinLookup: onBinLookup !== CardInputDefaultProps.onBinLookup,\n hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnEnterKeyPressed: onEnterKeyPressed !== CardInputDefaultProps.onEnterKeyPressed,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad\n };\n\n // TODO - keep until endpoint can accept more entries in the configData object (current limit: 32);\n if (Object.keys(configData).length > 32) {\n const strippedConfigData = Object.entries(configData).reduce((acc, [key, value], index) => {\n if (index < 32) {\n acc[key] = value;\n }\n return acc;\n }, {});\n\n return strippedConfigData as CardConfigData;\n }\n\n return configData;\n};\n"],"names":["getUTCTimestamp","Date","now","createAnalyticsObject","aObj","timestamp","String","component","id","uuid","event","code","errorType","message","type","ANALYTICS_ACTION_STR","THREEDS2_FULL","subType","subtype","result","target","issuer","isExpress","expressPage","isStoredPaymentMethod","brand","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","mapErrorCodesForAnalytics","validationErrorMessage","configData","metadata","errorCode","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","errorCodeMapping","errCode","isNaN","Number","digitsOnlyFormatter","processAnalyticsData","analyticsData","Object","keys","reduce","acc","prop","ALLOWED_ANALYTICS_DATA","includes","getCardConfigData","cardProps","autoFocus","billingAddressAllowedCountries","billingAddressMode","billingAddressRequired","billingAddressRequiredFields","brands","DEFAULT_CARD_GROUP_TYPES","brandsConfiguration","challengeWindowSize","DEFAULT_CHALLENGE_WINDOW_SIZE","configuration","countryCode","data","disclaimerMessage","disableIOSArrowKeys","doBinLookup","enableStoreDetails","exposeExpiryDate","forceCompat","hasHolderName","hideCVC","holderNameRequired","installmentOptions","keypadFix","legacyInputMode","maskSecurityCode","minimumExpiryDate","name","placeholders","positionHolderNameOnTop","showBrandIcon","showInstallmentAmounts","showPayButton","styles","onAllValid","onBinLookup","onBinValue","onBlur","onBrand","onConfigSuccess","onEnterKeyPressed","onFieldValid","onFocus","onLoad","dataString","JSON","stringify","CardInputDefaultProps","srPanelEnabled","modules","srPanel","enabled","srPanelMoveFocus","moveFocus","riskEnabled","risk","billingAddressModeValue","onAddressLookup","showKCPType","koreanAuthenticationRequired","toLowerCase","length","toString","substring","hasBrandsConfiguration","notFalsy","hasData","hasDisclaimerMessage","hasInstallmentOptions","hasPlaceholders","hasStylesConfigured","socialSecurityNumberMode","hasOnAllValid","hasOnBinLookup","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnEnterKeyPressed","hasOnFieldValid","hasOnFocus","hasOnLoad","entries","key","value","index"],"mappings":"wqBAWA,MACaA,EAAkB,IAAMC,KAAKC,MAoB7BC,EAAyBC,IAAkD,CACpFC,UAAWC,OAAON,KAClBO,UAAWH,EAAKG,UAChBC,GAAIC,OAEe,UAAfL,EAAKM,OAAqB,CAAEC,KAAMP,EAAKO,KAAMC,UAAWR,EAAKQ,UAAWC,QAAST,EAAKS,YAEvE,QAAfT,EAAKM,OAAmB,CAAEI,KAAMV,EAAKU,KAAMD,QAAST,EAAKS,YAC1C,QAAfT,EAAKM,QAAoBN,EAAKU,OAASC,GAAwBX,EAAKU,OAASE,IAAkB,CAAEC,QAASb,EAAKc,YAChG,QAAfd,EAAKM,OAAmBN,EAAKU,OAASE,GAAiB,CAAEG,OAAQf,EAAKe,WAEvD,SAAff,EAAKM,OAAoB,CAAEI,KAAMV,EAAKU,KAAMM,OAAQhB,EAAKgB,WAC1C,SAAfhB,EAAKM,OAAoBN,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etC,IAAeW,EAAsBX,WACpDuC,UAAWtC,IAAWU,EAAsBV,OAC5CuC,WAAYtC,IAAYS,EAAsBT,QAC9CuC,mBAAoBtC,IAAoBQ,EAAsBR,gBAC9DuC,qBAAsBtC,IAAsBO,EAAsBP,kBAClEuC,gBAAiBtC,IAAiBM,EAAsBN,aACxDuC,WAAYtC,IAAYK,EAAsBL,QAC9CuC,UAAWtC,IAAWI,EAAsBJ,QAIhD,GAAIpD,OAAOC,KAAKb,GAAYkF,OAAS,GAAI,CAQrC,OAP2BtE,OAAO2F,QAAQvG,GAAYc,QAAO,CAACC,GAAMyF,EAAKC,GAAQC,KACzEA,EAAQ,KACR3F,EAAIyF,GAAOC,GAER1F,IACR,CAAC,EAGR,CAEA,OAAOf,CAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0
|
|
1
|
+
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.1.0",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
|
|
2
2
|
//# sourceMappingURL=collect-id.js.map
|
package/dist/es/core/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.0
|
|
1
|
+
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.1.0",bundleType:"esm"};static registry=p;static setBundleType(t){P.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}constructor(t){n(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...E,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const a=this.options.clientKey?.substring(0,4);if(("test"===a||"live"===a)&&!this.loadingContext.includes(a))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${a} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===a&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=P.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await j(this.cdnTranslationsUrl,P.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=v(this.options.locale),this.options.translations=A(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...a(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:P.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}}export{P as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/dist/es/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
const e={IDR:1,JPY:1,KRW:1,VND:1,BYR:1,CVE:1,DJF:1,GHC:1,GNF:1,KMF:1,PYG:1,RWF:1,UGX:1,VUV:1,XAF:1,XOF:1,XPF:1,MRO:10,BHD:1e3,IQD:1e3,JOD:1e3,KWD:1e3,OMR:1e3,LYD:1e3,TND:1e3};export{e as default};
|
|
1
|
+
const e={IDR:1,JPY:1,KRW:1,VND:1,BYR:1,CVE:1,DJF:1,GHC:1,GNF:1,KMF:1,ISK:1,PYG:1,RWF:1,UGX:1,VUV:1,XAF:1,XOF:1,XPF:1,MRO:10,BHD:1e3,IQD:1e3,JOD:1e3,KWD:1e3,OMR:1e3,LYD:1e3,TND:1e3};export{e as default};
|
|
2
2
|
//# sourceMappingURL=currency-decimals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-decimals.js","sources":["../../../../src/utils/constants/currency-decimals.ts"],"sourcesContent":["const CURRENCY_DECIMALS = {\n // ZERO_DECIMAL_CURRENCIES\n IDR: 1,\n JPY: 1,\n KRW: 1,\n VND: 1,\n BYR: 1,\n CVE: 1,\n DJF: 1,\n GHC: 1,\n GNF: 1,\n KMF: 1,\n PYG: 1,\n RWF: 1,\n UGX: 1,\n VUV: 1,\n XAF: 1,\n XOF: 1,\n XPF: 1,\n\n // ONE_DECIMAL_CURRENCIES\n MRO: 10,\n\n // THREE_DECIMAL_CURRENCIES\n BHD: 1000,\n IQD: 1000,\n JOD: 1000,\n KWD: 1000,\n OMR: 1000,\n LYD: 1000,\n TND: 1000\n};\n\nexport default CURRENCY_DECIMALS;\n"],"names":["CURRENCY_DECIMALS","IDR","JPY","KRW","VND","BYR","CVE","DJF","GHC","GNF","KMF","PYG","RWF","UGX","VUV","XAF","XOF","XPF","MRO","BHD","IQD","JOD","KWD","OMR","LYD","TND"],"mappings":"AAAA,MAAMA,EAAoB,CAEtBC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EAGLC,IAAK,GAGLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK"}
|
|
1
|
+
{"version":3,"file":"currency-decimals.js","sources":["../../../../src/utils/constants/currency-decimals.ts"],"sourcesContent":["const CURRENCY_DECIMALS = {\n // ZERO_DECIMAL_CURRENCIES\n IDR: 1,\n JPY: 1,\n KRW: 1,\n VND: 1,\n BYR: 1,\n CVE: 1,\n DJF: 1,\n GHC: 1,\n GNF: 1,\n KMF: 1,\n ISK: 1,\n PYG: 1,\n RWF: 1,\n UGX: 1,\n VUV: 1,\n XAF: 1,\n XOF: 1,\n XPF: 1,\n\n // ONE_DECIMAL_CURRENCIES\n MRO: 10,\n\n // THREE_DECIMAL_CURRENCIES\n BHD: 1000,\n IQD: 1000,\n JOD: 1000,\n KWD: 1000,\n OMR: 1000,\n LYD: 1000,\n TND: 1000\n};\n\nexport default CURRENCY_DECIMALS;\n"],"names":["CURRENCY_DECIMALS","IDR","JPY","KRW","VND","BYR","CVE","DJF","GHC","GNF","KMF","ISK","PYG","RWF","UGX","VUV","XAF","XOF","XPF","MRO","BHD","IQD","JOD","KWD","OMR","LYD","TND"],"mappings":"AAAA,MAAMA,EAAoB,CAEtBC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EACLC,IAAK,EAGLC,IAAK,GAGLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,IAAK"}
|
|
@@ -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 i from"../../utils/browserInfo.js";import s from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as r}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import l from"../internal/ClickToPay/services/create-clicktopay-service.js";import d from"./components/ClickToPayWrapper.js";import u from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import{UIElement as c}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 v,ANALYTICS_UNFOCUS_STR as f,ANALYTICS_VALIDATION_ERROR_STR as b}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as g}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as P}from"../../utils/hasOwnProperty.js";import C,{IMPLEMENTATION_ERROR as S}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as k}from"../../core/Errors/utils.js";import{SF_ErrorCodes as j}from"../../core/Errors/constants.js";import O from"./components/CardInput/defaultProps.js";function T(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function R(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),i.forEach((function(o){T(t,o,e[o])}))}return t}function B(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}class I extends c{setStatus(t,o){var e,i;return(null===(e=this.componentRef)||void 0===e?void 0:e.setStatus)&&this.componentRef.setStatus(t,o),(null===(i=this.clickToPayRef)||void 0===i?void 0:i.setStatus)&&this.clickToPayRef.setStatus(t,o),this}formatProps(t){var o,e,i,s,r,n,a,l,d,u,c,h,m,y,v,f,b,g,P,k;const j=null!==(k=null===(e=t.session)||void 0===e||null===(o=e.configuration)||void 0===o?void 0:o.enableStoreDetails)&&void 0!==k?k:t.enableStoreDetails,T=!(0===(null===(i=t.amount)||void 0===i?void 0:i.value))&&j,I=t.storedPaymentMethodId||t.id,w=I&&(null==t||null===(s=t.supportedShopperInteractions)||void 0===s?void 0:s.includes("Ecommerce"));if(I&&!w)throw new C(S,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");var M,A;return R(B(R({},t),{holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?O.billingAddressMode:t.billingAddressMode,brand:null!==(M=t.brand)&&void 0!==M?M:p.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:B(R({},t.configuration),{socialSecurityNumberMode:null!==(A=null===(r=t.configuration)||void 0===r?void 0:r.socialSecurityNumberMode)&&void 0!==A?A:"auto"}),brandsConfiguration:t.brandsConfiguration||(null===(n=t.configuration)||void 0===n?void 0:n.brandsConfiguration)||{},icon:t.icon||(null===(a=t.configuration)||void 0===a?void 0:a.icon),installmentOptions:(null===(d=t.session)||void 0===d||null===(l=d.configuration)||void 0===l?void 0:l.installmentOptions)||t.installmentOptions,enableStoreDetails:j,showStoreDetailsCheckbox:T,clickToPayConfiguration:B(R({},t.clickToPayConfiguration),{disableOtpAutoFocus:(null===(u=t.clickToPayConfiguration)||void 0===u?void 0:u.disableOtpAutoFocus)||!1,shopperEmail:(null===(c=t.clickToPayConfiguration)||void 0===c?void 0:c.shopperEmail)||(null===(m=this.core.options)||void 0===m||null===(h=m.session)||void 0===h?void 0:h.shopperEmail),telephoneNumber:(null===(y=t.clickToPayConfiguration)||void 0===y?void 0:y.telephoneNumber)||(null===(f=this.core.options)||void 0===f||null===(v=f.session)||void 0===v?void 0:v.telephoneNumber),locale:(null===(b=t.clickToPayConfiguration)||void 0===b?void 0:b.locale)||(null===(P=t.i18n)||void 0===P||null===(g=P.locale)||void 0===g?void 0:g.replace("-","_"))})}),I&&{storedPaymentMethodId:I})}formatData(){const t=this.state.selectedBrandValue;return B(R({paymentMethod:R({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){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.updateStyles)&&this.componentRef.updateStyles(t),this}setFocusOn(t){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.setFocusOn)&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,o=!1){var e;return(null===(e=this.componentRef)||void 0===e?void 0:e.processBinLookupResponse)&&this.componentRef.processBinLookupResponse(t,o),this}handleUnsupportedCard(t){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.handleUnsupportedCard)&&this.componentRef.handleUnsupportedCard(t),this}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)}get storePaymentMethodPayload(){var t,o;if((null===(t=this.props.storedPaymentMethodId)||void 0===t?void 0:t.length)>0)return{};if(0===(null===(o=this.props.amount)||void 0===o?void 0:o.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(){var t;return null!==(t=this.props.icon)&&void 0!==t?t:this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:o}=this.props;return t?t.map((t=>{var e,i;return{icon:null!==(i=null===(e=o[t])||void 0===e?void 0:e.icon)&&void 0!==i?i: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 i()}renderCardInput(e=!0){return t(o,B(R({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(u,{srPanel:this.props.modules.srPanel},t(d,{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)))))}constructor(o,e){var i;(super(o,e),T(this,"clickToPayService",void 0),T(this,"clickToPayRef",null),T(this,"setClickToPayRef",(t=>{this.clickToPayRef=t})),T(this,"onBrand",(t=>{var o,e;null===(o=(e=this.props).onBrand)||void 0===o||o.call(e,t)})),T(this,"handleClickToPaySubmit",(t=>{this.setState({data:R({},t),valid:{},errors:{},isValid:!0}),this.submit()})),T(this,"onConfigSuccess",(t=>{var o,e;this.submitAnalytics({type:y}),null===(o=(e=this.props).onConfigSuccess)||void 0===o||o.call(e,t)})),T(this,"onFocus",(t=>{var o,e,i,s;(this.submitAnalytics({type:v,target:r(t.fieldType)}),g.includes(t.fieldType))?null===(o=(e=this.props).onFocus)||void 0===o||o.call(e,t.event):null===(i=(s=this.props).onFocus)||void 0===i||i.call(s,t)})),T(this,"onBlur",(t=>{var o,e,i,s;(this.submitAnalytics({type:f,target:r(t.fieldType)}),g.includes(t.fieldType))?null===(o=(e=this.props).onBlur)||void 0===o||o.call(e,t.event):null===(i=(s=this.props).onBlur)||void 0===i||i.call(s,t)})),T(this,"onValidationErrorAnalytics",(t=>{this.submitAnalytics({type:b,target:r(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:k(t.errorCode,j)})})),T(this,"onBinValue",s(this)),T(this,"payButton",(o=>{var e,i;const s=0===(null===(e=this.props.amount)||void 0===e?void 0:e.value),r=(null===(i=this.props.storedPaymentMethodId)||void 0===i?void 0:i.length)>0;return t(h,B(R({},o),{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:s&&!r?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit}))})),e&&!e._disableClickToPay)&&(this.clickToPayService=l(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),null===(i=this.clickToPayService)||void 0===i||i.initialize())}}T(I,"type",p.scheme),T(I,"defaultProps",R({showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0},n(["type","setComponentRef"]).from(O)));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 i from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as s}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import l from"../internal/ClickToPay/services/create-clicktopay-service.js";import d from"./components/ClickToPayWrapper.js";import u from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import{UIElement as c}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 v,ANALYTICS_UNFOCUS_STR as f,ANALYTICS_VALIDATION_ERROR_STR as b}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as g}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as P}from"../../utils/hasOwnProperty.js";import C,{IMPLEMENTATION_ERROR as S}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as k}from"../../core/Errors/utils.js";import{SF_ErrorCodes as j}from"../../core/Errors/constants.js";import O from"./components/CardInput/defaultProps.js";function T(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function R(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),i.forEach((function(o){T(t,o,e[o])}))}return t}function B(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}class I extends c{setStatus(t,o){var e,i;return(null===(e=this.componentRef)||void 0===e?void 0:e.setStatus)&&this.componentRef.setStatus(t,o),(null===(i=this.clickToPayRef)||void 0===i?void 0:i.setStatus)&&this.clickToPayRef.setStatus(t,o),this}formatProps(t){var o,e,i,r,s,n,a,l,d,u,c,h,m,y,v,f,b,g,P,k;const j=null!==(k=null===(e=t.session)||void 0===e||null===(o=e.configuration)||void 0===o?void 0:o.enableStoreDetails)&&void 0!==k?k:t.enableStoreDetails,T=!(0===(null===(i=t.amount)||void 0===i?void 0:i.value))&&j,I=t.storedPaymentMethodId||t.id,w=I&&(null==t||null===(r=t.supportedShopperInteractions)||void 0===r?void 0:r.includes("Ecommerce"));if(I&&!w)throw new C(S,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");var M,A;return R(B(R({},t),{holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?O.billingAddressMode:t.billingAddressMode,brand:null!==(M=t.brand)&&void 0!==M?M:p.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:B(R({},t.configuration),{socialSecurityNumberMode:null!==(A=null===(s=t.configuration)||void 0===s?void 0:s.socialSecurityNumberMode)&&void 0!==A?A:"auto"}),brandsConfiguration:t.brandsConfiguration||(null===(n=t.configuration)||void 0===n?void 0:n.brandsConfiguration)||{},icon:t.icon||(null===(a=t.configuration)||void 0===a?void 0:a.icon),installmentOptions:(null===(d=t.session)||void 0===d||null===(l=d.configuration)||void 0===l?void 0:l.installmentOptions)||t.installmentOptions,enableStoreDetails:j,showStoreDetailsCheckbox:T,clickToPayConfiguration:B(R({},t.clickToPayConfiguration),{disableOtpAutoFocus:(null===(u=t.clickToPayConfiguration)||void 0===u?void 0:u.disableOtpAutoFocus)||!1,shopperEmail:(null===(c=t.clickToPayConfiguration)||void 0===c?void 0:c.shopperEmail)||(null===(m=this.core.options)||void 0===m||null===(h=m.session)||void 0===h?void 0:h.shopperEmail),telephoneNumber:(null===(y=t.clickToPayConfiguration)||void 0===y?void 0:y.telephoneNumber)||(null===(f=this.core.options)||void 0===f||null===(v=f.session)||void 0===v?void 0:v.telephoneNumber),locale:(null===(b=t.clickToPayConfiguration)||void 0===b?void 0:b.locale)||(null===(P=t.i18n)||void 0===P||null===(g=P.locale)||void 0===g?void 0:g.replace("-","_"))})}),I&&{storedPaymentMethodId:I})}formatData(){const t=this.state.selectedBrandValue;var o;return B(R({paymentMethod:R({type:I.type},this.state.data,this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:null!==(o=this.props.holderName)&&void 0!==o?o:""},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){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.updateStyles)&&this.componentRef.updateStyles(t),this}setFocusOn(t){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.setFocusOn)&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,o=!1){var e;return(null===(e=this.componentRef)||void 0===e?void 0:e.processBinLookupResponse)&&this.componentRef.processBinLookupResponse(t,o),this}handleUnsupportedCard(t){var o;return(null===(o=this.componentRef)||void 0===o?void 0:o.handleUnsupportedCard)&&this.componentRef.handleUnsupportedCard(t),this}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)}get storePaymentMethodPayload(){var t,o;if((null===(t=this.props.storedPaymentMethodId)||void 0===t?void 0:t.length)>0)return{};if(0===(null===(o=this.props.amount)||void 0===o?void 0:o.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(){var t;return null!==(t=this.props.icon)&&void 0!==t?t:this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:o}=this.props;return t?t.map((t=>{var e,i;return{icon:null!==(i=null===(e=o[t])||void 0===e?void 0:e.icon)&&void 0!==i?i: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 i()}renderCardInput(e=!0){return t(o,B(R({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(u,{srPanel:this.props.modules.srPanel},t(d,{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)))))}constructor(o,e){var i;(super(o,e),T(this,"clickToPayService",void 0),T(this,"clickToPayRef",null),T(this,"setClickToPayRef",(t=>{this.clickToPayRef=t})),T(this,"onBrand",(t=>{var o,e;null===(o=(e=this.props).onBrand)||void 0===o||o.call(e,t)})),T(this,"handleClickToPaySubmit",(t=>{this.setState({data:R({},t),valid:{},errors:{},isValid:!0}),this.submit()})),T(this,"onConfigSuccess",(t=>{var o,e;this.submitAnalytics({type:y}),null===(o=(e=this.props).onConfigSuccess)||void 0===o||o.call(e,t)})),T(this,"onFocus",(t=>{var o,e,i,r;(this.submitAnalytics({type:v,target:s(t.fieldType)}),g.includes(t.fieldType))?null===(o=(e=this.props).onFocus)||void 0===o||o.call(e,t.event):null===(i=(r=this.props).onFocus)||void 0===i||i.call(r,t)})),T(this,"onBlur",(t=>{var o,e,i,r;(this.submitAnalytics({type:f,target:s(t.fieldType)}),g.includes(t.fieldType))?null===(o=(e=this.props).onBlur)||void 0===o||o.call(e,t.event):null===(i=(r=this.props).onBlur)||void 0===i||i.call(r,t)})),T(this,"onValidationErrorAnalytics",(t=>{this.submitAnalytics({type:b,target:s(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:k(t.errorCode,j)})})),T(this,"onBinValue",r(this)),T(this,"payButton",(o=>{var e,i;const r=0===(null===(e=this.props.amount)||void 0===e?void 0:e.value),s=(null===(i=this.props.storedPaymentMethodId)||void 0===i?void 0:i.length)>0;return t(h,B(R({},o),{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:r&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit}))})),e&&!e._disableClickToPay)&&(this.clickToPayService=l(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),null===(i=this.clickToPayService)||void 0===i||i.initialize())}}T(I,"type",p.scheme),T(I,"defaultProps",R({showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0},n(["type","setComponentRef"]).from(O)));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","setStatus","status","props","_this_componentRef","_this_clickToPayRef","this","componentRef","clickToPayRef","formatProps","_this_core_options_session","_this_core_options","_this_core_options_session1","_this_core_options1","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","_object_spread","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","_object_spread_props","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","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","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","constructor","hasOwnProperty","isStoredPaymentMethod","super","_this_props_storedPaymentMethodId","_this_props_amount","length","storePaymentMethod","Boolean","isValid","_this_props_icon","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onValidationErrorAnalytics","onConfigSuccess","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","checkout","_this_clickToPayService","_define_property","ref","event","_this_props_onBrand","_this_props","call","payload","valid","errors","_this_props_onConfigSuccess","_this_props_onFocus","_this_props_onFocus1","_this_props1","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","_this_props_onBlur","_this_props_onBlur1","ANALYTICS_UNFOCUS_STR","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"ktEAmCO,MAAMA,UAAoBC,EA2BtBC,SAAAA,CAAUC,EAAyBC,OAClCC,EAGAC,EAGJ,eANID,EAAAE,KAAKC,oBAAL,IAAAH,OAAA,EAAAA,EAAmBH,YACnBK,KAAKC,aAAaN,UAAUC,EAAQC,YAEpCE,EAAAC,KAAKE,qBAAL,IAAAH,OAAA,EAAAA,EAAoBJ,YACpBK,KAAKE,cAAcP,UAAUC,EAAQC,GAElCG,IACX,CAMAG,WAAAA,CAAYN,GAEmBA,IAAAA,EAAAA,EAERA,EAI2BA,EA4BZA,EAEoBA,EAC9BA,EAEAA,EAAAA,EASKA,EACPA,EAA+CO,EAAAC,EAC5CR,EAAkDS,EAAAC,EAC3DV,EAAyCA,EAAAA,EAnD9BA,EAA3B,MAAMW,UAAqBX,UAAAA,EAAAA,EAAMY,eAANZ,IAAAA,GAA4B,QAA5BA,EAAAA,EAAea,yBAAfb,OAAAA,EAAAA,EAA8BW,0BAA9BX,IAAAA,EAAAA,EAAoDA,EAAMW,mBAG/EG,IADqC,KAAxBd,QAAAA,EAAAA,EAAMe,cAANf,IAAAA,OAAAA,EAAAA,EAAcgB,SACqBL,EAEhDM,EAAejB,EAAMkB,uBAAyBlB,EAAMmB,GACpDC,EAAwBH,IAAgBjB,SAAmC,QAAnCA,EAAAA,EAAOqB,oCAAPrB,IAAAA,OAAAA,EAAAA,EAAqCsB,SAAS,cAG5F,GAAIL,IAAiBG,EAEjB,MAAM,IAAIG,EACNC,EACA,2GAeGxB,EAMuBA,EAjBlC,OAAOyB,EACAzB,EAAAA,EAAAA,CAAAA,EAAAA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mB7E,OAChC8J,GAAe,QAAAlF,EAAAzF,KAAKH,MAAMkB,6BAAX,IAAA0E,OAAA,EAAAA,EAAkCE,QAAS,EAChE,OACIkB,EAAC+D,EACO/K,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CACJe,OAAQZ,KAAKH,MAAMe,OACnBiK,gBAAiB7K,KAAKH,MAAMgL,gBAC5BC,MAAOJ,IAAeC,EAAe3K,KAAKH,MAAMmD,KAAKyD,IAAI,yBAA2B,GACpFsE,QAAS/K,KAAKmH,aApSlBtH,IAAUA,EAAMmL,sBAChBhL,KAAKoI,kBAAoB6C,EAAwBjL,KAAKH,MAAMa,cAAeV,KAAKH,MAAM4C,wBAAyBzC,KAAKH,MAAMqL,aACrH,QAAArC,EAAA7I,KAAKoI,yBAAL,IAAAS,GAAAA,EAAwBsC,aAErC,EAhBArC,EADSrJ,EACK8D,OAAOvB,EAAWoJ,QAkBhCtC,EAnBSrJ,EAmBQ4L,eAAe/J,EAAA,CAC5BgK,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,GAEVxG,EAAO,CAAC,OAAQ,oBAAoBC,KAAKjD"}
|
|
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","setStatus","status","props","_this_componentRef","_this_clickToPayRef","this","componentRef","clickToPayRef","formatProps","_this_core_options_session","_this_core_options","_this_core_options_session1","_this_core_options1","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","_object_spread","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","_object_spread_props","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","_this_props_holderName","paymentMethod","type","data","holderName","fundingSource","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","constructor","hasOwnProperty","isStoredPaymentMethod","super","_this_props_storedPaymentMethodId","_this_props_amount","length","storePaymentMethod","Boolean","isValid","_this_props_icon","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onValidationErrorAnalytics","onConfigSuccess","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","checkout","_this_clickToPayService","_define_property","ref","event","_this_props_onBrand","_this_props","call","payload","valid","errors","_this_props_onConfigSuccess","_this_props_onFocus","_this_props_onFocus1","_this_props1","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","_this_props_onBlur","_this_props_onBlur1","ANALYTICS_UNFOCUS_STR","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"ktEAmCO,MAAMA,UAAoBC,EA2BtBC,SAAAA,CAAUC,EAAyBC,OAClCC,EAGAC,EAGJ,eANID,EAAAE,KAAKC,oBAAL,IAAAH,OAAA,EAAAA,EAAmBH,YACnBK,KAAKC,aAAaN,UAAUC,EAAQC,YAEpCE,EAAAC,KAAKE,qBAAL,IAAAH,OAAA,EAAAA,EAAoBJ,YACpBK,KAAKE,cAAcP,UAAUC,EAAQC,GAElCG,IACX,CAMAG,WAAAA,CAAYN,GAEmBA,IAAAA,EAAAA,EAERA,EAI2BA,EA4BZA,EAEoBA,EAC9BA,EAEAA,EAAAA,EASKA,EACPA,EAA+CO,EAAAC,EAC5CR,EAAkDS,EAAAC,EAC3DV,EAAyCA,EAAAA,EAnD9BA,EAA3B,MAAMW,UAAqBX,UAAAA,EAAAA,EAAMY,eAANZ,IAAAA,GAA4B,QAA5BA,EAAAA,EAAea,yBAAfb,OAAAA,EAAAA,EAA8BW,0BAA9BX,IAAAA,EAAAA,EAAoDA,EAAMW,mBAG/EG,IADqC,KAAxBd,QAAAA,EAAAA,EAAMe,cAANf,IAAAA,OAAAA,EAAAA,EAAcgB,SACqBL,EAEhDM,EAAejB,EAAMkB,uBAAyB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AA8B/C,IAClC/E,KAAKmF,gBAAgB,CACjB3B,KAAM6G,EACNP,OAAQC,EAAqBhF,EAAIiF,WACjCM,oBAAqBvF,EAAIwF,UACzBC,uBAAwBC,EAAwB1F,EAAIwF,UAAWG,IACnE,IAGJ1B,EAAOvB,KAAAA,aAAakD,EAAiB3K,OAqErCgJ,EAAAhJ,KAAmBuH,aAAa1H,QACT+F,EACED,EADrB,MAAMiF,EAA0C,KAA7B,QAAAhF,EAAA5F,KAAKH,MAAMe,cAAX,IAAAgF,OAAA,EAAAA,EAAmB/E,OAChCgK,GAAe,QAAAlF,EAAA3F,KAAKH,MAAMkB,6BAAX,IAAA4E,OAAA,EAAAA,EAAkCE,QAAS,EAChE,OACIkB,EAAC+D,EACOjL,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CACJe,OAAQZ,KAAKH,MAAMe,OACnBmK,gBAAiB/K,KAAKH,MAAMkL,gBAC5BC,MAAOJ,IAAeC,EAAe7K,KAAKH,MAAMmD,KAAK2D,IAAI,yBAA2B,GACpFsE,QAASjL,KAAKqH,aAvSlBxH,IAAUA,EAAMqL,sBAChBlL,KAAKsI,kBAAoB6C,EAAwBnL,KAAKH,MAAMa,cAAeV,KAAKH,MAAM4C,wBAAyBzC,KAAKH,MAAMuL,aACrH,QAAArC,EAAA/I,KAAKsI,yBAAL,IAAAS,GAAAA,EAAwBsC,aAErC,EAhBArC,EADSvJ,EACK+D,OAAOxB,EAAWsJ,QAkBhCtC,EAnBSvJ,EAmBQ8L,eAAejK,EAAA,CAC5BkK,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,GAEVxG,EAAO,CAAC,OAAQ,oBAAoBC,KAAKnD"}
|
|
@@ -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":"
|
|
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 r}from"../../internal/UIElement/utils.js";import{ANALYTICS_RENDERED_STR as a}from"../../../core/Analytics/constants.js";import i from"../../../core/Errors/AdyenCheckoutError.js";function d(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function p(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),o.forEach((function(e){d(t,e,s[e])}))}return t}function
|
|
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 r}from"../../internal/UIElement/utils.js";import{ANALYTICS_RENDERED_STR as a}from"../../../core/Analytics/constants.js";import i from"../../../core/Errors/AdyenCheckoutError.js";function d(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function p(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),o.forEach((function(e){d(t,e,s[e])}))}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class l extends t{componentDidMount(){this.prepareDropinData()}get analyticConfigData(){return{openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,showStoredPaymentMethods:this.props.showStoredPaymentMethods}}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()}closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}render(t,{elements:n,instantPaymentElements:r,storedPaymentElements:a,status:i,activePaymentMethod:d,cachedPaymentMethods:p}){const h="loading"===i.type,l="redirect"===i.type,c=(null==n?void 0:n.length)||(null==r?void 0:r.length)||(null==a?void 0:a.length);switch(i.type){case"success":var m,y;return e(o.Success,{message:0===(null==t||null===(m=t.amount)||void 0===m?void 0:m.value)?"resultMessages.preauthorized":null===(y=i.props)||void 0===y?void 0:y.message});case"error":var u;return e(o.Error,{message:null===(u=i.props)||void 0===u?void 0:u.message});case"custom":var P,v;return null===(v=i.props)||void 0===v||null===(P=v.component)||void 0===P?void 0:P.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${i.type}`},l&&i.props.component&&i.props.component.render(),h&&i.props&&i.props.component&&i.props.component.render(),!!c&&e(s,{isLoading:h||l,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:n,instantPaymentMethods:r,storedPaymentMethods:a,activePaymentMethod:d,cachedPaymentMethods:p,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}))}}constructor(...t){super(...t),d(this,"state",{elements:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{}}),d(this,"prepareDropinData",(()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[o,r,i]=this.props.onCreateElements(),d=t?n({clientKey:e,loadingContext:s},t):null;Promise.all([o,r,i,d]).then((([t,e,s,o])=>{var n;this.setState({instantPaymentElements:s,elements:e,storedPaymentElements:t,orderStatus:o}),this.setStatus("ready"),null===(n=this.props.modules)||void 0===n||n.analytics.sendAnalytics("dropin",{type:a,configData:this.analyticConfigData})})),this.onOrderCancel=this.getOnOrderCancel()})),d(this,"setStatus",((t,e={})=>{this.setState({status:{type:t,props:e}})})),d(this,"setActivePaymentMethod",(t=>{this.setState((e=>({activePaymentMethod:t,cachedPaymentMethods:h(p({},e.cachedPaymentMethods),{[t._id]:!0})})))})),d(this,"handleOnSelectPaymentMethod",(t=>{const{activePaymentMethod:e}=this.state;var s,o;(this.setActivePaymentMethod(t),e&&e._id!==t._id||!e)&&(null===(s=(o=this.props).onSelect)||void 0===s||s.call(o,t),t.submitAnalytics({type:a}))})),d(this,"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})}))})),d(this,"getOnOrderCancel",(()=>this.props.onOrderCancel?t=>{const e=r(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((null==t?void 0:t.message)||"error")})):null)),d(this,"onOrderCancel",void 0)}}export{l as DropinComponent,l as default};
|
|
2
2
|
//# sourceMappingURL=DropinComponent.js.map
|