@adyen/adyen-web 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4397,11 +4397,7 @@ declare class UPI extends UIElement<UPIConfiguration> {
4397
4397
  constructor(checkout: ICore, props: UPIConfiguration);
4398
4398
  formatProps(props: UPIConfiguration): {
4399
4399
  defaultMode: UpiMode;
4400
- apps: {
4401
- type: TxVariants;
4402
- id: string;
4403
- name: string;
4404
- }[];
4400
+ apps: App[];
4405
4401
  url?: string;
4406
4402
  paymentData?: string;
4407
4403
  qrCodeData?: string;
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import i from"./defaultProps.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import s from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as a}from"./constants.js";import{TxVariants as o}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as h}from"./utils/format-paypal-order-contact-to-adyen-format.js";class p extends e{static type=o.paypal;static subtype="sdk";paymentData=null;resolve=null;reject=null;static defaultProps=i;constructor(t,e){super(t,e),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}formatProps(t){const e=t.configuration?.merchantId,n=t.configuration?.intent,i=0===t.amount?.value?"tokenize":t.intent||n,r="tokenize"===i||t.vault,s="continue"===t.userAction;return{...t,commit:!s&&t.commit,vault:r,configuration:{intent:i,merchantId:e}}}submitAnalytics(t){super.submitAnalytics({...t},this.props)}submit=()=>{this.handleError(new s("IMPLEMENTATION_ERROR",a.SUBMIT_NOT_SUPPORTED))};updatePaymentData(t){t||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=t}formatData(){const{isExpress:t,userAction:e}=this.props;return{paymentMethod:{type:p.type,userAction:e,subtype:t?"express":p.subtype}}}handleAction=t=>this.updateWithAction(t);updateWithAction=t=>{if(t.paymentMethodType!==this.type)throw new Error("Invalid Action");return t.paymentData&&(this.paymentData=t.paymentData),t.sdkData&&t.sdkData.token?this.handleResolve(t.sdkData.token):this.handleReject(a.NO_TOKEN_PROVIDED),null};get isValid(){return!0}handleOnApprove=(t,e)=>{const{onAuthorized:n}=this.props,i={data:{details:t,paymentData:this.paymentData}};if(n)return e.order.get().then((t=>{const e=h(t?.payer),i=h(t?.purchase_units?.[0].shipping,!0);return this.setState({authorizedEvent:t,...e&&{billingAddress:e},...i&&{deliveryAddress:i}}),new Promise(((r,s)=>n({authorizedEvent:t,...e&&{billingAddress:e},...i&&{deliveryAddress:i}},{resolve:r,reject:s})))})).then((()=>this.handleAdditionalDetails(i))).catch((t=>this.handleError(new s("ERROR","Something went wrong while parsing PayPal Order",{cause:t}))));this.handleAdditionalDetails(i)};handleResolve(t){if(!this.resolve)return this.handleError(new s("ERROR",a.WRONG_INSTANCE));this.resolve(t)}handleReject(t){if(!this.reject)return this.handleError(new s("ERROR",a.WRONG_INSTANCE));this.reject(new Error(t))}handleSubmit(){return super.submit(),new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}handleOnShippingAddressChange(t,e){return this.props.onShippingAddressChange(t,e,this)}handleOnShippingOptionsChange(t,e){return this.props.onShippingOptionsChange(t,e,this)}render(){if(!this.props.showPayButton)return null;const{onShippingAddressChange:e,onShippingOptionsChange:i,...a}=this.props;return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{ref:t=>{this.componentRef=t},...a,...e&&{onShippingAddressChange:this.handleOnShippingAddressChange},...i&&{onShippingOptionsChange:this.handleOnShippingOptionsChange},onCancel:()=>this.handleError(new s("CANCEL")),onChange:this.setState,onApprove:void this.handleOnApprove,onError:t=>{this.handleError(new s("ERROR",t.toString(),{cause:t}))},onScriptLoadFailure:t=>this.handleError(t),onSubmit:this.handleSubmit}))}}export{p as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import i from"./defaultProps.js";import{CoreProvider as r}from"../../core/Context/CoreProvider.js";import s from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as a}from"./constants.js";import{TxVariants as o}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as h}from"./utils/format-paypal-order-contact-to-adyen-format.js";class p extends e{static type=o.paypal;static subtype="sdk";paymentData=null;resolve=null;reject=null;static defaultProps=i;constructor(t,e){super(t,e),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}formatProps(t){const e=t.configuration?.merchantId,n=t.configuration?.intent,i=0===t.amount?.value?"tokenize":t.intent||n,r="tokenize"===i||t.vault,s="continue"===t.userAction;return{...t,commit:!s&&t.commit,vault:r,configuration:{intent:i,merchantId:e}}}submitAnalytics(t){super.submitAnalytics({...t},this.props)}submit=()=>{this.handleError(new s("IMPLEMENTATION_ERROR",a.SUBMIT_NOT_SUPPORTED))};updatePaymentData(t){t||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=t}formatData(){const{isExpress:t,userAction:e}=this.props;return{paymentMethod:{type:p.type,userAction:e,subtype:t?"express":p.subtype}}}handleAction=t=>this.updateWithAction(t);updateWithAction=t=>{if(t.paymentMethodType!==this.type)throw new Error("Invalid Action");return t.paymentData&&(this.paymentData=t.paymentData),t.sdkData&&t.sdkData.token?this.handleResolve(t.sdkData.token):this.handleReject(a.NO_TOKEN_PROVIDED),null};get isValid(){return!0}handleOnApprove=(t,e)=>{const{onAuthorized:n}=this.props,i={data:{details:t,paymentData:this.paymentData}};if(n)return e.order.get().then((t=>{const e=h(t?.payer),i=h(t?.purchase_units?.[0].shipping,!0);return this.setState({authorizedEvent:t,...e&&{billingAddress:e},...i&&{deliveryAddress:i}}),new Promise(((r,s)=>n({authorizedEvent:t,...e&&{billingAddress:e},...i&&{deliveryAddress:i}},{resolve:r,reject:s})))})).then((()=>this.handleAdditionalDetails(i))).catch((t=>this.handleError(new s("ERROR","Something went wrong while parsing PayPal Order",{cause:t}))));this.handleAdditionalDetails(i)};handleResolve(t){if(!this.resolve)return this.handleError(new s("ERROR",a.WRONG_INSTANCE));this.resolve(t)}handleReject(t){if(!this.reject)return this.handleError(new s("ERROR",a.WRONG_INSTANCE));this.reject(new Error(t))}handleSubmit(){return super.submit(),new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}handleOnShippingAddressChange(t,e){return this.props.onShippingAddressChange(t,e,this)}handleOnShippingOptionsChange(t,e){return this.props.onShippingOptionsChange(t,e,this)}render(){if(!this.props.showPayButton)return null;const{onShippingAddressChange:e,onShippingOptionsChange:i,...a}=this.props;return t(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{ref:t=>{this.componentRef=t},...a,...e&&{onShippingAddressChange:this.handleOnShippingAddressChange},...i&&{onShippingOptionsChange:this.handleOnShippingOptionsChange},onCancel:()=>this.handleError(new s("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:t=>{this.handleError(new s("ERROR",t.toString(),{cause:t}))},onScriptLoadFailure:t=>this.handleError(t),onSubmit:this.handleSubmit}))}}export{p as default};
2
2
  //# sourceMappingURL=Paypal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\n\nimport './Paypal.scss';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static type = TxVariants.paypal;\n public static subtype = 'sdk';\n\n public paymentData: string = null;\n\n private resolve = null;\n private reject = null;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\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 public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private handleOnApprove = (data: any, actions: any): Promise<void> | void => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return;\n }\n\n return actions.order\n .get()\n .then((paypalOrder: any) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<void> {\n super.submit();\n\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingOptionsChange(data, actions, this);\n }\n\n render() {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <PaypalComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...rest}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={void this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","static","TxVariants","paypal","paymentData","resolve","reject","defaultProps","constructor","checkout","props","super","this","handleSubmit","bind","handleOnShippingAddressChange","handleOnShippingOptionsChange","formatProps","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","commit","submitAnalytics","analyticsObj","submit","handleError","AdyenCheckoutError","ERRORS","SUBMIT_NOT_SUPPORTED","updatePaymentData","console","warn","formatData","isExpress","paymentMethod","type","subtype","handleAction","action","updateWithAction","paymentMethodType","Error","sdkData","token","handleResolve","handleReject","NO_TOKEN_PROVIDED","isValid","handleOnApprove","data","actions","onAuthorized","state","details","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","setState","authorizedEvent","Promise","handleAdditionalDetails","catch","error","cause","WRONG_INSTANCE","errorMessage","onShippingAddressChange","onShippingOptionsChange","render","showPayButton","rest","h","CoreProvider","i18n","loadingContext","resources","PaypalComponent","ref","componentRef","onCancel","onChange","onApprove","onError","toString","onScriptLoadFailure","onSubmit"],"mappings":"mhBAiBA,MAAMA,UAAsBC,EACxBC,YAAqBC,EAAWC,OAChCF,eAAwB,MAEjBG,YAAsB,KAErBC,QAAU,KACVC,OAAS,KAEjBL,oBAAgCM,EAEhCC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAChBE,KAAKC,aAAeD,KAAKC,aAAaC,KAAKF,MAC3CA,KAAKG,8BAAgCH,KAAKG,8BAA8BD,KAAKF,MAC7EA,KAAKI,8BAAgCJ,KAAKI,8BAA8BF,KAAKF,KACjF,CAEAK,WAAAA,CAAYP,GACR,MAAMQ,EAAaR,EAAMS,eAAeD,WAClCE,EAAmBV,EAAMS,eAAeE,OAExCA,EADqC,IAAxBX,EAAMY,QAAQC,MACG,WAAab,EAAMW,QAAUD,EAC3DI,EAAmB,aAAXH,GAAyBX,EAAMc,MAEvCC,EAAyD,aAArBf,EAAMgB,WAEhD,MAAO,IACAhB,EACHiB,QAAQF,GAA4Cf,EAAMiB,OAC1DH,QACAL,cAAe,CACXE,SACAH,cAGZ,CAEUU,eAAAA,CAAgBC,GAEtBlB,MAAMiB,gBAAgB,IAAKC,GAAgBjB,KAAKF,MACpD,CAEOoB,OAAS,KACZlB,KAAKmB,YAAY,IAAIC,EAAmB,uBAAwBC,EAAOC,sBAAoB,EAOxFC,iBAAAA,CAAkB/B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uB,SAAUtF,KAAKC,eAI/B"}
