@adyen/adyen-web 6.0.1 → 6.0.2

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.
@@ -4397,11 +4397,7 @@ declare class UPI extends UIElement<UPIConfiguration> {
4397
4397
  constructor(checkout: ICore, props: UPIConfiguration);
4398
4398
  formatProps(props: UPIConfiguration): {
4399
4399
  defaultMode: UpiMode;
4400
- apps: {
4401
- type: TxVariants;
4402
- id: string;
4403
- name: string;
4404
- }[];
4400
+ apps: App[];
4405
4401
  url?: string;
4406
4402
  paymentData?: string;
4407
4403
  qrCodeData?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n // @ts-ignore fix later\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","static","TxVariants","upi","upi_qr","upi_collect","upi_intent","selectedMode","constructor","checkout","props","super","this","defaultMode","formatProps","isMobile","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","map","app","includes","isValid","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","onUpdateMode","mode","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules"],"mappings":"meAsBA,MAAMA,UAAYC,EACdC,YAAqBC,EAAWC,IAChCF,kBAA2B,CAACC,EAAWC,IAAKD,EAAWE,OAAQF,EAAWG,YAAaH,EAAWI,YAE1FC,aAERC,WAAAA,CAAYC,EAA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AAMe,EAAKC,IAGjG"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","static","TxVariants","upi","upi_qr","upi_collect","upi_intent","selectedMode","constructor","checkout","props","super","this","defaultMode","formatProps","isMobile","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","map","app","includes","isValid","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","onUpdateMode","mode","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules"],"mappings":"meAsBA,MAAMA,UAAYC,EACdC,YAAqBC,EAAWC,IAChCF,kBAA2B,CAACC,EAAWC,IAAKD,EAAWE,OAAQF,EAAWG,YAAaH,EAAWI,YAE1FC,aAERC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAChBE,KAAKL,aAAeK,KAAKF,MAAMG,WACnC,CAEAC,WAAAA,CAAYJ,GACR,IAAKK,IACD,MAAO,IACAJ,MAAMG,YAAYJ,GACrBG,YAAaH,GAAOG,aAAe,SAEnCG,KAAM,IAId,MAAMC,EAAgBP,EAAMM,MAAME,OAAS,EACrCC,EAAsBF,EAAgB,SAAW,MACjDG,EAAe,CAACD,EAAqB,UACrCE,EAAqB,CACvBC,GAAI,MACJC,KAAMb,EAAMc,KAAKC,IAAI,8BACrBC,KAAMxB,EAAWG,aAEfW,EAAOC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KAAMgB,EACNc,oBAAAA,EACAC,6BAAAA,EACAJ,cAAe,EACfK,UAAW9C,KAAKF,MAAMgD,UACtBC,YAAa/C,KAAKF,MAAMiD,YACxBL,gBAAiB1C,KAAKF,MAAM4C,gBAC5BM,QAAShD,KAAKF,MAAMkD,QACpBC,YAAajD,KAAKF,MAAMc,KAAKC,IAAI,yBACjCqC,UAAWlD,KAAKF,MAAMc,KAAKC,IAAI,6BAC/B0B,WAAYvC,KAAKuC,WACjBF,UAAWrC,KAAKsC,OAG5B,QACI,OACIP,EAACoB,EAAAA,CACGlB,IAAMA,IACFjC,KAAKkC,aAAeD,CAAAA,EAExBmB,UAAWpD,KAAKoD,UAChBC,SAAUrD,KAAKsD,SACf5B,aAAc1B,KAAK0B,aACnBtB,KAAMJ,KAAKF,MAAMM,KACjBH,YAAaD,KAAKF,MAAMG,YACxBsD,cAAevD,KAAKF,MAAMyD,gBAI9C,CAEOC,MAAAA,GACH,MAAM1C,KAAEA,EAAIe,IAAEA,EAAGC,kBAAEA,GAAsB9B,KAAKF,MAC9C,OACIiC,EAAC0B,EAAAA,CAAa7C,KAAMZ,KAAKF,MAAMc,KAAM8C,eAAgB1D,KAAKF,MAAM4D,eAAgBC,UAAW3D,KAAK2D,WAC5F5B,EAAC6B,EAAAA,CAAgBC,QAAS7D,KAAKF,MAAMgE,QAAQD,SAAU7D,KAAK4B,cAAcd,EAAMe,EAAKC,IAGjG"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0.1",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0.2",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.0.1",bundleType:"esm"};static registry=p;static setBundleType(t){P.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}constructor(t){n(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...E,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const a=this.options.clientKey?.substring(0,4);if(("test"===a||"live"===a)&&!this.loadingContext.includes(a))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${a} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===a&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=P.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await j(this.cdnTranslationsUrl,P.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=v(this.options.locale),this.options.translations=A(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...a(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:P.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}}export{P as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.0.2",bundleType:"esm"};static registry=p;static setBundleType(t){P.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}constructor(t){n(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...E,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const a=this.options.clientKey?.substring(0,4);if(("test"===a||"live"===a)&&!this.loadingContext.includes(a))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${a} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===a&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=P.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await j(this.cdnTranslationsUrl,P.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=v(this.options.locale),this.options.translations=A(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...a(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:P.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}}export{P as default};
2
2
  //# sourceMappingURL=core.js.map
@@ -4397,11 +4397,7 @@ declare class UPI extends UIElement<UPIConfiguration> {
4397
4397
  constructor(checkout: ICore, props: UPIConfiguration);
4398
4398
  formatProps(props: UPIConfiguration): {
4399
4399
  defaultMode: UpiMode;
4400
- apps: {
4401
- type: TxVariants;
4402
- id: string;
4403
- name: string;
4404
- }[];
4400
+ apps: App[];
4405
4401
  url?: string;
4406
4402
  paymentData?: string;
4407
4403
  qrCodeData?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n // @ts-ignore fix later\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAYdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAAlBL,EAAAA,aAAAA,EAAAA,EAAOK,uBAAPL,EAAAA,EAAsB,SAEnCM,KAAM,KAId,MAAMC,GAAgBP,QAAAA,EAAAA,EAAMM,YAANN,IAAAA,OAAAA,EAAAA,EAAYQ,QAAS,EACrCC,EAAsBF,EAAgB,SAAW,MACjDG,EAAe,CAACD,EAAqB,UACrCE,EAAgB,CAClBC,GAAI,MACJC,KAAMb,EAAMc,KAAKC,IAAI,8BACrBC,KAAMC,EAAWC,aAEfZ,EAAOC,EAAgB,IAAIP,EAAMM,KAAKa,KAAIC,GAAQlB,EAAKkB,EAAAA,GAAAA,GAAAA,CAAKJ,KAAMC,EAAWI,eAAgBV,GAAiB,GACpH,OAAOT,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAAaK,EAAaY,SAAStB,aAAAA,EAAAA,EAAOK,aAAeL,EAAMK,YAAcI,EAC7EH,QAER,CAEA,WAAWiB,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH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,MAAMwD,QACpBC,YAAajC,KAAKxB,MAAMc,KAAKC,IAAI,yBACjC2C,UAAWlC,KAAKxB,MAAMc,KAAKC,IAAI,6BAC/BgC,WAAYvB,KAAKuB,WACjBF,UAAWrB,KAAKsB,OAG5B,QACI,OACIP,EAACoB,EAAAA,CACGlB,IAAMA,IACFjB,KAAKkB,aAAeD,CAAAA,EAExBmB,UAAWpC,KAAKoC,UAChBC,SAAUrC,KAAKsC,SACfC,aAAcvC,KAAKuC,aACnBzD,KAAMkB,KAAKxB,MAAMM,KACjBD,YAAamB,KAAKxB,MAAMK,YACxB2D,cAAexC,KAAKxB,MAAMgE,gBAI9C,CAEOC,MAAAA,GACH,MAAMjD,KAAEA,EAAIqB,IAAEA,EAAGC,kBAAEA,GAAsBd,KAAKxB,MAC9C,OACIuC,EAAC2B,EAAAA,CAAapD,KAAMU,KAAKxB,MAAMc,KAAMqD,eAAgB3C,KAAKxB,MAAMmE,eAAgBC,UAAW5C,KAAK4C,WAC5F7B,EAAC8B,EAAAA,CAAgBC,QAAS9C,KAAKxB,MAAMuE,QAAQD,SAAU9C,KAAKY,cAAcpB,EAAMqB,EAAKC,IAGjG,CA7HAkC,WAAAA,CAAYC,EAAiBzE,GACzBI,MAAMqE,EAAUzE,GAHpB0E,EAAAlD,KAAQU,oBAAR,GA4DAwC,EAAAlD,KAAQuC,gBAAgBY,IACpBnD,KAAKU,aAAeyC,CAAAA,IAzDpBnD,KAAKU,aAAeV,KAAKxB,MAAMK,WACnC,EARAqE,EADE7E,EACYmB,OAAOC,EAAW2D,KAChCF,EAFE7E,EAEYgF,aAAa,CAAC5D,EAAW2D,IAAK3D,EAAWkB,OAAQlB,EAAWC,YAAaD,EAAWI"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAAlBL,EAAAA,aAAAA,EAAAA,EAAOK,uBAAPL,EAAAA,EAAsB,SAEnCM,KAAM,KAId,MAAMC,GAAgBP,QAAAA,EAAAA,EAAMM,YAANN,IAAAA,OAAAA,EAAAA,EAAYQ,QAAS,EACrCC,EAAsBF,EAAgB,SAAW,MACjDG,EAAe,CAACD,EAAqB,UACrCE,EAAqB,CACvBC,GAAI,MACJC,KAAMb,EAAMc,KAAKC,IAAI,8BACrBC,KAAMC,EAAWC,aAEfZ,EAAOC,EAAgB,IAAIP,EAAMM,KAAKa,KAAIC,GAAQlB,EAAKkB,EAAAA,GAAAA,GAAAA,CAAKJ,KAAMC,EAAWI,eAA2BV,GAAiB,GAC/H,OAAOT,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAAaK,EAAaY,SAAStB,aA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Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.1",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.2",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class T{static setBundleType(t){T.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:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,T.metadata.version,this.options.locale)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,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(l(t,"action")&&l(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 e=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:g,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(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){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} 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(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:T.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substring(0,4);var c,h;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(h=this.options.clientKey)||void 0===h?void 0:h.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=T.metadata)}}E(T,"metadata",{version:"6.0.1",bundleType:"eslegacy"}),E(T,"registry",p);export{T as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class T{static setBundleType(t){T.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:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,T.metadata.version,this.options.locale)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,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(l(t,"action")&&l(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 e=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:g,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(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){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} 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(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:T.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substring(0,4);var c,h;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(h=this.options.clientKey)||void 0===h?void 0:h.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=T.metadata)}}E(T,"metadata",{version:"6.0.2",bundleType:"eslegacy"}),E(T,"registry",p);export{T as default};
2
2
  //# sourceMappingURL=core.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/adyen-web",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "license": "MIT",
5
5
  "homepage": "https://docs.adyen.com/checkout",
6
6
  "type": "module",