@adyen/adyen-web 6.44.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/adyen.css +8 -8
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +73 -10
- package/dist/es/adyen.css +8 -8
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/BacsDD/BacsDD.js +1 -1
- package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Donation/DonationCampaignService.js +1 -1
- package/dist/es/components/Donation/DonationCampaignService.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/Twint/Twint.js +1 -1
- package/dist/es/components/Twint/Twint.js.map +1 -1
- package/dist/es/components/internal/Address/validate.formats.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/Address/validate.js +1 -1
- package/dist/es/components/internal/Address/validate.js.map +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es/components/internal/PayButton/utils.js +1 -1
- package/dist/es/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/Analytics/constants.js +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/core/config.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/core/utils.js +1 -1
- package/dist/es/core/utils.js.map +1 -1
- package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/index.d.ts +73 -10
- package/dist/es/utils/validator-utils.js +1 -1
- package/dist/es/utils/validator-utils.js.map +1 -1
- package/dist/es-legacy/adyen.css +8 -8
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Donation/DonationCampaignService.js +1 -1
- package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodDetails.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/Twint/Twint.js +1 -1
- package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/core/config.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/core/utils.js +1 -1
- package/dist/es-legacy/core/utils.js.map +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/utils/validator-utils.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js.map +1 -1
- package/package.json +23 -23
- package/styles/adyen.css +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../../../core/Errors/constants';\nimport { isEmpty } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string | null, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string | null): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n houseNumberOrName: {\n
|
|
1
|
+
{"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS, ERROR_INVALID_CHARACTERS } from '../../../core/Errors/constants';\nimport { isEmpty, validateForSpecialChars } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string | null, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string | null): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nconst ruleIsEmpty: ValidatorRule = {\n modes: ['blur'],\n validate: value => (isEmpty(value) ? null : true),\n errorMessage: ERROR_FIELD_REQUIRED\n};\n\nconst ruleValidateForSpecialChars: ValidatorRule = {\n modes: ['blur'],\n validate: value => validateForSpecialChars(value),\n errorMessage: ERROR_INVALID_CHARACTERS\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n street: [\n ruleIsEmpty,\n ruleValidateForSpecialChars\n ],\n houseNumberOrName: [\n {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n ruleValidateForSpecialChars\n ],\n city: [\n ruleIsEmpty,\n ruleValidateForSpecialChars\n ],\n default: ruleIsEmpty\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","ruleIsEmpty","value","ruleValidateForSpecialChars","validateForSpecialChars","ERROR_INVALID_CHARACTERS","getAddressValidationRules","specifications","addressValidationRules","context","state","data","street","houseNumberOrName","selectedCountry","countryHasOptionalField","city","default"],"mappings":"oSAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,EAA4BC,KACxE,GAAID,EAAa,CAEb,GAAIE,EAAQH,GAAM,OAAO,KAGxBE,EAAeE,WAA6BC,aAAe,CACxDC,eAAgBC,EAChBC,kBAAmB,CACfC,OAAQ,CACJC,OAAQC,EAA0BV,IAAcG,WAAWM,QAAU,QAKjF,MAAMb,EAAUe,EAAmBX,IAAcJ,QACjD,OAAOA,EAAUA,EAAQgB,KAAKb,KAASA,CAC3C,CAEA,OAAOG,EAAQH,IAAO,MAGpBY,EAAqB,CACvBE,GAAInB,EAAsB,GAC1BoB,GAAIpB,EAAsB,GAC1BqB,GAAI,CAAEnB,QAAS,0BACfoB,GAAItB,EAAsB,GAC1Bu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AAUG,GAASE,EAAwBF,GAC3CxD,aAAc2D,GAGLC,EAA6BC,IACtC,MAAMC,EAAyC,CAC3C/D,WAAY,CACRqD,MAAO,CAAC,QACRC,SAAU,CAAC1D,EAAKoE,KACZ,MAAMb,EAAUa,EAAQC,MAAMC,KAAKf,QACnC,OAAOxD,EAAmBC,EAAKuD,EAASY,IAE5C9D,aAAcsD,GAElBY,OAAQ,CACJX,EACAE,GAEJU,kBAAmB,CACf,CACId,SAAU,CAACG,EAAOO,KACd,MAAMK,EAAkBL,EAAQC,OAAOC,MAAMf,QAE7C,OADmBkB,GAAmBP,EAAeQ,wBAAwBD,EAAiB,uBACxEtE,EAAQ0D,IAAS,MAE3CJ,MAAO,CAAC,QACRpD,aAAcsD,GAElBG,GAEJa,KAAM,CACFf,EACAE,GAEJc,QAAShB,GAEb,OAAOO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as o}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as
|
|
1
|
+
import{createElement as o}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as e}from"../../../core/Context/CoreProvider.js";import{createButtonLabel as r,createSecondaryLabel as s}from"./utils.js";import m from"./components/SecondaryButtonLabel.js";import{useAmount as i,useSecondaryAmount as a}from"../../../core/Context/AmountProvider.js";import{isAmountValid as n}from"../../../utils/amount-util.js";const u=({customAmount:u,classNameModifiers:l=[],label:c,icon:d,showReview:p,...f})=>{const{amount:b,isZeroAuth:j}=i(),{secondaryAmount:A}=a(),{i18n:v}=e(),h=r(v,{customLabel:c,amount:b,isZeroAuth:j,customAmount:u,secondaryAmount:A,showReview:p}),w=d&&!p?d:void 0,x=s(v,A,n(b),j,c),y=f.disabled||"loading"===f.status;return o(t,{...f,icon:w,disabled:y,classNameModifiers:[...l,"pay"],label:h},x&&o(m,{label:x}))};export{u as default};
|
|
2
2
|
//# sourceMappingURL=PayButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { createButtonLabel, createSecondaryLabel } from './utils';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\nimport { useAmount, useSecondaryAmount } from '../../../core/Context/AmountProvider';\nimport type { PaymentAmount } from '../../../types';\nimport { isAmountValid } from '../../../utils/amount-util';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n /**\n * Custom amount that can be passed to the button.\n * This is useful when the amount is not available in the amount provider, such as Giftcard scenario where\n * we need to display the remaining amount\n */\n customAmount?: PaymentAmount;\n label?: string;\n status?: string;\n disabled?: boolean;\n icon?: string;\n}\n\nconst PayButton = ({ customAmount, classNameModifiers = [], label, ...props }: Readonly<PayButtonProps>) => {\n const { amount, isZeroAuth } = useAmount();\n const { secondaryAmount } = useSecondaryAmount();\n const { i18n } = useCoreContext();\n\n const buttonLabel = createButtonLabel(i18n, label, amount, isZeroAuth, customAmount, secondaryAmount);\n const secondaryAmountLabel = createSecondaryLabel(i18n, secondaryAmount, isAmountValid(amount), isZeroAuth, label);\n\n const isDisabled = props.disabled || props.status === 'loading';\n\n return (\n <Button {...props} disabled={isDisabled} classNameModifiers={[...classNameModifiers, 'pay']} label={buttonLabel}>\n {secondaryAmountLabel && <SecondaryButtonLabel label={secondaryAmountLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\n"],"names":["PayButton","customAmount","classNameModifiers","label","props","amount","isZeroAuth","useAmount","secondaryAmount","useSecondaryAmount","i18n","useCoreContext","buttonLabel","createButtonLabel","secondaryAmountLabel","createSecondaryLabel","isAmountValid","isDisabled","disabled","status","h","Button","SecondaryButtonLabel"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { createButtonLabel, createSecondaryLabel } from './utils';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\nimport { useAmount, useSecondaryAmount } from '../../../core/Context/AmountProvider';\nimport type { PaymentAmount } from '../../../types';\nimport { isAmountValid } from '../../../utils/amount-util';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n /**\n * Custom amount that can be passed to the button.\n * This is useful when the amount is not available in the amount provider, such as Giftcard scenario where\n * we need to display the remaining amount\n */\n customAmount?: PaymentAmount;\n label?: string;\n status?: string;\n disabled?: boolean;\n icon?: string;\n showReview?: boolean;\n}\n\nconst PayButton = ({ customAmount, classNameModifiers = [], label, icon, showReview, ...props }: Readonly<PayButtonProps>) => {\n const { amount, isZeroAuth } = useAmount();\n const { secondaryAmount } = useSecondaryAmount();\n const { i18n } = useCoreContext();\n\n const buttonLabel = createButtonLabel(i18n, { customLabel: label, amount, isZeroAuth, customAmount, secondaryAmount, showReview });\n const buttonIcon = icon && !showReview ? icon : undefined;\n const secondaryAmountLabel = createSecondaryLabel(i18n, secondaryAmount, isAmountValid(amount), isZeroAuth, label);\n\n const isDisabled = props.disabled || props.status === 'loading';\n\n return (\n <Button {...props} icon={buttonIcon} disabled={isDisabled} classNameModifiers={[...classNameModifiers, 'pay']} label={buttonLabel}>\n {secondaryAmountLabel && <SecondaryButtonLabel label={secondaryAmountLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\n"],"names":["PayButton","customAmount","classNameModifiers","label","icon","showReview","props","amount","isZeroAuth","useAmount","secondaryAmount","useSecondaryAmount","i18n","useCoreContext","buttonLabel","createButtonLabel","customLabel","buttonIcon","undefined","secondaryAmountLabel","createSecondaryLabel","isAmountValid","isDisabled","disabled","status","h","Button","SecondaryButtonLabel"],"mappings":"ycA4BA,MAAMA,EAAY,EAAGC,eAAcC,qBAAqB,GAAIC,QAAOC,OAAMC,gBAAeC,MACpF,MAAMC,OAAEA,EAAMC,WAAEA,GAAeC,KACzBC,gBAAEA,GAAoBC,KACtBC,KAAEA,GAASC,IAEXC,EAAcC,EAAkBH,EAAM,CAAEI,YAAab,EAAOI,SAAQC,aAAYP,eAAcS,kBAAiBL,eAC/GY,EAAab,IAASC,EAAaD,OAAOc,EAC1CC,EAAuBC,EAAqBR,EAAMF,EAAiBW,EAAcd,GAASC,EAAYL,GAEtGmB,EAAahB,EAAMiB,UAA6B,YAAjBjB,EAAMkB,OAE3C,OACIC,EAACC,EAAAA,IAAWpB,EAAOF,KAAMa,EAAYM,SAAUD,EAAYpB,mBAAoB,IAAIA,EAAoB,OAAQC,MAAOW,GACjHK,GAAwBM,EAACE,EAAAA,CAAqBxB,MAAOgB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t="/ ",n=(t,n)=>n?.value&&n?.currency?t.amount(n.value,n.currency,{currencyDisplay:n.currencyDisplay||"symbol"}):"",r=t=>{const n=t.get("payAmountFormat"),r=n.indexOf("%@");return r>=0&&n.substring(r+2).trim().length>0},e=(t,e,o)=>{const c=n(t,e);if(!c)return t.get("payButton");if(o&&r(t)){const n=u(t,o);return t.get("payAmountFormat").replace("%@",`${c}${n}`)}return t.get("payAmountFormat").replace("%@",c)},u=(t,n)=>{const r=n&&n?.value&&n?.currency?t.amount(n.value,n.currency,{currencyDisplay:n.currencyDisplay||"symbol"}):"";return`${r.length?"/ ":""}${r}`};function o(t,{customLabel:n,amount:r,isZeroAuth:u,customAmount:o,secondaryAmount:c,showReview:a}){return a?t.get("continue"):n||(o?e(t,o):u?t.get("confirmPreauthorization"):e(t,r,c))}function c(t,n,e,o,c){return o||c||!e||!n||r(t)?null:u(t,n)}export{t as PAY_BTN_DIVIDER,n as amountLabel,o as createButtonLabel,c as createSecondaryLabel,e as payAmountLabel};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/PayButton/utils.ts"],"sourcesContent":["import Language from '../../../language';\nimport type { PaymentAmount } from '../../../types/global-types';\n\nexport const PAY_BTN_DIVIDER = '/ ';\n\nconst amountLabel = (i18n, amount: PaymentAmount) =>\n !!amount?.value && !!amount?.currency ? i18n.amount(amount.value, amount.currency, { currencyDisplay: amount.currencyDisplay || 'symbol' }) : '';\n\nconst isAmountFirstFormat = (i18n: Language): boolean => {\n const format = i18n.get('payAmountFormat');\n const tokenIndex = format.indexOf('%@');\n return tokenIndex >= 0 && format.substring(tokenIndex + 2).trim().length > 0;\n};\n\nconst payAmountLabel = (i18n: Language, amount: PaymentAmount, secondaryAmount?: PaymentAmount) => {\n const amountLabelValue = amountLabel(i18n, amount);\n if (!amountLabelValue) {\n return i18n.get('payButton');\n }\n\n if (secondaryAmount && isAmountFirstFormat(i18n)) {\n const secondaryAmountValue = formatSecondaryAmountLabel(i18n, secondaryAmount);\n return i18n.get('payAmountFormat').replace('%@', `${amountLabelValue}${secondaryAmountValue}`);\n }\n\n return i18n.get('payAmountFormat').replace('%@', amountLabelValue);\n};\n\nconst formatSecondaryAmountLabel = (i18n: Language, secondaryAmount: PaymentAmount) => {\n const convertedSecondaryAmount =\n secondaryAmount && !!secondaryAmount?.value && !!secondaryAmount?.currency\n ? i18n.amount(secondaryAmount.value, secondaryAmount.currency, { currencyDisplay: secondaryAmount.currencyDisplay || 'symbol' })\n : '';\n\n const divider = convertedSecondaryAmount.length ? PAY_BTN_DIVIDER : '';\n\n return `${divider}${convertedSecondaryAmount}`;\n};\n\nfunction createButtonLabel(\n i18n: Language,\n customLabel: string
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/PayButton/utils.ts"],"sourcesContent":["import Language from '../../../language';\nimport type { PaymentAmount } from '../../../types/global-types';\n\nexport const PAY_BTN_DIVIDER = '/ ';\n\nconst amountLabel = (i18n, amount: PaymentAmount) =>\n !!amount?.value && !!amount?.currency ? i18n.amount(amount.value, amount.currency, { currencyDisplay: amount.currencyDisplay || 'symbol' }) : '';\n\nconst isAmountFirstFormat = (i18n: Language): boolean => {\n const format = i18n.get('payAmountFormat');\n const tokenIndex = format.indexOf('%@');\n return tokenIndex >= 0 && format.substring(tokenIndex + 2).trim().length > 0;\n};\n\nconst payAmountLabel = (i18n: Language, amount: PaymentAmount, secondaryAmount?: PaymentAmount) => {\n const amountLabelValue = amountLabel(i18n, amount);\n if (!amountLabelValue) {\n return i18n.get('payButton');\n }\n\n if (secondaryAmount && isAmountFirstFormat(i18n)) {\n const secondaryAmountValue = formatSecondaryAmountLabel(i18n, secondaryAmount);\n return i18n.get('payAmountFormat').replace('%@', `${amountLabelValue}${secondaryAmountValue}`);\n }\n\n return i18n.get('payAmountFormat').replace('%@', amountLabelValue);\n};\n\nconst formatSecondaryAmountLabel = (i18n: Language, secondaryAmount: PaymentAmount) => {\n const convertedSecondaryAmount =\n secondaryAmount && !!secondaryAmount?.value && !!secondaryAmount?.currency\n ? i18n.amount(secondaryAmount.value, secondaryAmount.currency, { currencyDisplay: secondaryAmount.currencyDisplay || 'symbol' })\n : '';\n\n const divider = convertedSecondaryAmount.length ? PAY_BTN_DIVIDER : '';\n\n return `${divider}${convertedSecondaryAmount}`;\n};\n\nfunction createButtonLabel(\n i18n: Language,\n {\n customLabel,\n amount,\n isZeroAuth,\n customAmount,\n secondaryAmount,\n showReview\n }: {\n customLabel: string;\n amount: PaymentAmount;\n isZeroAuth: boolean;\n customAmount?: PaymentAmount;\n secondaryAmount?: PaymentAmount;\n showReview?: boolean;\n }\n): string {\n if (showReview) {\n return i18n.get('continue');\n }\n\n if (customLabel) {\n return customLabel;\n }\n\n if (customAmount) {\n return payAmountLabel(i18n, customAmount);\n }\n\n return isZeroAuth ? i18n.get('confirmPreauthorization') : payAmountLabel(i18n, amount, secondaryAmount);\n}\n\n/**\n * Show the secondaryLabel if:\n * - it's not zero auth, and\n * - we don't have a predefined label (i.e. redirect, qrcode, await based comps...), and\n * - we do have an amount object (merchant might not be passing this in order to not show the amount on the button), and\n * - we have a secondaryAmount object with some properties, and\n * - the payAmountFormat is not amount-first (e.g. \"%@ betalen\"), since in that case the secondary\n * amount is already embedded in the button label via createButtonLabel\n */\nfunction createSecondaryLabel(\n i18n: Language,\n secondaryAmount: PaymentAmount,\n isAmountValid: boolean,\n isZeroAuth: boolean,\n customLabel: string\n): string | null {\n if (isZeroAuth || customLabel || !isAmountValid || !secondaryAmount) {\n return null;\n }\n\n if (isAmountFirstFormat(i18n)) {\n return null;\n }\n\n return formatSecondaryAmountLabel(i18n, secondaryAmount);\n}\n\nexport { payAmountLabel, amountLabel, createButtonLabel, createSecondaryLabel };\n"],"names":["PAY_BTN_DIVIDER","amountLabel","i18n","amount","value","currency","currencyDisplay","isAmountFirstFormat","format","get","tokenIndex","indexOf","substring","trim","length","payAmountLabel","secondaryAmount","amountLabelValue","secondaryAmountValue","formatSecondaryAmountLabel","replace","convertedSecondaryAmount","createButtonLabel","customLabel","isZeroAuth","customAmount","showReview","createSecondaryLabel","isAmountValid"],"mappings":"AAGO,MAAMA,EAAkB,KAEzBC,EAAc,CAACC,EAAMC,IACrBA,GAAQC,OAAWD,GAAQE,SAAWH,EAAKC,OAAOA,EAAOC,MAAOD,EAAOE,SAAU,CAAEC,gBAAiBH,EAAOG,iBAAmB,WAAc,GAE5IC,EAAuBL,IACzB,MAAMM,EAASN,EAAKO,IAAI,mBAClBC,EAAaF,EAAOG,QAAQ,MAClC,OAAOD,GAAc,GAAKF,EAAOI,UAAUF,EAAa,GAAGG,OAAOC,OAAS,GAGzEC,EAAiB,CAACb,EAAgBC,EAAuBa,KAC3D,MAAMC,EAAmBhB,EAAYC,EAAMC,GAC3C,IAAKc,EACD,OAAOf,EAAKO,IAAI,aAGpB,GAAIO,GAAmBT,EAAoBL,GAAO,CAC9C,MAAMgB,EAAuBC,EAA2BjB,EAAMc,GAC9D,OAAOd,EAAKO,IAAI,mBAAmBW,QAAQ,KAAM,GAAGH,IAAmBC,IAC3E,CAEA,OAAOhB,EAAKO,IAAI,mBAAmBW,QAAQ,KAAMH,IAG/CE,EAA6B,CAACjB,EAAgBc,KAChD,MAAMK,EACFL,GAAqBA,GAAiBZ,OAAWY,GAAiBX,SAC5DH,EAAKC,OAAOa,EAAgBZ,MAAOY,EAAgBX,SAAU,CAAEC,gBAAiBU,EAAgBV,iBAAmB,WACnH,GAIV,MAAO,GAFSe,EAAyBP,OA/Bd,KA+ByC,KAEhDO,KAGxB,SAASC,EACLpB,GACAqB,YACIA,EAAWpB,OACXA,EAAMqB,WACNA,EAAUC,aACVA,EAAYT,gBACZA,EAAeU,WACfA,IAUJ,OAAIA,EACOxB,EAAKO,IAAI,YAGhBc,IAIAE,EACOV,EAAeb,EAAMuB,GAGzBD,EAAatB,EAAKO,IAAI,2BAA6BM,EAAeb,EAAMC,EAAQa,GAC3F,CAWA,SAASW,EACLzB,EACAc,EACAY,EACAJ,EACAD,GAEA,OAAIC,GAAcD,IAAgBK,IAAkBZ,GAIhDT,EAAoBL,GAHb,KAOJiB,EAA2BjB,EAAMc,EAC5C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as n}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as i}from"../../../utils/hasOwnProperty.js";import o from"../BaseElement/BaseElement.js";import r from"../PayButton/PayButton.js";import{assertIsDropin as a,getRegulatoryDefaults as h,sanitizeResponse as d,verifyPaymentDidNotFail as l,cleanupFinalResult as m}from"./utils.js";import{AnalyticsErrorEvent as p,ErrorEventType as c}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as u,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as f,LogEventType as R}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as A}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as E}from"../../../core/Context/AmountProvider.js";import{TxVariants as g}from"../../tx-variants.js";function v(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class w extends o{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(e?.originalAction)return;const t=new u({type:y.rendered,component:this.type,configData:{...e,showPayButton:this.props.showPayButton},...e?.oneClick&&{isStoredPaymentMethod:!0}});this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return e?.storedPaymentMethodId?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(e?.type,e?.paymentMethodId)}buildElementProps(e){const t={showPayButton:!0,...this.core.getCorePropsForComponent(),...this.getPaymentMethodConfigFromResponse(e),...e},s=a(this);this.props=this.formatProps({...this.constructor.defaultProps,...h(this.core.options.countryCode,s),...t})}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){return t?this.core.paymentMethodsResponse.findById(t):this.core.paymentMethodsResponse?.find(e||this.constructor.type)}storeElementRefOnCore(e){e?.isDropin||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state={...this.state,...e},this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){this.props={...this.props,...e&&{amount:e},...t&&{secondaryAmount:t}},this.amountProviderRef.current?.update(e,t)}setElementStatus(e,t){return this.elementRef?.setStatus(e,t),this}setStatus(e,t){return this.componentRef?.setStatus&&this.componentRef.setStatus(e,t),this}onChange(){this.props.onChange?.({data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(d).then(l).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new f({component:this.type,type:R.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new f({component:this.type,type:R.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(d).then(l).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(i(e,"action")&&i(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,{...this.elementRef.props,...t});return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){this.props?.onActionHandled?.({originalAction:this.props.originalAction,...e})}setupSessionsDonation(){const{amount:e,donation:t}=this.props;if(!1!==t?.autoMount){const t=a(this.elementRef)?this.elementRef._node:this._node;new(this.core.getComponent(g.donation))(this.core,{rootNode:t,commercialTxAmount:e.value})}}handleResponse(e){e.action?this.elementRef.handleAction(e.action):e.order?.remainingAmount?.value>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyDown(e){"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(document?.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){const e=this.props.paymentMethodType||this.type;return this.props.icon??this.resources.getImage()(e)}get displayName(){const e=this.core.paymentMethodsResponse?.paymentMethods?.find(e=>e.type===this.type);return this.props.name||e?.name||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest({...e&&{order:{orderData:e.orderData,pspReference:e.pspReference}},locale:this.core.options.locale},{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update({...s&&{paymentMethodsResponse:s},order:e,amount:e?e.remainingAmount:t}))}render(){return e(A,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},e(E,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,i){super(s,i),v(this,"componentRef",void 0),v(this,"resources",void 0),v(this,"elementRef",void 0),v(this,"amountProviderRef",t()),v(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===n&&e.options.code){const t=new p({component:this.type,errorType:c.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),v(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{this.props.onOrderUpdated?.({order:t})})}),v(this,"handleFailedResult",e=>{a(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),m(e),this.props.onPaymentFailed?.(e,this.elementRef)}),v(this,"handleSuccessResult",e=>{a(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),m(e),this.core.session&&!0===e.askDonation&&this.setupSessionsDonation(),this.props.onPaymentCompleted?.(e,this.elementRef)}),v(this,"setComponentRef",e=>{this.componentRef=e}),v(this,"payButton",t=>e(r,{...t,onClick:this.submit})),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.setupSessionsDonation=this.setupSessionsDonation.bind(this),this.elementRef=i&&i.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(i),this.reportIntegrationFlavor()}}v(w,"type",void 0),v(w,"txVariants",[]);export{w as UIElement,w as default};
|
|
1
|
+
import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as i}from"../../../core/Errors/AdyenCheckoutError.js";import o from"../../../core/Services/order-status.js";import{hasOwnProperty as n}from"../../../utils/hasOwnProperty.js";import r from"../BaseElement/BaseElement.js";import a from"../PayButton/PayButton.js";import{assertIsDropin as h,getRegulatoryDefaults as d,sanitizeResponse as l,verifyPaymentDidNotFail as p,cleanupFinalResult as m}from"./utils.js";import{AnalyticsErrorEvent as c,ErrorEventType as u}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as y,InfoEventType as f}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as R,LogEventType as A}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as P}from"../../../core/Context/CoreProvider.js";import g from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as E}from"../../../core/Context/AmountProvider.js";import{TxVariants as v}from"../../tx-variants.js";function w(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class C extends r{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(e?.originalAction)return;const t=new y({type:f.rendered,component:this.type,configData:{...e,showPayButton:this.props.showPayButton},...e?.oneClick&&{isStoredPaymentMethod:!0}});this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return e?.storedPaymentMethodId?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(e?.type,e?.paymentMethodId)}buildElementProps(e){const t={showPayButton:!0,...this.core.getCorePropsForComponent(),...this.getPaymentMethodConfigFromResponse(e),...e},s=h(this);this.props=this.formatProps({...this.constructor.defaultProps,...d(this.core.options.countryCode,s),...t})}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){return t?this.core.paymentMethodsResponse.findById(t):this.core.paymentMethodsResponse?.find(e||this.constructor.type)}storeElementRefOnCore(e){e?.isDropin||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state={...this.state,...e},this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){this.props={...this.props,...e&&{amount:e},...t&&{secondaryAmount:t}},this.amountProviderRef.current?.update(e,t)}setElementStatus(e,t){return this.elementRef?.setStatus(e,t),this}setStatus(e,t){return this.componentRef?.setStatus&&this.componentRef.setStatus(e,t),this}onChange(){this.props.onChange?.({data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){if(this.isValid){if(this.props.onReview){const e=this.state.order??this.props.order,t=(e={})=>{this.submitAnalytics(new R({component:this.type,type:A.review,message:"Review flow triggered"})),this.props.onReview(this.data,this.elementRef,e)};return e?void o({clientKey:this.props.clientKey,loadingContext:this.props.loadingContext},e).then(e=>t({orderStatus:e})).catch(()=>t()):void t()}this.executePaymentsCall()}else this.showValidation()}executePaymentsCall(){this.makePaymentsCall().then(l).then(p).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)})}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new R({component:this.type,type:A.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new R({component:this.type,type:A.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(l).then(p).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(n(e,"action")&&n(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,{...this.elementRef.props,...t});return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){this.props?.onActionHandled?.({originalAction:this.props.originalAction,...e})}setupSessionsDonation(){const{amount:e,donation:t}=this.props;if(!1!==t?.autoMount){const t=h(this.elementRef)?this.elementRef._node:this._node;new(this.core.getComponent(v.donation))(this.core,{rootNode:t,commercialTxAmount:e.value})}}handleResponse(e){e.action?this.core.options?.onAction?this.core.options.onAction(this.core.createFromAction(e.action,{...this.elementRef.props})):this.elementRef.handleAction(e.action):e.order?.remainingAmount?.value>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyDown(e){"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(document?.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){const e=this.props.paymentMethodType||this.type;return this.props.icon??this.resources.getImage()(e)}get displayName(){const e=this.core.paymentMethodsResponse?.paymentMethods?.find(e=>e.type===this.type);return this.props.name||e?.name||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest({...e&&{order:{orderData:e.orderData,pspReference:e.pspReference}},locale:this.core.options.locale},{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update({...s&&{paymentMethodsResponse:s},order:e,amount:e?e.remainingAmount:t}))}render(){return e(P,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(g,{srPanel:this.srPanel},e(E,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,o){super(s,o),w(this,"componentRef",void 0),w(this,"resources",void 0),w(this,"elementRef",void 0),w(this,"amountProviderRef",t()),w(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===i&&e.options.code){const t=new c({component:this.type,errorType:u.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),w(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{this.props.onOrderUpdated?.({order:t})})}),w(this,"handleFailedResult",e=>{h(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),m(e),this.props.onPaymentFailed?.(e,this.elementRef)}),w(this,"handleSuccessResult",e=>{h(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),m(e),this.core.session&&!0===e.askDonation&&this.setupSessionsDonation(),this.props.onPaymentCompleted?.(e,this.elementRef)}),w(this,"setComponentRef",e=>{this.componentRef=e}),w(this,"payButton",t=>e(a,{...t,onClick:this.submit,showReview:!!this.props.onReview})),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.setupSessionsDonation=this.setupSessionsDonation.bind(this),this.elementRef=o&&o.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(o),this.reportIntegrationFlavor()}}w(C,"type",void 0),w(C,"txVariants",[]);export{C as UIElement,C as default};
|
|
2
2
|
//# sourceMappingURL=UIElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { createRef, h, RefObject, TargetedKeyboardEvent } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { ComponentMethodsRef, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { AmountProvider, AmountProviderRef } from '../../../core/Context/AmountProvider';\nimport { PayButtonProps } from '../PayButton/PayButton';\nimport { TxVariants } from '../../tx-variants';\nimport Donation from '../../Donation/Donation';\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n /**\n * componentRef is a ref to the primary component inside the subclass that extends UIElement e.g. CardInput.tsx (which sits inside Card.tsx)\n */\n protected componentRef: any;\n\n protected resources: Resources;\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx or Dropin.tsx\n */\n public elementRef: UIElement;\n\n public static readonly type: string | undefined = undefined;\n\n /**\n * Reference to the methods exposed by the AmountProvider context\n */\n protected amountProviderRef: RefObject<AmountProviderRef> = createRef();\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static readonly txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n this.updateAmount = this.updateAmount.bind(this);\n this.setupSessionsDonation = this.setupSessionsDonation.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n protected getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * Updates the amount in the props and propagates it to the AmountProvider.\n * This allows children components to access the updated amount via context.\n *\n * @param amount - Primary payment amount object\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n public updateAmount(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n this.props = {\n ...this.props,\n ...(amount && { amount }),\n ...(secondaryAmount && { secondaryAmount })\n };\n this.amountProviderRef.current?.update(amount, secondaryAmount);\n }\n\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) => {\n void this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n });\n })\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8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HNZiiANOf3uvSknPKBID8sdOXUStA0crmO322FYjDqh1n6FG+D7+OJSayNsXIz6Zoy0eFn4HbT8nt8L2X2tdzkMayCYHXRwKh13Xyleqxt4WoEZmhwTmB3p9d1F0SylWnjcC6o/DnshJ9mMW/8D3oWS30Z7BwRODqKGVahRD0YGRzwMbVnEe5JFRfNvJZdLGl35L9632DVmuFQ0lr/8WNL/NrAJNtI6PXrZMNiza0/omPwPfe5ZYuD1Jgq59TX4h9d+3fdkArcJYL7AdoMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n this.handleAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session\n ? this.core.update({\n order\n })\n : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n protected setupSessionsDonation() {\n const { amount, donation } = this.props;\n\n // If merchant hasn't explicitly disabled autoMount by setting it to false\n if (donation?.autoMount !== false) {\n const rootNode: HTMLElement = assertIsDropin(this.elementRef) ? this.elementRef._node : this._node;\n\n const DonationComponentRef = this.core.getComponent(TxVariants.donation) as typeof Donation;\n new DonationComponentRef(this.core, { rootNode, commercialTxAmount: amount.value }); // NOSONAR: Instantiation triggers internal async initialization (fire-and-forget pattern)\n }\n }\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n\n /** If we are using sessions and the response mandates it - create a Donation instance */\n if (this.core.session && result.askDonation === true) {\n this.setupSessionsDonation();\n }\n\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyDown(e: TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyDown)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonProps) => {\n return <PayButton {...props} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element | null;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n <SRPanelProvider srPanel={this.srPanel}>\n <AmountProvider amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} providerRef={this.amountProviderRef}>\n {this.componentToRender()}\n </AmountProvider>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","configData","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","updateAmount","amount","secondaryAmount","amountProviderRef","current","update","setElementStatus","status","elementRef","setStatus","data","isValid","errors","valid","submitAnalytics","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","AnalyticsLogEvent","LogEventType","message","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","setupSessionsDonation","donation","autoMount","rootNode","getComponent","TxVariants","commercialTxAmount","value","response","order","remainingAmount","handleOrder","handleSuccessResult","handleKeyDown","key","code","preventDefault","onEnterKeyPressed","document","activeElement","blur","updateParent","icon","paymentMethodType","resources","getImage","displayName","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","loadingContext","SRPanelProvider","AmountProvider","providerRef","componentToRender","checkout","super","_define_property","createRef","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","onOrderUpdated","result","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","askDonation","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","onClick","register","bind","undefined","txVariants"],"mappings":"wrCAsCO,MAAeA,UAA6DC,EAgEvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiB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BAA4BjG,KAAKiG,0BAA0BoF,KAAKrL,MACrEA,KAAKsF,wBAA0BtF,KAAKsF,wBAAwB+F,KAAKrL,MACjEA,KAAKwD,aAAexD,KAAKwD,aAAa6H,KAAKrL,MAC3CA,KAAKgH,sBAAwBhH,KAAKgH,sBAAsBqE,KAAKrL,MAE7DA,KAAKgE,WAAclD,GAASA,EAAMkD,YAAehE,KACjDA,KAAKwI,UAAYxI,KAAKc,MAAMQ,QAAUtB,KAAKc,MAAMQ,QAAQkH,eAAY8C,EAErEtL,KAAK4C,sBAAsB5C,KAAKc,OAEhCd,KAAKiI,kBAAoBjI,KAAKiI,kBAAkBoD,KAAKrL,MACrDA,KAAK8G,gBAAkB9G,KAAK8G,gBAAgBuE,KAAKrL,MAEjDA,KAAKH,uBAAuBiB,GAC5Bd,KAAKmB,yBACT,EA1CA6I,EAbkBrK,EAaKa,YAA2B8K,GAUlDtB,EAvBkBrK,EAuBK4L,aAAuB"}
|
|
1
|
+
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { createRef, h, RefObject, TargetedKeyboardEvent } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport getOrderStatus from '../../../core/Services/order-status';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore, ReviewDetails } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { ComponentMethodsRef, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { AmountProvider, AmountProviderRef } from '../../../core/Context/AmountProvider';\nimport { PayButtonProps } from '../PayButton/PayButton';\nimport { TxVariants } from '../../tx-variants';\nimport Donation from '../../Donation/Donation';\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n /**\n * componentRef is a ref to the primary component inside the subclass that extends UIElement e.g. CardInput.tsx (which sits inside Card.tsx)\n */\n protected componentRef: any;\n\n protected resources: Resources;\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx or Dropin.tsx\n */\n public elementRef: UIElement;\n\n public static readonly type: string | undefined = undefined;\n\n /**\n * Reference to the methods exposed by the AmountProvider context\n */\n protected amountProviderRef: RefObject<AmountProviderRef> = createRef();\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static readonly txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n this.updateAmount = this.updateAmount.bind(this);\n this.setupSessionsDonation = this.setupSessionsDonation.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n protected getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * Updates the amount in the props and propagates it to the AmountProvider.\n * This allows children components to access the updated amount via context.\n *\n * @param amount - Primary payment amount object\n * @param secondaryAmount - Optional secondary amount for display purposes (e.g., converted currency)\n * @internal\n */\n public updateAmount(amount: PaymentAmount, secondaryAmount?: PaymentAmount): void {\n this.props = {\n ...this.props,\n ...(amount && { amount }),\n ...(secondaryAmount && { secondaryAmount })\n };\n this.amountProviderRef.current?.update(amount, secondaryAmount);\n }\n\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n if (this.props.onReview) {\n const order = this.state.order ?? this.props.order;\n const onReview = (reviewDetails: ReviewDetails = {}) => {\n this.submitAnalytics(new AnalyticsLogEvent({ component: this.type, type: LogEventType.review, message: 'Review flow triggered' }));\n this.props.onReview(this.data, this.elementRef, reviewDetails);\n };\n if (order) {\n void getOrderStatus({ clientKey: this.props.clientKey, loadingContext: this.props.loadingContext }, order)\n .then(orderStatus => onReview({ orderStatus }))\n .catch(() => onReview());\n return;\n }\n onReview();\n return;\n }\n\n this.executePaymentsCall();\n }\n\n public executePaymentsCall(): void {\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) => {\n void this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n });\n })\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXCdSC4ksw9CNDBAjOa+B88wRoj/rLTieuWh/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJ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/NrAJNtI6PXrZMNiza0/omPwPfe5ZYuD1Jgq59TX4h9d+3fdkArcJYL7AdoMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n this.handleAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session\n ? this.core.update({\n order\n })\n : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n protected setupSessionsDonation() {\n const { amount, donation } = this.props;\n\n // If merchant hasn't explicitly disabled autoMount by setting it to false\n if (donation?.autoMount !== false) {\n const rootNode: HTMLElement = assertIsDropin(this.elementRef) ? this.elementRef._node : this._node;\n\n const DonationComponentRef = this.core.getComponent(TxVariants.donation) as typeof Donation;\n new DonationComponentRef(this.core, { rootNode, commercialTxAmount: amount.value }); // NOSONAR: Instantiation triggers internal async initialization (fire-and-forget pattern)\n }\n }\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n\n /** If we are using sessions and the response mandates it - create a Donation instance */\n if (this.core.session && result.askDonation === true) {\n this.setupSessionsDonation();\n }\n\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n if (this.core.options?.onAction) {\n this.core.options.onAction(this.core.createFromAction(response.action, { ...this.elementRef.props }));\n } else {\n this.elementRef.handleAction(response.action);\n }\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyDown(e: TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyDown)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonProps) => {\n return <PayButton {...props} onClick={this.submit} showReview={!!this.props.onReview} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element | null;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n <SRPanelProvider srPanel={this.srPanel}>\n <AmountProvider amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} providerRef={this.amountProviderRef}>\n {this.componentToRender()}\n </AmountProvider>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","configData","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","updateAmount","amount","secondaryAmount","amountProviderRef","current","update","setElementStatus","status","elementRef","setStatus","data","isValid","errors","valid","submitAnalytics","submit","onReview","order","reviewDetails","AnalyticsLogEvent","LogEventType","review","message","getOrderStatus","clientKey","loadingContext","then","orderStatus","catch","executePaymentsCall","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","setupSessionsDonation","donation","autoMount","rootNode","getComponent","TxVariants","commercialTxAmount","value","response","onAction","remainingAmount","handleOrder","handleSuccessResult","handleKeyDown","key","code","preventDefault","onEnterKeyPressed","document","activeElement","blur","updateParent","icon","paymentMethodType","resources","getImage","displayName","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","SRPanelProvider","AmountProvider","providerRef","componentToRender","checkout","super","_define_property","createRef","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","onOrderUpdated","result","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","askDonation","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","onClick","showReview","register","bind","undefined","txVariants"],"mappings":"8uCAuCO,MAAeA,UAA6DC,EAgEvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiBC,KAAKC,OAE5BD,KAAKC,OAAS,IAAIC,KACdF,KAAKG,aAAaL,GACXC,EAAeK,MAAMJ,KAAME,GA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+1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ERROR_INVALID_CHARACTERS as t,ERROR_INVALID_FORMAT_EXPECTS as o,ERROR_FIELD_REQUIRED as e,BOLETO_SOCIAL_SECURITY_NUMBER_INVALID as r,CREDITCARD_TAX_NUMBER_INVALID as c,CREDITCARD_HOLDER_NAME_INVALID as s}from"../Errors/constants.js";const n=3e3,$={[s]:"925",[c]:"942",[r]:"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",[t]:"937"},_="fetch-checkoutAttemptId-failed";export{n as ANALYTICS_SEARCH_DEBOUNCE_TIME,_ as NO_CHECKOUT_ATTEMPT_ID,$ 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_SEARCH_DEBOUNCE_TIME = 3000;\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 NO_CHECKOUT_ATTEMPT_ID = 'fetch-checkoutAttemptId-failed';\n"],"names":["ANALYTICS_SEARCH_DEBOUNCE_TIME","errorCodeMapping","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","NO_CHECKOUT_ATTEMPT_ID"],"mappings":"
|
|
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_CHARACTERS,\n ERROR_INVALID_FORMAT_EXPECTS\n} from '../Errors/constants';\n\nexport const ANALYTICS_PATH = 'v3/analytics';\n\nexport const ANALYTICS_SEARCH_DEBOUNCE_TIME = 3000;\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 [ERROR_INVALID_CHARACTERS]: '937'\n //\n};\n\nexport const NO_CHECKOUT_ATTEMPT_ID = 'fetch-checkoutAttemptId-failed';\n"],"names":["ANALYTICS_SEARCH_DEBOUNCE_TIME","errorCodeMapping","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ERROR_FIELD_REQUIRED","ERROR_INVALID_FORMAT_EXPECTS","ERROR_INVALID_CHARACTERS","NO_CHECKOUT_ATTEMPT_ID"],"mappings":"gPAWO,MAAMA,EAAiC,IAKjCC,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,MACjDC,CAACA,GAA2B,OAInBC,EAAyB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AbstractAnalyticsEvent as e,AnalyticsEventCategory as t}from"./AbstractAnalyticsEvent.js";function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n=function(e){return e.action="action",e.submit="submit",e.redirect="redirect",e.threeDS2="threeDS2",e.closed="closed",e.apiRequest="apiRequest",e}({}),
|
|
1
|
+
import{AbstractAnalyticsEvent as e,AnalyticsEventCategory as t}from"./AbstractAnalyticsEvent.js";function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n=function(e){return e.action="action",e.submit="submit",e.redirect="redirect",e.threeDS2="threeDS2",e.closed="closed",e.apiRequest="apiRequest",e.review="review",e}({}),i=function(e){return e.challengeIframeLoaded="challengeIframeLoaded",e.challengeDataSentWeb="challengeDataSentWeb",e.challengeCompleted="challengeCompleted",e.fingerprintDataSentWeb="fingerprintDataSentWeb",e.fingerprintCompleted="fingerprintCompleted",e.fingerprintIframeLoaded="fingerprintIframeLoaded",e.threeDS2="threeDS2",e.redirect="redirect",e.voucher="voucher",e.await="awat",e.qrCode="qrCode",e.bankTransfer="bankTransfer",e.sdk="sdk",e.donation="donation",e.donationCampaigns="donationCampaigns",e.review="review",e}({});class a extends e{getEventCategory(){return t.log}static getSubtypeFromActionType(e){return i[e]}constructor(e){super(e.component),r(this,"type",void 0),r(this,"subType",void 0),r(this,"message",void 0),r(this,"result",void 0),this.type=e.type,this.message=e.message,e.subType&&(this.subType=e.subType),e.result&&(this.result=e.result)}}export{a as AnalyticsLogEvent,i as LogEventSubtype,n as LogEventType};
|
|
2
2
|
//# sourceMappingURL=AnalyticsLogEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsLogEvent.js","sources":["../../../../../src/core/Analytics/events/AnalyticsLogEvent.ts"],"sourcesContent":["import { AbstractAnalyticsEvent, AnalyticsEventCategory } from './AbstractAnalyticsEvent';\nimport type { PaymentAction } from '../../../types/global-types';\n\ntype AnalyticsLogEventProps = {\n type: LogEventType;\n subType?: LogEventSubtype;\n component: string;\n message: string;\n result?: string;\n};\n\nexport enum LogEventType {\n action = 'action',\n submit = 'submit',\n redirect = 'redirect',\n threeDS2 = 'threeDS2',\n closed = 'closed',\n apiRequest = 'apiRequest'\n}\n\nexport enum LogEventSubtype {\n challengeIframeLoaded = 'challengeIframeLoaded',\n challengeDataSentWeb = 'challengeDataSentWeb',\n challengeCompleted = 'challengeCompleted',\n fingerprintDataSentWeb = 'fingerprintDataSentWeb',\n fingerprintCompleted = 'fingerprintCompleted',\n fingerprintIframeLoaded = 'fingerprintIframeLoaded',\n threeDS2 = 'threeDS2',\n redirect = 'redirect',\n voucher = 'voucher',\n await = 'awat',\n qrCode = 'qrCode',\n bankTransfer = 'bankTransfer',\n sdk = 'sdk',\n donation = 'donation',\n donationCampaigns = 'donationCampaigns'\n}\n\nexport class AnalyticsLogEvent extends AbstractAnalyticsEvent {\n private readonly type: LogEventType;\n private readonly subType: LogEventSubtype;\n\n private readonly message?: string;\n private readonly result?: string;\n\n constructor(props: AnalyticsLogEventProps) {\n super(props.component);\n\n this.type = props.type;\n this.message = props.message;\n\n if (props.subType) this.subType = props.subType;\n if (props.result) this.result = props.result;\n }\n\n public getEventCategory(): AnalyticsEventCategory {\n return AnalyticsEventCategory.log;\n }\n\n public static getSubtypeFromActionType(type: PaymentAction['type']): LogEventSubtype {\n return LogEventSubtype[type];\n }\n}\n"],"names":["LogEventType","LogEventSubtype","AnalyticsLogEvent","AbstractAnalyticsEvent","getEventCategory","AnalyticsEventCategory","log","getSubtypeFromActionType","type","constructor","props","super","component","_define_property","this","subType","message","result"],"mappings":"yNAWO,IAAAA,EAAKA,SAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"AnalyticsLogEvent.js","sources":["../../../../../src/core/Analytics/events/AnalyticsLogEvent.ts"],"sourcesContent":["import { AbstractAnalyticsEvent, AnalyticsEventCategory } from './AbstractAnalyticsEvent';\nimport type { PaymentAction } from '../../../types/global-types';\n\ntype AnalyticsLogEventProps = {\n type: LogEventType;\n subType?: LogEventSubtype;\n component: string;\n message: string;\n result?: string;\n};\n\nexport enum LogEventType {\n action = 'action',\n submit = 'submit',\n redirect = 'redirect',\n threeDS2 = 'threeDS2',\n closed = 'closed',\n apiRequest = 'apiRequest',\n review = 'review'\n}\n\nexport enum LogEventSubtype {\n challengeIframeLoaded = 'challengeIframeLoaded',\n challengeDataSentWeb = 'challengeDataSentWeb',\n challengeCompleted = 'challengeCompleted',\n fingerprintDataSentWeb = 'fingerprintDataSentWeb',\n fingerprintCompleted = 'fingerprintCompleted',\n fingerprintIframeLoaded = 'fingerprintIframeLoaded',\n threeDS2 = 'threeDS2',\n redirect = 'redirect',\n voucher = 'voucher',\n await = 'awat',\n qrCode = 'qrCode',\n bankTransfer = 'bankTransfer',\n sdk = 'sdk',\n donation = 'donation',\n donationCampaigns = 'donationCampaigns',\n review = 'review'\n}\n\nexport class AnalyticsLogEvent extends AbstractAnalyticsEvent {\n private readonly type: LogEventType;\n private readonly subType: LogEventSubtype;\n\n private readonly message?: string;\n private readonly result?: string;\n\n constructor(props: AnalyticsLogEventProps) {\n super(props.component);\n\n this.type = props.type;\n this.message = props.message;\n\n if (props.subType) this.subType = props.subType;\n if (props.result) this.result = props.result;\n }\n\n public getEventCategory(): AnalyticsEventCategory {\n return AnalyticsEventCategory.log;\n }\n\n public static getSubtypeFromActionType(type: PaymentAction['type']): LogEventSubtype {\n return LogEventSubtype[type];\n }\n}\n"],"names":["LogEventType","LogEventSubtype","AnalyticsLogEvent","AbstractAnalyticsEvent","getEventCategory","AnalyticsEventCategory","log","getSubtypeFromActionType","type","constructor","props","super","component","_define_property","this","subType","message","result"],"mappings":"yNAWO,IAAAA,EAAKA,SAAAA,GAAAA,qJAAAA,CAQX,CARWA,CAQX,CAAA,GAEMC,EAAKA,SAAAA,GAAAA,8fAAAA,CAiBX,CAjBWA,CAiBX,CAAA,GAEM,MAAMC,UAA0BC,EAiB5BC,gBAAAA,GACH,OAAOC,EAAuBC,GAClC,CAEA,+BAAcC,CAAyBC,GACnC,OAAOP,EAAgBO,EAC3B,CAhBA,WAAAC,CAAYC,GACRC,MAAMD,EAAME,WAPhBC,EAAAC,KAAiBN,YAAjB,GACAK,EAAAC,KAAiBC,kBAEjBF,EAAAC,KAAiBE,kBACjBH,EAAAC,KAAiBG,iBAKbH,KAAKN,KAAOE,EAAMF,KAClBM,KAAKE,QAAUN,EAAMM,QAEjBN,EAAMK,UAASD,KAAKC,QAAUL,EAAMK,SACpCL,EAAMO,SAAQH,KAAKG,OAASP,EAAMO,OAC1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ENCRYPTED_PWD_FIELD as _,ENCRYPTED_SECURITY_CODE as R,ENCRYPTED_EXPIRY_YEAR as c,ENCRYPTED_EXPIRY_MONTH as E,ENCRYPTED_EXPIRY_DATE as
|
|
1
|
+
import{ENCRYPTED_PWD_FIELD as _,ENCRYPTED_SECURITY_CODE as R,ENCRYPTED_EXPIRY_YEAR as c,ENCRYPTED_EXPIRY_MONTH as E,ENCRYPTED_EXPIRY_DATE as r,ENCRYPTED_CARD_NUMBER as C}from"../../components/internal/SecuredFields/lib/constants.js";const O="-ariaError",e="-ariaContext",t="focusField",a="notValidating:blurScenario",M="field.error.required",i="field.error.invalid",n="field.error.invalidCharacters",d="invalid.format.expects",S="creditCard.holderName.invalid",L="creditCard.taxNumber.invalid",T="boleto.socialSecurityNumber.invalid";var o=function(_){return _.CC_NUM="cc.num",_.CC_DAT="cc.dat",_.CC_MTH="cc.mth",_.CC_YR="cc.yr",_.CC_CVC="cc.cvc",_.KCP_PWD="kcp.pwd",_}({}),D=function(_){return _.ERROR_MSG_INCOMPLETE_FIELD="err.gen.9100",_.ERROR_MSG_INVALID_FIELD="err.gen.9101",_.ERROR_MSG_LUHN_CHECK_FAILED="cc.num.902",_.ERROR_MSG_EMPTY_PAN="cc.num.900",_.ERROR_MSG_UNSUPPORTED_CARD_ENTERED="cc.num.903",_.ERROR_MSG_INCORRECTLY_FILLED_PAN="cc.num.901",_.ERROR_MSG_CARD_TOO_OLD="cc.dat.912",_.ERROR_MSG_CARD_TOO_FAR_IN_FUTURE="cc.dat.913",_.ERROR_MSG_CARD_EXPIRES_TOO_SOON="cc.dat.914",_.ERROR_MSG_EMPTY_DATE="cc.dat.910",_.ERROR_MSG_INCORRECTLY_FILLED__DATE="cc.dat.911",_.ERROR_MSG_EMPTY_YEAR="cc.yr.917",_.ERROR_MSG_INCORRECTLY_FILLED_YEAR="cc.yr.918",_.ERROR_MSG_EMPTY_MONTH="cc.mth.915",_.ERROR_MSG_EMPTY_CVC="cc.cvc.920",_.ERROR_MSG_INCORRECTLY_FILLED_CVC="cc.cvc.921",_.ERROR_MSG_EMPTY_CVC_AMEX="cc.cvc.920.amex",_.ERROR_MSG_INCORRECTLY_FILLED_CVC_AMEX="cc.cvc.921.amex",_.ERROR_MSG_EMPTY_KCP_PWD="kcp.pwd.940",_.ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD="kcp.pwd.941",_}({});const G={[C]:"cc.num.900",[r]:"cc.dat.910",[E]:"cc.mth.915",[c]:"cc.yr.917",[R]:"cc.cvc.920",[_]:"kcp.pwd.940"};export{e as ARIA_CONTEXT_SUFFIX,O as ARIA_ERROR_SUFFIX,T as BOLETO_SOCIAL_SECURITY_NUMBER_INVALID,S as CREDITCARD_HOLDER_NAME_INVALID,L as CREDITCARD_TAX_NUMBER_INVALID,G as EMPTY_FIELD_ERROR_MESSAGES,a as ERROR_ACTION_BLUR_SCENARIO,t as ERROR_ACTION_FOCUS_FIELD,i as ERROR_FIELD_INVALID,M as ERROR_FIELD_REQUIRED,n as ERROR_INVALID_CHARACTERS,d as ERROR_INVALID_FORMAT_EXPECTS,o as ErrorCodePrefixes,D as SF_ErrorCodes};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/core/Errors/constants.ts"],"sourcesContent":["import {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\n\nexport const ARIA_ERROR_SUFFIX = '-ariaError';\nexport const ARIA_CONTEXT_SUFFIX = '-ariaContext';\n\nexport const ERROR_ACTION_FOCUS_FIELD = 'focusField';\nexport const ERROR_ACTION_BLUR_SCENARIO = 'notValidating:blurScenario';\nexport const ERROR_FIELD_REQUIRED = 'field.error.required';\nexport const ERROR_FIELD_INVALID = 'field.error.invalid';\n\nexport const ERROR_INVALID_FORMAT_EXPECTS = 'invalid.format.expects';\nexport const CREDITCARD_HOLDER_NAME_INVALID = 'creditCard.holderName.invalid';\nexport const CREDITCARD_TAX_NUMBER_INVALID = 'creditCard.taxNumber.invalid';\nexport const BOLETO_SOCIAL_SECURITY_NUMBER_INVALID = 'boleto.socialSecurityNumber.invalid';\n\nexport enum ErrorCodePrefixes {\n CC_NUM = 'cc.num',\n CC_DAT = 'cc.dat',\n CC_MTH = 'cc.mth',\n CC_YR = 'cc.yr',\n CC_CVC = 'cc.cvc',\n KCP_PWD = 'kcp.pwd'\n}\n\n/**\n * For SecuredFields\n * Human readable error strings mapped to the codes, used as keys, in the translations files\n */\nexport enum SF_ErrorCodes {\n ERROR_MSG_INCOMPLETE_FIELD = 'err.gen.9100',\n ERROR_MSG_INVALID_FIELD = 'err.gen.9101',\n\n ERROR_MSG_LUHN_CHECK_FAILED = `${ErrorCodePrefixes.CC_NUM}.902`,\n ERROR_MSG_EMPTY_PAN = `${ErrorCodePrefixes.CC_NUM}.900`,\n ERROR_MSG_UNSUPPORTED_CARD_ENTERED = `${ErrorCodePrefixes.CC_NUM}.903`,\n ERROR_MSG_INCORRECTLY_FILLED_PAN = `${ErrorCodePrefixes.CC_NUM}.901`, // 'Enter the complete card number'\n\n ERROR_MSG_CARD_TOO_OLD = `${ErrorCodePrefixes.CC_DAT}.912`,\n ERROR_MSG_CARD_TOO_FAR_IN_FUTURE = `${ErrorCodePrefixes.CC_DAT}.913`,\n ERROR_MSG_CARD_EXPIRES_TOO_SOON = `${ErrorCodePrefixes.CC_DAT}.914`,\n ERROR_MSG_EMPTY_DATE = `${ErrorCodePrefixes.CC_DAT}.910`,\n ERROR_MSG_INCORRECTLY_FILLED__DATE = `${ErrorCodePrefixes.CC_DAT}.911`,\n\n ERROR_MSG_EMPTY_YEAR = `${ErrorCodePrefixes.CC_YR}.917`,\n ERROR_MSG_INCORRECTLY_FILLED_YEAR = `${ErrorCodePrefixes.CC_YR}.918`,\n\n // ERROR_MSG_INCORRECTLY_FILLED_MONTH= `cc.mth.916`,\n ERROR_MSG_EMPTY_MONTH = `${ErrorCodePrefixes.CC_MTH}.915`,\n\n ERROR_MSG_EMPTY_CVC = `${ErrorCodePrefixes.CC_CVC}.920`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC = `${ErrorCodePrefixes.CC_CVC}.921`,\n\n ERROR_MSG_EMPTY_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.920.amex`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.921.amex`,\n\n ERROR_MSG_EMPTY_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.940`,\n ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.941`\n}\n\nexport const EMPTY_FIELD_ERROR_MESSAGES = {\n [ENCRYPTED_CARD_NUMBER]: SF_ErrorCodes.ERROR_MSG_EMPTY_PAN,\n [ENCRYPTED_EXPIRY_DATE]: SF_ErrorCodes.ERROR_MSG_EMPTY_DATE,\n [ENCRYPTED_EXPIRY_MONTH]: SF_ErrorCodes.ERROR_MSG_EMPTY_MONTH,\n [ENCRYPTED_EXPIRY_YEAR]: SF_ErrorCodes.ERROR_MSG_EMPTY_YEAR,\n [ENCRYPTED_SECURITY_CODE]: SF_ErrorCodes.ERROR_MSG_EMPTY_CVC,\n [ENCRYPTED_PWD_FIELD]: SF_ErrorCodes.ERROR_MSG_EMPTY_KCP_PWD\n};\n"],"names":["ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","ERROR_ACTION_FOCUS_FIELD","ERROR_ACTION_BLUR_SCENARIO","ERROR_FIELD_REQUIRED","ERROR_FIELD_INVALID","ERROR_INVALID_FORMAT_EXPECTS","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ErrorCodePrefixes","SF_ErrorCodes","EMPTY_FIELD_ERROR_MESSAGES","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD"],"mappings":"yOASO,MAAMA,EAAoB,aACpBC,EAAsB,eAEtBC,EAA2B,aAC3BC,EAA6B,6BAC7BC,EAAuB,uBACvBC,EAAsB,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/core/Errors/constants.ts"],"sourcesContent":["import {\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/constants';\n\nexport const ARIA_ERROR_SUFFIX = '-ariaError';\nexport const ARIA_CONTEXT_SUFFIX = '-ariaContext';\n\nexport const ERROR_ACTION_FOCUS_FIELD = 'focusField';\nexport const ERROR_ACTION_BLUR_SCENARIO = 'notValidating:blurScenario';\nexport const ERROR_FIELD_REQUIRED = 'field.error.required';\nexport const ERROR_FIELD_INVALID = 'field.error.invalid';\nexport const ERROR_INVALID_CHARACTERS = 'field.error.invalidCharacters';\n\nexport const ERROR_INVALID_FORMAT_EXPECTS = 'invalid.format.expects';\nexport const CREDITCARD_HOLDER_NAME_INVALID = 'creditCard.holderName.invalid';\nexport const CREDITCARD_TAX_NUMBER_INVALID = 'creditCard.taxNumber.invalid';\nexport const BOLETO_SOCIAL_SECURITY_NUMBER_INVALID = 'boleto.socialSecurityNumber.invalid';\n\nexport enum ErrorCodePrefixes {\n CC_NUM = 'cc.num',\n CC_DAT = 'cc.dat',\n CC_MTH = 'cc.mth',\n CC_YR = 'cc.yr',\n CC_CVC = 'cc.cvc',\n KCP_PWD = 'kcp.pwd'\n}\n\n/**\n * For SecuredFields\n * Human readable error strings mapped to the codes, used as keys, in the translations files\n */\nexport enum SF_ErrorCodes {\n ERROR_MSG_INCOMPLETE_FIELD = 'err.gen.9100',\n ERROR_MSG_INVALID_FIELD = 'err.gen.9101',\n\n ERROR_MSG_LUHN_CHECK_FAILED = `${ErrorCodePrefixes.CC_NUM}.902`,\n ERROR_MSG_EMPTY_PAN = `${ErrorCodePrefixes.CC_NUM}.900`,\n ERROR_MSG_UNSUPPORTED_CARD_ENTERED = `${ErrorCodePrefixes.CC_NUM}.903`,\n ERROR_MSG_INCORRECTLY_FILLED_PAN = `${ErrorCodePrefixes.CC_NUM}.901`, // 'Enter the complete card number'\n\n ERROR_MSG_CARD_TOO_OLD = `${ErrorCodePrefixes.CC_DAT}.912`,\n ERROR_MSG_CARD_TOO_FAR_IN_FUTURE = `${ErrorCodePrefixes.CC_DAT}.913`,\n ERROR_MSG_CARD_EXPIRES_TOO_SOON = `${ErrorCodePrefixes.CC_DAT}.914`,\n ERROR_MSG_EMPTY_DATE = `${ErrorCodePrefixes.CC_DAT}.910`,\n ERROR_MSG_INCORRECTLY_FILLED__DATE = `${ErrorCodePrefixes.CC_DAT}.911`,\n\n ERROR_MSG_EMPTY_YEAR = `${ErrorCodePrefixes.CC_YR}.917`,\n ERROR_MSG_INCORRECTLY_FILLED_YEAR = `${ErrorCodePrefixes.CC_YR}.918`,\n\n // ERROR_MSG_INCORRECTLY_FILLED_MONTH= `cc.mth.916`,\n ERROR_MSG_EMPTY_MONTH = `${ErrorCodePrefixes.CC_MTH}.915`,\n\n ERROR_MSG_EMPTY_CVC = `${ErrorCodePrefixes.CC_CVC}.920`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC = `${ErrorCodePrefixes.CC_CVC}.921`,\n\n ERROR_MSG_EMPTY_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.920.amex`,\n ERROR_MSG_INCORRECTLY_FILLED_CVC_AMEX = `${ErrorCodePrefixes.CC_CVC}.921.amex`,\n\n ERROR_MSG_EMPTY_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.940`,\n ERROR_MSG_INCORRECTLY_FILLED_KCP_PWD = `${ErrorCodePrefixes.KCP_PWD}.941`\n}\n\nexport const EMPTY_FIELD_ERROR_MESSAGES = {\n [ENCRYPTED_CARD_NUMBER]: SF_ErrorCodes.ERROR_MSG_EMPTY_PAN,\n [ENCRYPTED_EXPIRY_DATE]: SF_ErrorCodes.ERROR_MSG_EMPTY_DATE,\n [ENCRYPTED_EXPIRY_MONTH]: SF_ErrorCodes.ERROR_MSG_EMPTY_MONTH,\n [ENCRYPTED_EXPIRY_YEAR]: SF_ErrorCodes.ERROR_MSG_EMPTY_YEAR,\n [ENCRYPTED_SECURITY_CODE]: SF_ErrorCodes.ERROR_MSG_EMPTY_CVC,\n [ENCRYPTED_PWD_FIELD]: SF_ErrorCodes.ERROR_MSG_EMPTY_KCP_PWD\n};\n"],"names":["ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","ERROR_ACTION_FOCUS_FIELD","ERROR_ACTION_BLUR_SCENARIO","ERROR_FIELD_REQUIRED","ERROR_FIELD_INVALID","ERROR_INVALID_CHARACTERS","ERROR_INVALID_FORMAT_EXPECTS","CREDITCARD_HOLDER_NAME_INVALID","CREDITCARD_TAX_NUMBER_INVALID","BOLETO_SOCIAL_SECURITY_NUMBER_INVALID","ErrorCodePrefixes","SF_ErrorCodes","EMPTY_FIELD_ERROR_MESSAGES","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD"],"mappings":"yOASO,MAAMA,EAAoB,aACpBC,EAAsB,eAEtBC,EAA2B,aAC3BC,EAA6B,6BAC7BC,EAAuB,uBACvBC,EAAsB,sBACtBC,EAA2B,gCAE3BC,EAA+B,yBAC/BC,EAAiC,gCACjCC,EAAgC,+BAChCC,EAAwC,sCAE9C,IAAAC,EAAKA,SAAAA,GAAAA,mHAAAA,CAOX,CAPWA,CAOX,CAAA,GAMWC,EAAAA,SAAAA,GAAAA,s3BAAAA,CA6BX,CA7BWA,CA6BX,CAAA,SAEYC,EAA6B,CACtCC,CAACA,GAAsB,aACvBC,CAACA,GAAsB,aACvBC,CAACA,GAAuB,aACxBC,CAACA,GAAsB,YACvBC,CAACA,GAAwB,aACzBC,CAACA,GAAoB"}
|
package/dist/es/core/config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.
|
|
1
|
+
function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.45.0","LIBRARY_VERSION is not defined"),t=e("esm","BUNDLE_TYPE is not defined"),r=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","donation","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onReview","onAction","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],i=6e4;var d=function(e){return e.WEB="web",e}({});const a="web";var c=function(e){return e.NATIVE="nativeComponent",e.GENERIC="genericComponent",e}({});export{d as CHANNEL,i as DEFAULT_HTTP_TIMEOUT,n as FALLBACK_CONTEXT,r as GENERIC_OPTIONS,t as LIBRARY_BUNDLE_TYPE,o as LIBRARY_VERSION,c as PAYMENT_METHOD_BEHAVIOR,a as PLATFORM};
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * Asserts that a value is defined and throws an error if it is not.\n *\n * @param value The value to check.\n * @param message The error message to throw if the value is undefined.\n * @returns The value if it is defined.\n */\nfunction assertDefined<T>(value: T | undefined, message: string): T {\n if (value === undefined || value === null) {\n throw new Error(message);\n }\n return value;\n}\n\n/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\n/**\n * Library version injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_VERSION = assertDefined(process.env.VERSION, 'LIBRARY_VERSION is not defined');\n\n/**\n * Bundle type injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_BUNDLE_TYPE = assertDefined(process.env.BUNDLE_TYPE, 'BUNDLE_TYPE is not defined');\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n '_environmentUrls',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n 'donation',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onEnterKeyPressed',\n 'onError',\n 'onBalanceCheck',\n 'onOrderCancel',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n\n/**\n * @internal\n */\n\nexport enum CHANNEL {\n WEB = 'web'\n}\n\n/**\n * @internal\n */\nexport const PLATFORM = 'web';\n\n/**\n * How the SDK handles the rendering of a payment method.\n *\n * - NATIVE: The payment method has a dedicated component in the SDK.\n * - GENERIC: The payment method has no dedicated component; it falls back to a generic component (Redirect).\n * @internal\n */\nexport enum PAYMENT_METHOD_BEHAVIOR {\n NATIVE = 'nativeComponent',\n GENERIC = 'genericComponent'\n}\n"],"names":["assertDefined","value","message","Error","FALLBACK_CONTEXT","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT","CHANNEL","PLATFORM","PAYMENT_METHOD_BEHAVIOR"],"mappings":"AAOA,SAASA,EAAiBC,EAAsBC,GAC5C,GAAID,QACA,MAAM,IAAIE,MAAMD,GAEpB,OAAOD,CACX,CAKO,MAAMG,EAAmB,0DAMnBC,EAAkBL,EAAc,SAAqB,kCAMrDM,EAAsBN,EAAc,MAAyB,8BAE7DO,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,mBACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BACA,WAGA,qBACA,kBACA,iBACA,eACA,WACA,kBACA,sBACA,WACA,oBACA,UACA,iBACA,gBACA,iBACA,iBACA,2BAGSC,EAAuB,IAY7B,IAAKC,EAAAA,SAAAA,GAAAA,mBAAAA,CAEZ,CAFYA,CAEZ,CAAA,GAKO,MAAMC,EAAW,MASjB,IAAKC,EAAAA,SAAAA,GAAAA,+DAAAA,CAGZ,CAHYA,CAGZ,CAAA"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * Asserts that a value is defined and throws an error if it is not.\n *\n * @param value The value to check.\n * @param message The error message to throw if the value is undefined.\n * @returns The value if it is defined.\n */\nfunction assertDefined<T>(value: T | undefined, message: string): T {\n if (value === undefined || value === null) {\n throw new Error(message);\n }\n return value;\n}\n\n/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\n/**\n * Library version injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_VERSION = assertDefined(process.env.VERSION, 'LIBRARY_VERSION is not defined');\n\n/**\n * Bundle type injected at build time.\n * Always defined - the build process ensures this value is set.\n */\nexport const LIBRARY_BUNDLE_TYPE = assertDefined(process.env.BUNDLE_TYPE, 'BUNDLE_TYPE is not defined');\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n '_environmentUrls',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n 'donation',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onReview',\n 'onAction',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onEnterKeyPressed',\n 'onError',\n 'onBalanceCheck',\n 'onOrderCancel',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n\n/**\n * @internal\n */\n\nexport enum CHANNEL {\n WEB = 'web'\n}\n\n/**\n * @internal\n */\nexport const PLATFORM = 'web';\n\n/**\n * How the SDK handles the rendering of a payment method.\n *\n * - NATIVE: The payment method has a dedicated component in the SDK.\n * - GENERIC: The payment method has no dedicated component; it falls back to a generic component (Redirect).\n * @internal\n */\nexport enum PAYMENT_METHOD_BEHAVIOR {\n NATIVE = 'nativeComponent',\n GENERIC = 'genericComponent'\n}\n"],"names":["assertDefined","value","message","Error","FALLBACK_CONTEXT","LIBRARY_VERSION","LIBRARY_BUNDLE_TYPE","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT","CHANNEL","PLATFORM","PAYMENT_METHOD_BEHAVIOR"],"mappings":"AAOA,SAASA,EAAiBC,EAAsBC,GAC5C,GAAID,QACA,MAAM,IAAIE,MAAMD,GAEpB,OAAOD,CACX,CAKO,MAAMG,EAAmB,0DAMnBC,EAAkBL,EAAc,SAAqB,kCAMrDM,EAAsBN,EAAc,MAAyB,8BAE7DO,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,mBACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BACA,WAGA,qBACA,kBACA,iBACA,eACA,WACA,WACA,WACA,kBACA,sBACA,WACA,oBACA,UACA,iBACA,gBACA,iBACA,iBACA,2BAGSC,EAAuB,IAY7B,IAAKC,EAAAA,SAAAA,GAAAA,mBAAAA,CAEZ,CAFYA,CAEZ,CAAA,GAKO,MAAMC,EAAW,MASjB,IAAKC,EAAAA,SAAAA,GAAAA,+DAAAA,CAGZ,CAHYA,CAGZ,CAAA"}
|
package/dist/es/core/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Language as t}from"../language/Language.js";import e from"./RiskModule/RiskModule.js";import o from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import s from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as
|
|
1
|
+
import{Language as t}from"../language/Language.js";import e from"./RiskModule/RiskModule.js";import o from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import s from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as c}from"../utils/hasOwnProperty.js";import{Resources as h}from"./Context/Resources.js";import{SRPanel as l}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{THREEDS2_FULL as f}from"../components/ThreeDS2/constants.js";import{defaultProps as A}from"./core.defaultProps.js";import{resolveEnvironments as C}from"./Environment/Environment.js";import{LIBRARY_BUNDLE_TYPE as v,LIBRARY_VERSION as w}from"./config.js";import{AnalyticsLogEvent as E,LogEventType as b,LogEventSubtype as P}from"./Analytics/events/AnalyticsLogEvent.js";import j from"./Errors/CancelError.js";import{AnalyticsService as T}from"./Analytics/AnalyticsService.js";import{AnalyticsEventQueue as M}from"./Analytics/AnalyticsEventQueue.js";import{isAmountValid as R}from"../utils/amount-util.js";import{LanguageService as I}from"../language/LanguageService.js";function U(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class k{static setBundleType(t){k.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),this.createCoreModules(),this.assignLocaleToCore(),this.requestAnalyticsAttemptId(),await this.requestTranslations(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then(t=>{const{amount:e,shopperLocale:o,countryCode:s,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:e,locale:this.options.locale||o,countryCode:this.options.countryCode||s}),this.createPaymentMethodsList(i),this}).catch(t=>(this.options.onError&&this.options.onError(t),Promise.reject(t))):(this.createPaymentMethodsList(),Promise.resolve(this))}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.")}submitDetails(t){let e=null;this.options.onAdditionalDetails&&(e=new Promise((e,o)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:e,reject:o})})),this.session&&(e=this.session.submitDetails(t).catch(t=>(this.options.onError?.(t),Promise.reject(t)))),e?e.then(m).then(d).then(this.afterAdditionalDetails).then(t=>{u(t),this.options.onPaymentCompleted?.(t)}).catch(t=>{t instanceof j||(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,e={}){if(!t||!t.type){if(c(t,"action")&&c(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 o=t.type===f?`${t.type}${t.subtype}`:t.paymentMethodType,i=new E({type:b.action,subType:E.getSubtypeFromActionType(t.type),message:`${o} action was handled by the SDK`,component:o});this.modules.analytics.sendAnalytics(i);const n={...this.getCorePropsForComponent(),...e};return s(this,p,t,n)}return this.handleCreateError()}update(t={},{shouldReinitializeCheckout:e=!0}={}){if(e)return this.setOptions(t),this.initialize().then(()=>(this.components.forEach(e=>{const o={...t.order?.remainingAmount?{amount:t.order.remainingAmount}:{amount:this.options.amount},...this.session&&{session:this.session},...t};e.update(o)}),this));const{amount:o,secondaryAmount:s}=t;return(o||s)&&this.triggerAmountUpdate(o,s),Promise.resolve(this)}triggerAmountUpdate(t,e){R(t)?!e||R(e)?(this.setOptions({amount:t,...e&&{secondaryAmount:e}}),this.components.forEach(o=>{o.updateAmount(t,e)})):console.warn("Core update(): Update canceled. Invalid secondary amount object"):console.warn("Core update(): Update canceled. Invalid amount object")}getCorePropsForComponent(){return{...n(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}processPayment(t){if(!this.session)return void this.options.onError?.(new y("IMPLEMENTATION_ERROR","processPayment requires a session to be configured"));const e=new E({type:b.submit,subType:P.review,message:"Shopper clicked pay",component:t.paymentMethod?.type});this.modules.analytics.sendAnalytics(e),this.session.submitPayment(t).then(m).then(d).then(t=>{if(t.action)return void(this.options.onAction?this.options.onAction(this.createFromAction(t.action)):this.options.onError?.(new y("IMPLEMENTATION_ERROR","onAction callback is required to handle payment actions")));const e=t.order;e&&(e.remainingAmount?.value??0)>0?this.options.onOrderUpdated?.({order:e}):(u(t),this.options.onPaymentCompleted?.(t))}).catch(t=>{t instanceof j||(u(t),this.options.onPaymentFailed?.(t))})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const e=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(e)}createPaymentMethodsList(t){this.paymentMethodsResponse=new o(this.options.paymentMethodsResponse||t,this.options)}createCoreModules(){this.modules||(this.modules=Object.freeze({risk:new e(this,{...this.options,loadingContext:this.loadingContext}),analytics:new i({eventQueue:new M,service:new T({analyticsContext:this.analyticsContext,clientKey:this.options.clientKey}),enabled:this.options.analytics?.enabled,analyticsData:this.options.analytics?.analyticsData}),resources:new h(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,customTranslations:this.options.translations,service:new I({cdnUrl:this.cdnTranslationsUrl,sdkVersion:k.metadata.version}),onError:this.options?.onError}),srPanel:new l(this,{...this.options.srConfig})}))}assignLocaleToCore(){this.options.locale=this.modules.i18n.locale}async requestTranslations(){try{await this.modules.i18n.requestTranslations()}catch(t){console.warn("Core - requestTranslations(): Something went wrong.",t)}}async requestAnalyticsAttemptId(){await this.modules.analytics.setUp({locale:this.options.locale,...this.session?.id&&{sessionId:this.session.id}})}constructor(t){U(this,"session",void 0),U(this,"paymentMethodsResponse",void 0),U(this,"modules",void 0),U(this,"options",void 0),U(this,"analyticsContext",void 0),U(this,"loadingContext",void 0),U(this,"cdnImagesUrl",void 0),U(this,"cdnTranslationsUrl",void 0),U(this,"components",[]),U(this,"afterAdditionalDetails",t=>{if(this.options.afterAdditionalDetails&&t?.action){const e=this.createFromAction(t.action);return this.options.afterAdditionalDetails(e),Promise.reject(new j("Handled by afterAdditionalDetails"))}return Promise.resolve(t)}),U(this,"remove",t=>(this.components=this.components.filter(e=>e._id!==t._id),t.unmount(),this)),U(this,"setOptions",t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale,environment:String.prototype.toLowerCase.apply(t?.environment||this.options?.environment)}}),r(t),this.createFromAction=this.createFromAction.bind(this),this.update=this.update.bind(this),this.setOptions({...A,...t});const{apiUrl:e,analyticsUrl:o,cdnImagesUrl:s,cdnTranslationsUrl:i}=C(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=o,this.cdnImagesUrl=s,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const n=this.options.clientKey?.substring(0,4);if(("test"===n||"live"===n)&&!this.loadingContext.includes(n))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${n} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===n&&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=k.metadata)}}U(k,"metadata",{version:w,bundleType:v}),U(k,"registry",p);export{k as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|