1
+ {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\n\nimport './Paypal.scss';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static type = TxVariants.paypal;\n public static subtype = 'sdk';\n\n public paymentData: string = null;\n\n private resolve = null;\n private reject = null;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\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 public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private handleOnApprove = (data: any, actions: any): Promise<void> | void => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return;\n }\n\n return actions.order\n .get()\n .then((paypalOrder: any) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<void> {\n super.submit();\n\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingOptionsChange(data, actions, this);\n }\n\n render() {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <PaypalComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...rest}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","static","TxVariants","paypal","paymentData","resolve","reject","defaultProps","constructor","checkout","props","super","this","handleSubmit","bind","handleOnShippingAddressChange","handleOnShippingOptionsChange","formatProps","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","commit","submitAnalytics","analyticsObj","submit","handleError","AdyenCheckoutError","ERRORS","SUBMIT_NOT_SUPPORTED","updatePaymentData","console","warn","formatData","isExpress","paymentMethod","type","subtype","handleAction","action","updateWithAction","paymentMethodType","Error","sdkData","token","handleResolve","handleReject","NO_TOKEN_PROVIDED","isValid","handleOnApprove","data","actions","onAuthorized","state","details","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","setState","authorizedEvent","Promise","handleAdditionalDetails","catch","error","cause","WRONG_INSTANCE","errorMessage","onShippingAddressChange","onShippingOptionsChange","render","showPayButton","rest","h","CoreProvider","i18n","loadingContext","resources","PaypalComponent","ref","componentRef","onCancel","onChange","onApprove","onError","toString","onScriptLoadFailure","onSubmit"],"mappings":"mhBAiBA,MAAMA,UAAsBC,EACxBC,YAAqBC,EAAWC,OAChCF,eAAwB,MAEjBG,YAAsB,KAErBC,QAAU,KACVC,OAAS,KAEjBL,oBAAgCM,EAEhCC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAChBE,KAAKC,aAAeD,KAAKC,aAAaC,KAAKF,MAC3CA,KAAKG,8BAAgCH,KAAKG,8BAA8BD,KAAKF,MAC7EA,KAAKI,8BAAgCJ,KAAKI,8BAA8BF,KAAKF,KACjF,CAEAK,WAAAA,CAAYP,GACR,MAAMQ,EAAaR,EAAMS,eAAeD,WAClCE,EAAmBV,EAAMS,eAAeE,OAExCA,EADqC,IAAxB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ACGC,IAAKA,IACD9E,KAAK+E,aAAeD,CAAAA,KAEpBP,KACCJ,GAA2B,CAAEA,wBAAyBnE,KAAKG,kCAC3DiE,GAA2B,CAAEA,wBAAyBpE,KAAKI,+BAChE4E,SAAU,IAAMhF,KAAKmB,YAAY,IAAIC,EAAmB,WACxD6D,SAAUjF,KAAK0D,SACfwB,UAAWlF,KAAK0C,gBAChByC,QAASpB,IACL/D,KAAKmB,YAAY,IAAIC,EAAmB,QAAS2C,EAAMqB,WAAY,CAAEpB,MAAOD,IAAM,EAEtFsB,oBAAqBtB,GAAS/D,KAAKmB,YAAY4C,GAC/CuB,SAAUtF,KAAKC,eAI/B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as a,useCallback as n,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import t from"./PaypalButtons.js";import s from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as r}from"../utils/get-paypal-url.js";import p from"../../../utils/Script.js";function c({onApprove:c,onCancel:i,onChange:l,onError:u,onSubmit:m,onScriptLoadFailure:d,...y}){const[_,f]=a("pending");this.setStatus=f;const h=n(((e,a)=>{f("processing"),c(e,a)}),[c]),g=()=>{f("ready")},N=e=>{d(e)};return o((()=>{const e=r(y),a={...y.cspNonce&&{nonce:y.cspNonce}},n={...y.cspNonce&&{cspNonce:y.cspNonce}},o=new p(e,"body",a,n);return o.load().then(g).catch(N),()=>{o.remove()}}),[]),"pending"===_?e("div",{className:"adyen-checkout__paypal","aria-live":"polite","aria-busy":"true"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending"},e(s,null))):e("div",{className:"adyen-checkout__paypal"},e(t,{...y,onCancel:i,onChange:l,onError:u,onSubmit:m,onApprove:h,isProcessingPayment:"processing"===_,paypalRef:window.paypal}))}export{c as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as a,useCallback as n,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import t from"./PaypalButtons.js";import s from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as r}from"../utils/get-paypal-url.js";import p from"../../../utils/Script.js";function c({onApprove:c,onCancel:i,onChange:l,onError:u,onSubmit:d,onScriptLoadFailure:m,...y}){const[_,f]=a("pending");this.setStatus=f;const h=n(((e,a)=>{f("processing"),c(e,a)}),[c]),g=()=>{f("ready")},N=e=>{m(e)};return o((()=>{const e=r(y),a={...y.cspNonce&&{nonce:y.cspNonce}},n={...y.cspNonce&&{cspNonce:y.cspNonce}},o=new p(e,"body",a,n);return o.load().then(g).catch(N),()=>{o.remove()}}),[]),"pending"===_?e("div",{className:"adyen-checkout__paypal","aria-live":"polite","aria-busy":"true"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending","data-testid":"paypal-loader"},e(s,null))):e("div",{className:"adyen-checkout__paypal"},e(t,{...y,onCancel:i,onChange:l,onError:u,onSubmit:d,onApprove:h,isProcessingPayment:"processing"===_,paypalRef:window.paypal}))}export{c as default};
2
2
  //# sourceMappingURL=PaypalComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaypalComponent.js","sources":["../../../../../src/components/PayPal/components/PaypalComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useCallback } from 'preact/hooks';\nimport PaypalButtons from './PaypalButtons';\nimport Spinner from '../../internal/Spinner';\nimport { getPaypalUrl } from '../utils/get-paypal-url';\nimport Script from '../../../utils/Script';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport type { PayPalComponentProps } from './types';\n\nexport default function PaypalComponent({ onApprove, onCancel, onChange, onError, onSubmit, onScriptLoadFailure, ...props }: PayPalComponentProps) {\n const [status, setStatus] = useState('pending');\n\n this.setStatus = setStatus;\n\n const handleOnApprove = useCallback(\n (data: any, actions: any) => {\n setStatus('processing');\n onApprove(data, actions);\n },\n [onApprove]\n );\n\n const handlePaypalLoad = () => {\n setStatus('ready');\n };\n\n const handlePaypalLoadFailure = (error: AdyenCheckoutError) => {\n onScriptLoadFailure(error);\n };\n\n useEffect(() => {\n const src = getPaypalUrl(props);\n\n const attributes = { ...(props.cspNonce && { nonce: props.cspNonce }) },\n dataAttributes = { ...(props.cspNonce && { cspNonce: props.cspNonce }) };\n\n const script = new Script(src, 'body', attributes, dataAttributes);\n\n script.load().then(handlePaypalLoad).catch(handlePaypalLoadFailure);\n\n return () => {\n script.remove();\n };\n }, []);\n\n if (status === 'pending') {\n return (\n <div className=\"adyen-checkout__paypal\" aria-live=\"polite\" aria-busy=\"true\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending\">\n <Spinner />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"adyen-checkout__paypal\">\n <PaypalButtons\n {...props}\n onCancel={onCancel}\n onChange={onChange}\n onError={onError}\n onSubmit={onSubmit}\n onApprove={handleOnApprove}\n isProcessingPayment={status === 'processing'}\n paypalRef={window.paypal}\n />\n </div>\n );\n}\n"],"names":["PaypalComponent","onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure","props","status","setStatus","useState","this","handleOnApprove","useCallback","data","actions","handlePaypalLoad","handlePaypalLoadFailure","error","useEffect","src","getPaypalUrl","attributes","cspNonce","nonce","dataAttributes","script","Script","load","then","catch","remove","h","div","className","aria-live","aria-busy","Spinner","PaypalButtons","isProcessingPayment","paypalRef","window","paypal"],"mappings":"qWASe,SAASA,GAAgBC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,QAAEA,EAAOC,SAAEA,EAAQC,oBAAEA,KAAwBC,IAChH,MAAOC,EAAQC,GAAaC,EAAS,WAErCC,KAAKF,UAAYA,EAEjB,MAAMG,EAAkBC,GACpB,CAACC,EAAWC,KACRN,EAAU,cACVR,EAAUa,EAAMC,EAAAA,GAEpB,CAACd,IAGCe,EAAmB,KACrBP,EAAU,QAAA,EAGRQ,EAA2BC,IAC7BZ,EAAoBY,EAAAA,EAkBxB,OAfAC,GAAU,KACN,MAAMC,EAAMC,EAAad,GAEnBe,EAAa,IAAMf,EAAMgB,UAAY,CAAEC,MAAOjB,EAAMgB,WACtDE,EAAiB,IAAMlB,EAAMgB,UAAY,CAAEA,SAAUhB,EAAMgB,WAEzDG,EAAS,IAAIC,EAAOP,EAAK,OAAQE,EAAYG,GAInD,OAFAC,EAAOE,OAAOC,KAAKb,GAAkBc,MAAMb,GAEpC,KACHS,EAAOK,QAAM,CACjB,GACD,IAEY,YAAXvB,EAEIwB,EAACC,MAAAA,CAAIC,UAAU,yBAAyBC,YAAU,SAASC,YAAU,QACjEJ,EAACC,MAAAA,CAAIC,UAAU,0EACXF,EAACK,EAAAA,QAObL,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACM,EAAAA,IACO/B,EACJL,SAAUA,EACVC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVJ,UAAWW,EACX2B,oBAAgC,eAAX/B,EACrBgC,UAAWC,OAAOC,SAIlC"}
