@adyen/adyen-web 6.9.0 → 6.10.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 +13 -13
- 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 +54 -23
- package/dist/es/adyen.css +13 -13
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ApplePay/ApplePay.js +1 -1
- package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es/components/ApplePay/components/ApplePayButton.js +1 -1
- package/dist/es/components/ApplePay/components/ApplePayButton.js.map +1 -1
- package/dist/es/components/ApplePay/defaultProps.js +1 -1
- package/dist/es/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es/components/ApplePay/services/ApplePaySdkLoader.js +2 -0
- package/dist/es/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -0
- package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -0
- package/dist/es/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js +2 -0
- package/dist/es/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js.map +1 -0
- package/dist/es/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js +2 -0
- package/dist/es/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -0
- package/dist/es/components/ApplePay/utils/payment-request.js +2 -0
- package/dist/es/components/ApplePay/utils/payment-request.js.map +1 -0
- package/dist/es/components/ApplePay/utils/resolve-supported-version.js +2 -0
- package/dist/es/components/ApplePay/utils/resolve-supported-version.js.map +1 -0
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVCHint.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/internal/ExpandButton/ExpandButton.js +1 -1
- package/dist/es/components/internal/ExpandButton/ExpandButton.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/index.d.ts +54 -23
- package/dist/es/utils/inIframe.js +2 -0
- package/dist/es/utils/inIframe.js.map +1 -0
- package/dist/es-legacy/adyen.css +13 -13
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js +1 -1
- package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/services/ApplePaySdkLoader.js +2 -0
- package/dist/es-legacy/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/resolve-supported-version.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/resolve-supported-version.js.map +1 -0
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/internal/ExpandButton/ExpandButton.js +1 -1
- package/dist/es-legacy/components/internal/ExpandButton/ExpandButton.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/utils/inIframe.js +2 -0
- package/dist/es-legacy/utils/inIframe.js.map +1 -0
- package/package.json +12 -12
- package/styles/adyen.css +13 -13
- package/dist/es/components/ApplePay/ApplePayService.js.map +0 -1
- package/dist/es/components/ApplePay/config.js +0 -2
- package/dist/es/components/ApplePay/config.js.map +0 -1
- package/dist/es/components/ApplePay/payment-request.js +0 -2
- package/dist/es/components/ApplePay/payment-request.js.map +0 -1
- package/dist/es/components/ApplePay/utils.js +0 -2
- package/dist/es/components/ApplePay/utils.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/ApplePayService.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/config.js +0 -2
- package/dist/es-legacy/components/ApplePay/config.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/payment-request.js +0 -2
- package/dist/es-legacy/components/ApplePay/payment-request.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/utils.js +0 -2
- package/dist/es-legacy/components/ApplePay/utils.js.map +0 -1
- /package/dist/es/components/ApplePay/{ApplePayService.js → services/ApplePayService.js} +0 -0
- /package/dist/es-legacy/components/ApplePay/{ApplePayService.js → services/ApplePayService.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nimport type { AddressData, BrowserInfo, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport type { ICore } from '../../core/types';\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n this.showGooglePayPaymentSheet = this.showGooglePayPaymentSheet.bind(this);\n\n const { isExpress, paymentDataCallbacks } = this.props;\n\n if (isExpress === false && paymentDataCallbacks?.onPaymentDataChanged) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - You must set \"isExpress\" flag to \"true\" in order to use \"onPaymentDataChanged\" callback'\n );\n }\n\n this.googlePay = new GooglePayService(this.props.environment, {\n ...(isExpress && paymentDataCallbacks?.onPaymentDataChanged && { onPaymentDataChanged: paymentDataCallbacks.onPaymentDataChanged }),\n onPaymentAuthorized: this.onPaymentAuthorized\n });\n }\n\n protected override formatProps(props): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n return {\n ...props,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n // Analytics will need to know about this.props.isExpress & this.props.expressPage\n super.submitAnalytics({ ...analyticsObj }, this.props);\n }\n\n /**\n * Displays the Google Pay payment sheet overlay\n */\n private showGooglePayPaymentSheet() {\n this.googlePay.initiatePayment(this.props, this.core.options.countryCode).catch((error: google.payments.api.PaymentsError) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n this.handleError(new AdyenCheckoutError(error.statusCode === 'CANCELED' ? 'CANCEL' : 'ERROR', error.toString(), { cause: error }));\n });\n }\n\n public override submit = () => {\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n\n new Promise<void>((resolve, reject) => this.props.onClick(resolve, reject)).then(this.showGooglePayPaymentSheet).catch(() => {\n // Swallow exception triggered by onClick reject\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse?.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n const responseWithError = {\n ...paymentResponse,\n error: {\n googlePayError: error\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Validation\n */\n get isValid(): boolean {\n return !!this.state.googlePayToken;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo(): BrowserInfo {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n render() {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n buttonRadius={this.props.buttonRadius}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["GooglePay","UIElement","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","_object_spread_props","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","this","state","isExpress","_object_spread","paymentMethod","type","subtype","browserInfo","origin","window","location","submitAnalytics","analyticsObj","super","showGooglePayPaymentSheet","googlePay","initiatePayment","core","options","countryCode","catch","error","handleError","AdyenCheckoutError","statusCode","toString","cause","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","render","showPayButton","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","buttonRadius","paymentsClient","onClick","submit","constructor","checkout","_define_property","isInstantPayment","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","responseWithError","handleFailedResult","prefetch","prefetchPaymentData","bind","paymentDataCallbacks","onPaymentDataChanged","GooglePayService","environment","TxVariants","googlepay","txVariants","paywithgoogle","defaultProps"],"mappings":"w+CAiBA,MAAMA,UAAkBC,EA2BDC,WAAAA,CAAYC,GAEmCA,IAAAA,EADvCA,EAAvB,MAAMC,EAAiBD,QAAAA,EAAAA,EAAMC,sBAAND,IAAAA,EAAAA,EAAyBA,EAAME,SAAW,OAAS,SAClCF,IAAAA,EAAxC,MAAMG,EAAeC,EAAqC,QAAlBJ,EAAAA,EAAMG,oBAANH,IAAAA,EAAAA,EAAsBA,QAAAA,EAAAA,EAAMK,YAANL,IAAAA,OAAAA,EAAAA,EAAYM,QAEpEC,EAAwD,IAAIP,EAAMO,gBAAiB,yBAEzF,OAAOC,EACAR,EAAAA,CAAAA,EAAAA,GAAAA,CACHS,cAAeT,EAAMS,cACrBR,iBACAE,eACAI,mBAER,CAKA,UAAAG,GACI,MAAMC,qBAAEA,EAAoBC,eAAEA,EAAcC,eAAEA,EAAcC,gBAAEA,GAAoBC,KAAKC,OACjFC,UAAEA,GAAcF,KAAKf,MAE3B,OAAOkB,EAAA,CACHC,cAAeD,EAAA,CACXE,KAAML,KAAKK,KACXT,uBACAC,kBACIK,GAAa,CAAEI,QAAS,YAEhCC,YAAaP,KAAKO,YAClBC,SAAUC,QAAUA,OAAOC,SAASF,QAChCV,GAAkB,CAAEA,kBACpBC,GAAmB,CAAEA,mBAEjC,CAEUY,eAAAA,CAAgBC,GAEtBC,MAAMF,gBAAgBR,EAAA,CAAA,EAAKS,GAAgBZ,K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AQ,wBACRC,OAAQ,cACRC,QAASrD,GAA8BiD,GAE3C,CACIE,QAAQnD,aAAAA,EAAAA,EAAgBmD,SAAU,wBAClCC,QAAQpD,aAAAA,EAAAA,EAAgBoD,SAAU,cAClCC,SAASrD,aAAAA,EAAAA,EAAgBqD,UAAWJ,GAGlDtD,EAAQ,CACJmD,iBAAkB,QAClB3D,UAGJ,MAAMmE,EAAoB/F,EACnBsF,EAAAA,CAAAA,EAAAA,GAAAA,CACH1D,MAAO,CACHa,eAAgBb,KAIxBrB,KAAKyF,mBAAmBD,EAAAA,GAC5B,GACR,IA6DJ5B,OAAOvB,gBAAe,IACXrC,KAAKe,UAAUsB,aAAarC,KAAKf,SAM5C2E,OAAO8B,YAAW,IACP1F,KAAKe,UAAU4E,oBAAoB3F,KAAKf,MAAOe,KAAKiB,KAAKC,QAAQC,eAlNxEnB,KAAK2B,oBAAsB3B,KAAK2B,oBAAoBiE,KAAK5F,MACzDA,KAAKc,0BAA4Bd,KAAKc,0BAA0B8E,KAAK5F,MAErE,MAAME,UAAEA,EAAS2F,qBAAEA,GAAyB7F,KAAKf,MAEjD,IAAkB,IAAdiB,IAAuB2F,aAAAA,EAAAA,EAAsBC,sBAC7C,MAAM,IAAIvE,EACN,uBACA,uGAIRvB,KAAKe,UAAY,IAAIgF,EAAiB/F,KAAKf,MAAM+G,YAAavG,EACtDS,EAAAA,CAAAA,EAAAA,IAAa2F,aAAAA,EAAAA,EAAsBC,uBAAwB,CAAEA,qBAAsBD,EAAqBC,uBAAqB,CACjI7B,oBAAqBjE,KAAKiE,sBAElC,EAxBAL,EADE9E,EACYuB,OAAO4F,EAAWC,WAChCtC,EAFE9E,EAEYqH,aAAa,CAACF,EAAWC,UAAWD,EAAWG,gBAC7DxC,EAHE9E,EAGYuH,eAAeA"}
|
|
1
|
+
{"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nimport type { AddressData, BrowserInfo, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport type { ICore } from '../../core/types';\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n this.showGooglePayPaymentSheet = this.showGooglePayPaymentSheet.bind(this);\n\n const { isExpress, paymentDataCallbacks } = this.props;\n\n if (isExpress === false && paymentDataCallbacks?.onPaymentDataChanged) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - You must set \"isExpress\" flag to \"true\" in order to use \"onPaymentDataChanged\" callback'\n );\n }\n\n if (!this.props.configuration.merchantId) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - Missing merchantId. Please ensure that it is correctly configured in your customer area.'\n );\n }\n\n this.googlePay = new GooglePayService(this.props.environment, {\n ...(isExpress && paymentDataCallbacks?.onPaymentDataChanged && { onPaymentDataChanged: paymentDataCallbacks.onPaymentDataChanged }),\n onPaymentAuthorized: this.onPaymentAuthorized\n });\n }\n\n protected override formatProps(props): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n return {\n ...props,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n // Analytics will need to know about this.props.isExpress & this.props.expressPage\n super.submitAnalytics({ ...analyticsObj }, this.props);\n }\n\n /**\n * Displays the Google Pay payment sheet overlay\n */\n private showGooglePayPaymentSheet() {\n this.googlePay.initiatePayment(this.props, this.core.options.countryCode).catch((error: google.payments.api.PaymentsError) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n this.handleError(new AdyenCheckoutError(error.statusCode === 'CANCELED' ? 'CANCEL' : 'ERROR', error.toString(), { cause: error }));\n });\n }\n\n public override submit = () => {\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n\n new Promise<void>((resolve, reject) => this.props.onClick(resolve, reject)).then(this.showGooglePayPaymentSheet).catch(() => {\n // Swallow exception triggered by onClick reject\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse?.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n const responseWithError = {\n ...paymentResponse,\n error: {\n googlePayError: error\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Validation\n */\n get isValid(): boolean {\n return !!this.state.googlePayToken;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo(): BrowserInfo {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n render() {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n buttonRadius={this.props.buttonRadius}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["GooglePay","UIElement","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","_object_spread_props","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","this","state","isExpress","_object_spread","paymentMethod","type","subtype","browserInfo","origin","window","location","submitAnalytics","analyticsObj","super","showGooglePayPaymentSheet","googlePay","initiatePayment","core","options","countryCode","catch","error","handleError","AdyenCheckoutError","statusCode","toString","cause","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","render","showPayButton","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","buttonRadius","paymentsClient","onClick","submit","constructor","checkout","_define_property","isInstantPayment","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","responseWithError","handleFailedResult","prefetch","prefetchPaymentData","bind","paymentDataCallbacks","onPaymentDataChanged","merchantId","GooglePayService","environment","TxVariants","googlepay","txVariants","paywithgoogle","defaultProps"],"mappings":"w+CAiBA,MAAMA,UAAkBC,EAkCDC,WAAAA,CAAYC,GAEmCA,IAAAA,EADvCA,EAAvB,MAAMC,EAAiBD,QAAAA,EAAAA,EAAMC,sBAAND,IAAAA,EAAAA,EAAyBA,EAAME,SAAW,OAAS,SAClCF,IAAAA,EAAxC,MAAMG,EAAeC,EAAqC,QAAlBJ,EAAAA,EAAMG,oBAANH,IAAAA,EAAAA,EAAsBA,QAAAA,EAAAA,EAAMK,YAANL,IAAAA,OAAAA,EAAAA,EAAYM,QAEpEC,EAAwD,IAAIP,EAAMO,gBAAiB,yBAEzF,OAAOC,EACAR,EAAAA,CAAAA,EAAAA,GAAAA,CACHS,cAAeT,EAAMS,cACrBR,iBACAE,eACAI,mBA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C1B,MAAM,IAAIxE,EACN,uBACA,wGAIRvB,KAAKe,UAAY,IAAIiF,EAAiBhG,KAAKf,MAAMgH,YAAaxG,EACtDS,EAAAA,CAAAA,EAAAA,IAAa2F,aAAAA,EAAAA,EAAsBC,uBAAwB,CAAEA,qBAAsBD,EAAqBC,uBAAqB,CACjI7B,oBAAqBjE,KAAKiE,sBAElC,EA/BAL,EADE9E,EACYuB,OAAO6F,EAAWC,WAChCvC,EAFE9E,EAEYsH,aAAa,CAACF,EAAWC,UAAWD,EAAWG,gBAC7DzC,EAHE9E,EAGYwH,eAAeA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../../../_virtual/index.js";import{createElement as t}from"../../../external/preact/dist/preact.js";function a({buttonId:a,showRadioButton:
|
|
1
|
+
import e from"../../../_virtual/index.js";import{createElement as t}from"../../../external/preact/dist/preact.js";function a({buttonId:a,showRadioButton:o,isSelected:d,expandContentId:n,children:r,classNameModifiers:c=[]}){return t("button",{className:e("adyen-checkout__payment-method__header__title",...c.map((e=>`adyen-checkout-expand-button--${e}`))),id:a,role:"radio","aria-checked":d,"aria-controls":n,type:"button"},o&&t("span",{className:e({"adyen-checkout__payment-method__radio":!0,"adyen-checkout__payment-method__radio--selected":d}),"aria-hidden":"true"}),r)}export{a as default};
|
|
2
2
|
//# sourceMappingURL=ExpandButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandButton.js","sources":["../../../../../src/components/internal/ExpandButton/ExpandButton.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ComponentChildren, h } from 'preact';\nimport './ExpandButton.scss';\n\ninterface ExpandButton {\n buttonId: string;\n isSelected: boolean;\n expandContentId: string;\n children?: ComponentChildren;\n showRadioButton?: boolean;\n classNameModifiers?: string[];\n}\n\nfunction ExpandButton({ buttonId, showRadioButton, isSelected, expandContentId, children, classNameModifiers = [] }: Readonly<ExpandButton>) {\n return (\n // See discussion: https://github.com/w3c/aria/issues/1404\n //
|
|
1
|
+
{"version":3,"file":"ExpandButton.js","sources":["../../../../../src/components/internal/ExpandButton/ExpandButton.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ComponentChildren, h } from 'preact';\nimport './ExpandButton.scss';\n\ninterface ExpandButton {\n buttonId: string;\n isSelected: boolean;\n expandContentId: string;\n children?: ComponentChildren;\n showRadioButton?: boolean;\n classNameModifiers?: string[];\n}\n\nfunction ExpandButton({ buttonId, showRadioButton, isSelected, expandContentId, children, classNameModifiers = [] }: Readonly<ExpandButton>) {\n return (\n // See discussion: https://github.com/w3c/aria/issues/1404\n // this has been disabled as we got quite a few complains\n // mainly from merchants running automated systems\n <button\n className={classNames(\n 'adyen-checkout__payment-method__header__title',\n ...classNameModifiers.map(modifier => `adyen-checkout-expand-button--${modifier}`)\n )}\n id={buttonId}\n role={'radio'}\n aria-checked={isSelected}\n //aria-expanded={isSelected} - disabled for now\n aria-controls={expandContentId}\n type=\"button\"\n >\n {showRadioButton && (\n <span\n className={classNames({\n 'adyen-checkout__payment-method__radio': true,\n 'adyen-checkout__payment-method__radio--selected': isSelected\n })}\n aria-hidden=\"true\"\n />\n )}\n {children}\n </button>\n );\n}\n\nexport default ExpandButton;\n"],"names":["ExpandButton","buttonId","showRadioButton","isSelected","expandContentId","children","classNameModifiers","h","button","className","classNames","map","modifier","id","role","aria-checked","aria-controls","type","span","aria-hidden"],"mappings":"kHAaA,SAASA,GAAaC,SAAEA,EAAQC,gBAAEA,EAAeC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,mBAAEA,EAAqB,KAC3G,OAIIC,EAACC,SAAAA,CACGC,UAAWC,EACP,mDACGJ,EAAmBK,KAAIC,GAAY,iCAAiCA,OAE3EC,GAAIZ,EACJa,KAAM,QACNC,eAAcZ,EAEda,gBAAeZ,EACfa,KAAK,UAEJf,GACGK,EAACW,OAAAA,CACGT,UAAWC,EAAW,CAClB,yCAAyC,EACzC,kDAAmDP,IAEvDgB,cAAY,SAGnBd,EAGb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"../utils/cardType.js";import{error as e}from"../../utilities/logger.js";import{CVC_POLICY_REQUIRED as r}from"../../constants.js";function o({csfState:o,csfConfig:i,csfProps:s,csfCallbacks:n},a){o.isConfigured=!0;const c={iframesConfigured:!0,type:o.type,rootNode:s.rootNode};if(n.onConfigSuccess(c),1===o.numIframes&&i.isCreditCardType){if("card"===o.type)return e("ERROR: Payment method with a single secured field - but 'brands' has not been set to an array containing the specific card brand"),!1;const i=t.getCardByBrand(o.type);if(i){var f;(null!==(f=i.cvcPolicy)&&void 0!==f?f:r)!==r&&a()}}return!0}export{o as isConfigured};
|
|
2
2
|
//# sourceMappingURL=isConfigured.js.map
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConfigured.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/isConfigured.ts"],"sourcesContent":["import cardType from '../utils/cardType';\nimport { CardObject, CardConfigSuccessData } from '../../types';\nimport * as logger from '../../utilities/logger';\nimport { CVC_POLICY_REQUIRED } from '../../constants';\nimport { CSFThisObject } from '../types';\n\n/**\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfProps - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n * @param validateForm - comes from initial, partial, implementation\n */\nexport function isConfigured({ csfState, csfConfig, csfProps, csfCallbacks }: CSFThisObject, validateForm): boolean {\n csfState.isConfigured = true;\n\n const callbackObj: CardConfigSuccessData = { iframesConfigured: true, type: csfState.type, rootNode: csfProps.rootNode as HTMLElement };\n\n csfCallbacks.onConfigSuccess(callbackObj);\n\n // If a recurring card\n if (csfState.numIframes === 1 && csfConfig.isCreditCardType) {\n if (csfState.type === 'card') {\n logger.error(\"ERROR: Payment method with a single secured field - but '
|
|
1
|
+
{"version":3,"file":"isConfigured.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/isConfigured.ts"],"sourcesContent":["import cardType from '../utils/cardType';\nimport { CardObject, CardConfigSuccessData } from '../../types';\nimport * as logger from '../../utilities/logger';\nimport { CVC_POLICY_REQUIRED } from '../../constants';\nimport { CSFThisObject } from '../types';\n\n/**\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfProps - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n * @param validateForm - comes from initial, partial, implementation\n */\nexport function isConfigured({ csfState, csfConfig, csfProps, csfCallbacks }: CSFThisObject, validateForm): boolean {\n csfState.isConfigured = true;\n\n const callbackObj: CardConfigSuccessData = { iframesConfigured: true, type: csfState.type, rootNode: csfProps.rootNode as HTMLElement };\n\n csfCallbacks.onConfigSuccess(callbackObj);\n\n // If a recurring card\n if (csfState.numIframes === 1 && csfConfig.isCreditCardType) {\n if (csfState.type === 'card') {\n logger.error(\n \"ERROR: Payment method with a single secured field - but 'brands' has not been set to an array containing the specific card brand\"\n );\n return false;\n }\n\n // Get card object from txVariant\n const card: CardObject = cardType.getCardByBrand(csfState.type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (card) {\n // Assess whether cvc field is required\n const cvcPolicy = card.cvcPolicy ?? CVC_POLICY_REQUIRED;\n\n // If cvc is optional - the form can be considered valid\n if (cvcPolicy !== CVC_POLICY_REQUIRED) {\n validateForm();\n }\n }\n }\n return true;\n}\n"],"names":["isConfigured","csfState","csfConfig","csfProps","csfCallbacks","validateForm","callbackObj","iframesConfigured","type","rootNode","onConfigSuccess","numIframes","isCreditCardType","logger","card","cardType","getCardByBrand","cvcPolicy","CVC_POLICY_REQUIRED"],"mappings":"+IAaO,SAASA,GAAaC,SAAEA,EAAQC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,GAA+BC,GACzFJ,EAASD,cAAe,EAExB,MAAMM,EAAqC,CAAEC,mBAAmB,EAAMC,KAAMP,EAASO,KAAMC,SAAUN,EAASM,UAK9G,GAHAL,EAAaM,gBAAgBJ,GAGD,IAAxBL,EAASU,YAAoBT,EAAUU,iBAAkB,CACzD,GAAsB,SAAlBX,EAASO,KAIT,OAHAK,EACI,qIAEG,EAIX,MAAMC,EAAmBC,EAASC,eAAef,EAASO,MAI1D,GAAIM,EAAM,CAEYA,IAAAA,GAAc,QAAdA,EAAAA,EAAKG,qBAALH,EAAAA,EAAkBI,KAGlBA,GACdb,GAER,CACJ,CACA,OAAO,CACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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.
|
|
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.10.0",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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","_object_spread","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch"],"mappings":"uMAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,wUAAiCC,CAAA,CAEnCC,QAAS,
|
|
1
|
+
{"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdEvent, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event: CollectIdEvent): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","_object_spread","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch"],"mappings":"uMAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,wUAAiCC,CAAA,CAEnCC,QAAS,SAETC,QAAS,MACTC,SAAU,MACVC,UAAWZ,EACXF,SACAe,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,OACxBb,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKJ,EAAW,OAAOuB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,KAAKA,aAAAA,EAAAA,EAA0BE,IAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDzB,EAAUgC,EAAS/B,EAASK,GACvB2B,MAAKC,IACF,GAAIA,aAAAA,EAAAA,EAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,iBAEfE,IAEVC,OAAM,IACInB,QAAQC,OAAO3B,KAGvBO,EAAAA,CACX"}
|
|
@@ -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.
|
|
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.10.0",bundleType:"eslegacy"}),E(T,"registry",p);export{T as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { DEFAULT_LOCALE } from '../language/constants';\nimport getTranslations from './Services/get-translations';\nimport { defaultProps } from './core.defaultProps';\nimport { formatCustomTranslations, formatLocale } from '../language/utils';\nimport { resolveEnvironments } from './Environment';\n\nimport type { AnalyticsModule, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from './types';\nimport type { Translations } from '../language/types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: Readonly<{\n risk: RiskModule;\n analytics: AnalyticsModule;\n resources: Resources;\n i18n: Language;\n srPanel: SRPanel;\n }>;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata = {\n version: process.env.VERSION,\n bundleType: process.env.BUNDLE_TYPE\n };\n\n public static registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `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.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n await this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private async fetchLocaleTranslations(): Promise<Translations> {\n try {\n return await getTranslations(this.cdnTranslationsUrl, Core.metadata.version, this.options.locale);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.options.onError?.(error);\n else this.options.onError?.(new AdyenCheckoutError('ERROR', 'Failed to fetch translation', { cause: error }));\n }\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n this.options.locale = formatLocale(this.options.locale);\n this.options.translations = formatCustomTranslations(this.options.translations);\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentFailed?.(response);\n });\n }\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n this.modules.analytics.sendAnalytics(component, {\n type: ANALYTICS_ACTION_STR,\n subtype: action.type,\n message: `${component} action was handled by the SDK`\n });\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...options,\n ...(this.session && { session: this.session })\n };\n component.update(newProps);\n });\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private async createCoreModules(): Promise<void> {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n const translations = await this.fetchLocaleTranslations();\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n loadingContext: this.loadingContext,\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n amount: this.options.amount,\n bundleType: Core.metadata.bundleType\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n translations,\n customTranslations: this.options.translations\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","_object_spread_props","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","fetchLocaleTranslations","getTranslations","cdnTranslationsUrl","version","_this_options_onError","_this_options","_this_options_onError1","_this_options1","AdyenCheckoutError","call","cause","paymentMethodsConfiguration","console","warn","IMPLEMENTATION_ERROR","DEFAULT_LOCALE","formatLocale","translations","formatCustomTranslations","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","response","_this_options_onPaymentCompleted","cleanupFinalResult","onPaymentCompleted","_this_options_onPaymentFailed","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","modules","analytics","sendAnalytics","ANALYTICS_ACTION_STR","message","props","_object_spread","getCorePropsForComponent","getComponentForAction","handleCreateError","globalOptions","processGlobalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","storeElementReference","element","components","push","paymentMethod","paymentMethodName","name","errorMessage","JSON","stringify","paymentMethodsResponse","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","analyticsContext","clientKey","resources","Resources","Language","customTranslations","srPanel","SRPanel","srConfig","constructor","_this_options_clientKey","_define_property","update","forEach","newProps","remove","filter","c","_id","unmount","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","environment","_environmentUrls","Session","clientKeyType","substring","_this_options__environmentUrls","_this_options_clientKey1","includes","api","debug","exposeLibraryMetadata","window"],"mappings":"q5EA2BA,MAAMA,EA0BF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,EACpB,CAEOG,YAAAA,CAAaC,GAChB,OAAOH,EAASE,aAAaC,EACjC,CAuCA,gBAAaC,GAIT,aAHMC,KAAKC,iBACXD,KAAKE,kCACCF,KAAKG,oBACJH,IACX,CAEA,oBAAcC,GACV,OAAID,KAAKI,QACEJ,KAAKI,QACPC,aAAaL,KAAKM,SAClBC,MAAKC,IACF,MAAMC,OAAEA,EAAMC,cAAEA,EAAaC,YAAEA,EAAWC,eAAEA,GAA4BJ,EAATK,EAASL,EAAAA,EAAAA,CAAhEC,SAAQC,gBAAeC,cAAaC,mBAW5C,OATAZ,KAAKc,WAAWC,EACTF,EAAAA,CAAAA,EAAAA,GAAAA,CACHJ,OAAQT,KAAKM,QAAQU,MAAQhB,KAAKM,QAAQU,MAAMC,gBAAkBR,EAClES,OAAQlB,KAAKM,QAA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AKmF,aAAeA,EACpBnF,KAAK4B,mBAAqBA,EAE1B5B,KAAKI,QAAUJ,KAAKM,QAAQF,SAAW,IAAI6H,EAAQjI,KAAKM,QAAQF,QAASJ,KAAKM,QAAQgG,UAAWtG,KAAKiF,gBAEtG,MAAMiD,EAAsC,QAAtBnB,EAAA/G,KAAKM,QAAQgG,iBAAb,IAAAS,OAAA,EAAAA,EAAwBoB,UAAU,EAAG,GAIc,IAAAC,EAKSC,EARlF,IAAuB,SAAlBH,GAA8C,SAAlBA,KAA8BlI,KAAKiF,eAAeqD,SAASJ,GACxF,MAAM,IAAIhG,EACN,uBACA,0BAA0BgG,4BAAuC,QAAAE,EAAApI,KAAKM,QAAQ0H,wBAAb,IAAAI,OAAA,EAAAA,EAA+BG,MAAOvI,KAAKM,QAAQyH,2BAGtG,SAAlBG,GACA5F,QAAQkG,MACJ,0EAAgG,QAAtBH,EAAArI,KAAKM,QAAQgG,qBAAb+B,SAAAA,EAAwBF,UAAU,EAAG,oQAInHnI,KAAKM,QAAQmI,wBACbC,OAAO,iBAAsBtJ,EAAKG,SAE1C,EA9DAyH,EAnBE5H,EAmBqBG,WAAW,CAC9BsC,QAAS,QACTrC,WAAY,aAGhBwH,EAxBE5H,EAwBYO,WAAWA"}
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport Analytics from './Analytics';\nimport { assertConfigurationPropertiesAreValid, processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/constants';\nimport { DEFAULT_LOCALE } from '../language/constants';\nimport getTranslations from './Services/get-translations';\nimport { defaultProps } from './core.defaultProps';\nimport { formatCustomTranslations, formatLocale } from '../language/utils';\nimport { resolveEnvironments } from './Environment';\n\nimport type { AnalyticsModule, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from './types';\nimport type { Translations } from '../language/types';\nimport type { UIElementProps } from '../components/internal/UIElement/types';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: Readonly<{\n risk: RiskModule;\n analytics: AnalyticsModule;\n resources: Resources;\n i18n: Language;\n srPanel: SRPanel;\n }>;\n public options: CoreConfiguration;\n\n public analyticsContext: string;\n public loadingContext: string;\n public cdnImagesUrl: string;\n public cdnTranslationsUrl: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata = {\n version: process.env.VERSION,\n bundleType: process.env.BUNDLE_TYPE\n };\n\n public static registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n assertConfigurationPropertiesAreValid(props);\n\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions({ ...defaultProps, ...props });\n\n const { apiUrl, analyticsUrl, cdnImagesUrl, cdnTranslationsUrl } = resolveEnvironments(\n this.options.environment,\n this.options._environmentUrls\n );\n\n this.loadingContext = apiUrl;\n this.analyticsContext = analyticsUrl;\n this.cdnImagesUrl = cdnImagesUrl;\n this.cdnTranslationsUrl = cdnTranslationsUrl;\n\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substring(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options._environmentUrls?.api || this.options.environment} environment`\n );\n }\n if (clientKeyType === 'pub.') {\n console.debug(\n `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.`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n await this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private async fetchLocaleTranslations(): Promise<Translations> {\n try {\n return await getTranslations(this.cdnTranslationsUrl, Core.metadata.version, this.options.locale);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.options.onError?.(error);\n else this.options.onError?.(new AdyenCheckoutError('ERROR', 'Failed to fetch translation', { cause: error }));\n }\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(IMPLEMENTATION_ERROR, 'You must specify a countryCode when initializing checkout.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n this.options.locale = formatLocale(this.options.locale);\n this.options.translations = formatCustomTranslations(this.options.translations);\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentFailed?.(response);\n });\n }\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): UIElement {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n this.modules.analytics.sendAnalytics(component, {\n type: ANALYTICS_ACTION_STR,\n subtype: action.type,\n message: `${component} action was handled by the SDK`\n });\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n this.components.forEach(component => {\n // We update only with the new options that have been received\n const newProps: Partial<UIElementProps> = {\n ...options,\n ...(this.session && { session: this.session })\n };\n component.update(newProps);\n });\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnImagesUrl,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private async createCoreModules(): Promise<void> {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n const translations = await this.fetchLocaleTranslations();\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n loadingContext: this.loadingContext,\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n amount: this.options.amount,\n bundleType: Core.metadata.bundleType\n }),\n resources: new Resources(this.cdnImagesUrl),\n i18n: new Language({\n locale: this.options.locale,\n translations,\n customTranslations: this.options.translations\n }),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","setBundleType","type","metadata","bundleType","register","items","registry","add","getComponent","txVariant","initialize","this","initializeCore","validateCoreConfiguration","createCoreModules","session","setupSession","options","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","setOptions","_object_spread_props","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","fetchLocaleTranslations","getTranslations","cdnTranslationsUrl","version","_this_options_onError","_this_options","_this_options_onError1","_this_options1","AdyenCheckoutError","call","cause","paymentMethodsConfiguration","console","warn","IMPLEMENTATION_ERROR","DEFAULT_LOCALE","formatLocale","translations","formatCustomTranslations","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","response","_this_options_onPaymentCompleted","cleanupFinalResult","onPaymentCompleted","_this_options_onPaymentFailed","onPaymentFailed","createFromAction","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","modules","analytics","sendAnalytics","ANALYTICS_ACTION_STR","message","props","_object_spread","getCorePropsForComponent","getComponentForAction","handleCreateError","globalOptions","processGlobalOptions","core","i18n","loadingContext","cdnContext","cdnImagesUrl","storeElementReference","element","components","push","paymentMethod","paymentMethodName","name","errorMessage","JSON","stringify","paymentMethodsResponse","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","analyticsContext","clientKey","resources","Resources","Language","customTranslations","srPanel","SRPanel","srConfig","constructor","_this_options_clientKey","_define_property","update","forEach","newProps","remove","filter","c","_id","unmount","assertConfigurationPropertiesAreValid","bind","defaultProps","apiUrl","analyticsUrl","resolveEnvironments","environment","_environmentUrls","Session","clientKeyType","substring","_this_options__environmentUrls","_this_options_clientKey1","includes","api","debug","exposeLibraryMetadata","window"],"mappings":"q5EA2BA,MAAMA,EA0BF,oBAAcC,CAAcC,GACxBF,EAAKG,SAASC,WAAaF,CAC/B,CAEA,eAAcG,IAAYC,GACtBC,EAASC,OAAOF,EACpB,CAMA,QAAAD,IAAmBC,GACfC,EAASC,OAAOF,EACpB,CAEOG,YAAAA,CAAaC,GAChB,OAAOH,EAASE,aAAaC,EACjC,CAuCA,gBAAaC,GAIT,aAHMC,KAAKC,iBACXD,KAAKE,kCACCF,KAAKG,oBACJH,IACX,CAEA,oBAAcC,GACV,OAAID,KAAKI,QACEJ,KAAKI,QACPC,aAAaL,KAAKM,SAClBC,MAAKC,IACF,MAAMC,OAAEA,EAAMC,cAAEA,EAAaC,YAAEA,EAAWC,eAAEA,GAA4BJ,EAATK,EAASL,EAAAA,EAAAA,CAAhEC,SAAQC,gBAAeC,cAAaC,mBAW5C,OATAZ,KAAKc,WAAWC,EACTF,EAAAA,CAAAA,EAAAA,GAAAA,CACHJ,O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,KAAKM,QAAQ0H,kBAGjBhI,KAAKiF,eAAiB2C,EACtB5H,KAAKqG,iBAAmBwB,EACxB7H,KAAKmF,aAAeA,EACpBnF,KAAK4B,mBAAqBA,EAE1B5B,KAAKI,QAAUJ,KAAKM,QAAQF,SAAW,IAAI6H,EAAQjI,KAAKM,QAAQF,QAASJ,KAAKM,QAAQgG,UAAWtG,KAAKiF,gBAEtG,MAAMiD,EAAsC,QAAtBnB,EAAA/G,KAAKM,QAAQgG,iBAAb,IAAAS,OAAA,EAAAA,EAAwBoB,UAAU,EAAG,GAIc,IAAAC,EAKSC,EARlF,IAAuB,SAAlBH,GAA8C,SAAlBA,KAA8BlI,KAAKiF,eAAeqD,SAASJ,GACxF,MAAM,IAAIhG,EACN,uBACA,0BAA0BgG,4BAAuC,QAAAE,EAAApI,KAAKM,QAAQ0H,wBAAb,IAAAI,OAAA,EAAAA,EAA+BG,MAAOvI,KAAKM,QAAQyH,2BAGtG,SAAlBG,GACA5F,QAAQkG,MACJ,0EAAgG,QAAtBH,EAAArI,KAAKM,QAAQgG,qBAAb+B,SAAAA,EAAwBF,UAAU,EAAG,oQAInHnI,KAAKM,QAAQmI,wBACbC,OAAO,iBAAsBtJ,EAAKG,SAE1C,EA9DAyH,EAnBE5H,EAmBqBG,WAAW,CAC9BsC,QAAS,SACTrC,WAAY,aAGhBwH,EAxBE5H,EAwBYO,WAAWA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inIframe.js","sources":["../../../src/utils/inIframe.ts"],"sourcesContent":["const inIframe = () => window.self !== window.top;\n\nexport { inIframe };\n"],"names":["inIframe","window","self","top"],"mappings":"AAAA,MAAMA,EAAW,IAAMC,OAAOC,OAASD,OAAOE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adyen/adyen-web",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://docs.adyen.com/checkout",
|
|
6
6
|
"type": "module",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"start": "npm run dev-server",
|
|
62
62
|
"story": "storybook dev --port 3020 --disable-telemetry",
|
|
63
63
|
"dev-server": "rollup --watch --config config/rollup.dev.js",
|
|
64
|
-
"build": "rm -rf dist/ && npm run lint && npm run lint-styles && npm run type-check && npm run types
|
|
64
|
+
"build": "rm -rf dist/ && npm run lint && npm run lint-styles && npm run type-check && npm run build:types && rollup --config config/rollup.prod.js && rm -rf dist/temp-types",
|
|
65
|
+
"build:types": "tsc --emitDeclarationOnly && node scripts/add-type-references.cjs",
|
|
65
66
|
"docs:generate": "typedoc --out docs src --exclude \"**/*+(index|.test).ts\"",
|
|
66
67
|
"start:storybook": "node .storybook/run.cjs",
|
|
67
68
|
"build:storybook": "storybook build --disable-telemetry",
|
|
@@ -69,7 +70,6 @@
|
|
|
69
70
|
"test:watch": "npm run test -- --watchAll",
|
|
70
71
|
"test:coverage": "npm run test -- --coverage",
|
|
71
72
|
"type-check": "tsc --noEmit",
|
|
72
|
-
"types:generate": "tsc --emitDeclarationOnly",
|
|
73
73
|
"format": "npm run lint:fix && npm run prettier:fix && npm run styles:fix",
|
|
74
74
|
"lint": "eslint .",
|
|
75
75
|
"lint-styles": "stylelint \"**/*.scss\"",
|
|
@@ -92,16 +92,16 @@
|
|
|
92
92
|
"@rollup/plugin-replace": "5.0.7",
|
|
93
93
|
"@rollup/plugin-terser": "0.4.4",
|
|
94
94
|
"@size-limit/preset-big-lib": "11.1.6",
|
|
95
|
-
"@storybook/addon-a11y": "
|
|
96
|
-
"@storybook/addon-essentials": "
|
|
97
|
-
"@storybook/manager-api": "
|
|
98
|
-
"@storybook/preact": "
|
|
99
|
-
"@storybook/preact-vite": "
|
|
95
|
+
"@storybook/addon-a11y": "8.6.3",
|
|
96
|
+
"@storybook/addon-essentials": "8.6.3",
|
|
97
|
+
"@storybook/manager-api": "8.6.3",
|
|
98
|
+
"@storybook/preact": "8.6.3",
|
|
99
|
+
"@storybook/preact-vite": "8.6.3",
|
|
100
100
|
"@swc/core": "1.10.17",
|
|
101
101
|
"@testing-library/jest-dom": "6.6.3",
|
|
102
102
|
"@testing-library/preact": "3.2.4",
|
|
103
103
|
"@testing-library/preact-hooks": "1.1.0",
|
|
104
|
-
"@testing-library/user-event": "14.
|
|
104
|
+
"@testing-library/user-event": "14.5.2",
|
|
105
105
|
"@types/eslint__js": "8.42.3",
|
|
106
106
|
"@types/jest": "29.5.14",
|
|
107
107
|
"autoprefixer": "10.4.20",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"eslint-plugin-import": "2.31.0",
|
|
115
115
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
116
116
|
"eslint-plugin-react": "7.37.4",
|
|
117
|
-
"eslint-plugin-storybook": "0.11.
|
|
117
|
+
"eslint-plugin-storybook": "0.11.3",
|
|
118
118
|
"eslint-plugin-testing-library": "6.5.0",
|
|
119
119
|
"globals": "15.14.0",
|
|
120
120
|
"husky": "9.1.7",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"rollup-plugin-swc3": "0.12.1",
|
|
134
134
|
"sass": "1.77.8",
|
|
135
135
|
"size-limit": "11.1.6",
|
|
136
|
-
"storybook": "
|
|
136
|
+
"storybook": "8.6.3",
|
|
137
137
|
"stylelint": "16.12.0",
|
|
138
138
|
"stylelint-config-standard-scss": "13.1.0",
|
|
139
139
|
"ts-jest": "29.2.5",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"whatwg-fetch": "3.6.20"
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
|
-
"@types/applepayjs": "14.0.
|
|
149
|
+
"@types/applepayjs": "14.0.9",
|
|
150
150
|
"@types/googlepay": "0.7.6",
|
|
151
151
|
"classnames": "2.5.1",
|
|
152
152
|
"preact": "10.22.1"
|