@adyen/adyen-web 6.1.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +20 -4
  4. package/dist/es/components/ApplePay/ApplePayService.js +1 -1
  5. package/dist/es/components/ApplePay/ApplePayService.js.map +1 -1
  6. package/dist/es/components/Card/Card.js +1 -1
  7. package/dist/es/components/Card/Card.js.map +1 -1
  8. package/dist/es/components/Card/components/CardInput/defaultProps.js +1 -1
  9. package/dist/es/components/Card/components/CardInput/defaultProps.js.map +1 -1
  10. package/dist/es/components/Dropin/elements/createElements.js +1 -1
  11. package/dist/es/components/Dropin/elements/createElements.js.map +1 -1
  12. package/dist/es/components/Dropin/elements/filters.js +1 -1
  13. package/dist/es/components/Dropin/elements/filters.js.map +1 -1
  14. package/dist/es/components/components-name-map.js +1 -1
  15. package/dist/es/components/components-name-map.js.map +1 -1
  16. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  17. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  18. package/dist/es/core/Analytics/Analytics.js +1 -1
  19. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  20. package/dist/es/core/Analytics/constants.js +1 -1
  21. package/dist/es/core/Analytics/constants.js.map +1 -1
  22. package/dist/es/core/Analytics/utils.js +1 -1
  23. package/dist/es/core/Analytics/utils.js.map +1 -1
  24. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  25. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  26. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  27. package/dist/es/core/Services/sessions/setup-session.js +1 -1
  28. package/dist/es/core/Services/sessions/setup-session.js.map +1 -1
  29. package/dist/es/core/core.js +1 -1
  30. package/dist/es/index.d.ts +20 -4
  31. package/dist/es-legacy/components/ApplePay/ApplePayService.js +1 -1
  32. package/dist/es-legacy/components/ApplePay/ApplePayService.js.map +1 -1
  33. package/dist/es-legacy/components/Card/Card.js +1 -1
  34. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  35. package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js +1 -1
  36. package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js.map +1 -1
  37. package/dist/es-legacy/components/Dropin/elements/createElements.js +1 -1
  38. package/dist/es-legacy/components/Dropin/elements/createElements.js.map +1 -1
  39. package/dist/es-legacy/components/Dropin/elements/filters.js +1 -1
  40. package/dist/es-legacy/components/Dropin/elements/filters.js.map +1 -1
  41. package/dist/es-legacy/components/components-name-map.js +1 -1
  42. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  43. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  44. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  45. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  46. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  47. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  48. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  49. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  50. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  51. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
  52. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  53. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  54. package/dist/es-legacy/core/Services/sessions/setup-session.js +1 -1
  55. package/dist/es-legacy/core/Services/sessions/setup-session.js.map +1 -1
  56. package/dist/es-legacy/core/core.js +1 -1
  57. package/package.json +3 -2
  58. package/styles/adyen.css +84 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject, processAnalyticsData } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n checkoutAttemptId: null,\n analyticsData: {}\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(() => void sendAnalyticsEvents(), ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n /**\n * Make \"setup\" call, to pass containerWidth, buildType, channel etc, and receive a checkoutAttemptId in return\n * @param initialEvent -\n */\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { enabled, payload } = props; // TODO what is payload, is it ever used?\n\n const analyticsData = processAnalyticsData(props.analyticsData);\n\n if (enabled === true && !capturedCheckoutAttemptId) {\n try {\n const checkoutAttemptId = await collectId({\n ...initialEvent,\n ...(payload && { ...payload }),\n ...(Object.keys(analyticsData).length && { ...analyticsData })\n });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e: any) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject): AnalyticsObject => {\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n\n return aObj;\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = analyticsPreProcessor(anlModule);\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","sendEventsTimerId","Analytics","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","enabled","checkoutAttemptId","analyticsData","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","processAnalyticsData","Object","keys","length","e","console","warn","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","aObj","createAnalyticsObject","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"ubASA,IAAIA,EAA4B,KAC5BC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzE,MAMMC,EAAQ,CALVC,SAAS,EACTC,kBAAmB,KACnBC,cAAe,CAAC,KAGgBP,GAE9BQ,EAAYC,EAAU,CAAEP,mBAAkBH,YAAWD,SAAQG,SAAQS,cAAeC,EAAgBR,eACpGS,EAAiCC,EAAY,CAAEX,mBAAkBH,YAAWW,cAAeC,IAE3FG,EAAsB,IACpBnB,EACOiB,EAAYG,IAAIpB,GAEpBqB,QAAQC,QAAQ,MA8BrBC,EAA6B,CAK/BC,MAAOC,MAAOC,IACV,MAAMhB,QAAEA,EAAOiB,QAAEA,GAAYlB,EAEvBG,EAAgBgB,EAAqBnB,EAAMG,eAEjD,IAAgB,IAAZF,IAAqBV,EACrB,IACI,MAAMW,QAA0BE,EAAU,IACnCa,KACCC,GAAW,IAAKA,MAChBE,OAAOC,KAAKlB,GAAemB,QAAU,IAAKnB,KAElDZ,EAA4BW,CAChC,CAAE,MAAOqB,GACLC,QAAQC,KAAK,sCAAqCF,EAAI,UAAUA,IAAM,IAC1E,CACJ,EAGJG,qBAAsB,IAAcnC,EAGpCoC,eAAgB,IAAMnB,EAEtBoB,qBAAsB,EAAGC,QAAOC,WAC5B,MAAMC,EAAwBC,EAAsB,CAChDH,WACGC,IAMP,MAjEkB,EAACG,EAAuBC,KAC9C,MAAMC,EAAYF,IAASG,EAAuBH,EAAO,GAAGA,KAC5DzB,EAAY6B,IAAI,GAAGF,IAAaD,GAO5BD,IAASG,IACTE,aAAa9C,GACbA,EAAoB+C,YAAW,KAAW7B,GAAuB8B,GAAAA,IASjEP,IAASQ,GAAuBR,IAASS,IACzCJ,aAAa9C,GAEbmD,EAASjC,EAATiC,GACJ,EAuCIC,CAAkBf,EAAOE,GAElBA,CAAAA,EAGXc,WAAY,IAAM7C,EAAMC,QAExB6C,cAAe,MAKnB,OAFAhC,EAAUgC,cAAgBC,EAAsBjC,GAEzCA,CAAAA"}
1
+ {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject, processAnalyticsData } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n checkoutAttemptId: null,\n analyticsData: {}\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(() => void sendAnalyticsEvents(), ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n /**\n * Make \"setup\" call, to pass containerWidth, buildType, channel etc, and receive a checkoutAttemptId in return\n * @param initialEvent -\n */\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { payload } = props; // TODO what is payload, is it ever used?\n\n const analyticsData = processAnalyticsData(props.analyticsData);\n\n if (!capturedCheckoutAttemptId) {\n try {\n const checkoutAttemptId = await collectId({\n ...initialEvent,\n ...(payload && { ...payload }),\n ...(Object.keys(analyticsData).length && { ...analyticsData })\n });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e: any) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject): AnalyticsObject => {\n if (!props.enabled) return;\n\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n\n return aObj;\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = props.enabled === true ? analyticsPreProcessor(anlModule) : () => {};\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","sendEventsTimerId","Analytics","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","enabled","checkoutAttemptId","analyticsData","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","processAnalyticsData","Object","keys","length","e","console","warn","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","aObj","createAnalyticsObject","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"ubASA,IAAIA,EAA4B,KAC5BC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzE,MAMMC,EAAQ,CALVC,SAAS,EACTC,kBAAmB,KACnBC,cAAe,CAAC,KAGgBP,GAE9BQ,EAAYC,EAAU,CAAEP,mBAAkBH,YAAWD,SAAQG,SAAQS,cAAeC,EAAgBR,eACpGS,EAAiCC,EAAY,CAAEX,mBAAkBH,YAAWW,cAAeC,IAE3FG,EAAsB,IACpBnB,EACOiB,EAAYG,IAAIpB,GAEpBqB,QAAQC,QAAQ,MA8BrBC,EAA6B,CAK/BC,MAAOC,MAAOC,IACV,MAAMC,QAAEA,GAAYlB,EAEdG,EAAgBgB,EAAqBnB,EAAMG,eAEjD,IAAKZ,EACD,IACI,MAAMW,QAA0BE,EAAU,IACnCa,KACCC,GAAW,IAAKA,MAChBE,OAAOC,KAAKlB,GAAemB,QAAU,IAAKnB,KAElDZ,EAA4BW,CAChC,CAAE,MAAOqB,GACLC,QAAQC,KAAK,sCAAqCF,EAAI,UAAUA,IAAM,IAC1E,CACJ,EAGJG,qBAAsB,IAAcnC,EAGpCoC,eAAgB,IAAMnB,EAEtBoB,qBAAsB,EAAGC,QAAOC,WAC5B,IAAK9B,EAAMC,QAAS,OAEpB,MAAM8B,EAAwBC,EAAsB,CAChDH,WACGC,IAMP,MAnEkB,EAACG,EAAuBC,KAC9C,MAAMC,EAAYF,IAASG,EAAuBH,EAAO,GAAGA,KAC5DzB,EAAY6B,IAAI,GAAGF,IAAaD,GAO5BD,IAASG,IACTE,aAAa9C,GACbA,EAAoB+C,YAAW,KAAW7B,GAAuB8B,GAAAA,IASjEP,IAASQ,GAAuBR,IAASS,IACzCJ,aAAa9C,GAEbmD,EAASjC,EAATiC,GACJ,EAyCIC,CAAkBf,EAAOE,GAElBA,CAAAA,EAGXc,WAAY,IAAM7C,EAAMC,QAExB6C,cAAe,MAKnB,OAFAhC,EAAUgC,eAAkC,IAAlB9C,EAAMC,QAAmB8C,EAAsBjC,GAAa,OAE/EA,CAAAA"}
@@ -1,2 +1,2 @@
1
- import{CREDITCARD_HOLDER_NAME_INVALID as _,CREDITCARD_TAX_NUMBER_INVALID as e,BOLETO_SOCIAL_SECURITY_NUMBER_INVALID as E,ERROR_FIELD_REQUIRED as t,ERROR_INVALID_FORMAT_EXPECTS as o}from"../Errors/constants.js";const r="v3/analytics",n=1e4,I=3e3,N="log",T="error",S="info",a="action",O="submit",i="selected",A="rendered",c="displayed",R="input",d="download",s="validationError",L="focus",l="unfocus",D="configured",p="qr_download_button",u="instant_payment_button",C="featured_issuer",f="list",G="list_search",M="ApiError",m="SdkError",P="Network";var F,H;!function(_){_.ACTION_IS_MISSING_PAYMENT_DATA="700",_.ACTION_IS_MISSING_TOKEN="701",_.TOKEN_IS_MISSING_THREEDSMETHODURL="702",_.TOKEN_IS_MISSING_OTHER_PROPS="703",_.TOKEN_DECODE_OR_PARSING_FAILED="704",_.THREEDS2_TIMEOUT="705",_.TOKEN_IS_MISSING_ACSURL="800",_.NO_TRANSSTATUS="801",_.NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED="802",_.NO_COMPONENT_FOR_ACTION="803",_.NO_ACTION_FOR_CHALLENGE="804",_.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP="805"}(F||(F={})),function(_){_.FINGERPRINT_DATA_SENT="fingerprintDataSentWeb",_.FINGERPRINT_IFRAME_LOADED="fingerprintIframeLoaded",_.FINGERPRINT_COMPLETED="fingerprintCompleted",_.CHALLENGE_DATA_SENT="challengeDataSentWeb",_.CHALLENGE_IFRAME_LOADED="challengeIframeLoaded",_.CHALLENGE_COMPLETED="challengeCompleted"}(H||(H={}));const g={[_]:"925",[e]:"942",[E]:"926",[`${t}.country`]:"930",[`${t}.street`]:"931",[`${t}.house_number_or_name`]:"932",[`${t}.postal_code`]:"933",[`${t}.city`]:"935",[`${t}.state_or_province`]:"936",[`${o}.postal_code`]:"934"},h=["cart","minicart","pdp","checkout"],U=["applicationInfo","checkoutAttemptId"];export{U as ALLOWED_ANALYTICS_DATA,a as ANALYTICS_ACTION_STR,M as ANALYTICS_API_ERROR,D as ANALYTICS_CONFIGURED_STR,c as ANALYTICS_DISPLAYED_STR,d as ANALYTICS_DOWNLOAD_STR,T as ANALYTICS_EVENT_ERROR,S as ANALYTICS_EVENT_INFO,N as ANALYTICS_EVENT_LOG,h as ANALYTICS_EXPRESS_PAGES_ARRAY,C as ANALYTICS_FEATURED_ISSUER,L as ANALYTICS_FOCUS_STR,n as ANALYTICS_INFO_TIMER_INTERVAL,R as ANALYTICS_INPUT_STR,u as ANALYTICS_INSTANT_PAYMENT_BUTTON,f as ANALYTICS_LIST,G as ANALYTICS_LIST_SEARCH,P as ANALYTICS_NETWORK_ERROR,r as ANALYTICS_PATH,p as ANALYTICS_QR_CODE_DOWNLOAD,A as ANALYTICS_RENDERED_STR,m as ANALYTICS_SDK_ERROR,I as ANALYTICS_SEARCH_DEBOUNCE_TIME,i as ANALYTICS_SELECTED_STR,O as ANALYTICS_SUBMIT_STR,l as ANALYTICS_UNFOCUS_STR,s as ANALYTICS_VALIDATION_ERROR_STR,F as Analytics3DS2Errors,H as Analytics3DS2Events,g as errorCodeMapping};
1
+ import{CREDITCARD_HOLDER_NAME_INVALID as _,CREDITCARD_TAX_NUMBER_INVALID as e,BOLETO_SOCIAL_SECURITY_NUMBER_INVALID as t,ERROR_FIELD_REQUIRED as E,ERROR_INVALID_FORMAT_EXPECTS as o}from"../Errors/constants.js";const r="v3/analytics",n=1e4,I=3e3,N="log",T="error",a="info",S="action",O="submit",c="selected",i="rendered",A="displayed",R="input",d="download",s="validationError",L="focus",l="unfocus",p="configured",D="qr_download_button",u="instant_payment_button",C="featured_issuer",f="list",G="list_search",m="ApiError",M="SdkError",P="Network";var F,H;!function(_){_.ACTION_IS_MISSING_PAYMENT_DATA="700",_.ACTION_IS_MISSING_TOKEN="701",_.TOKEN_IS_MISSING_THREEDSMETHODURL="702",_.TOKEN_IS_MISSING_OTHER_PROPS="703",_.TOKEN_DECODE_OR_PARSING_FAILED="704",_.THREEDS2_TIMEOUT="705",_.TOKEN_IS_MISSING_ACSURL="800",_.NO_TRANSSTATUS="801",_.NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED="802",_.NO_COMPONENT_FOR_ACTION="803",_.NO_ACTION_FOR_CHALLENGE="804",_.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP="805"}(F||(F={})),function(_){_.FINGERPRINT_DATA_SENT="fingerprintDataSentWeb",_.FINGERPRINT_IFRAME_LOADED="fingerprintIframeLoaded",_.FINGERPRINT_COMPLETED="fingerprintCompleted",_.CHALLENGE_DATA_SENT="challengeDataSentWeb",_.CHALLENGE_IFRAME_LOADED="challengeIframeLoaded",_.CHALLENGE_COMPLETED="challengeCompleted"}(H||(H={}));const h={[_]:"925",[e]:"942",[t]:"926",[`${E}.country`]:"930",[`${E}.street`]:"931",[`${E}.house_number_or_name`]:"932",[`${E}.postal_code`]:"933",[`${E}.city`]:"935",[`${E}.state_or_province`]:"936",[`${o}.postal_code`]:"934"},g=["cart","minicart","pdp","checkout"],U=["applicationInfo","checkoutAttemptId"],$="fetch-checkoutAttemptId-failed";export{U as ALLOWED_ANALYTICS_DATA,S as ANALYTICS_ACTION_STR,m as ANALYTICS_API_ERROR,p as ANALYTICS_CONFIGURED_STR,A as ANALYTICS_DISPLAYED_STR,d as ANALYTICS_DOWNLOAD_STR,T as ANALYTICS_EVENT_ERROR,a as ANALYTICS_EVENT_INFO,N as ANALYTICS_EVENT_LOG,g as ANALYTICS_EXPRESS_PAGES_ARRAY,C as ANALYTICS_FEATURED_ISSUER,L as ANALYTICS_FOCUS_STR,n as ANALYTICS_INFO_TIMER_INTERVAL,R as ANALYTICS_INPUT_STR,u as ANALYTICS_INSTANT_PAYMENT_BUTTON,f as ANALYTICS_LIST,G as ANALYTICS_LIST_SEARCH,P as ANALYTICS_NETWORK_ERROR,r as ANALYTICS_PATH,D as ANALYTICS_QR_CODE_DOWNLOAD,i as ANALYTICS_RENDERED_STR,M as ANALYTICS_SDK_ERROR,I as ANALYTICS_SEARCH_DEBOUNCE_TIME,c as ANALYTICS_SELECTED_STR,O as ANALYTICS_SUBMIT_STR,l as ANALYTICS_UNFOCUS_STR,s as ANALYTICS_VALIDATION_ERROR_STR,F as Analytics3DS2Errors,H as Analytics3DS2Events,$ as NO_CHECKOUT_ATTEMPT_ID,h as errorCodeMapping};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/core/Analytics/constants.ts"],"sourcesContent":["import {\n BOLETO_SOCIAL_SECURITY_NUMBER_INVALID,\n CREDITCARD_HOLDER_NAME_INVALID,\n CREDITCARD_TAX_NUMBER_INVALID,\n ERROR_FIELD_REQUIRED,\n ERROR_INVALID_FORMAT_EXPECTS\n} from '../Errors/constants';\n\nexport const ANALYTICS_PATH = 'v3/analytics';\n\nexport const ANALYTICS_INFO_TIMER_INTERVAL = process.env.NODE_ENV === 'development' ? 5000 : 10000;\n\nexport const ANALYTICS_SEARCH_DEBOUNCE_TIME = 3000;\n\nexport const ANALYTICS_EVENT_LOG = 'log';\nexport const ANALYTICS_EVENT_ERROR = 'error';\nexport const ANALYTICS_EVENT_INFO = 'info';\n\nexport const ANALYTICS_ACTION_STR = 'action';\nexport const ANALYTICS_SUBMIT_STR = 'submit';\nexport const ANALYTICS_SELECTED_STR = 'selected';\nexport const ANALYTICS_RENDERED_STR = 'rendered';\nexport const ANALYTICS_DISPLAYED_STR = 'displayed';\nexport const ANALYTICS_INPUT_STR = 'input';\n\nexport const ANALYTICS_DOWNLOAD_STR = 'download';\n\nexport const ANALYTICS_VALIDATION_ERROR_STR = 'validationError';\n\nexport const ANALYTICS_FOCUS_STR = 'focus';\nexport const ANALYTICS_UNFOCUS_STR = 'unfocus';\n\nexport const ANALYTICS_CONFIGURED_STR = 'configured';\n\nexport const ANALYTICS_QR_CODE_DOWNLOAD = 'qr_download_button';\n\nexport const ANALYTICS_INSTANT_PAYMENT_BUTTON = 'instant_payment_button';\nexport const ANALYTICS_FEATURED_ISSUER = 'featured_issuer';\nexport const ANALYTICS_LIST = 'list';\nexport const ANALYTICS_LIST_SEARCH = 'list_search';\n\nexport const ANALYTICS_IMPLEMENTATION_ERROR = 'ImplementationError';\nexport const ANALYTICS_API_ERROR = 'ApiError';\nexport const ANALYTICS_SDK_ERROR = 'SdkError';\nexport const ANALYTICS_NETWORK_ERROR = 'Network';\n\nexport enum Analytics3DS2Errors {\n ACTION_IS_MISSING_PAYMENT_DATA = '700', // Missing 'paymentData' property from threeDS2 action\n ACTION_IS_MISSING_TOKEN = '701', // Missing 'token' property from threeDS2 action\n TOKEN_IS_MISSING_THREEDSMETHODURL = '702', // Decoded token is missing a valid threeDSMethodURL property\n\n /**\n * Decoded token is missing one or more of the following properties:\n * fingerprint: (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * challenge: (acsTransID | messageVersion | threeDSServerTransID)\n */\n TOKEN_IS_MISSING_OTHER_PROPS = '703',\n\n TOKEN_DECODE_OR_PARSING_FAILED = '704', // token decoding or parsing has failed. ('not base64', 'malformed URI sequence' or 'Could not JSON parse token')\n THREEDS2_TIMEOUT = '705', // 3DS2 process has timed out\n\n TOKEN_IS_MISSING_ACSURL = '800', // Decoded token is missing a valid acsURL property\n NO_TRANSSTATUS = '801', // Challenge has resulted in an error (no transStatus could be retrieved by the backend)\n NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED = '802', // callSubmit3DS2Fingerprint has received a response indicating either a \"frictionless\" flow, or a \"refused\" response, but without a details object\n NO_COMPONENT_FOR_ACTION = '803', // callSubmit3DS2Fingerprint cannot find a component to handle the action response\n NO_ACTION_FOR_CHALLENGE = '804', // callSubmit3DS2Fingerprint has received a response indicating a \"challenge\" but without an action object\n CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP = '805' // The challenge process has happened, an object has been returned, parsed & accepted as legit, but the result prop on that object is either missing or doesn't have a transStatus prop\n}\n\nexport enum Analytics3DS2Events {\n FINGERPRINT_DATA_SENT = 'fingerprintDataSentWeb',\n FINGERPRINT_IFRAME_LOADED = 'fingerprintIframeLoaded',\n FINGERPRINT_COMPLETED = 'fingerprintCompleted',\n CHALLENGE_DATA_SENT = 'challengeDataSentWeb',\n CHALLENGE_IFRAME_LOADED = 'challengeIframeLoaded',\n CHALLENGE_COMPLETED = 'challengeCompleted'\n}\n\n/**\n * Function to map errorCodes based on translation keys to the codes expected by the analytics endpoint\n */\nexport const errorCodeMapping: Record<string, string> = {\n [CREDITCARD_HOLDER_NAME_INVALID]: '925',\n [CREDITCARD_TAX_NUMBER_INVALID]: '942',\n //\n [BOLETO_SOCIAL_SECURITY_NUMBER_INVALID]: '926',\n //\n [`${ERROR_FIELD_REQUIRED}.country`]: '930',\n [`${ERROR_FIELD_REQUIRED}.street`]: '931',\n [`${ERROR_FIELD_REQUIRED}.house_number_or_name`]: '932',\n [`${ERROR_FIELD_REQUIRED}.postal_code`]: '933',\n [`${ERROR_FIELD_REQUIRED}.city`]: '935',\n [`${ERROR_FIELD_REQUIRED}.state_or_province`]: '936',\n //\n [`${ERROR_INVALID_FORMAT_EXPECTS}.postal_code`]: '934'\n //\n};\n\nexport const ANALYTICS_EXPRESS_PAGES_ARRAY = ['cart', 'minicart', 'pdp', 'checkout'];\n\nexport const ALLOWED_ANALYTICS_DATA = ['applicationInfo', 'checkoutAttemptId'];\n"],"names":["ANALYTICS_PATH","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_SEARCH_DEBOUNCE_TIME","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","ANALYTICS_EVENT_INFO","ANALYTICS_ACTION_STR","ANALYTICS_SUBMIT_STR","ANALYTICS_SELECTED_STR","ANALYTICS_RENDERED_STR","ANALYTICS_DISPLAYED_STR","ANALYTICS_INPUT_STR","ANALYTICS_DOWNLOAD_STR","ANALYTICS_VALIDATION_ERROR_STR","ANALYTICS_FOCUS_STR","ANALYTICS_UNFOCUS_STR","ANALYTICS_CONFIGURED_STR","ANALYTICS_QR_CODE_DOWNLOAD","ANALYTICS_INSTANT_PAYMENT_BUTTON","ANALYTICS_FEATURED_ISSUER","ANALYTICS_LIST","ANALYTICS_LIST_SEARCH","ANALYTICS_API_ERROR","ANALYTICS_SDK_ERROR","ANALYTICS_NETWORK_ERROR","Analytics3DS2Errors","Analytics3DS2Events","errorCodeMapping","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","ANALYTICS_EXPRESS_PAGES_ARRAY","ALLOWED_ANALYTICS_DATA"],"mappings":"kNAQO,MAAMA,EAAiB,eAEjBC,EAAgF,IAEhFC,EAAiC,IAEjCC,EAAsB,MACtBC,EAAwB,QACxBC,EAAuB,OAEvBC,EAAuB,SACvBC,EAAuB,SACvBC,EAAyB,WACzBC,EAAyB,WACzBC,EAA0B,YAC1BC,EAAsB,QAEtBC,EAAyB,WAEzBC,EAAiC,kBAEjCC,EAAsB,QACtBC,EAAwB,UAExBC,EAA2B,aAE3BC,EAA6B,qBAE7BC,EAAmC,yBACnCC,EAA4B,kBAC5BC,EAAiB,OACjBC,EAAwB,cAGxBC,EAAsB,WACtBC,EAAsB,WACtBC,EAA0B,mBAE3BC,SAAAA,oHASPA,EAAA,6BAAA,2RATOA,CAAAA,IAAAA,EAAAA,CAAAA,IAuBAC,SAAAA,mSAAAA,CAAAA,IAAAA,EAAAA,CAAAA,UAYCC,EAA2C,CACpDC,CAACA,GAAiC,MAClCC,CAACA,GAAgC,MAEjCC,CAACA,GAAwC,MAEzC,CAAC,GAAGC,aAAiC,MACrC,CAAC,GAAGA,YAAgC,MACpC,CAAC,GAAGA,0BAA8C,MAClD,CAAC,GAAGA,iBAAqC,MACzC,CAAC,GAAGA,UAA8B,MAClC,CAAC,GAAGA,uBAA2C,MAE/C,CAAC,GAAGC,iBAA6C,OAIxCC,EAAgC,CAAC,OAAQ,WAAY,MAAO,YAE5DC,EAAyB,CAAC,kBAAmB"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/core/Analytics/constants.ts"],"sourcesContent":["import {\n BOLETO_SOCIAL_SECURITY_NUMBER_INVALID,\n CREDITCARD_HOLDER_NAME_INVALID,\n CREDITCARD_TAX_NUMBER_INVALID,\n ERROR_FIELD_REQUIRED,\n ERROR_INVALID_FORMAT_EXPECTS\n} from '../Errors/constants';\n\nexport const ANALYTICS_PATH = 'v3/analytics';\n\nexport const ANALYTICS_INFO_TIMER_INTERVAL = process.env.NODE_ENV === 'development' ? 5000 : 10000;\n\nexport const ANALYTICS_SEARCH_DEBOUNCE_TIME = 3000;\n\nexport const ANALYTICS_EVENT_LOG = 'log';\nexport const ANALYTICS_EVENT_ERROR = 'error';\nexport const ANALYTICS_EVENT_INFO = 'info';\n\nexport const ANALYTICS_ACTION_STR = 'action';\nexport const ANALYTICS_SUBMIT_STR = 'submit';\nexport const ANALYTICS_SELECTED_STR = 'selected';\nexport const ANALYTICS_RENDERED_STR = 'rendered';\nexport const ANALYTICS_DISPLAYED_STR = 'displayed';\nexport const ANALYTICS_INPUT_STR = 'input';\n\nexport const ANALYTICS_DOWNLOAD_STR = 'download';\n\nexport const ANALYTICS_VALIDATION_ERROR_STR = 'validationError';\n\nexport const ANALYTICS_FOCUS_STR = 'focus';\nexport const ANALYTICS_UNFOCUS_STR = 'unfocus';\n\nexport const ANALYTICS_CONFIGURED_STR = 'configured';\n\nexport const ANALYTICS_QR_CODE_DOWNLOAD = 'qr_download_button';\n\nexport const ANALYTICS_INSTANT_PAYMENT_BUTTON = 'instant_payment_button';\nexport const ANALYTICS_FEATURED_ISSUER = 'featured_issuer';\nexport const ANALYTICS_LIST = 'list';\nexport const ANALYTICS_LIST_SEARCH = 'list_search';\n\nexport const ANALYTICS_IMPLEMENTATION_ERROR = 'ImplementationError';\nexport const ANALYTICS_API_ERROR = 'ApiError';\nexport const ANALYTICS_SDK_ERROR = 'SdkError';\nexport const ANALYTICS_NETWORK_ERROR = 'Network';\n\nexport enum Analytics3DS2Errors {\n ACTION_IS_MISSING_PAYMENT_DATA = '700', // Missing 'paymentData' property from threeDS2 action\n ACTION_IS_MISSING_TOKEN = '701', // Missing 'token' property from threeDS2 action\n TOKEN_IS_MISSING_THREEDSMETHODURL = '702', // Decoded token is missing a valid threeDSMethodURL property\n\n /**\n * Decoded token is missing one or more of the following properties:\n * fingerprint: (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * challenge: (acsTransID | messageVersion | threeDSServerTransID)\n */\n TOKEN_IS_MISSING_OTHER_PROPS = '703',\n\n TOKEN_DECODE_OR_PARSING_FAILED = '704', // token decoding or parsing has failed. ('not base64', 'malformed URI sequence' or 'Could not JSON parse token')\n THREEDS2_TIMEOUT = '705', // 3DS2 process has timed out\n\n TOKEN_IS_MISSING_ACSURL = '800', // Decoded token is missing a valid acsURL property\n NO_TRANSSTATUS = '801', // Challenge has resulted in an error (no transStatus could be retrieved by the backend)\n NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED = '802', // callSubmit3DS2Fingerprint has received a response indicating either a \"frictionless\" flow, or a \"refused\" response, but without a details object\n NO_COMPONENT_FOR_ACTION = '803', // callSubmit3DS2Fingerprint cannot find a component to handle the action response\n NO_ACTION_FOR_CHALLENGE = '804', // callSubmit3DS2Fingerprint has received a response indicating a \"challenge\" but without an action object\n CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP = '805' // The challenge process has happened, an object has been returned, parsed & accepted as legit, but the result prop on that object is either missing or doesn't have a transStatus prop\n}\n\nexport enum Analytics3DS2Events {\n FINGERPRINT_DATA_SENT = 'fingerprintDataSentWeb',\n FINGERPRINT_IFRAME_LOADED = 'fingerprintIframeLoaded',\n FINGERPRINT_COMPLETED = 'fingerprintCompleted',\n CHALLENGE_DATA_SENT = 'challengeDataSentWeb',\n CHALLENGE_IFRAME_LOADED = 'challengeIframeLoaded',\n CHALLENGE_COMPLETED = 'challengeCompleted'\n}\n\n/**\n * Function to map errorCodes based on translation keys to the codes expected by the analytics endpoint\n */\nexport const errorCodeMapping: Record<string, string> = {\n [CREDITCARD_HOLDER_NAME_INVALID]: '925',\n [CREDITCARD_TAX_NUMBER_INVALID]: '942',\n //\n [BOLETO_SOCIAL_SECURITY_NUMBER_INVALID]: '926',\n //\n [`${ERROR_FIELD_REQUIRED}.country`]: '930',\n [`${ERROR_FIELD_REQUIRED}.street`]: '931',\n [`${ERROR_FIELD_REQUIRED}.house_number_or_name`]: '932',\n [`${ERROR_FIELD_REQUIRED}.postal_code`]: '933',\n [`${ERROR_FIELD_REQUIRED}.city`]: '935',\n [`${ERROR_FIELD_REQUIRED}.state_or_province`]: '936',\n //\n [`${ERROR_INVALID_FORMAT_EXPECTS}.postal_code`]: '934'\n //\n};\n\nexport const ANALYTICS_EXPRESS_PAGES_ARRAY = ['cart', 'minicart', 'pdp', 'checkout'];\n\nexport const ALLOWED_ANALYTICS_DATA = ['applicationInfo', 'checkoutAttemptId'];\n\nexport const NO_CHECKOUT_ATTEMPT_ID = 'fetch-checkoutAttemptId-failed';\n"],"names":["ANALYTICS_PATH","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_SEARCH_DEBOUNCE_TIME","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","ANALYTICS_EVENT_INFO","ANALYTICS_ACTION_STR","ANALYTICS_SUBMIT_STR","ANALYTICS_SELECTED_STR","ANALYTICS_RENDERED_STR","ANALYTICS_DISPLAYED_STR","ANALYTICS_INPUT_STR","ANALYTICS_DOWNLOAD_STR","ANALYTICS_VALIDATION_ERROR_STR","ANALYTICS_FOCUS_STR","ANALYTICS_UNFOCUS_STR","ANALYTICS_CONFIGURED_STR","ANALYTICS_QR_CODE_DOWNLOAD","ANALYTICS_INSTANT_PAYMENT_BUTTON","ANALYTICS_FEATURED_ISSUER","ANALYTICS_LIST","ANALYTICS_LIST_SEARCH","ANALYTICS_API_ERROR","ANALYTICS_SDK_ERROR","ANALYTICS_NETWORK_ERROR","Analytics3DS2Errors","Analytics3DS2Events","errorCodeMapping","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","ANALYTICS_EXPRESS_PAGES_ARRAY","ALLOWED_ANALYTICS_DATA","NO_CHECKOUT_ATTEMPT_ID"],"mappings":"kNAQO,MAAMA,EAAiB,eAEjBC,EAAgF,IAEhFC,EAAiC,IAEjCC,EAAsB,MACtBC,EAAwB,QACxBC,EAAuB,OAEvBC,EAAuB,SACvBC,EAAuB,SACvBC,EAAyB,WACzBC,EAAyB,WACzBC,EAA0B,YAC1BC,EAAsB,QAEtBC,EAAyB,WAEzBC,EAAiC,kBAEjCC,EAAsB,QACtBC,EAAwB,UAExBC,EAA2B,aAE3BC,EAA6B,qBAE7BC,EAAmC,yBACnCC,EAA4B,kBAC5BC,EAAiB,OACjBC,EAAwB,cAGxBC,EAAsB,WACtBC,EAAsB,WACtBC,EAA0B,mBAE3BC,SAAAA,oHASPA,EAAA,6BAAA,2RATOA,CAAAA,IAAAA,EAAAA,CAAAA,IAuBAC,SAAAA,mSAAAA,CAAAA,IAAAA,EAAAA,CAAAA,UAYCC,EAA2C,CACpDC,CAACA,GAAiC,MAClCC,CAACA,GAAgC,MAEjCC,CAACA,GAAwC,MAEzC,CAAC,GAAGC,aAAiC,MACrC,CAAC,GAAGA,YAAgC,MACpC,CAAC,GAAGA,0BAA8C,MAClD,CAAC,GAAGA,iBAAqC,MACzC,CAAC,GAAGA,UAA8B,MAClC,CAAC,GAAGA,uBAA2C,MAE/C,CAAC,GAAGC,iBAA6C,OAIxCC,EAAgC,CAAC,OAAQ,WAAY,MAAO,YAE5DC,EAAyB,CAAC,kBAAmB,qBAE7CC,EAAyB"}
@@ -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)),{}),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};
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:A,hasHolderName:O,hideCVC:B,holderNameRequired:F,installmentOptions:P,keypadFix:k,legacyInputMode:v,maskSecurityCode:w,minimumExpiryDate:E,name:M,placeholders:x,positionHolderNameOnTop:D,showBrandIcon:N,showInstallmentAmounts:V,showPayButton:I=!1,styles:j,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");return{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:A,hasBrandsConfiguration:p(i),hasData:y&&JSON.stringify(e.data)!==U,hasDisclaimerMessage:!!h,hasHolderName:O,hasInstallmentOptions:p(P),hasPlaceholders:p(x),hasStylesConfigured:p(j),hideCVC:B,holderNameRequired:F,keypadFix:k,legacyInputMode:v,maskSecurityCode:w,minimumExpiryDate:!!E,name:M,positionHolderNameOnTop:D,riskEnabled:X,showBrandIcon:N,showInstallmentAmounts:!!V,showKCPType:Z,showPayButton:I,socialSecurityNumberMode:c?.socialSecurityNumberMode,srPanelEnabled:G,srPanelMoveFocus:Q,hasOnAllValid:L!==u.onAllValid,hasOnBinValue:R!==u.onBinValue,hasOnBlur:T!==u.onBlur,hasOnBrand:K!==u.onBrand,hasOnConfigSuccess:H!==u.onConfigSuccess,hasOnFieldValid:J!==u.onFieldValid,hasOnFocus:W!==u.onFocus,hasOnLoad:$!==u.onLoad,hasOnBinLookup:!!q,hasOnEnterKeyPressed:!!z}};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\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,EAAKiB,QAAU,CAAEA,OAAQjB,EAAKiB,WACxC,SAAfjB,EAAKM,OAAoB,CAAEY,UAAWlB,EAAKkB,UAAWC,YAAanB,EAAKmB,gBACzD,SAAfnB,EAAKM,OAAoBN,EAAKoB,uBAAyB,CAAEA,sBAAuBpB,EAAKoB,sBAAuBC,MAAOrB,EAAKqB,UACzG,SAAfrB,EAAKM,OACLN,EAAKU,OAASY,GAAkC,CAC5CC,oBAAqBC,EAA0BxB,EAAKuB,oBAAqBvB,EAAKgB,QAC9ES,uBAAwBzB,EAAKyB,2BAEjCzB,EAAK0B,YAAc,CAAEA,WAAY1B,EAAK0B,eAEtC1B,EAAK2B,UAAY,CAAEA,SAAU3B,EAAK2B,YAGpCH,EAA4B,CAACI,EAAmBZ,KAElD,GAAIY,IAAcC,GAAwBD,IAAcE,EACpD,OAAOC,EAAiB,GAAGH,KAAaZ,MAAaY,EAGzD,IAAII,EAAUD,EAAiBH,IAAcA,EAQ7C,OAJIK,MAAMC,OAAOF,MACbA,EAAUG,EAAoBH,IAG3BA,CAAAA,EAGEI,EAAwBC,GAC1BC,OAAOC,KAAKF,GAAeG,QAAO,CAACC,EAAKC,KACvCC,EAAuBC,SAASF,KAAOD,EAAIC,GAAQL,EAAcK,IAC9DD,IACR,CAAC,GAGKI,EAAqBC,IAE9B,MAAMC,UACFA,EAASC,+BACTA,EAA8BC,mBAC9BA,EAAkBC,uBAClBA,EAAsBC,6BACtBA,EAA4BC,OAC5BA,EAASC,EAAwBC,oBACjCA,EAAmBC,oBACnBA,EAAsBC,EAA6BC,cACnDA,EAAaC,YACbA,EAAWC,KACXA,EAAIC,kBACJA,EAAiBC,oBACjBA,EAAmBC,YACnBA,EAAWC,mBACXA,EAAkBC,iBAClBA,EAAgBC,YAChBA,EAAWC,cACXA,EAAaC,QACbA,EAAOC,mBACPA,EAAkBC,mBAClBA,EAAkBC,UAClBA,EAASC,gBACTA,EAAeC,iBACfA,EAAgBC,kBAChBA,EAAiBC,KACjBA,EAAIC,aACJA,EAAYC,wBACZA,EAAuBC,cACvBA,EAAaC,uBACbA,EAAsBC,cACtBA,GAAgB,EAAKC,OACrBA,EAAMC,WACNA,EAAUC,YACVA,EAAWC,WACXA,EAAUC,OACVA,EAAMC,QACNA,EAAOC,gBACPA,EAAeC,kBACfA,EAAiBC,aACjBA,EAAYC,QACZA,EAAOC,OACPA,GACA5C,EAEE6C,EAAaC,KAAKC,UAAUC,EAAsBnC,MAElDoC,EAAiBjD,EAAUkD,SAASC,SAASC,QAC7CC,EAAmBrD,EAAUkD,SAASC,SAASG,UAE/CC,EAAcvD,EAAUkD,SAASM,MAAMJ,QAEvCK,EAA0BzD,EAAU0D,gBAAkB,SAAWvD,EAEvE,IAAIwD,EAA2C,QACK,IAAhDhD,GAAeiD,+BACfD,EAA6C,OAA/B/C,GAAaiD,cAAyB,UAAY,QAIpE,MAAMjF,EAA6B,CAC/BqB,eACIC,GAAgC4D,OAAS,GAAK,CAC9C5D,+BAAgCA,EAA+B6D,WAAWC,UAAU,EAvI7E,MAyIX7D,mBAAoBsD,EACpBrD,yBACAC,6BAA8BA,GAA8B0D,YAAYC,UAAU,EA3IvE,KA6IX1D,OAAQA,GAAQyD,YAAYC,UAAU,EA7I3B,KA8IXvD,sBACAM,sBACAC,cACAC,qBACAC,mBACAC,cACA8C,uBAAwBC,EAAS1D,GACjC2D,QAAStD,GAAQiC,KAAKC,UAAU/C,EAAUa,QAAUgC,EACpDuB,uBAAwBtD,EACxBM,gBACAiD,sBAAuBH,EAAS3C,GAChC+C,gBAAiBJ,EAASrC,GAC1B0C,oBAAqBL,EAAShC,GAC9Bb,UACAC,qBACAE,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,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
+ {"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 hasOnBinValue: onBinValue !== CardInputDefaultProps.onBinValue,\n hasOnBlur: onBlur !== CardInputDefaultProps.onBlur,\n hasOnBrand: onBrand !== CardInputDefaultProps.onBrand,\n hasOnConfigSuccess: onConfigSuccess !== CardInputDefaultProps.onConfigSuccess,\n hasOnFieldValid: onFieldValid !== CardInputDefaultProps.onFieldValid,\n hasOnFocus: onFocus !== CardInputDefaultProps.onFocus,\n hasOnLoad: onLoad !== CardInputDefaultProps.onLoad,\n // Card level props\n hasOnBinLookup: !!onBinLookup,\n hasOnEnterKeyPressed: !!onEnterKeyPressed\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","hasOnBinValue","hasOnBlur","hasOnBrand","hasOnConfigSuccess","hasOnFieldValid","hasOnFocus","hasOnLoad","hasOnBinLookup","hasOnEnterKeyPressed"],"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,EAAKiB,QAAU,CAAEA,OAAQjB,EAAKiB,WACxC,SAAfjB,EAAKM,OAAoB,CAAEY,UAAWlB,EAAKkB,UAAWC,YAAanB,EAAKmB,gBACzD,SAAfnB,EAAKM,OAAoBN,EAAKoB,uBAAyB,CAAEA,sBAAuBpB,EAAKoB,sBAAuBC,MAAOrB,EAAKqB,UACzG,SAAfrB,EAAKM,OACLN,EAAKU,OAASY,GAAkC,CAC5CC,oBAAqBC,EAA0BxB,EAAKuB,oBAAqBvB,EAAKgB,QAC9ES,uBAAwBzB,EAAKyB,2BAEjCzB,EAAK0B,YAAc,CAAEA,WAAY1B,EAAK0B,eAEtC1B,EAAK2B,UAAY,CAAEA,SAAU3B,EAAK2B,YAGpCH,EAA4B,CAACI,EAAmBZ,KAElD,GAAIY,IAAcC,GAAwBD,IAAcE,EACpD,OAAOC,EAAiB,GAAGH,KAAaZ,MAAaY,EAGzD,IAAII,EAAUD,EAAiBH,IAAcA,EAQ7C,OAJIK,MAAMC,OAAOF,MACbA,EAAUG,EAAoBH,IAG3BA,CAAAA,EAGEI,EAAwBC,GAC1BC,OAAOC,KAAKF,GAAeG,QAAO,CAACC,EAAKC,KACvCC,EAAuBC,SAASF,KAAOD,EAAIC,GAAQL,EAAcK,IAC9DD,IACR,CAAC,GAGKI,EAAqBC,IAE9B,MAAMC,UACFA,EAASC,+BACTA,EAA8BC,mBAC9BA,EAAkBC,uBAClBA,EAAsBC,6BACtBA,EAA4BC,OAC5BA,EAASC,EAAwBC,oBACjCA,EAAmBC,oBACnBA,EAAsBC,EAA6BC,cACnDA,EAAaC,YACbA,EAAWC,KACXA,EAAIC,kBACJA,EAAiBC,oBACjBA,EAAmBC,YACnBA,EAAWC,mBACXA,EAAkBC,iBAClBA,EAAgBC,YAChBA,EAAWC,cACXA,EAAaC,QACbA,EAAOC,mBACPA,EAAkBC,mBAClBA,EAAkBC,UAClBA,EAASC,gBACTA,EAAeC,iBACfA,EAAgBC,kBAChBA,EAAiBC,KACjBA,EAAIC,aACJA,EAAYC,wBACZA,EAAuBC,cACvBA,EAAaC,uBACbA,EAAsBC,cACtBA,GAAgB,EAAKC,OACrBA,EAAMC,WACNA,EAAUC,YACVA,EAAWC,WACXA,EAAUC,OACVA,EAAMC,QACNA,EAAOC,gBACPA,EAAeC,kBACfA,EAAiBC,aACjBA,EAAYC,QACZA,EAAOC,OACPA,GACA5C,EAEE6C,EAAaC,KAAKC,UAAUC,EAAsBnC,MAElDoC,EAAiBjD,EAAUkD,SAASC,SAASC,QAC7CC,EAAmBrD,EAAUkD,SAASC,SAASG,UAE/CC,EAAcvD,EAAUkD,SAASM,MAAMJ,QAEvCK,EAA0BzD,EAAU0D,gBAAkB,SAAWvD,EAEvE,IAAIwD,EAA2C,QACK,IAAhDhD,GAAeiD,+BACfD,EAA6C,OAA/B/C,GAAaiD,cAAyB,UAAY,QA0DpE,MAtDmC,CAC/B5D,eACIC,GAAgC4D,OAAS,GAAK,CAC9C5D,+BAAgCA,EAA+B6D,WAAWC,UAAU,EAvI7E,MAyIX7D,mBAAoBsD,EACpBrD,yBACAC,6BAA8BA,GAA8B0D,YAAYC,UAAU,EA3IvE,KA6IX1D,OAAQA,GAAQyD,YAAYC,UAAU,EA7I3B,KA8IXvD,sBACAM,sBACAC,cACAC,qBACAC,mBACAC,cACA8C,uBAAwBC,EAAS1D,GACjC2D,QAAStD,GAAQiC,KAAKC,UAAU/C,EAAUa,QAAUgC,EACpDuB,uBAAwBtD,EACxBM,gBACAiD,sBAAuBH,EAAS3C,GAChC+C,gBAAiBJ,EAASrC,GAC1B0C,oBAAqBL,EAAShC,GAC9Bb,UACAC,qBACAE,YACAC,kBACAC,mBACAC,oBAAqBA,EACrBC,OACAE,0BACAyB,cACAxB,gBACAC,yBAA0BA,EAC1B2B,cACA1B,gBACAuC,yBAA0B7D,GAAe6D,yBACzCvB,iBACAI,mBAGAoB,cAAetC,IAAea,EAAsBb,WACpDuC,cAAerC,IAAeW,EAAsBX,WACpDsC,UAAWrC,IAAWU,EAAsBV,OAC5CsC,WAAYrC,IAAYS,EAAsBT,QAC9CsC,mBAAoBrC,IAAoBQ,EAAsBR,gBAC9DsC,gBAAiBpC,IAAiBM,EAAsBN,aACxDqC,WAAYpC,IAAYK,EAAsBL,QAC9CqC,UAAWpC,IAAWI,EAAsBJ,OAE5CqC,iBAAkB7C,EAClB8C,uBAAwBzC,EAGrB7D"}
@@ -1,2 +1,2 @@
1
- import s from"../Services/sessions/make-payment.js";import e from"../Services/sessions/submit-details.js";import t from"../Services/sessions/setup-session.js";import i from"../Services/sessions/check-balance.js";import o from"../../utils/Storage.js";import a from"../Services/sessions/create-order.js";import{sanitizeSession as n}from"./utils.js";import r from"../Services/sessions/cancel-order.js";class h{session;storage;clientKey;loadingContext;configuration;constructor(s,e,t){const i=n(s);if(!e)throw new Error("No clientKey available");if(!t)throw new Error("No loadingContext available");this.storage=new o("session","localStorage"),this.clientKey=e,this.loadingContext=t,this.session=i,this.session.sessionData?this.storeSession():this.session=this.getStoredSession()}get shopperLocale(){return this.session.shopperLocale}get id(){return this.session.id}get data(){return this.session.sessionData}updateSessionData(s){this.session.sessionData=s,this.storeSession()}setupSession(s){return t(this,s).then((s=>(s.configuration&&(this.configuration={...s.configuration}),s.sessionData&&this.updateSessionData(s.sessionData),s)))}submitPayment(e){return s(e,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}submitDetails(s){return e(s,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}checkBalance(s){return i(s,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}createOrder(){return a(this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}cancelOrder(s){return r(s.order,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}getStoredSession(){const s=this.storage.get();return this.id===s?.id?s:this.session}storeSession(){this.storage.set({id:this.session.id,sessionData:this.session.sessionData})}removeStoredSession(){this.storage.remove()}}export{h as default};
1
+ import s from"../Services/sessions/make-payment.js";import e from"../Services/sessions/submit-details.js";import t from"../Services/sessions/setup-session.js";import i from"../Services/sessions/check-balance.js";import o from"../../utils/Storage.js";import n from"../Services/sessions/create-order.js";import{sanitizeSession as a}from"./utils.js";import r from"../Services/sessions/cancel-order.js";import h from"../../utils/browserInfo.js";class c{session;storage;clientKey;loadingContext;configuration;constructor(s,e,t){const i=a(s);if(!e)throw new Error("No clientKey available");if(!t)throw new Error("No loadingContext available");this.storage=new o("session","localStorage"),this.clientKey=e,this.loadingContext=t,this.session=i,this.session.sessionData?this.storeSession():this.session=this.getStoredSession()}get shopperLocale(){return this.session.shopperLocale}get id(){return this.session.id}get data(){return this.session.sessionData}updateSessionData(s){this.session.sessionData=s,this.storeSession()}setupSession(s){const e={...s,browserInfo:h()};return t(this,e).then((s=>(s.configuration&&(this.configuration={...s.configuration}),s.sessionData&&this.updateSessionData(s.sessionData),s)))}submitPayment(e){return s(e,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}submitDetails(s){return e(s,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}checkBalance(s){return i(s,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}createOrder(){return n(this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}cancelOrder(s){return r(s.order,this).then((s=>(s.sessionData&&this.updateSessionData(s.sessionData),s)))}getStoredSession(){const s=this.storage.get();return this.id===s?.id?s:this.session}storeSession(){this.storage.set({id:this.session.id,sessionData:this.session.sessionData})}removeStoredSession(){this.storage.remove()}}export{c as default};
2
2
  //# sourceMappingURL=CheckoutSession.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutSession.js","sources":["../../../../src/core/CheckoutSession/CheckoutSession.ts"],"sourcesContent":["import makePayment from '../Services/sessions/make-payment';\nimport submitDetails from '../Services/sessions/submit-details';\nimport setupSession from '../Services/sessions/setup-session';\nimport checkBalance from '../Services/sessions/check-balance';\nimport Storage from '../../utils/Storage';\nimport createOrder from '../Services/sessions/create-order';\nimport { sanitizeSession } from './utils';\nimport {\n CheckoutSession,\n CheckoutSessionBalanceResponse,\n CheckoutSessionDetailsResponse,\n CheckoutSessionOrdersResponse,\n CheckoutSessionPaymentResponse,\n CheckoutSessionSetupResponse,\n SessionConfiguration\n} from './types';\nimport cancelOrder from '../Services/sessions/cancel-order';\nimport { onOrderCancelData } from '../../components/Dropin/types';\nimport type { AdditionalDetailsData } from '../types';\n\nclass Session {\n private readonly session: CheckoutSession;\n private readonly storage: Storage<CheckoutSession>;\n public readonly clientKey: string;\n public readonly loadingContext: string;\n public configuration: SessionConfiguration;\n\n constructor(rawSession: Partial<CheckoutSession>, clientKey: string, loadingContext: string) {\n const session = sanitizeSession(rawSession) as CheckoutSession;\n\n if (!clientKey) throw new Error('No clientKey available');\n if (!loadingContext) throw new Error('No loadingContext available');\n\n this.storage = new Storage('session', 'localStorage');\n this.clientKey = clientKey;\n this.loadingContext = loadingContext;\n this.session = session;\n\n if (!this.session.sessionData) {\n this.session = this.getStoredSession();\n } else {\n this.storeSession();\n }\n }\n\n get shopperLocale() {\n return this.session.shopperLocale;\n }\n\n get id() {\n return this.session.id;\n }\n\n get data() {\n return this.session.sessionData;\n }\n\n /**\n * Updates the session.data with the latest data blob\n */\n private updateSessionData(latestData: string): void {\n this.session.sessionData = latestData;\n this.storeSession();\n }\n\n /**\n * Fetches data from a session\n */\n setupSession(options): Promise<CheckoutSessionSetupResponse> {\n return setupSession(this, options).then(response => {\n if (response.configuration) {\n this.configuration = { ...response.configuration };\n }\n\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits a session payment\n */\n submitPayment(data): Promise<CheckoutSessionPaymentResponse> {\n return makePayment(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits session payment additional details\n */\n submitDetails(data: AdditionalDetailsData['data']): Promise<CheckoutSessionDetailsResponse> {\n return submitDetails(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Checks the balance for a payment method\n */\n checkBalance(data): Promise<CheckoutSessionBalanceResponse> {\n return checkBalance(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Creates an order for the current session\n */\n createOrder(): Promise<CheckoutSessionOrdersResponse> {\n return createOrder(this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Cancels an order for the current session\n */\n cancelOrder(data: onOrderCancelData): Promise<CheckoutSessionOrdersResponse> {\n return cancelOrder(data.order, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Gets the stored session but only if the current id and the stored id match\n */\n getStoredSession(): CheckoutSession {\n const storedSession = this.storage.get();\n return this.id === storedSession?.id ? storedSession : this.session;\n }\n\n /**\n * Stores the session\n */\n storeSession(): void {\n this.storage.set({ id: this.session.id, sessionData: this.session.sessionData });\n }\n\n /**\n * Clears the stored session\n */\n removeStoredSession(): void {\n this.storage.remove();\n }\n}\n\nexport default Session;\n"],"names":["Session","session","storage","clientKey","loadingContext","configuration","constructor","rawSession","sanitizeSession","Error","this","Storage","sessionData","storeSession","getStoredSession","shopperLocale","id","data","updateSessionData","latestData","setupSession","options","then","response","submitPayment","makePayment","submitDetails","checkBalance","createOrder","cancelOrder","order","storedSession","get","set","removeStoredSession","remove"],"mappings":"+YAoBA,MAAMA,EACeC,QACAC,QACDC,UACAC,eACTC,cAEPC,WAAAA,CAAYC,EAAsCJ,EAAmBC,GACjE,MAAMH,EAAUO,EAAgBD,GAEhC,IAAKJ,EAAW,MAAM,IAAIM,MAAM,0BAChC,IAAKL,EAAgB,MAAM,IAAIK,MAAM,+BAErCC,KAAKR,QAAU,IAAIS,EAAQ,UAAW,gBACtCD,KAAKP,UAAYA,EACjBO,KAAKN,eAAiBA,EACtBM,KAAKT,QAAUA,EAEVS,KAAKT,QAAQW,YAGdF,KAAKG,eAFLH,KAAKT,QAAUS,KAAKI,kBAI5B,CAEA,iBAAIC,GACA,OAAOL,KAAKT,QAAQc,aACxB,CAEA,MAAIC,GACA,OAAON,KAAKT,QAAQe,EACxB,CAEA,QAAIC,GACA,OAAOP,KAAKT,QAAQW,WACxB,CAKQM,iBAAAA,CAAkBC,GACtBT,KAAKT,QAAQW,YAAcO,EAC3BT,KAAKG,cACT,CAKAO,YAAAA,CAAaC,GACT,OAAOD,EAAaV,KAAMW,GAASC,MAAKC,IAChCA,EAASlB,gBACTK,KAAKL,cAAgB,IAAKkB,EAASlB,gBAGnCkB,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAC,aAAAA,CAAcP,GACV,OAAOQ,EAAYR,EAAMP,MAAMY,MAAKC,IAC5BA,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAG,aAAAA,CAAcT,GACV,OAAOS,EAAcT,EAAMP,MAAMY,MAAKC,IAC9BA,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAI,YAAAA,CAAaV,GACT,OAAOU,EAAaV,EAAMP,MAAMY,MAAKC,IAC7BA,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAK,WAAAA,GACI,OAAOA,EAAYlB,MAAMY,MAAKC,IACtBA,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAM,WAAAA,CAAYZ,GACR,OAAOY,EAAYZ,EAAKa,MAAOpB,MAAMY,MAAKC,IAClCA,EAASX,aACTF,KAAKQ,kBAAkBK,EAASX,aAG7BW,IAEf,CAKAT,gBAAAA,GACI,MAAMiB,EAAgBrB,KAAKR,QAAQ8B,MACnC,OAAOtB,KAAKM,KAAOe,GAAef,GAAKe,EAAgBrB,KAAKT,OAChE,CAKAY,YAAAA,GACIH,KAAKR,QAAQ+B,IAAI,CAAEjB,GAAIN,KAAKT,QAAQe,GAAIJ,YAAaF,KAAKT,QAAQW,aACtE,CAKAsB,mBAAAA,GACIxB,KAAKR,QAAQiC,QACjB"}
1
+ {"version":3,"file":"CheckoutSession.js","sources":["../../../../src/core/CheckoutSession/CheckoutSession.ts"],"sourcesContent":["import makePayment from '../Services/sessions/make-payment';\nimport submitDetails from '../Services/sessions/submit-details';\nimport setupSession from '../Services/sessions/setup-session';\nimport checkBalance from '../Services/sessions/check-balance';\nimport Storage from '../../utils/Storage';\nimport createOrder from '../Services/sessions/create-order';\nimport { sanitizeSession } from './utils';\nimport {\n CheckoutSession,\n CheckoutSessionBalanceResponse,\n CheckoutSessionDetailsResponse,\n CheckoutSessionOrdersResponse,\n CheckoutSessionPaymentResponse,\n CheckoutSessionSetupResponse,\n SessionConfiguration,\n SetupSessionOptions\n} from './types';\nimport cancelOrder from '../Services/sessions/cancel-order';\nimport { onOrderCancelData } from '../../components/Dropin/types';\nimport type { AdditionalDetailsData } from '../types';\nimport collectBrowserInfo from '../../utils/browserInfo';\n\nclass Session {\n private readonly session: CheckoutSession;\n private readonly storage: Storage<CheckoutSession>;\n public readonly clientKey: string;\n public readonly loadingContext: string;\n public configuration: SessionConfiguration;\n\n constructor(rawSession: Partial<CheckoutSession>, clientKey: string, loadingContext: string) {\n const session = sanitizeSession(rawSession) as CheckoutSession;\n\n if (!clientKey) throw new Error('No clientKey available');\n if (!loadingContext) throw new Error('No loadingContext available');\n\n this.storage = new Storage('session', 'localStorage');\n this.clientKey = clientKey;\n this.loadingContext = loadingContext;\n this.session = session;\n\n if (!this.session.sessionData) {\n this.session = this.getStoredSession();\n } else {\n this.storeSession();\n }\n }\n\n get shopperLocale() {\n return this.session.shopperLocale;\n }\n\n get id() {\n return this.session.id;\n }\n\n get data() {\n return this.session.sessionData;\n }\n\n /**\n * Updates the session.data with the latest data blob\n */\n private updateSessionData(latestData: string): void {\n this.session.sessionData = latestData;\n this.storeSession();\n }\n\n /**\n * Fetches data from a session\n */\n setupSession(options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {\n const mergedOptions = { ...options, browserInfo: collectBrowserInfo() }\n return setupSession(this, mergedOptions).then(response => {\n if (response.configuration) {\n this.configuration = { ...response.configuration };\n }\n\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits a session payment\n */\n submitPayment(data): Promise<CheckoutSessionPaymentResponse> {\n return makePayment(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Submits session payment additional details\n */\n submitDetails(data: AdditionalDetailsData['data']): Promise<CheckoutSessionDetailsResponse> {\n return submitDetails(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Checks the balance for a payment method\n */\n checkBalance(data): Promise<CheckoutSessionBalanceResponse> {\n return checkBalance(data, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Creates an order for the current session\n */\n createOrder(): Promise<CheckoutSessionOrdersResponse> {\n return createOrder(this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Cancels an order for the current session\n */\n cancelOrder(data: onOrderCancelData): Promise<CheckoutSessionOrdersResponse> {\n return cancelOrder(data.order, this).then(response => {\n if (response.sessionData) {\n this.updateSessionData(response.sessionData);\n }\n\n return response;\n });\n }\n\n /**\n * Gets the stored session but only if the current id and the stored id match\n */\n getStoredSession(): CheckoutSession {\n const storedSession = this.storage.get();\n return this.id === storedSession?.id ? storedSession : this.session;\n }\n\n /**\n * Stores the session\n */\n storeSession(): void {\n this.storage.set({ id: this.session.id, sessionData: this.session.sessionData });\n }\n\n /**\n * Clears the stored session\n */\n removeStoredSession(): void {\n this.storage.remove();\n }\n}\n\nexport default Session;\n"],"names":["Session","session","storage","clientKey","loadingContext","configuration","constructor","rawSession","sanitizeSession","Error","this","Storage","sessionData","storeSession","getStoredSession","shopperLocale","id","data","updateSessionData","latestData","setupSession","options","mergedOptions","browserInfo","collectBrowserInfo","then","response","submitPayment","makePayment","submitDetails","checkBalance","createOrder","cancelOrder","order","storedSession","get","set","removeStoredSession","remove"],"mappings":"ybAsBA,MAAMA,EACeC,QACAC,QACDC,UACAC,eACTC,cAEPC,WAAAA,CAAYC,EAAsCJ,EAAmBC,GACjE,MAAMH,EAAUO,EAAgBD,GAEhC,IAAKJ,EAAW,MAAM,IAAIM,MAAM,0BAChC,IAAKL,EAAgB,MAAM,IAAIK,MAAM,+BAErCC,KAAKR,QAAU,IAAIS,EAAQ,UAAW,gBACtCD,KAAKP,UAAYA,EACjBO,KAAKN,eAAiBA,EACtBM,KAAKT,QAAUA,EAEVS,KAAKT,QAAQW,YAGdF,KAAKG,eAFLH,KAAKT,QAAUS,KAAKI,kBAI5B,CAEA,iBAAIC,GACA,OAAOL,KAAKT,QAAQc,aACxB,CAEA,MAAIC,GACA,OAAON,KAAKT,QAAQe,EACxB,CAEA,QAAIC,GACA,OAAOP,KAAKT,QAAQW,WACxB,CAKQM,iBAAAA,CAAkBC,GACtBT,KAAKT,QAAQW,YAAcO,EAC3BT,KAAKG,cACT,CAKAO,YAAAA,CAAaC,GACT,MAAMC,EAAgB,IAAKD,EAASE,YAAaC,KACjD,OAAOJ,EAAaV,KAAMY,GAAeG,MAAKC,IACtCA,EAASrB,gBACTK,KAAKL,cAAgB,IAAKqB,EAASrB,gBAGnCqB,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAC,aAAAA,CAAcV,GACV,OAAOW,EAAYX,EAAMP,MAAMe,MAAKC,IAC5BA,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAG,aAAAA,CAAcZ,GACV,OAAOY,EAAcZ,EAAMP,MAAMe,MAAKC,IAC9BA,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAI,YAAAA,CAAab,GACT,OAAOa,EAAab,EAAMP,MAAMe,MAAKC,IAC7BA,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAK,WAAAA,GACI,OAAOA,EAAYrB,MAAMe,MAAKC,IACtBA,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAM,WAAAA,CAAYf,GACR,OAAOe,EAAYf,EAAKgB,MAAOvB,MAAMe,MAAKC,IAClCA,EAASd,aACTF,KAAKQ,kBAAkBQ,EAASd,aAG7Bc,IAEf,CAKAZ,gBAAAA,GACI,MAAMoB,EAAgBxB,KAAKR,QAAQiC,MACnC,OAAOzB,KAAKM,KAAOkB,GAAelB,GAAKkB,EAAgBxB,KAAKT,OAChE,CAKAY,YAAAA,GACIH,KAAKR,QAAQkC,IAAI,CAAEpB,GAAIN,KAAKT,QAAQe,GAAIJ,YAAaF,KAAKT,QAAQW,aACtE,CAKAyB,mBAAAA,GACI3B,KAAKR,QAAQoC,QACjB"}
@@ -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.1.1",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};
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.2.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
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import{API_VERSION as r}from"./constants.js";function t(t,o){const a=`${r}/sessions/${t.id}/setup?clientKey=${t.clientKey}`,n={sessionData:t.data,...o.order?{order:{orderData:o.order.orderData,pspReference:o.order.pspReference}}:{}};return e({loadingContext:t.loadingContext,path:a,errorLevel:"fatal"},n)}export{t as default};
1
+ import{httpPost as e}from"../http.js";import{API_VERSION as r}from"./constants.js";function o(o,t){const n=`${r}/sessions/${o.id}/setup?clientKey=${o.clientKey}`,s={browserInfo:t.browserInfo,sessionData:o.data,...t.order?{order:{orderData:t.order.orderData,pspReference:t.order.pspReference}}:{}};return e({loadingContext:o.loadingContext,path:n,errorLevel:"fatal"},s)}export{o as default};
2
2
  //# sourceMappingURL=setup-session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-session.js","sources":["../../../../../src/core/Services/sessions/setup-session.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Session from '../../CheckoutSession';\nimport { CheckoutSessionSetupResponse } from '../../CheckoutSession/types';\nimport { API_VERSION } from './constants';\n\nfunction setupSession(session: Session, options): Promise<CheckoutSessionSetupResponse> {\n const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;\n const data = {\n sessionData: session.data,\n ...(options.order\n ? {\n order: { orderData: options.order.orderData, pspReference: options.order.pspReference }\n }\n : {})\n };\n\n return httpPost<CheckoutSessionSetupResponse>(\n {\n loadingContext: session.loadingContext,\n path,\n errorLevel: 'fatal'\n },\n data\n );\n}\n\nexport default setupSession;\n"],"names":["setupSession","session","options","path","API_VERSION","id","clientKey","data","sessionData","order","orderData","pspReference","httpPost","loadingContext","errorLevel"],"mappings":"mFAKA,SAASA,EAAaC,EAAkBC,GACpC,MAAMC,EAAO,GAAGC,cAAwBH,EAAQI,sBAAsBJ,EAAQK,YACxEC,EAAO,CACTC,YAAaP,EAAQM,QACjBL,EAAQO,MACN,CACIA,MAAO,CAAEC,UAAWR,EAAQO,MAAMC,UAAWC,aAAcT,EAAQO,MAAME,eAE7E,CAAE,GAGZ,OAAOC,EACH,CACIC,eAAgBZ,EAAQY,eACxBV,OACAW,WAAY,SAEhBP,EAER"}
1
+ {"version":3,"file":"setup-session.js","sources":["../../../../../src/core/Services/sessions/setup-session.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Session from '../../CheckoutSession';\nimport { CheckoutSessionSetupResponse, SetupSessionOptions } from '../../CheckoutSession/types';\nimport { API_VERSION } from './constants';\n\nfunction setupSession(session: Session, options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {\n const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;\n const data = {\n browserInfo: options.browserInfo,\n sessionData: session.data,\n ...(options.order\n ? {\n order: { orderData: options.order.orderData, pspReference: options.order.pspReference }\n }\n : {})\n };\n\n return httpPost<CheckoutSessionSetupResponse>(\n {\n loadingContext: session.loadingContext,\n path,\n errorLevel: 'fatal'\n },\n data\n );\n}\n\nexport default setupSession;\n"],"names":["setupSession","session","options","path","API_VERSION","id","clientKey","data","browserInfo","sessionData","order","orderData","pspReference","httpPost","loadingContext","errorLevel"],"mappings":"mFAKA,SAASA,EAAaC,EAAkBC,GACpC,MAAMC,EAAO,GAAGC,cAAwBH,EAAQI,sBAAsBJ,EAAQK,YACxEC,EAAO,CACTC,YAAaN,EAAQM,YACrBC,YAAaR,EAAQM,QACjBL,EAAQQ,MACN,CACIA,MAAO,CAAEC,UAAWT,EAAQQ,MAAMC,UAAWC,aAAcV,EAAQQ,MAAME,eAE7E,CAAE,GAGZ,OAAOC,EACH,CACIC,eAAgBb,EAAQa,eACxBX,OACAY,WAAY,SAEhBR,EAER"}
@@ -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.1.1",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};
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.2.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
@@ -1082,6 +1082,10 @@ type CheckoutSessionOrdersResponse = {
1082
1082
  orderData: string;
1083
1083
  pspReference: string;
1084
1084
  };
1085
+ type SetupSessionOptions = {
1086
+ browserInfo?: BrowserInfo;
1087
+ order?: Order;
1088
+ };
1085
1089
 
1086
1090
  type NewableComponent = new (checkout: ICore, props?: any) => UIElement;
1087
1091
  interface IRegistry {
@@ -1647,7 +1651,7 @@ declare class ANCVElement extends UIElement<ANCVConfiguration> {
1647
1651
 
1648
1652
  declare global {
1649
1653
  interface Window {
1650
- ApplePaySession: ApplePaySession;
1654
+ ApplePaySession?: ApplePaySession;
1651
1655
  }
1652
1656
  }
1653
1657
  type Initiative = 'web' | 'messaging';
@@ -1940,8 +1944,16 @@ interface AchConfiguration extends UIElementProps {
1940
1944
  holderNameRequired?: boolean;
1941
1945
  hasHolderName?: boolean;
1942
1946
  enableStoreDetails: boolean;
1943
- bankAccountNumber: string;
1947
+ bankAccountNumber?: string;
1944
1948
  placeholders?: Placeholders;
1949
+ /**
1950
+ * Object that contains placeholder information that you can use to prefill fields.
1951
+ * - merchant set config option
1952
+ */
1953
+ data?: {
1954
+ holderName?: string;
1955
+ billingAddress?: Partial<AddressData>;
1956
+ };
1945
1957
  }
1946
1958
 
1947
1959
  interface BankTransferConfiguration extends UIElementProps {
@@ -4124,8 +4136,12 @@ declare class AchElement extends UIElement<AchConfiguration> {
4124
4136
  storedPaymentMethodId?: string;
4125
4137
  hasHolderName?: boolean;
4126
4138
  enableStoreDetails: boolean;
4127
- bankAccountNumber: string;
4139
+ bankAccountNumber?: string;
4128
4140
  placeholders?: Placeholders;
4141
+ data?: {
4142
+ holderName?: string;
4143
+ billingAddress?: Partial<AddressData>;
4144
+ };
4129
4145
  order?: Order;
4130
4146
  modules?: {
4131
4147
  srPanel?: SRPanel;
@@ -5030,7 +5046,7 @@ declare class Session {
5030
5046
  /**
5031
5047
  * Fetches data from a session
5032
5048
  */
5033
- setupSession(options: any): Promise<CheckoutSessionSetupResponse>;
5049
+ setupSession(options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse>;
5034
5050
  /**
5035
5051
  * Submits a session payment
5036
5052
  */
@@ -1,2 +1,2 @@
1
- function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class t{begin(){return this.session.begin()}onvalidatemerchant(e,t){return new Promise(((n,o)=>t(n,o,e.validationURL))).then((e=>{this.session.completeMerchantValidation(e)})).catch((e=>{console.error(e),this.session.abort(),this.options.onError(e)}))}onpaymentauthorized(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completePayment(e)})).catch((e=>{this.session.completePayment(e)}))}onpaymentmethodselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completePaymentMethodSelection(e)})).catch((e=>{this.session.completePaymentMethodSelection(e)}))}onshippingcontactselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completeShippingContactSelection(e)})).catch((e=>{this.session.completeShippingContactSelection(e)}))}onshippingmethodselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completeShippingMethodSelection(e)})).catch((e=>{this.session.completeShippingMethodSelection(e)}))}oncancel(e,t){t(e)}constructor(t,n){e(this,"session",void 0),e(this,"options",void 0),this.options=n,this.session=new ApplePaySession(n.version,t),this.session.onvalidatemerchant=e=>this.onvalidatemerchant(e,n.onValidateMerchant),this.session.onpaymentauthorized=e=>this.onpaymentauthorized(e,n.onPaymentAuthorized),this.session.oncancel=e=>this.oncancel(e,n.onCancel),"function"==typeof n.onPaymentMethodSelected&&(this.session.onpaymentmethodselected=e=>this.onpaymentmethodselected(e,n.onPaymentMethodSelected)),"function"==typeof n.onShippingContactSelected&&(this.session.onshippingcontactselected=e=>this.onshippingcontactselected(e,n.onShippingContactSelected)),"function"==typeof n.onShippingMethodSelected&&(this.session.onshippingmethodselected=e=>this.onshippingmethodselected(e,n.onShippingMethodSelected))}}export{t as default};
1
+ function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class t{begin(){return this.session.begin()}onvalidatemerchant(e,t){return new Promise(((n,o)=>t(n,o,e.validationURL))).then((e=>{this.session.completeMerchantValidation(e)})).catch((e=>{console.error(e),this.session.abort(),this.options.onError(e)}))}onpaymentauthorized(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completePayment(e)})).catch((e=>{this.session.completePayment(e)}))}onpaymentmethodselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completePaymentMethodSelection(e)})).catch((e=>{this.session.completePaymentMethodSelection(e)}))}onshippingcontactselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completeShippingContactSelection(e)})).catch((e=>{this.session.completeShippingContactSelection(e)}))}onshippingmethodselected(e,t){return new Promise(((n,o)=>t(n,o,e))).then((e=>{this.session.completeShippingMethodSelection(e)})).catch((e=>{this.session.completeShippingMethodSelection(e)}))}oncancel(e,t){t(e)}constructor(t,n){e(this,"session",void 0),e(this,"options",void 0),this.options=n,this.session=new ApplePaySession(n.version,t),this.session.onvalidatemerchant=e=>{this.onvalidatemerchant(e,n.onValidateMerchant)},this.session.onpaymentauthorized=e=>{this.onpaymentauthorized(e,n.onPaymentAuthorized)},this.session.oncancel=e=>{this.oncancel(e,n.onCancel)},"function"==typeof n.onPaymentMethodSelected&&(this.session.onpaymentmethodselected=e=>{this.onpaymentmethodselected(e,n.onPaymentMethodSelected)}),"function"==typeof n.onShippingContactSelected&&(this.session.onshippingcontactselected=e=>{this.onshippingcontactselected(e,n.onShippingContactSelected)}),"function"==typeof n.onShippingMethodSelected&&(this.session.onshippingmethodselected=e=>{this.onshippingmethodselected(e,n.onShippingMethodSelected)})}}export{t as default};
2
2
  //# sourceMappingURL=ApplePayService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplePayService.js","sources":["../../../../src/components/ApplePay/ApplePayService.ts"],"sourcesContent":["import { ApplePayPaymentAuthorizationResult } from './types';\n\ninterface ApplePayServiceOptions {\n version: number;\n onValidateMerchant: (resolve, reject, url) => void;\n onError: (error?: unknown) => void;\n onCancel?: (event: ApplePayJS.Event) => void;\n onPaymentMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayPaymentMethodSelectedEvent) => void;\n onShippingMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingMethodSelectedEvent) => void;\n onShippingContactSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingContactSelectedEvent) => void;\n onPaymentAuthorized: (\n resolve: (result: ApplePayPaymentAuthorizationResult) => void,\n reject: (result: ApplePayPaymentAuthorizationResult) => void,\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent\n ) => void;\n}\n\nclass ApplePayService {\n private session: ApplePaySession;\n private readonly options: ApplePayServiceOptions;\n\n constructor(paymentRequest: ApplePayJS.ApplePayPaymentRequest, options: ApplePayServiceOptions) {\n this.options = options;\n\n this.session = new ApplePaySession(options.version, paymentRequest);\n /* eslint-disable @typescript-eslint/no-misused-promises */\n this.session.onvalidatemerchant = event => this.onvalidatemerchant(event, options.onValidateMerchant);\n this.session.onpaymentauthorized = event => this.onpaymentauthorized(event, options.onPaymentAuthorized);\n this.session.oncancel = event => this.oncancel(event, options.onCancel);\n\n if (typeof options.onPaymentMethodSelected === 'function') {\n this.session.onpaymentmethodselected = event => this.onpaymentmethodselected(event, options.onPaymentMethodSelected);\n }\n\n if (typeof options.onShippingContactSelected === 'function') {\n this.session.onshippingcontactselected = event => this.onshippingcontactselected(event, options.onShippingContactSelected);\n }\n\n if (typeof options.onShippingMethodSelected === 'function') {\n this.session.onshippingmethodselected = event => this.onshippingmethodselected(event, options.onShippingMethodSelected);\n }\n /* eslint-enable @typescript-eslint/no-misused-promises */\n }\n\n /**\n * Begins the merchant validation process.\n * When this method is called, the payment sheet is presented and the merchant validation process is initiated.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin}\n */\n begin() {\n return this.session.begin();\n }\n\n /**\n * An event handler that is called when the payment sheet is displayed.\n * Use this attribute to request and return a merchant session.\n * @param event - An ApplePayValidateMerchantEvent object (contains validationURL)\n * @param onValidateMerchant - A promise implemented by the merchant that will resolve with the merchantSession\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/providing_merchant_validation}\n */\n onvalidatemerchant(event: ApplePayJS.ApplePayValidateMerchantEvent, onValidateMerchant) {\n return new Promise((resolve, reject) => onValidateMerchant(resolve, reject, event.validationURL))\n .then(response => {\n this.session.completeMerchantValidation(response);\n })\n .catch(error => {\n console.error(error);\n this.session.abort();\n this.options.onError(error);\n });\n }\n\n /**\n * An event handler that is called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode.\n * The onpaymentauthorized function must complete the payment and respond by calling completePayment before the 30 second timeout.\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentAuthorized - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized}\n */\n onpaymentauthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n onPaymentAuthorized: ApplePayServiceOptions['onPaymentAuthorized']\n ): Promise<void> {\n return new Promise((resolve, reject) => onPaymentAuthorized(resolve, reject, event))\n .then((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n })\n .catch((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentMethodSelected - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778013-onpaymentmethodselected}\n */\n onpaymentmethodselected(event: ApplePayJS.ApplePayPaymentMethodSelectedEvent, onPaymentMethodSelected) {\n return new Promise((resolve, reject) => onPaymentMethodSelected(resolve, reject, event))\n .then((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n })\n .catch((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingContact attribute.\n * @param onShippingContactSelected - A promise that will complete the selection of a shipping contact with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingcontactselected(event: ApplePayJS.ApplePayShippingContactSelectedEvent, onShippingContactSelected) {\n return new Promise((resolve, reject) => onShippingContactSelected(resolve, reject, event))\n .then((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n })\n .catch((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingMethod attribute.\n * @param onShippingMethodSelected - A promise that will complete the selection of a shipping method with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingmethodselected(event: ApplePayJS.ApplePayShippingMethodSelectedEvent, onShippingMethodSelected) {\n return new Promise((resolve, reject) => onShippingMethodSelected(resolve, reject, event))\n .then((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n })\n .catch((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n });\n }\n\n /**\n * An event handler that is automatically called when the payment UI is dismissed.\n * This function can be called even after an onpaymentauthorized event has been dispatched.\n * @param event -\n * @param onCancel -\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778029-oncancel}\n */\n oncancel(event: ApplePayJS.Event, onCancel): void {\n onCancel(event);\n }\n}\n\nexport default ApplePayService;\n"],"names":["ApplePayService","begin","this","session","onvalidatemerchant","event","onValidateMerchant","Promise","resolve","reject","validationURL","then","response","completeMerchantValidation","catch","error","console","abort","options","onError","onpaymentauthorized","onPaymentAuthorized","result","completePayment","onpaymentmethodselected","onPaymentMethodSelected","paymentMethodUpdate","completePaymentMethodSelection","onshippingcontactselected","onShippingContactSelected","shippingContactUpdate","completeShippingContactSelection","onshippingmethodselected","onShippingMethodSelected","shippingMethodUpdate","completeShippingMethodSelection","oncancel","onCancel","constructor","paymentRequest","_define_property","ApplePaySession","version"],"mappings":"wHAiBA,MAAMA,EAgCFC,KAAAA,GACI,OAAOC,KAAKC,QAAQF,OACxB,CASAG,kBAAAA,CAAmBC,EAAiDC,GAChE,OAAO,IAAIC,SAAQ,CAACC,EAASC,IAAWH,EAAmBE,EAASC,EAAQJ,EAAMK,iBAC7EC,MAAKC,IACFV,KAAKC,QAAQU,2BAA2BD,EAAAA,IAE3CE,OAAMC,IACHC,QAAQD,MAAMA,GACdb,KAAKC,QAAQc,QACbf,KAAKgB,QAAQC,QAAQJ,EAAAA,GAEjC,CAUAK,mBAAAA,CACIf,EACAgB,GAEA,OAAO,IAAId,SAAQ,CAACC,EAASC,IAAWY,EAAoBb,EAASC,EAAQJ,KACxEM,MAAMW,IACHpB,KAAKC,QAAQoB,gBAAgBD,EAAAA,IAEhCR,OAAOQ,IACJpB,KAAKC,QAAQoB,gBAAgBD,EAAAA,GAEzC,CAUAE,uBAAAA,CAAwBnB,EAAsDoB,GAC1E,OAAO,IAAIlB,SAAQ,CAACC,EAASC,IAAWgB,EAAwBjB,EAASC,EAAQJ,KAC5EM,MAAMe,IACHxB,KAAKC,QAAQwB,+BAA+BD,EAAAA,IAE/CZ,OAAOY,IACJxB,KAAKC,QAAQwB,+BAA+BD,EAAAA,GAExD,CASAE,yBAAAA,CAA0BvB,EAAwDwB,GAC9E,OAAO,IAAItB,SAAQ,CAACC,EAASC,IAAWoB,EAA0BrB,EAASC,EAAQJ,KAC9EM,MAAMmB,IACH5B,KAAKC,QAAQ4B,iCAAiCD,EAAAA,IAEjDhB,OAAOgB,IACJ5B,KAAKC,QAAQ4B,iCAAiCD,EAAAA,GAE1D,CASAE,wBAAAA,CAAyB3B,EAAuD4B,GAC5E,OAAO,IAAI1B,SAAQ,CAACC,EAASC,IAAWwB,EAAyBzB,EAASC,EAAQJ,KAC7EM,MAAMuB,IACHhC,KAAKC,QAAQgC,gCAAgCD,EAAAA,IAEhDpB,OAAOoB,IACJhC,KAAKC,QAAQgC,gCAAgCD,EAAAA,GAEzD,CASAE,QAAAA,CAAS/B,EAAyBgC,GAC9BA,EAAShC,EACb,CArIAiC,WAAAA,CAAYC,EAAmDrB,GAH/DsB,EAAAtC,KAAQC,eAAR,GACAqC,EAAAtC,KAAiBgB,eAAjB,GAGIhB,KAAKgB,QAAUA,EAEfhB,KAAKC,QAAU,IAAIsC,gBAAgBvB,EAAQwB,QAASH,GAEpDrC,KAAKC,QAAQC,mBAAqBC,GAASH,KAAKE,mBAAmBC,EAAOa,EAAQZ,oBAClFJ,KAAKC,QAAQiB,oBAAsBf,GAASH,KAAKkB,oBAAoBf,EAAOa,EAAQG,qBACpFnB,KAAKC,QAAQiC,SAAW/B,GAASH,KAAKkC,SAAS/B,EAAOa,EAAQmB,UAEf,mBAApCnB,EAAQO,0BACfvB,KAAKC,QAAQqB,wBAA0BnB,GAASH,KAAKsB,wBAAwBnB,EAAOa,EAAQO,0BAG/C,mBAAtCP,EAAQW,4BACf3B,KAAKC,QAAQyB,0BAA4BvB,GAASH,KAAK0B,0BAA0BvB,EAAOa,EAAQW,4BAGpD,mBAArCX,EAAQe,2BACf/B,KAAKC,QAAQ6B,yBAA2B3B,GAASH,KAAK8B,yBAAyB3B,EAAOa,EAAQe,0BAGtG"}