1
+ {"version":3,"file":"PaypalComponent.js","sources":["../../../../../src/components/PayPal/components/PaypalComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useCallback } from 'preact/hooks';\nimport PaypalButtons from './PaypalButtons';\nimport Spinner from '../../internal/Spinner';\nimport { getPaypalUrl } from '../utils/get-paypal-url';\nimport Script from '../../../utils/Script';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport type { PayPalComponentProps } from './types';\n\nexport default function PaypalComponent({ onApprove, onCancel, onChange, onError, onSubmit, onScriptLoadFailure, ...props }: PayPalComponentProps) {\n const [status, setStatus] = useState('pending');\n\n this.setStatus = setStatus;\n\n const handleOnApprove = useCallback(\n (data: any, actions: any) => {\n setStatus('processing');\n onApprove(data, actions);\n },\n [onApprove]\n );\n\n const handlePaypalLoad = () => {\n setStatus('ready');\n };\n\n const handlePaypalLoadFailure = (error: AdyenCheckoutError) => {\n onScriptLoadFailure(error);\n };\n\n useEffect(() => {\n const src = getPaypalUrl(props);\n\n const attributes = { ...(props.cspNonce && { nonce: props.cspNonce }) },\n dataAttributes = { ...(props.cspNonce && { cspNonce: props.cspNonce }) };\n\n const script = new Script(src, 'body', attributes, dataAttributes);\n\n script.load().then(handlePaypalLoad).catch(handlePaypalLoadFailure);\n\n return () => {\n script.remove();\n };\n }, []);\n\n if (status === 'pending') {\n return (\n <div className=\"adyen-checkout__paypal\" aria-live=\"polite\" aria-busy=\"true\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending\" data-testid={'paypal-loader'}>\n <Spinner />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"adyen-checkout__paypal\">\n <PaypalButtons\n {...props}\n onCancel={onCancel}\n onChange={onChange}\n onError={onError}\n onSubmit={onSubmit}\n onApprove={handleOnApprove}\n isProcessingPayment={status === 'processing'}\n paypalRef={window.paypal}\n />\n </div>\n );\n}\n"],"names":["PaypalComponent","onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure","props","status","setStatus","useState","this","handleOnApprove","useCallback","data","actions","handlePaypalLoad","handlePaypalLoadFailure","error","useEffect","src","getPaypalUrl","attributes","cspNonce","nonce","dataAttributes","script","Script","load","then","catch","remove","h","div","className","aria-live","aria-busy","data-testid","Spinner","PaypalButtons","isProcessingPayment","paypalRef","window","paypal"],"mappings":"qWASe,SAASA,GAAgBC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,QAAEA,EAAOC,SAAEA,EAAQC,oBAAEA,KAAwBC,IAChH,MAAOC,EAAQC,GAAaC,EAAS,WAErCC,KAAKF,UAAYA,EAEjB,MAAMG,EAAkBC,GACpB,CAACC,EAAWC,KACRN,EAAU,cACVR,EAAUa,EAAMC,EAAAA,GAEpB,CAACd,IAGCe,EAAmB,KACrBP,EAAU,QAAA,EAGRQ,EAA2BC,IAC7BZ,EAAoBY,EAAAA,EAkBxB,OAfAC,GAAU,KACN,MAAMC,EAAMC,EAAad,GAEnBe,EAAa,IAAMf,EAAMgB,UAAY,CAAEC,MAAOjB,EAAMgB,WACtDE,EAAiB,IAAMlB,EAAMgB,UAAY,CAAEA,SAAUhB,EAAMgB,WAEzDG,EAAS,IAAIC,EAAOP,EAAK,OAAQE,EAAYG,GAInD,OAFAC,EAAOE,OAAOC,KAAKb,GAAkBc,MAAMb,GAEpC,KACHS,EAAOK,QAAM,CACjB,GACD,IAEY,YAAXvB,EAEIwB,EAACC,MAAAA,CAAIC,UAAU,yBAAyBC,YAAU,SAASC,YAAU,QACjEJ,EAACC,MAAAA,CAAIC,UAAU,yEAAyEG,cAAa,iBACjGL,EAACM,EAAAA,QAObN,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACO,EAAAA,IACOhC,EACJL,SAAUA,EACVC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVJ,UAAWW,EACX4B,oBAAgC,eAAXhC,EACrBiC,UAAWC,OAAOC,SAIlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n // @ts-ignore fix later\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","static","TxVariants","upi","upi_qr","upi_collect","upi_intent","selectedMode","constructor","checkout","props","super","this","defaultMode","formatProps","isMobile","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","map","app","includes","isValid","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","onUpdateMode","mode","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules"],"mappings":"meAsBA,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eAAgB1D,KAAKF,MAAM4D,eAAgBC,UAAW3D,KAAK2D,WAC5F5B,EAAC6B,EAAAA,CAAgBC,QAAS7D,KAAKF,MAAMgE,QAAQD,SAAU7D,KAAK4B,cAAcd,EAAMe,EAAKC,IAGjG"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","static","TxVariants","upi","upi_qr","upi_collect","upi_intent","selectedMode","constructor","checkout","props","super","this","defaultMode","formatProps","isMobile","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","map","app","includes","isValid","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","onUpdateMode","mode","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules"],"mappings":"meAsBA,MAAMA,UAAYC,EACdC,YAAqBC,EAAWC,IAChCF,kBAA2B,CAACC,EAAWC,IAAKD,EAAWE,OAAQF,EAAWG,YAAaH,EAAWI,YAE1FC,aAERC,WAAAA,CAAYC,EAAiBC,GACzBC,MAAMF,EAAUC,GAChBE,KAAKL,aAAeK,KAAKF,MAAMG,WACnC,CAEAC,WAAAA,CAAYJ,GACR,IAAKK,IACD,MAAO,IACAJ,MAAMG,YAAYJ,GACrBG,YAAaH,GAAOG,aAAe,SAEnCG,KAAM,IAId,MAAMC,EAAgBP,EAAMM,MAAME,OAAS,EACrCC,EAAsB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AAe,EACfC,gBAAiB1C,KAAKF,MAAM4C,kBAGxC,IAAK,QACD,OACIX,EAACY,EAAAA,CACGV,IAAKA,IACDjC,KAAKkC,aAAeD,CAAAA,EAExBJ,IAAKA,EACLf,KAAMgB,EACNc,oBAAAA,EACAC,6BAAAA,EACAJ,cAAe,EACfK,UAAW9C,KAAKF,MAAMgD,UACtBC,YAAa/C,KAAKF,MAAMiD,YACxBL,gBAAiB1C,KAAKF,MAAM4C,gBAC5BM,QAAShD,KAAKF,MAAMkD,QACpBC,YAAajD,KAAKF,MAAMc,KAAKC,IAAI,yBACjCqC,UAAWlD,KAAKF,MAAMc,KAAKC,IAAI,6BAC/B0B,WAAYvC,KAAKuC,WACjBF,UAAWrC,KAAKsC,OAG5B,QACI,OACIP,EAACoB,EAAAA,CACGlB,IAAMA,IACFjC,KAAKkC,aAAeD,CAAAA,EAExBmB,UAAWpD,KAAKoD,UAChBC,SAAUrD,KAAKsD,SACf5B,aAAc1B,KAAK0B,aACnBtB,KAAMJ,KAAKF,MAAMM,KACjBH,YAAaD,KAAKF,MAAMG,YACxBsD,cAAevD,KAAKF,MAAMyD,gBAI9C,CAEOC,MAAAA,GACH,MAAM1C,KAAEA,EAAIe,IAAEA,EAAGC,kBAAEA,GAAsB9B,KAAKF,MAC9C,OACIiC,EAAC0B,EAAAA,CAAa7C,KAAMZ,KAAKF,MAAMc,KAAM8C,eAAgB1D,KAAKF,MAAM4D,eAAgBC,UAAW3D,KAAK2D,WAC5F5B,EAAC6B,EAAAA,CAAgBC,QAAS7D,KAAKF,MAAMgE,QAAQD,SAAU7D,KAAK4B,cAAcd,EAAMe,EAAKC,IAGjG"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0.0",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c,bundleType:a})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0.2",channel:"Web",platform:"Web",buildType:a,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),d=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(l=e(s,c).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.0.0",bundleType:"esm"};static registry=p;static setBundleType(t){P.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}constructor(t){n(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...E,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const a=this.options.clientKey?.substring(0,4);if(("test"===a||"live"===a)&&!this.loadingContext.includes(a))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${a} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===a&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=P.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await j(this.cdnTranslationsUrl,P.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=v(this.options.locale),this.options.translations=A(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...a(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:P.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}}export{P as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import s from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as e}from"./ProcessResponse/PaymentAction/PaymentAction.js";import i from"./Analytics/Analytics.js";import{assertConfigurationPropertiesAreValid as n,processGlobalOptions as a}from"./utils.js";import r from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as h}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as c}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as m,verifyPaymentDidNotFail as d,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as f}from"./Analytics/constants.js";import{THREEDS2_FULL as C}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as w}from"../language/constants.js";import j from"./Services/get-translations.js";import{defaultProps as E}from"./core.defaultProps.js";import{formatLocale as v,formatCustomTranslations as A}from"../language/utils.js";import{resolveEnvironments as b}from"./Environment/Environment.js";class P{session;paymentMethodsResponse;modules;options;analyticsContext;loadingContext;cdnImagesUrl;cdnTranslationsUrl;components=[];static metadata={version:"6.0.2",bundleType:"esm"};static registry=p;static setBundleType(t){P.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}constructor(t){n(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions({...E,...t});const{apiUrl:o,analyticsUrl:s,cdnImagesUrl:e,cdnTranslationsUrl:i}=b(this.options.environment,this.options._environmentUrls);this.loadingContext=o,this.analyticsContext=s,this.cdnImagesUrl=e,this.cdnTranslationsUrl=i,this.session=this.options.session&&new r(this.options.session,this.options.clientKey,this.loadingContext);const a=this.options.clientKey?.substring(0,4);if(("test"===a||"live"===a)&&!this.loadingContext.includes(a))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${a} clientKey against the ${this.options._environmentUrls?.api||this.options.environment} environment`);"pub."===a&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${this.options.clientKey?.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`),this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=P.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:s,countryCode:e,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||s,countryCode:this.options.countryCode||e}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await j(this.cdnTranslationsUrl,P.metadata.version,this.options.locale)}catch(t){t instanceof y?this.options.onError?.(t):this.options.onError?.(new y("ERROR","Failed to fetch translation",{cause:t}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(g,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:w}),this.options.locale=v(this.options.locale),this.options.translations=A(this.options.translations)}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,s)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:s})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(m).then(d).then((t=>{u(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{u(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(h(t,"action")&&h(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const s=t.type===C?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(s,{type:f,subtype:t.type,message:`${s} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return e(this,p,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const s={...t,...this.session&&{session:this.session}};o.update(s)})),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...a(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new s(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const s=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:i({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:P.metadata.bundleType}),resources:new l(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:s,customTranslations:this.options.translations}),srPanel:new c(this,{...this.options.srConfig})})}}export{P as default};
2
2
  //# sourceMappingURL=core.js.map
@@ -4397,11 +4397,7 @@ declare class UPI extends UIElement<UPIConfiguration> {
4397
4397
  constructor(checkout: ICore, props: UPIConfiguration);
4398
4398
  formatProps(props: UPIConfiguration): {
4399
4399
  defaultMode: UpiMode;
4400
- apps: {
4401
- type: TxVariants;
4402
- id: string;
4403
- name: string;
4404
- }[];
4400
+ apps: App[];
4405
4401
  url?: string;
4406
4402
  paymentData?: string;
4407
4403
  qrCodeData?: string;
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import{CoreProvider as i}from"../../core/Context/CoreProvider.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as s}from"./constants.js";import{TxVariants as a}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as p}from"./utils/format-paypal-order-contact-to-adyen-format.js";function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),r.forEach((function(e){h(t,e,n[e])}))}return t}function d(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e}(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t}function u(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}class c extends e{formatProps(t){var e,n,r;const i=null===(e=t.configuration)||void 0===e?void 0:e.merchantId,o=null===(n=t.configuration)||void 0===n?void 0:n.intent,s=0===(null===(r=t.amount)||void 0===r?void 0:r.value)?"tokenize":t.intent||o,a="tokenize"===s||t.vault,p="continue"===t.userAction;return d(l({},t),{commit:!p&&t.commit,vault:a,configuration:{intent:s,merchantId:i}})}submitAnalytics(t){super.submitAnalytics(l({},t),this.props)}updatePaymentData(t){t||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=t}formatData(){const{isExpress:t,userAction:e}=this.props;return{paymentMethod:{type:c.type,userAction:e,subtype:t?"express":c.subtype}}}get isValid(){return!0}handleResolve(t){if(!this.resolve)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.resolve(t)}handleReject(t){if(!this.reject)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.reject(new Error(t))}handleSubmit(){return super.submit(),new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}handleOnShippingAddressChange(t,e){return this.props.onShippingAddressChange(t,e,this)}handleOnShippingOptionsChange(t,e){return this.props.onShippingOptionsChange(t,e,this)}render(){if(!this.props.showPayButton)return null;const e=this.props,{onShippingAddressChange:r,onShippingOptionsChange:s}=e,a=u(e,["onShippingAddressChange","onShippingOptionsChange"]);return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,d(l({ref:t=>{this.componentRef=t}},a,r&&{onShippingAddressChange:this.handleOnShippingAddressChange},s&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new o("CANCEL")),onChange:this.setState,onApprove:void this.handleOnApprove,onError:t=>{this.handleError(new o("ERROR",t.toString(),{cause:t}))},onScriptLoadFailure:t=>this.handleError(t),onSubmit:this.handleSubmit})))}constructor(t,e){super(t,e),h(this,"paymentData",null),h(this,"resolve",null),h(this,"reject",null),h(this,"submit",(()=>{this.handleError(new o("IMPLEMENTATION_ERROR",s.SUBMIT_NOT_SUPPORTED))})),h(this,"handleAction",(t=>this.updateWithAction(t))),h(this,"updateWithAction",(t=>{if(t.paymentMethodType!==this.type)throw new Error("Invalid Action");return t.paymentData&&(this.paymentData=t.paymentData),t.sdkData&&t.sdkData.token?this.handleResolve(t.sdkData.token):this.handleReject(s.NO_TOKEN_PROVIDED),null})),h(this,"handleOnApprove",((t,e)=>{const{onAuthorized:n}=this.props,r={data:{details:t,paymentData:this.paymentData}};if(n)return e.order.get().then((t=>{var e;const r=p(null==t?void 0:t.payer),i=p(null==t||null===(e=t.purchase_units)||void 0===e?void 0:e[0].shipping,!0);return this.setState(l({authorizedEvent:t},r&&{billingAddress:r},i&&{deliveryAddress:i})),new Promise(((e,o)=>n(l({authorizedEvent:t},r&&{billingAddress:r},i&&{deliveryAddress:i}),{resolve:e,reject:o})))})).then((()=>this.handleAdditionalDetails(r))).catch((t=>this.handleError(new o("ERROR","Something went wrong while parsing PayPal Order",{cause:t}))));this.handleAdditionalDetails(r)})),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}}h(c,"type",a.paypal),h(c,"subtype","sdk"),h(c,"defaultProps",r);export{c as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import{CoreProvider as i}from"../../core/Context/CoreProvider.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{ERRORS as s}from"./constants.js";import{TxVariants as a}from"../tx-variants.js";import{formatPaypalOrderContactToAdyenFormat as p}from"./utils/format-paypal-order-contact-to-adyen-format.js";function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),r.forEach((function(e){h(t,e,n[e])}))}return t}function d(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e}(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t}function u(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}class c extends e{formatProps(t){var e,n,r;const i=null===(e=t.configuration)||void 0===e?void 0:e.merchantId,o=null===(n=t.configuration)||void 0===n?void 0:n.intent,s=0===(null===(r=t.amount)||void 0===r?void 0:r.value)?"tokenize":t.intent||o,a="tokenize"===s||t.vault,p="continue"===t.userAction;return d(l({},t),{commit:!p&&t.commit,vault:a,configuration:{intent:s,merchantId:i}})}submitAnalytics(t){super.submitAnalytics(l({},t),this.props)}updatePaymentData(t){t||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=t}formatData(){const{isExpress:t,userAction:e}=this.props;return{paymentMethod:{type:c.type,userAction:e,subtype:t?"express":c.subtype}}}get isValid(){return!0}handleResolve(t){if(!this.resolve)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.resolve(t)}handleReject(t){if(!this.reject)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.reject(new Error(t))}handleSubmit(){return super.submit(),new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}handleOnShippingAddressChange(t,e){return this.props.onShippingAddressChange(t,e,this)}handleOnShippingOptionsChange(t,e){return this.props.onShippingOptionsChange(t,e,this)}render(){if(!this.props.showPayButton)return null;const e=this.props,{onShippingAddressChange:r,onShippingOptionsChange:s}=e,a=u(e,["onShippingAddressChange","onShippingOptionsChange"]);return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,d(l({ref:t=>{this.componentRef=t}},a,r&&{onShippingAddressChange:this.handleOnShippingAddressChange},s&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new o("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:t=>{this.handleError(new o("ERROR",t.toString(),{cause:t}))},onScriptLoadFailure:t=>this.handleError(t),onSubmit:this.handleSubmit})))}constructor(t,e){super(t,e),h(this,"paymentData",null),h(this,"resolve",null),h(this,"reject",null),h(this,"submit",(()=>{this.handleError(new o("IMPLEMENTATION_ERROR",s.SUBMIT_NOT_SUPPORTED))})),h(this,"handleAction",(t=>this.updateWithAction(t))),h(this,"updateWithAction",(t=>{if(t.paymentMethodType!==this.type)throw new Error("Invalid Action");return t.paymentData&&(this.paymentData=t.paymentData),t.sdkData&&t.sdkData.token?this.handleResolve(t.sdkData.token):this.handleReject(s.NO_TOKEN_PROVIDED),null})),h(this,"handleOnApprove",((t,e)=>{const{onAuthorized:n}=this.props,r={data:{details:t,paymentData:this.paymentData}};if(n)return e.order.get().then((t=>{var e;const r=p(null==t?void 0:t.payer),i=p(null==t||null===(e=t.purchase_units)||void 0===e?void 0:e[0].shipping,!0);return this.setState(l({authorizedEvent:t},r&&{billingAddress:r},i&&{deliveryAddress:i})),new Promise(((e,o)=>n(l({authorizedEvent:t},r&&{billingAddress:r},i&&{deliveryAddress:i}),{resolve:e,reject:o})))})).then((()=>this.handleAdditionalDetails(r))).catch((t=>this.handleError(new o("ERROR","Something went wrong while parsing PayPal Order",{cause:t}))));this.handleAdditionalDetails(r)})),this.handleSubmit=this.handleSubmit.bind(this),this.handleOnShippingAddressChange=this.handleOnShippingAddressChange.bind(this),this.handleOnShippingOptionsChange=this.handleOnShippingOptionsChange.bind(this)}}h(c,"type",a.paypal),h(c,"subtype","sdk"),h(c,"defaultProps",r);export{c as default};
2
2
  //# sourceMappingURL=Paypal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\n\nimport './Paypal.scss';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static type = TxVariants.paypal;\n public static subtype = 'sdk';\n\n public paymentData: string = null;\n\n private resolve = null;\n private reject = null;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\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 public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private handleOnApprove = (data: any, actions: any): Promise<void> | void => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return;\n }\n\n return actions.order\n .get()\n .then((paypalOrder: any) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<void> {\n super.submit();\n\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingOptionsChange(data, actions, this);\n }\n\n render() {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <PaypalComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...rest}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={void this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","commit","submitAnalytics","analyticsObj","super","_object_spread","this","updatePaymentData","paymentData","console","warn","formatData","isExpress","paymentMethod","type","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","submit","Promise","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","render","showPayButton","_this_props","rest","_object_without_properties","h","CoreProvider","i18n","loadingContext","resources","PaypalComponent","ref","componentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","toString","cause","onScriptLoadFailure","onSubmit","constructor","checkout","_define_property","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","NO_TOKEN_PROVIDED","onAuthorized","state","details","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"srDAiBA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACWA,IAAAA,EACMA,EACNA,EAFnB,MAAMC,EAAaD,QAAAA,EAAAA,EAAME,qBAANF,IAAAA,OAAAA,EAAAA,EAAqBC,WAClCE,EAAmBH,QAAAA,EAAAA,EAAME,qBAANF,IAAAA,OAAAA,EAAAA,EAAqBI,OAExCA,EADqC,KAAxBJ,QAAAA,EAAAA,EAAMK,cAANL,IAAAA,OAAAA,EAAAA,EAAcM,OACG,WAAaN,EAAMI,QAAUD,EAC3DI,EAAmB,aAAXH,GAAyBJ,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,OAAOC,EACAV,EAAAA,CAAAA,EAAAA,GAAAA,CACHW,QAAQH,GAA4CR,EAAMW,OAC1DJ,QACAL,cAAe,CACXE,SACAH,eAGZ,CAEUW,eAAAA,CAAgBC,GAEtBC,MAAMF,gBAAgBG,EAAA,CAAA,EAAKF,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AiBC,EAAsCF,aAAAA,EAAAA,EAAaG,OACpEC,EAAkBF,EAAsCF,SAAAA,QAAAA,EAAAA,EAAaK,sBAAbL,IAAAA,OAAAA,EAAAA,EAA8B,GAAGM,UAAU,GAQzG,OANA7E,KAAK8C,SAAS/C,EAAA,CACV+E,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,qBAGtB,IAAInD,SAAc,CAACX,EAASO,IAC/B6C,EACIlE,EAAA,CACI+E,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,oBAE7B,CAAE9D,UAASO,YAAO,IAI7BkD,MAAK,IAAMtE,KAAK+E,wBAAwBb,KACxCc,OAAM9B,GAASlD,KAAKc,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAEqC,MAAOF,OA5B7HlD,KAAK+E,wBAAwBb,EA4BsG,IAzHvIlE,KAAKsB,aAAetB,KAAKsB,aAAa2D,KAAKjF,MAC3CA,KAAKyB,8BAAgCzB,KAAKyB,8BAA8BwD,KAAKjF,MAC7EA,KAAK6B,8BAAgC7B,KAAK6B,8BAA8BoD,KAAKjF,KACjF,EAfAyD,EADE5E,EACY2B,OAAO0E,EAAWC,QAChC1B,EAFE5E,EAEY4B,UAAU,OAOxBgD,EATE5E,EASeuG,eAAeA"}
1
+ {"version":3,"file":"Paypal.js","sources":["../../../../src/components/PayPal/Paypal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport PaypalComponent from './components/PaypalComponent';\nimport defaultProps from './defaultProps';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { ERRORS } from './constants';\nimport { TxVariants } from '../tx-variants';\nimport { formatPaypalOrderContactToAdyenFormat } from './utils/format-paypal-order-contact-to-adyen-format';\n\nimport type { ICore } from '../../core/types';\nimport type { PaymentAction } from '../../types/global-types';\nimport type { Intent, PayPalConfiguration } from './types';\n\nimport './Paypal.scss';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nclass PaypalElement extends UIElement<PayPalConfiguration> {\n public static type = TxVariants.paypal;\n public static subtype = 'sdk';\n\n public paymentData: string = null;\n\n private resolve = null;\n private reject = null;\n\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: PayPalConfiguration) {\n super(checkout, props);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.handleOnShippingAddressChange = this.handleOnShippingAddressChange.bind(this);\n this.handleOnShippingOptionsChange = this.handleOnShippingOptionsChange.bind(this);\n }\n\n formatProps(props: PayPalConfiguration): PayPalConfiguration {\n const merchantId = props.configuration?.merchantId;\n const intentFromConfig = props.configuration?.intent;\n const isZeroAuth = props.amount?.value === 0;\n const intent: Intent = isZeroAuth ? 'tokenize' : props.intent || intentFromConfig;\n const vault = intent === 'tokenize' || props.vault;\n\n const displayContinueToReviewPageButton = props.userAction === 'continue';\n\n return {\n ...props,\n commit: displayContinueToReviewPageButton ? false : props.commit,\n vault,\n configuration: {\n intent,\n merchantId\n }\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 public submit = () => {\n this.handleError(new AdyenCheckoutError('IMPLEMENTATION_ERROR', ERRORS.SUBMIT_NOT_SUPPORTED));\n };\n\n /**\n * Updates the paymentData value. It must be used in the PayPal Express flow, when patching the amount\n * @param paymentData - Payment data value\n */\n public updatePaymentData(paymentData: string): void {\n if (!paymentData) console.warn('PayPal - Updating payment data with an invalid value');\n this.paymentData = paymentData;\n }\n\n /**\n * Formats the component data output\n */\n protected formatData() {\n const { isExpress, userAction } = this.props;\n\n return {\n paymentMethod: {\n type: PaypalElement.type,\n userAction,\n subtype: isExpress ? 'express' : PaypalElement.subtype\n }\n };\n }\n\n public handleAction = (action: PaymentAction) => {\n return this.updateWithAction(action);\n };\n\n public updateWithAction = (action: PaymentAction) => {\n if (action.paymentMethodType !== this.type) throw new Error('Invalid Action');\n\n if (action.paymentData) {\n this.paymentData = action.paymentData;\n }\n\n if (action.sdkData && action.sdkData.token) {\n this.handleResolve(action.sdkData.token);\n } else {\n this.handleReject(ERRORS.NO_TOKEN_PROVIDED);\n }\n\n return null;\n };\n\n /**\n * Dropin Validation\n *\n * @remarks\n * Paypal does not require any specific Dropin validation\n */\n get isValid() {\n return true;\n }\n\n private handleOnApprove = (data: any, actions: any): Promise<void> | void => {\n const { onAuthorized } = this.props;\n const state = { data: { details: data, paymentData: this.paymentData } };\n\n if (!onAuthorized) {\n this.handleAdditionalDetails(state);\n return;\n }\n\n return actions.order\n .get()\n .then((paypalOrder: any) => {\n const billingAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContactToAdyenFormat(paypalOrder?.purchase_units?.[0].shipping, true);\n\n this.setState({\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<void>((resolve, reject) =>\n onAuthorized(\n {\n authorizedEvent: paypalOrder,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n )\n );\n })\n .then(() => this.handleAdditionalDetails(state))\n .catch(error => this.handleError(new AdyenCheckoutError('ERROR', 'Something went wrong while parsing PayPal Order', { cause: error })));\n };\n\n handleResolve(token: string) {\n if (!this.resolve) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.resolve(token);\n }\n\n handleReject(errorMessage: string) {\n if (!this.reject) return this.handleError(new AdyenCheckoutError('ERROR', ERRORS.WRONG_INSTANCE));\n this.reject(new Error(errorMessage));\n }\n\n private handleSubmit(): Promise<void> {\n super.submit();\n\n return new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n /**\n * If the merchant provides the 'onShippingAddressChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingAddressChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingAddressChange(data, actions, this);\n }\n\n /**\n * If the merchant provides the 'onShippingOptionsChange' callback, then this method is used as a wrapper to it, in order\n * to expose to the merchant the 'component' instance. The merchant needs the 'component' in order to manipulate the\n * paymentData\n *\n * @param data - PayPal data\n * @param actions - PayPal actions.\n */\n private handleOnShippingOptionsChange(data: any, actions: any): Promise<void> {\n return this.props.onShippingOptionsChange(data, actions, this);\n }\n\n render() {\n if (!this.props.showPayButton) return null;\n\n const { onShippingAddressChange, onShippingOptionsChange, ...rest } = this.props;\n\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <PaypalComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...rest}\n {...(onShippingAddressChange && { onShippingAddressChange: this.handleOnShippingAddressChange })}\n {...(onShippingOptionsChange && { onShippingOptionsChange: this.handleOnShippingOptionsChange })}\n onCancel={() => this.handleError(new AdyenCheckoutError('CANCEL'))}\n onChange={this.setState}\n onApprove={this.handleOnApprove}\n onError={error => {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }}\n onScriptLoadFailure={error => this.handleError(error)}\n onSubmit={this.handleSubmit}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","configuration","intentFromConfig","intent","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","commit","submitAnalytics","analyticsObj","super","_object_spread","this","updatePaymentData","paymentData","console","warn","formatData","isExpress","paymentMethod","type","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","submit","Promise","handleOnShippingAddressChange","data","actions","onShippingAddressChange","handleOnShippingOptionsChange","onShippingOptionsChange","render","showPayButton","_this_props","rest","_object_without_properties","h","CoreProvider","i18n","loadingContext","resources","PaypalComponent","ref","componentRef","onCancel","onChange","setState","onApprove","handleOnApprove","onError","error","toString","cause","onScriptLoadFailure","onSubmit","constructor","checkout","_define_property","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","NO_TOKEN_PROVIDED","onAuthorized","state","details","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContactToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"srDAiBA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GACWA,IAAAA,EACMA,EACNA,EAFnB,MAAMC,EAAaD,QAAAA,EAAAA,EAAME,qBAANF,IAAAA,OAAAA,EAAAA,EAAqBC,WAClCE,EAAmBH,QAAAA,EAAAA,EAAME,qBAANF,IAAAA,OAAAA,EAAAA,EAAqBI,OAExCA,EADqC,KAAxBJ,QAAAA,EAAAA,EAAMK,cAANL,IAAAA,OAAAA,EAAAA,EAAcM,OACG,WAAaN,EAAMI,QAAUD,EAC3DI,EAAmB,aAAXH,GAAyBJ,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,OAAOC,EACAV,EAAAA,CAAAA,EAAAA,GAAAA,CACHW,QAAQH,GAA4CR,EAAMW,OAC1DJ,QACAL,cAAe,CACXE,SACAH,eAGZ,CAEUW,eAAAA,CAAgBC,GAEtBC,MAAMF,gBAAgBG,EAAA,CAAA,EAAKF,GAAgBG,KAAKhB,MACpD,CAUOiB,iBAAAA,CAAkBC,GAChBA,GAAaC,QAAQC,KAAK,wDAC/BJ,KAAKE,YAAcA,CACvB,CAKA,UAAAG,GACI,MAAMC,UAAEA,EAASb,WAAEA,GAAeO,KAAKhB,MAEvC,MAAO,CACHuB,cAAe,CACXC,KAAM3B,EAAc2B,KACpBf,aACAgB,QAASH,EAAY,UAAYzB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SAAc,CAACX,EAASO,IAC/B6C,EACIlE,EAAA,CACI+E,gBAAiBP,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,oBAE7B,CAAE9D,UAASO,YAAO,IAI7BkD,MAAK,IAAMtE,KAAK+E,wBAAwBb,KACxCc,OAAM9B,GAASlD,KAAKc,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAEqC,MAAOF,OA5B7HlD,KAAK+E,wBAAwBb,EA4BsG,IAzHvIlE,KAAKsB,aAAetB,KAAKsB,aAAa2D,KAAKjF,MAC3CA,KAAKyB,8BAAgCzB,KAAKyB,8BAA8BwD,KAAKjF,MAC7EA,KAAK6B,8BAAgC7B,KAAK6B,8BAA8BoD,KAAKjF,KACjF,EAfAyD,EADE5E,EACY2B,OAAO0E,EAAWC,QAChC1B,EAFE5E,EAEY4B,UAAU,OAOxBgD,EATE5E,EASeuG,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import o from"./PaypalButtons.js";import a from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as c}from"../utils/get-paypal-url.js";import p from"../../../utils/Script.js";function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){s(e,t,r[t])}))}return e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function u(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(s){var{onApprove:y,onCancel:f,onChange:b,onError:m,onSubmit:O,onScriptLoadFailure:d}=s,g=u(s,["onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure"]);const[j,h]=t("pending");this.setStatus=h;const v=r(((e,t)=>{h("processing"),y(e,t)}),[y]),P=()=>{h("ready")},S=e=>{d(e)};return n((()=>{const e=c(g),t=i({},g.cspNonce&&{nonce:g.cspNonce}),r=i({},g.cspNonce&&{cspNonce:g.cspNonce}),n=new p(e,"body",t,r);return n.load().then(P).catch(S),()=>{n.remove()}}),[]),"pending"===j?e("div",{className:"adyen-checkout__paypal","aria-live":"polite","aria-busy":"true"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending"},e(a,null))):e("div",{className:"adyen-checkout__paypal"},e(o,l(i({},g),{onCancel:f,onChange:b,onError:m,onSubmit:O,onApprove:v,isProcessingPayment:"processing"===j,paypalRef:window.paypal})))}export{y as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import o from"./PaypalButtons.js";import a from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as c}from"../utils/get-paypal-url.js";import p from"../../../utils/Script.js";function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){s(e,t,r[t])}))}return e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function u(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(s){var{onApprove:y,onCancel:f,onChange:b,onError:m,onSubmit:O,onScriptLoadFailure:d}=s,g=u(s,["onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure"]);const[j,h]=t("pending");this.setStatus=h;const v=r(((e,t)=>{h("processing"),y(e,t)}),[y]),P=()=>{h("ready")},S=e=>{d(e)};return n((()=>{const e=c(g),t=i({},g.cspNonce&&{nonce:g.cspNonce}),r=i({},g.cspNonce&&{cspNonce:g.cspNonce}),n=new p(e,"body",t,r);return n.load().then(P).catch(S),()=>{n.remove()}}),[]),"pending"===j?e("div",{className:"adyen-checkout__paypal","aria-live":"polite","aria-busy":"true"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending","data-testid":"paypal-loader"},e(a,null))):e("div",{className:"adyen-checkout__paypal"},e(o,l(i({},g),{onCancel:f,onChange:b,onError:m,onSubmit:O,onApprove:v,isProcessingPayment:"processing"===j,paypalRef:window.paypal})))}export{y as default};
2
2
  //# sourceMappingURL=PaypalComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaypalComponent.js","sources":["../../../../../src/components/PayPal/components/PaypalComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useCallback } from 'preact/hooks';\nimport PaypalButtons from './PaypalButtons';\nimport Spinner from '../../internal/Spinner';\nimport { getPaypalUrl } from '../utils/get-paypal-url';\nimport Script from '../../../utils/Script';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport type { PayPalComponentProps } from './types';\n\nexport default function PaypalComponent({ onApprove, onCancel, onChange, onError, onSubmit, onScriptLoadFailure, ...props }: PayPalComponentProps) {\n const [status, setStatus] = useState('pending');\n\n this.setStatus = setStatus;\n\n const handleOnApprove = useCallback(\n (data: any, actions: any) => {\n setStatus('processing');\n onApprove(data, actions);\n },\n [onApprove]\n );\n\n const handlePaypalLoad = () => {\n setStatus('ready');\n };\n\n const handlePaypalLoadFailure = (error: AdyenCheckoutError) => {\n onScriptLoadFailure(error);\n };\n\n useEffect(() => {\n const src = getPaypalUrl(props);\n\n const attributes = { ...(props.cspNonce && { nonce: props.cspNonce }) },\n dataAttributes = { ...(props.cspNonce && { cspNonce: props.cspNonce }) };\n\n const script = new Script(src, 'body', attributes, dataAttributes);\n\n script.load().then(handlePaypalLoad).catch(handlePaypalLoadFailure);\n\n return () => {\n script.remove();\n };\n }, []);\n\n if (status === 'pending') {\n return (\n <div className=\"adyen-checkout__paypal\" aria-live=\"polite\" aria-busy=\"true\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending\">\n <Spinner />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"adyen-checkout__paypal\">\n <PaypalButtons\n {...props}\n onCancel={onCancel}\n onChange={onChange}\n onError={onError}\n onSubmit={onSubmit}\n onApprove={handleOnApprove}\n isProcessingPayment={status === 'processing'}\n paypalRef={window.paypal}\n />\n </div>\n );\n}\n"],"names":["PaypalComponent","_param","onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure","props","_object_without_properties","status","setStatus","useState","this","handleOnApprove","useCallback","data","actions","handlePaypalLoad","handlePaypalLoadFailure","error","useEffect","src","getPaypalUrl","attributes","_object_spread","cspNonce","nonce","dataAttributes","script","Script","load","then","catch","remove","h","div","className","aria-live","aria-busy","Spinner","PaypalButtons","isProcessingPayment","paypalRef","window","paypal"],"mappings":"wgDASe,SAASA,EAAgBC,GAAA,IAAAC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,QAAEA,EAAOC,SAAEA,EAAQC,oBAAEA,GAApDN,EAA4EO,EAA5EC,EAAAR,EAAA,CAAEC,YAAWC,WAAUC,WAAUC,UAASC,WAAUC,wBACxF,MAAOG,EAAQC,GAAaC,EAAS,WAErCC,KAAKF,UAAYA,EAEjB,MAAMG,EAAkBC,GACpB,CAACC,EAAWC,KACRN,EAAU,cACVT,EAAUc,EAAMC,EAAAA,GAEpB,CAACf,IAGCgB,EAAmB,KACrBP,EAAU,QAAA,EAGRQ,EAA2BC,IAC7Bb,EAAoBa,EAAAA,EAkBxB,OAfAC,GAAU,KACN,MAAMC,EAAMC,EAAaf,GAEnBgB,EAAaC,EAAA,GAAMjB,EAAMkB,UAAY,CAAEC,MAAOnB,EAAMkB,WACtDE,EAAiBH,EAAA,CAAA,EAAMjB,EAAMkB,UAAY,CAAEA,SAAUlB,EAAMkB,WAEzDG,EAAS,IAAIC,EAAOR,EAAK,OAAQE,EAAYI,GAInD,OAFAC,EAAOE,OAAOC,KAAKd,GAAkBe,MAAMd,GAEpC,KACHU,EAAOK,QAAM,CACjB,GACD,IAEY,YAAXxB,EAEIyB,EAACC,MAAAA,CAAIC,UAAU,yBAAyBC,YAAU,SAASC,YAAU,QACjEJ,EAACC,MAAAA,CAAIC,UAAU,0EACXF,EAACK,EAAAA,QAObL,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACM,EACOjC,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CACJL,SAAUA,EACVC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVJ,UAAWY,EACX4B,oBAAgC,eAAXhC,EACrBiC,UAAWC,OAAOC,UAIlC"}
1
+ {"version":3,"file":"PaypalComponent.js","sources":["../../../../../src/components/PayPal/components/PaypalComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useEffect, useCallback } from 'preact/hooks';\nimport PaypalButtons from './PaypalButtons';\nimport Spinner from '../../internal/Spinner';\nimport { getPaypalUrl } from '../utils/get-paypal-url';\nimport Script from '../../../utils/Script';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport type { PayPalComponentProps } from './types';\n\nexport default function PaypalComponent({ onApprove, onCancel, onChange, onError, onSubmit, onScriptLoadFailure, ...props }: PayPalComponentProps) {\n const [status, setStatus] = useState('pending');\n\n this.setStatus = setStatus;\n\n const handleOnApprove = useCallback(\n (data: any, actions: any) => {\n setStatus('processing');\n onApprove(data, actions);\n },\n [onApprove]\n );\n\n const handlePaypalLoad = () => {\n setStatus('ready');\n };\n\n const handlePaypalLoadFailure = (error: AdyenCheckoutError) => {\n onScriptLoadFailure(error);\n };\n\n useEffect(() => {\n const src = getPaypalUrl(props);\n\n const attributes = { ...(props.cspNonce && { nonce: props.cspNonce }) },\n dataAttributes = { ...(props.cspNonce && { cspNonce: props.cspNonce }) };\n\n const script = new Script(src, 'body', attributes, dataAttributes);\n\n script.load().then(handlePaypalLoad).catch(handlePaypalLoadFailure);\n\n return () => {\n script.remove();\n };\n }, []);\n\n if (status === 'pending') {\n return (\n <div className=\"adyen-checkout__paypal\" aria-live=\"polite\" aria-busy=\"true\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--pending\" data-testid={'paypal-loader'}>\n <Spinner />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"adyen-checkout__paypal\">\n <PaypalButtons\n {...props}\n onCancel={onCancel}\n onChange={onChange}\n onError={onError}\n onSubmit={onSubmit}\n onApprove={handleOnApprove}\n isProcessingPayment={status === 'processing'}\n paypalRef={window.paypal}\n />\n </div>\n );\n}\n"],"names":["PaypalComponent","_param","onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure","props","_object_without_properties","status","setStatus","useState","this","handleOnApprove","useCallback","data","actions","handlePaypalLoad","handlePaypalLoadFailure","error","useEffect","src","getPaypalUrl","attributes","_object_spread","cspNonce","nonce","dataAttributes","script","Script","load","then","catch","remove","h","div","className","aria-live","aria-busy","data-testid","Spinner","PaypalButtons","isProcessingPayment","paypalRef","window","paypal"],"mappings":"wgDASe,SAASA,EAAgBC,GAAA,IAAAC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,QAAEA,EAAOC,SAAEA,EAAQC,oBAAEA,GAApDN,EAA4EO,EAA5EC,EAAAR,EAAA,CAAEC,YAAWC,WAAUC,WAAUC,UAASC,WAAUC,wBACxF,MAAOG,EAAQC,GAAaC,EAAS,WAErCC,KAAKF,UAAYA,EAEjB,MAAMG,EAAkBC,GACpB,CAACC,EAAWC,KACRN,EAAU,cACVT,EAAUc,EAAMC,EAAAA,GAEpB,CAACf,IAGCgB,EAAmB,KACrBP,EAAU,QAAA,EAGRQ,EAA2BC,IAC7Bb,EAAoBa,EAAAA,EAkBxB,OAfAC,GAAU,KACN,MAAMC,EAAMC,EAAaf,GAEnBgB,EAAaC,EAAA,GAAMjB,EAAMkB,UAAY,CAAEC,MAAOnB,EAAMkB,WACtDE,EAAiBH,EAAA,CAAA,EAAMjB,EAAMkB,UAAY,CAAEA,SAAUlB,EAAMkB,WAEzDG,EAAS,IAAIC,EAAOR,EAAK,OAAQE,EAAYI,GAInD,OAFAC,EAAOE,OAAOC,KAAKd,GAAkBe,MAAMd,GAEpC,KACHU,EAAOK,QAAM,CACjB,GACD,IAEY,YAAXxB,EAEIyB,EAACC,MAAAA,CAAIC,UAAU,yBAAyBC,YAAU,SAASC,YAAU,QACjEJ,EAACC,MAAAA,CAAIC,UAAU,yEAAyEG,cAAa,iBACjGL,EAACM,EAAAA,QAObN,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACO,EACOlC,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CACJL,SAAUA,EACVC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVJ,UAAWY,EACX6B,oBAAgC,eAAXjC,EACrBkC,UAAWC,OAAOC,UAIlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n // @ts-ignore fix later\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAYdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAAlBL,EAAAA,aAAAA,EAAAA,EAAOK,uBAAPL,EAAAA,EAAsB,SAEnCM,KAAM,KAId,MAAMC,GAAgBP,QAAAA,EAAAA,EAAMM,YAANN,IAAAA,OAAAA,EAAAA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AAYC,EAAiBzE,GACzBI,MAAMqE,EAAUzE,GAHpB0E,EAAAlD,KAAQU,oBAAR,GA4DAwC,EAAAlD,KAAQuC,gBAAgBY,IACpBnD,KAAKU,aAAeyC,CAAAA,IAzDpBnD,KAAKU,aAAeV,KAAKxB,MAAMK,WACnC,EARAqE,EADE7E,EACYmB,OAAOC,EAAW2D,KAChCF,EAFE7E,EAEYgF,aAAa,CAAC5D,EAAW2D,IAAK3D,EAAWkB,OAAQlB,EAAWC,YAAaD,EAAWI"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.props.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.props.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAAlBL,EAAAA,aAAAA,EA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AC8B,EAAAA,CAAgBC,QAAS9C,KAAKxB,MAAMuE,QAAQD,SAAU9C,KAAKY,cAAcpB,EAAMqB,EAAKC,IAGjG,CA5HAkC,WAAAA,CAAYC,EAAiBzE,GACzBI,MAAMqE,EAAUzE,GAHpB0E,EAAAlD,KAAQU,oBAAR,GA2DAwC,EAAAlD,KAAQuC,gBAAgBY,IACpBnD,KAAKU,aAAeyC,CAAAA,IAxDpBnD,KAAKU,aAAeV,KAAKxB,MAAMK,WACnC,EARAqE,EADE7E,EACYmB,OAAOC,EAAW2D,KAChCF,EAFE7E,EAEYgF,aAAa,CAAC5D,EAAW2D,IAAK3D,EAAWkB,OAAQlB,EAAWC,YAAaD,EAAWI"}
@@ -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.0.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};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.2",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class T{static setBundleType(t){T.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,T.metadata.version,this.options.locale)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:g,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:T.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substring(0,4);var c,h;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(h=this.options.clientKey)||void 0===h?void 0:h.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=T.metadata)}}E(T,"metadata",{version:"6.0.0",bundleType:"eslegacy"}),E(T,"registry",p);export{T as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as g}from"./Analytics/constants.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);o.push.apply(o,e)}return o}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class T{static setBundleType(t){T.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,T.metadata.version,this.options.locale)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:g,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:T.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>{const e=A({},t,this.session&&{session:this.session});o.update(e)})),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substring(0,4);var c,h;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);"pub."===l&&console.debug(`The value you are passing as your "clientKey" looks like an originKey (${null===(h=this.options.clientKey)||void 0===h?void 0:h.substring(0,12)}..). Although this is supported it is not the recommended way to integrate. To generate a clientKey, see the documentation (https://docs.adyen.com/development-resources/client-side-authentication/migrate-from-origin-key-to-client-key/) for more details.`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=T.metadata)}}E(T,"metadata",{version:"6.0.2",bundleType:"eslegacy"}),E(T,"registry",p);export{T as default};
2
2
  //# sourceMappingURL=core.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/adyen-web",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "license": "MIT",
5
5
  "homepage": "https://docs.adyen.com/checkout",
6
6
  "type": "module",
@@ -69,7 +69,7 @@
69
69
  "types:generate": "tsc --emitDeclarationOnly",
70
70
  "format": "npm run lint:fix && npm run prettier:fix && npm run styles:fix",
71
71
  "lint": "eslint .",
72
- "lint-styles": "stylelint '**/*.scss'",
72
+ "lint-styles": "stylelint \"**/*.scss\"",
73
73
  "styles:fix": "npm run lint-styles -- --fix",
74
74
  "lint:fix": "npm run lint -- --fix",
75
75
  "prettier:fix": "prettier \"src/**/*.{js,ts,tsx}\" \"package.json\" --write --loglevel silent",