@adyen/adyen-web 6.7.0 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adyen.css +44 -44
- 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 +1 -1
- package/dist/es/adyen.css +44 -44
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es-legacy/adyen.css +44 -44
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/package.json +4 -4
- package/styles/adyen.css +44 -44
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.
|
|
1
|
+
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.5.0",m=["amex","mc","visa"],C=["ach",p],b=[r,c,t,a,d,i],x=[n,o],h=b.concat(x),D=["bcmc"],g="required",k="optional",B="hidden",l=g,v=k,A=B,E=g,M=k,N=B,S="data-cse",f="data-info",j="data-uid",I=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},L={[r]:"cardNumber",[c]:"expiryDate",[d]:"securityCode",[t]:"expiryMonth",[a]:"expiryYear",[i]:"password",[n]:"bankAccountNumber",[o]:"bankLocationId",[s]:"securityCodeThreeDigits",[y]:"securityCodeFourDigits"},P=6e3;export{h as ALL_SECURED_FIELDS,I as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,b as CREDIT_CARD_SF_FIELDS,A as CVC_POLICY_HIDDEN,v as CVC_POLICY_OPTIONAL,l as CVC_POLICY_REQUIRED,S as DATA_ENCRYPTED_FIELD_ATTR,f as DATA_INFO,j as DATA_UID,N as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,D as DEDICATED_CARD_COMPONENTS,m as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,n as ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,o as ENCRYPTED_BANK_LOCATION_FIELD,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,t as ENCRYPTED_EXPIRY_MONTH,a as ENCRYPTED_EXPIRY_YEAR,i as ENCRYPTED_PWD_FIELD,d as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,y as ENCRYPTED_SECURITY_CODE_4_DIGITS,p as GIFT_CARD,B as HIDDEN,C as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,k as OPTIONAL,x as OTHER_SF_FIELDS,g as REQUIRED,P as SF_CONFIG_TIMEOUT,L as SF_FIELDS_MAP,u as SF_VERSION};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.5.0';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = ['ach', GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n // ENCRYPTED_PIN_FIELD,// probably redundant - it was an alt. name for KCP's encryptedPassword. But maybe has a role to play if we ever encrypt ibans.\n];\n\nexport const OTHER_SF_FIELDS = [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD, ENCRYPTED_BANK_LOCATION_FIELD]; // ACH fields\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard or ach) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS.concat(OTHER_SF_FIELDS);\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD]: 'bankAccountNumber',\n [ENCRYPTED_BANK_LOCATION_FIELD]: 'bankLocationId',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","OTHER_SF_FIELDS","ALL_SECURED_FIELDS","concat","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAEtBC,EAAoC,6BACpCC,EAAgC,0BAEhCC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAAC,MAAOH,GAG9CI,EAAwB,CACjCd,EACAC,EACAC,EACAC,EACAC,EACAC,GAISU,EAAkB,CAACT,EAAmCC,GAGtDS,EAAqBF,EAAsBG,OAAOF,GAIlDG,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzB3C,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WACvBC,CAACA,GAAoC,oBACrCC,CAACA,GAAgC,iBAEjCC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BmC,EAAoB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.
|
|
1
|
+
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.8.0",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
|
|
2
2
|
//# sourceMappingURL=collect-id.js.map
|
package/dist/es/core/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import v from"./Services/get-translations.js";import{defaultProps as b}from"./core.defaultProps.js";import{formatLocale as j,formatCustomTranslations as E}from"../language/utils.js";import{resolveEnvironments as A}from"./Environment/Environment.js";function P(t,o,s){return o in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}class M{static setBundleType(t){M.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(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await v(this.cdnTranslationsUrl,M.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=j(this.options.locale),this.options.translations=E(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}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}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:M.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}constructor(t){P(this,"session",void 0),P(this,"paymentMethodsResponse",void 0),P(this,"modules",void 0),P(this,"options",void 0),P(this,"analyticsContext",void 0),P(this,"loadingContext",void 0),P(this,"cdnImagesUrl",void 0),P(this,"cdnTranslationsUrl",void 0),P(this,"components",[]),P(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this)))))),P(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),P(this,"setOptions",(t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}})),a(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...b,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=A(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const 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=M.metadata)}}P(M,"metadata",{version:"6.
|
|
1
|
+
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{processGlobalOptions as n,assertConfigurationPropertiesAreValid as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import v from"./Services/get-translations.js";import{defaultProps as b}from"./core.defaultProps.js";import{formatLocale as j,formatCustomTranslations as E}from"../language/utils.js";import{resolveEnvironments as A}from"./Environment/Environment.js";function P(t,o,s){return o in t?Object.defineProperty(t,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[o]=s,t}class M{static setBundleType(t){M.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(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await v(this.cdnTranslationsUrl,M.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=j(this.options.locale),this.options.translations=E(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}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}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:M.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}constructor(t){P(this,"session",void 0),P(this,"paymentMethodsResponse",void 0),P(this,"modules",void 0),P(this,"options",void 0),P(this,"analyticsContext",void 0),P(this,"loadingContext",void 0),P(this,"cdnImagesUrl",void 0),P(this,"cdnTranslationsUrl",void 0),P(this,"components",[]),P(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this)))))),P(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),P(this,"setOptions",(t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}})),a(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...b,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=A(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const 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=M.metadata)}}P(M,"metadata",{version:"6.8.0",bundleType:"esm"}),P(M,"registry",p);export{M as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/dist/es/index.d.ts
CHANGED
|
@@ -5271,7 +5271,7 @@ interface ICore {
|
|
|
5271
5271
|
submitDetails(details: AdditionalDetailsData['data']): void;
|
|
5272
5272
|
getCorePropsForComponent(): any;
|
|
5273
5273
|
getComponent(txVariant: string): NewableComponent | undefined;
|
|
5274
|
-
createFromAction(action: PaymentAction, options
|
|
5274
|
+
createFromAction(action: PaymentAction, options?: any): UIElement;
|
|
5275
5275
|
storeElementReference(element: UIElement): void;
|
|
5276
5276
|
options: CoreConfiguration;
|
|
5277
5277
|
paymentMethodsResponse: PaymentMethods;
|