1
+ {"version":3,"file":"ApplePayService.js","sources":["../../../../src/components/ApplePay/ApplePayService.ts"],"sourcesContent":["import { ApplePayPaymentAuthorizationResult } from './types';\n\ninterface ApplePayServiceOptions {\n version: number;\n onValidateMerchant: (resolve, reject, url) => void;\n onError: (error?: unknown) => void;\n onCancel?: (event: ApplePayJS.Event) => void;\n onPaymentMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayPaymentMethodSelectedEvent) => void;\n onShippingMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingMethodSelectedEvent) => void;\n onShippingContactSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingContactSelectedEvent) => void;\n onPaymentAuthorized: (\n resolve: (result: ApplePayPaymentAuthorizationResult) => void,\n reject: (result: ApplePayPaymentAuthorizationResult) => void,\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent\n ) => void;\n}\n\nclass ApplePayService {\n private session: ApplePaySession;\n private readonly options: ApplePayServiceOptions;\n\n constructor(paymentRequest: ApplePayJS.ApplePayPaymentRequest, options: ApplePayServiceOptions) {\n this.options = options;\n\n this.session = new ApplePaySession(options.version, paymentRequest);\n this.session.onvalidatemerchant = event => {\n void this.onvalidatemerchant(event, options.onValidateMerchant);\n };\n this.session.onpaymentauthorized = event => {\n void this.onpaymentauthorized(event, options.onPaymentAuthorized);\n };\n\n this.session.oncancel = event => {\n this.oncancel(event, options.onCancel);\n };\n\n if (typeof options.onPaymentMethodSelected === 'function') {\n this.session.onpaymentmethodselected = event => {\n void this.onpaymentmethodselected(event, options.onPaymentMethodSelected);\n };\n }\n\n if (typeof options.onShippingContactSelected === 'function') {\n this.session.onshippingcontactselected = event => {\n void this.onshippingcontactselected(event, options.onShippingContactSelected);\n };\n }\n\n if (typeof options.onShippingMethodSelected === 'function') {\n this.session.onshippingmethodselected = event => {\n void this.onshippingmethodselected(event, options.onShippingMethodSelected);\n };\n }\n }\n\n /**\n * Begins the merchant validation process.\n * When this method is called, the payment sheet is presented and the merchant validation process is initiated.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin}\n */\n begin() {\n return this.session.begin();\n }\n\n /**\n * An event handler that is called when the payment sheet is displayed.\n * Use this attribute to request and return a merchant session.\n * @param event - An ApplePayValidateMerchantEvent object (contains validationURL)\n * @param onValidateMerchant - A promise implemented by the merchant that will resolve with the merchantSession\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/providing_merchant_validation}\n */\n onvalidatemerchant(event: ApplePayJS.ApplePayValidateMerchantEvent, onValidateMerchant) {\n return new Promise((resolve, reject) => onValidateMerchant(resolve, reject, event.validationURL))\n .then(response => {\n this.session.completeMerchantValidation(response);\n })\n .catch(error => {\n console.error(error);\n this.session.abort();\n this.options.onError(error);\n });\n }\n\n /**\n * An event handler that is called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode.\n * The onpaymentauthorized function must complete the payment and respond by calling completePayment before the 30 second timeout.\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentAuthorized - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized}\n */\n onpaymentauthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n onPaymentAuthorized: ApplePayServiceOptions['onPaymentAuthorized']\n ): Promise<void> {\n return new Promise((resolve, reject) => onPaymentAuthorized(resolve, reject, event))\n .then((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n })\n .catch((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentMethodSelected - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778013-onpaymentmethodselected}\n */\n onpaymentmethodselected(event: ApplePayJS.ApplePayPaymentMethodSelectedEvent, onPaymentMethodSelected) {\n return new Promise((resolve, reject) => onPaymentMethodSelected(resolve, reject, event))\n .then((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n })\n .catch((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingContact attribute.\n * @param onShippingContactSelected - A promise that will complete the selection of a shipping contact with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingcontactselected(event: ApplePayJS.ApplePayShippingContactSelectedEvent, onShippingContactSelected) {\n return new Promise((resolve, reject) => onShippingContactSelected(resolve, reject, event))\n .then((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n })\n .catch((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingMethod attribute.\n * @param onShippingMethodSelected - A promise that will complete the selection of a shipping method with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingmethodselected(event: ApplePayJS.ApplePayShippingMethodSelectedEvent, onShippingMethodSelected) {\n return new Promise((resolve, reject) => onShippingMethodSelected(resolve, reject, event))\n .then((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n })\n .catch((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n });\n }\n\n /**\n * An event handler that is automatically called when the payment UI is dismissed.\n * This function can be called even after an onpaymentauthorized event has been dispatched.\n * @param event -\n * @param onCancel -\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778029-oncancel}\n */\n oncancel(event: ApplePayJS.Event, onCancel): void {\n onCancel(event);\n }\n}\n\nexport default ApplePayService;\n"],"names":["ApplePayService","begin","this","session","onvalidatemerchant","event","onValidateMerchant","Promise","resolve","reject","validationURL","then","response","completeMerchantValidation","catch","error","console","abort","options","onError","onpaymentauthorized","onPaymentAuthorized","result","completePayment","onpaymentmethodselected","onPaymentMethodSelected","paymentMethodUpdate","completePaymentMethodSelection","onshippingcontactselected","onShippingContactSelected","shippingContactUpdate","completeShippingContactSelection","onshippingmethodselected","onShippingMethodSelected","shippingMethodUpdate","completeShippingMethodSelection","oncancel","onCancel","constructor","paymentRequest","_define_property","ApplePaySession","version"],"mappings":"wHAiBA,MAAMA,EA2CFC,KAAAA,GACI,OAAOC,KAAKC,QAAQF,OACxB,CASAG,kBAAAA,CAAmBC,EAAiDC,GAChE,OAAO,IAAIC,SAAQ,CAACC,EAASC,IAAWH,EAAmBE,EAASC,EAAQJ,EAAMK,iBAC7EC,MAAKC,IACFV,KAAKC,QAAQU,2BAA2BD,EAAAA,IAE3CE,OAAMC,IACHC,QAAQD,MAAMA,GACdb,KAAKC,QAAQc,QACbf,KAAKgB,QAAQC,QAAQJ,EAAAA,GAEjC,CAUAK,mBAAAA,CACIf,EACAgB,GAEA,OAAO,IAAId,SAAQ,CAACC,EAASC,IAAWY,EAAoBb,EAASC,EAAQJ,KACxEM,MAAMW,IACHpB,KAAKC,QAAQoB,gBAAgBD,EAAAA,IAEhCR,OAAOQ,IACJpB,KAAKC,QAAQoB,gBAAgBD,EAAAA,GAEzC,CAUAE,uBAAAA,CAAwBnB,EAAsDoB,GAC1E,OAAO,IAAIlB,SAAQ,CAACC,EAASC,IAAWgB,EAAwBjB,EAASC,EAAQJ,KAC5EM,MAAMe,IACHxB,KAAKC,QAAQwB,+BAA+BD,EAAAA,IAE/CZ,OAAOY,IACJxB,KAAKC,QAAQwB,+BAA+BD,EAAAA,GAExD,CASAE,yBAAAA,CAA0BvB,EAAwDwB,GAC9E,OAAO,IAAItB,SAAQ,CAACC,EAASC,IAAWoB,EAA0BrB,EAASC,EAAQJ,KAC9EM,MAAMmB,IACH5B,KAAKC,QAAQ4B,iCAAiCD,EAAAA,IAEjDhB,OAAOgB,IACJ5B,KAAKC,QAAQ4B,iCAAiCD,EAAAA,GAE1D,CASAE,wBAAAA,CAAyB3B,EAAuD4B,GAC5E,OAAO,IAAI1B,SAAQ,CAACC,EAASC,IAAWwB,EAAyBzB,EAASC,EAAQJ,KAC7EM,MAAMuB,IACHhC,KAAKC,QAAQgC,gCAAgCD,EAAAA,IAEhDpB,OAAOoB,IACJhC,KAAKC,QAAQgC,gCAAgCD,EAAAA,GAEzD,CASAE,QAAAA,CAAS/B,EAAyBgC,GAC9BA,EAAShC,EACb,CAhJAiC,WAAAA,CAAYC,EAAmDrB,GAH/DsB,EAAAtC,KAAQC,eAAR,GACAqC,EAAAtC,KAAiBgB,eAAjB,GAGIhB,KAAKgB,QAAUA,EAEfhB,KAAKC,QAAU,IAAIsC,gBAAgBvB,EAAQwB,QAASH,GACpDrC,KAAKC,QAAQC,mBAAqBC,IACzBH,KAAKE,mBAAmBC,EAAOa,EAAQZ,mBAAkB,EAElEJ,KAAKC,QAAQiB,oBAAsBf,IAC1BH,KAAKkB,oBAAoBf,EAAOa,EAAQG,oBAAmB,EAGpEnB,KAAKC,QAAQiC,SAAW/B,IACpBH,KAAKkC,SAAS/B,EAAOa,EAAQmB,SAAQ,EAGM,mBAApCnB,EAAQO,0BACfvB,KAAKC,QAAQqB,wBAA0BnB,IAC9BH,KAAKsB,wBAAwBnB,EAAOa,EAAQO,wBAAuB,GAI/B,mBAAtCP,EAAQW,4BACf3B,KAAKC,QAAQyB,0BAA4BvB,IAChCH,KAAK0B,0BAA0BvB,EAAOa,EAAQW,0BAAyB,GAIpC,mBAArCX,EAAQe,2BACf/B,KAAKC,QAAQ6B,yBAA2B3B,IAC/BH,KAAK8B,yBAAyB3B,EAAOa,EAAQe,yBAAwB,EAGtF"}
@@ -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 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};
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){var o,e;const i=n("supportedBrandsRaw").from(t);null===(o=(e=this.props).onBinLookup)||void 0===o||o.call(e,i)}}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