@adyen/adyen-web 6.0.0-alpha.0 → 6.0.0-alpha.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.
Files changed (130) hide show
  1. package/auto/auto.js +2 -0
  2. package/dist/cjs/adyen.css +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +161 -248
  6. package/dist/es/adyen.css +1 -1
  7. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  8. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  9. package/dist/es/components/Dropin/Dropin.js +1 -1
  10. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  11. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  12. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  13. package/dist/es/components/Dropin/defaultProps.js +1 -1
  14. package/dist/es/components/Dropin/defaultProps.js.map +1 -1
  15. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  16. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  17. package/dist/es/components/PayPal/Paypal.js +1 -1
  18. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  19. package/dist/es/components/PayPal/components/PaypalButtons.js +1 -1
  20. package/dist/es/components/PayPal/components/PaypalButtons.js.map +1 -1
  21. package/dist/es/components/PayPal/components/PaypalComponent.js +1 -1
  22. package/dist/es/components/PayPal/components/PaypalComponent.js.map +1 -1
  23. package/dist/es/components/PayPal/defaultProps.js +1 -1
  24. package/dist/es/components/PayPal/defaultProps.js.map +1 -1
  25. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  26. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  27. package/dist/es/components/PayPal/utils/get-paypal-locale.js +2 -0
  28. package/dist/es/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  29. package/dist/es/components/PayPal/utils/get-paypal-settings.js +2 -0
  30. package/dist/es/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  31. package/dist/es/components/PayPal/utils/get-paypal-styles.js +2 -0
  32. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  33. package/dist/es/components/PayPal/utils/get-paypal-url.js +2 -0
  34. package/dist/es/components/PayPal/utils/get-paypal-url.js.map +1 -0
  35. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  36. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  37. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  38. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  39. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  40. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  41. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  42. package/dist/es/core/AdyenCheckout.js +1 -1
  43. package/dist/es/core/AdyenCheckout.js.map +1 -1
  44. package/dist/es/core/Analytics/Analytics.js +1 -1
  45. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  46. package/dist/es/core/Analytics/EventsQueue.js +1 -1
  47. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  48. package/dist/es/core/Analytics/utils.js +1 -1
  49. package/dist/es/core/Analytics/utils.js.map +1 -1
  50. package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
  51. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  52. package/dist/es/core/Errors/utils.js +1 -1
  53. package/dist/es/core/Errors/utils.js.map +1 -1
  54. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  55. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  56. package/dist/es/core/Services/analytics/log-event.js +1 -1
  57. package/dist/es/core/config.js +1 -1
  58. package/dist/es/core/config.js.map +1 -1
  59. package/dist/es/core/core.js +1 -1
  60. package/dist/es/core/core.js.map +1 -1
  61. package/dist/es/index.d.ts +161 -248
  62. package/dist/es/language/locales/en-US.json.js +1 -1
  63. package/dist/es/utils/Script.js +1 -1
  64. package/dist/es/utils/Script.js.map +1 -1
  65. package/dist/es-legacy/adyen.css +1 -1
  66. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  67. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  68. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  69. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  70. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  71. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  72. package/dist/es-legacy/components/Dropin/defaultProps.js +1 -1
  73. package/dist/es-legacy/components/Dropin/defaultProps.js.map +1 -1
  74. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  75. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  76. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  77. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  78. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  79. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  80. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  81. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  82. package/dist/es-legacy/components/PayPal/defaultProps.js +1 -1
  83. package/dist/es-legacy/components/PayPal/defaultProps.js.map +1 -1
  84. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  85. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  86. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js +2 -0
  87. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  88. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +2 -0
  89. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  90. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js +2 -0
  91. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  92. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js +2 -0
  93. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js.map +1 -0
  94. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  95. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  96. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  97. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  98. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  99. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  100. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  101. package/dist/es-legacy/core/AdyenCheckout.js +1 -1
  102. package/dist/es-legacy/core/AdyenCheckout.js.map +1 -1
  103. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  104. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  105. package/dist/es-legacy/core/Analytics/EventsQueue.js +1 -1
  106. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  107. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  108. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  109. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js +1 -1
  110. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  111. package/dist/es-legacy/core/Errors/utils.js +1 -1
  112. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  113. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  114. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  115. package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
  116. package/dist/es-legacy/core/config.js +1 -1
  117. package/dist/es-legacy/core/config.js.map +1 -1
  118. package/dist/es-legacy/core/core.js +1 -1
  119. package/dist/es-legacy/core/core.js.map +1 -1
  120. package/dist/es-legacy/language/locales/en-US.json.js +1 -1
  121. package/dist/es-legacy/utils/Script.js +1 -1
  122. package/dist/es-legacy/utils/Script.js.map +1 -1
  123. package/dist/umd/adyen.css +1 -1
  124. package/dist/umd/adyen.js +2 -2
  125. package/dist/umd/adyen.js.map +1 -1
  126. package/package.json +2 -2
  127. package/dist/es/components/PayPal/utils.js +0 -2
  128. package/dist/es/components/PayPal/utils.js.map +0 -1
  129. package/dist/es-legacy/components/PayPal/utils.js +0 -2
  130. package/dist/es-legacy/components/PayPal/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport type { AddressData, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport { ICore } from '../../core/types';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n\n this.googlePay = new GooglePayService({\n ...this.props,\n paymentDataCallbacks: {\n ...this.props.paymentDataCallbacks,\n onPaymentAuthorized: this.onPaymentAuthorized\n }\n });\n }\n\n formatProps(props): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n return {\n ...props,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n public override submit = () => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n\n new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => this.googlePay.initiatePayment(this.props, this.core.options.countryCode))\n .catch((error: google.payments.api.PaymentsError) => {\n if (error.statusCode === 'CANCELED') {\n this.handleError(new AdyenCheckoutError('CANCEL', error.toString(), { cause: error }));\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n this.handleFailedResult(paymentResponse);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Validation\n */\n get isValid(): boolean {\n return !!this.state.googlePayToken;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new Error('Google Pay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new Error('Google Pay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n render() {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["GooglePay","UIElement","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","_object_spread_props","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","this","state","_object_spread","paymentMethod","type","browserInfo","origin","window","location","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","catch","error","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","Error","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","render","showPayButton","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","paymentsClient","googlePay","onClick","submit","constructor","checkout","super","_define_property","isInstantPayment","submitAnalytics","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","initiatePayment","core","options","countryCode","statusCode","handleError","AdyenCheckoutError","toString","cause","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","handleFailedResult","prefetch","prefetchPaymentData","bind","GooglePayService","paymentDataCallbacks","TxVariants","googlepay","txVariants","paywithgoogle","defaultProps"],"mappings":"ikDAeA,MAAMA,UAAkBC,EAoBpBC,WAAAA,CAAYC,GAEsDA,IAAAA,EADvCA,EAAvB,MAAMC,EAAiBD,QAAAA,EAAAA,EAAMC,sBAAND,IAAAA,EAAAA,EAAyBA,EAAME,SAAW,OAAS,SAClCF,IAAAA,EAAxC,MAAMG,EAAeC,EAAqC,QAAlBJ,EAAAA,EAAMG,oBAANH,IAAAA,EAAAA,EAAsBA,QAAAA,EAAAA,EAAMK,YAANL,IAAAA,OAAAA,EAAAA,EAAYM,QAEpEC,EAAwD,IAAIP,EAAMO,gBAAiB,yBAEzF,OAAOC,EACAR,EAAAA,CAAAA,EAAAA,GAAAA,CACHS,cAAeT,EAAMS,cACrBR,iBACAE,eACAI,mBAER,CAKAG,UAAAA,GACI,MAAMC,qBAAEA,EAAoBC,eAAEA,EAAcC,eAAEA,EAAcC,gBAAEA,GAAoBC,KAAKC,MAEvF,OAAOC,EAAA,CACHC,cAAe,CACXC,KAAMJ,KAAKI,KACXR,uBACAC,kBAEJQ,YAAaL,KAAKK,YAClBC,SAAUC,QAAUA,OAAOC,SAASF,QAChCR,GAAkB,CAAEA,kBACpBC,GAAmB,CAAEA,mBAEjC,CAiFA,yBAAcU,GACV,OAAO,IAAIC,SAAc,CAACC,EAASC,KAC1BZ,KAAKf,MAAM4B,cACZF,IAGJ,MAAMG,gBAAEA,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AClCC,SAASjE,aAAAA,EAAAA,EAAgBiE,UAAWJ,GAGlDpE,EAAQ,CACJiE,iBAAkB,QAClB5D,UAGJhB,KAAKoF,mBAAmBT,EAAAA,GAC5B,GACR,IA6DJ7B,OAAOzB,gBAAe,IACXrB,KAAKwC,UAAUnB,aAAarB,KAAKf,SAM5C6D,OAAOuC,YAAW,IACPrF,KAAKwC,UAAU8C,oBAAoBtF,KAAKf,MAAOe,KAAKqD,KAAKC,QAAQC,eA1LxEvD,KAAKS,oBAAsBT,KAAKS,oBAAoB8E,KAAKvF,MAEzDA,KAAKwC,UAAY,IAAIgD,EAAiB/F,EAC/BS,EAAA,CAAA,EAAAF,KAAKf,OAAK,CACbwG,qBAAsBhG,EACfS,EAAA,CAAA,EAAAF,KAAKf,MAAMwG,sBAAoB,CAClC5B,oBAAqB7D,KAAK6D,wBAGtC,EAjBAf,EADEhE,EACYsB,OAAOsF,EAAWC,WAChC7C,EAFEhE,EAEY8G,aAAa,CAACF,EAAWC,UAAWD,EAAWG,gBAC7D/C,EAHEhE,EAGYgH,eAAeA"}
1
+ {"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\nimport type { AddressData, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport type { ICore } from '../../core/types';\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n\n this.googlePay = new GooglePayService({\n ...this.props,\n paymentDataCallbacks: {\n ...this.props.paymentDataCallbacks,\n onPaymentAuthorized: this.onPaymentAuthorized\n }\n });\n }\n\n formatProps(props): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n return {\n ...props,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n public override submit = () => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n\n new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => this.googlePay.initiatePayment(this.props, this.core.options.countryCode))\n .catch((error: google.payments.api.PaymentsError) => {\n if (error.statusCode === 'CANCELED') {\n this.handleError(new AdyenCheckoutError('CANCEL', error.toString(), { cause: error }));\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error.toString(), { cause: error }));\n }\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse?.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n const responseWithError = {\n ...paymentResponse,\n error: {\n googlePayError: error\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Validation\n */\n get isValid(): boolean {\n return !!this.state.googlePayToken;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n render() {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["GooglePay","UIElement","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","_object_spread_props","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","this","state","_object_spread","paymentMethod","type","browserInfo","origin","window","location","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","catch","error","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","AdyenCheckoutError","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","render","showPayButton","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","paymentsClient","googlePay","onClick","submit","constructor","checkout","super","_define_property","isInstantPayment","submitAnalytics","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","initiatePayment","core","options","countryCode","statusCode","handleError","toString","cause","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","responseWithError","handleFailedResult","prefetch","prefetchPaymentData","bind","GooglePayService","paymentDataCallbacks","TxVariants","googlepay","txVariants","paywithgoogle","defaultProps"],"mappings":"ikDAeA,MAAMA,UAAkBC,EAoBpBC,WAAAA,CAAYC,GAEsDA,IAAAA,EADvCA,EAAvB,MAAMC,EAAiBD,QAAAA,EAAAA,EAAMC,sBAAND,IAAAA,EAAAA,EAAyBA,EAAME,SAAW,OAAS,SAClCF,IAAAA,EAAxC,MAAMG,EAAeC,EAAqC,QAAlBJ,EAAAA,EAAMG,oBAANH,IAAAA,EAAAA,EAAsBA,QAAAA,EAAAA,EAAMK,YAANL,IAAAA,OAAAA,EAAAA,EAAYM,QAEpEC,EAAwD,IAAIP,EAAMO,gBAAiB,yBAEzF,OAAOC,EACAR,EAAAA,CAAAA,EAAAA,GAAAA,CACHS,cAAeT,EAAMS,cACrBR,iBACAE,eACAI,mBAER,CAKAG,U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/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import 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{formatPaypalOrderContatcToAdyenFormat as p}from"./utils/format-paypal-order-contact-to-adyen-format.js";function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){h(e,t,n[t])}))}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}class c extends t{formatProps(e){var t;const{merchantId:n,intent:r}=e.configuration,i=0===(null===(t=e.amount)||void 0===t?void 0:t.value)?"tokenize":e.intent||r,o="tokenize"===i||e.vault,s="continue"===e.userAction;return d(l({},e),{commit:!s&&e.commit,vault:o,configuration:{intent:i,merchantId:n}})}updatePaymentData(e){e||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=e}formatData(){const{isExpress:e,userAction:t}=this.props;return{paymentMethod:{type:c.type,userAction:t,subtype:e?"express":c.subtype}}}get isValid(){return!0}handleResolve(e){if(!this.resolve)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.resolve(e)}handleReject(e){if(!this.reject)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.reject(new Error(e))}handleSubmit(){return super.submit(),new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}handleOnShippingAddressChange(e,t){return this.props.onShippingAddressChange(e,t,this)}handleOnShippingOptionsChange(e,t){return this.props.onShippingOptionsChange(e,t,this)}render(){if(!this.props.showPayButton)return null;const t=this.props,{onShippingAddressChange:r,onShippingOptionsChange:s}=t,a=u(t,["onShippingAddressChange","onShippingOptionsChange"]);return e(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(n,d(l({ref:e=>{this.componentRef=e}},a,r&&{onShippingAddressChange:this.handleOnShippingAddressChange},s&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new o("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:e=>{this.handleError(new o("ERROR",e.toString(),{cause:e}))},onSubmit:this.handleSubmit})))}constructor(e,t){super(e,t),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",(e=>this.updateWithAction(e))),h(this,"updateWithAction",(e=>{if(e.paymentMethodType!==this.type)throw new Error("Invalid Action");return e.paymentData&&(this.paymentData=e.paymentData),e.sdkData&&e.sdkData.token?this.handleResolve(e.sdkData.token):this.handleReject(s.NO_TOKEN_PROVIDED),null})),h(this,"handleOnApprove",((e,t)=>{const{onAuthorized:n}=this.props,r={data:{details:e,paymentData:this.paymentData}};if(n)return t.order.get().then((e=>{var t;const r=p(null==e?void 0:e.payer),i=p(null==e||null===(t=e.purchase_units)||void 0===t?void 0:t[0].shipping,!0);return this.setState(l({authorizedEvent:e},r&&{billingAddress:r},i&&{deliveryAddress:i})),new Promise(((t,o)=>n(l({authorizedEvent:e},r&&{billingAddress:r},i&&{deliveryAddress:i}),{resolve:t,reject:o})))})).then((()=>this.handleAdditionalDetails(r))).catch((e=>this.handleError(new o("ERROR","Something went wrong while parsing PayPal Order",{cause:e}))));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 e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./components/PaypalComponent.js";import r from"./defaultProps.js";import 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(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){h(e,t,n[t])}))}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}class c extends t{formatProps(e){var t,n,r;const i=null===(t=e.configuration)||void 0===t?void 0:t.merchantId,o=null===(n=e.configuration)||void 0===n?void 0:n.intent,s=0===(null===(r=e.amount)||void 0===r?void 0:r.value)?"tokenize":e.intent||o,a="tokenize"===s||e.vault,p="continue"===e.userAction;return d(l({},e),{commit:!p&&e.commit,vault:a,configuration:{intent:s,merchantId:i}})}updatePaymentData(e){e||console.warn("PayPal - Updating payment data with an invalid value"),this.paymentData=e}formatData(){const{isExpress:e,userAction:t}=this.props;return{paymentMethod:{type:c.type,userAction:t,subtype:e?"express":c.subtype}}}get isValid(){return!0}handleResolve(e){if(!this.resolve)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.resolve(e)}handleReject(e){if(!this.reject)return this.handleError(new o("ERROR",s.WRONG_INSTANCE));this.reject(new Error(e))}handleSubmit(){return super.submit(),new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}handleOnShippingAddressChange(e,t){return this.props.onShippingAddressChange(e,t,this)}handleOnShippingOptionsChange(e,t){return this.props.onShippingOptionsChange(e,t,this)}render(){if(!this.props.showPayButton)return null;const t=this.props,{onShippingAddressChange:r,onShippingOptionsChange:s}=t,a=u(t,["onShippingAddressChange","onShippingOptionsChange"]);return e(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(n,d(l({ref:e=>{this.componentRef=e}},a,r&&{onShippingAddressChange:this.handleOnShippingAddressChange},s&&{onShippingOptionsChange:this.handleOnShippingOptionsChange}),{onCancel:()=>this.handleError(new o("CANCEL")),onChange:this.setState,onApprove:this.handleOnApprove,onError:e=>{this.handleError(new o("ERROR",e.toString(),{cause:e}))},onScriptLoadFailure:e=>this.handleError(e),onSubmit:this.handleSubmit})))}constructor(e,t){super(e,t),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",(e=>this.updateWithAction(e))),h(this,"updateWithAction",(e=>{if(e.paymentMethodType!==this.type)throw new Error("Invalid Action");return e.paymentData&&(this.paymentData=e.paymentData),e.sdkData&&e.sdkData.token?this.handleResolve(e.sdkData.token):this.handleReject(s.NO_TOKEN_PROVIDED),null})),h(this,"handleOnApprove",((e,t)=>{const{onAuthorized:n}=this.props,r={data:{details:e,paymentData:this.paymentData}};if(n)return t.order.get().then((e=>{var t;const r=p(null==e?void 0:e.payer),i=p(null==e||null===(t=e.purchase_units)||void 0===t?void 0:t[0].shipping,!0);return this.setState(l({authorizedEvent:e},r&&{billingAddress:r},i&&{deliveryAddress:i})),new Promise(((t,o)=>n(l({authorizedEvent:e},r&&{billingAddress:r},i&&{deliveryAddress:i}),{resolve:t,reject:o})))})).then((()=>this.handleAdditionalDetails(r))).catch((e=>this.handleError(new o("ERROR","Something went wrong while parsing PayPal Order",{cause:e}))));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 { formatPaypalOrderContatcToAdyenFormat } 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';\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, intent: intentFromConfig } = props.configuration;\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 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 = formatPaypalOrderContatcToAdyenFormat(paypalOrder?.payer);\n const deliveryAddress = formatPaypalOrderContatcToAdyenFormat(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, actions): 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, actions): 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 onSubmit={this.handleSubmit}\n />\n </CoreProvider>\n );\n }\n}\n\nexport default PaypalElement;\n"],"names":["PaypalElement","UIElement","formatProps","props","merchantId","intent","intentFromConfig","configuration","amount","value","vault","displayContinueToReviewPageButton","userAction","_object_spread_props","commit","updatePaymentData","paymentData","console","warn","this","formatData","isExpress","paymentMethod","type","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","super","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","onSubmit","constructor","checkout","_define_property","SUBMIT_NOT_SUPPORTED","handleAction","action","updateWithAction","paymentMethodType","sdkData","NO_TOKEN_PROVIDED","onAuthorized","state","details","order","get","then","paypalOrder","billingAddress","formatPaypalOrderContatcToAdyenFormat","payer","deliveryAddress","purchase_units","shipping","_object_spread","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"+vDAgBA,MAAMA,UAAsBC,EAkBxBC,WAAAA,CAAYC,GAEWA,IAAAA,EADnB,MAAMC,WAAEA,EAAYC,OAAQC,GAAqBH,EAAMI,cAEjDF,EADqC,KAAxBF,QAAAA,EAAAA,EAAMK,cAANL,IAAAA,OAAAA,EAAAA,EAAcM,OACG,WAAaN,EAAME,QAAUC,EAC3DI,EAAmB,aAAXL,GAAyBF,EAAMO,MAEvCC,EAAyD,aAArBR,EAAMS,WAEhD,OAAOC,EACAV,EAAAA,CAAAA,EAAAA,GAAAA,CACHW,QAAQH,GAA4CR,EAAMW,OAC1DJ,QACAH,cAAe,CACXF,SACAD,eAGZ,CAUOW,iBAAAA,CAAkBC,GAChBA,GAAaC,QAAQC,KAAK,wDAC/BC,KAAKH,YAAcA,CACvB,CAKA,UAAAI,GACI,MAAMC,UAAEA,EAAST,WAAEA,GAAeO,KAAKhB,MAEvC,MAAO,CACHmB,cAAe,CACXC,KAAMvB,EAAcuB,KACpBX,aACAY,QAASH,EAAY,UAAYrB,EAAcwB,SAG3D,CA4BA,WAAIC,GACA,OAAO,CACX,CAsCAC,aAAAA,CAAcC,GACV,IAAKR,KAAKS,QAAS,OAAOT,KAAKU,YAAY,IAAIC,EAAmB,QAASC,EAAOC,iBAClFb,KAAKS,QAAQ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AS,kDAAmD,CAAEsC,MAAOF,OA5B7H/C,KAAK4E,wBAAwBd,EA4BsG,IAnHvI9D,KAAKkB,aAAelB,KAAKkB,aAAa4D,KAAK9E,MAC3CA,KAAKsB,8BAAgCtB,KAAKsB,8BAA8BwD,KAAK9E,MAC7EA,KAAK0B,8BAAgC1B,KAAK0B,8BAA8BoD,KAAK9E,KACjF,EAfAqD,EADExE,EACYuB,OAAO2E,EAAWC,QAChC3B,EAFExE,EAEYwB,UAAU,OAOxBgD,EATExE,EASeoG,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';\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 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","updatePaymentData","paymentData","console","warn","this","formatData","isExpress","paymentMethod","type","subtype","isValid","handleResolve","token","resolve","handleError","AdyenCheckoutError","ERRORS","WRONG_INSTANCE","handleReject","errorMessage","reject","Error","handleSubmit","super","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","_object_spread","authorizedEvent","handleAdditionalDetails","catch","bind","TxVariants","paypal","defaultProps"],"mappings":"+vDAgBA,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,QAAA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,KAAAA,mBAAkB,CAACtB,EAAWC,KAClC,MAAMsC,aAAEA,GAAiB9D,KAAKhB,MACxB+E,EAAQ,CAAExC,KAAM,CAAEyC,QAASzC,EAAM1B,YAAaG,KAAKH,cAEzD,GAAKiE,EAKL,OAAOtC,EAAQyC,MACVC,MACAC,MAAMC,IAE2DA,IAAAA,EAD9D,MAAMC,EAAiBC,EAAsCF,aAAAA,EAAAA,EAAaG,OACpEC,EAAkBF,EAAsCF,SAAAA,QAAAA,EAAAA,EAAaK,sBAAbL,IAAAA,OAAAA,EAAAA,EAA8B,GAAGM,UAAU,GAQzG,OANA1E,KAAK2C,SAASgC,EAAA,CACVC,gBAAiBR,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,qBAGtB,IAAInD,SAAc,CAACZ,EAASO,IAC/B8C,EACIa,EAAA,CACIC,gBAAiBR,GACbC,GAAkB,CAAEA,kBACpBG,GAAmB,CAAEA,oBAE7B,CAAE/D,UAASO,YAAO,IAI7BmD,MAAK,IAAMnE,KAAK6E,wBAAwBd,KACxCe,OAAM/B,GAAS/C,KAAKU,YAAY,IAAIC,EAAmB,QAAS,kDAAmD,CAAEsC,MAAOF,OA5B7H/C,KAAK6E,wBAAwBd,EA4BsG,IApHvI/D,KAAKkB,aAAelB,KAAKkB,aAAa6D,KAAK/E,MAC3CA,KAAKsB,8BAAgCtB,KAAKsB,8BAA8ByD,KAAK/E,MAC7EA,KAAK0B,8BAAgC1B,KAAK0B,8BAA8BqD,KAAK/E,KACjF,EAfAsD,EADEzE,EACYuB,OAAO4E,EAAWC,QAChC3B,EAFEzE,EAEYwB,UAAU,OAOxBiD,EATEzE,EASeqG,eAAeA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as n,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../external/classnames/index.js";import{getStyle as r}from"../utils.js";import a from"../../internal/Spinner/Spinner.js";import i from"../../../core/Context/useCoreContext.js";function p(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})),e}function s(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t=a[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function l(l){var u,{onInit:y,onApprove:d,onClick:g,onCancel:f,onError:m,onShippingChange:_,onShippingAddressChange:h,onShippingOptionsChange:b,onSubmit:O,isProcessingPayment:P,paypalRef:j,style:k}=l,v=s(l,["onInit","onApprove","onClick","onCancel","onError","onShippingChange","onShippingAddressChange","onShippingOptionsChange","onSubmit","isProcessingPayment","paypalRef","style"]);const{i18n:C}=i(),S="tokenize"===(null===(u=v.configuration)||void 0===u?void 0:u.intent),w=n(null),A=n(null),E=n(null),N=n(null),x=(e,n)=>{const t=c(function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(n){p(e,n,t[n])}))}return e}({},S&&{createBillingAgreement:O},!S&&{createOrder:O},!S&&"venmo"!==e&&_&&{onShippingChange:_},!S&&"venmo"!==e&&h&&{onShippingAddressChange:h},!S&&"venmo"!==e&&b&&{onShippingOptionsChange:b}),{fundingSource:e,style:r(e,k),onInit:y,onClick:g,onCancel:f,onError:m,onApprove:d}),o=j.Buttons(t);o.isEligible()&&o.render(n.current)};t((()=>{_&&h&&console.warn('PayPal - "onShippingChange" and "onShippingAddressChange" are defined. It is recommended to only use "onShippingAddressChange", as "onShippingChange" is getting deprecated')}),[_,h]),t((()=>{const{PAYPAL:e,CREDIT:n,PAYLATER:t,VENMO:o}=j.FUNDING;x(e,w),v.blockPayPalCreditButton||x(n,A),v.blockPayPalPayLaterButton||x(t,E),v.blockPayPalVenmoButton||x(o,N)}),[]);const D=!0===v.commit;return e("div",{className:o("adyen-checkout__paypal__buttons",{"adyen-checkout__paypal-processing":P})},e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--paypal",ref:w}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--credit",ref:A}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--pay-later",ref:E}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--venmo",ref:N}),P&&e("div",{className:"adyen-checkout__paypal"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--processing"},e(a,{size:"medium",inline:!0}),D&&C.get("paypal.processingPayment"))))}export{l as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as t,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../external/classnames/index.js";import{getStyle as r}from"../utils/get-paypal-styles.js";import a from"../../internal/Spinner/Spinner.js";import c from"../../../core/Context/useCoreContext.js";function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function l(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function s(s){var u,{onInit:y,onApprove:f,onClick:_,onCancel:b,onError:m,onShippingAddressChange:d,onShippingOptionsChange:g,onSubmit:O,isProcessingPayment:h,paypalRef:P,style:j}=s,k=l(s,["onInit","onApprove","onClick","onCancel","onError","onShippingAddressChange","onShippingOptionsChange","onSubmit","isProcessingPayment","paypalRef","style"]);const{i18n:v}=c(),C="tokenize"===(null===(u=k.configuration)||void 0===u?void 0:u.intent),S=t(null),w=t(null),E=t(null),A=t(null),N=(e,t)=>{const n=p(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(t){i(e,t,n[t])}))}return e}({},C&&{createBillingAgreement:O},!C&&{createOrder:O},!C&&"venmo"!==e&&d&&{onShippingAddressChange:d},!C&&"venmo"!==e&&g&&{onShippingOptionsChange:g}),{fundingSource:e,style:r(e,j),onInit:y,onClick:_,onCancel:b,onError:m,onApprove:f}),o=P.Buttons(n);o.isEligible()&&o.render(t.current)};n((()=>{const{PAYPAL:e,CREDIT:t,PAYLATER:n,VENMO:o}=P.FUNDING;N(e,S),k.blockPayPalCreditButton||N(t,w),k.blockPayPalPayLaterButton||N(n,E),k.blockPayPalVenmoButton||N(o,A)}),[]);const x=!0===k.commit;return e("div",{className:o("adyen-checkout__paypal__buttons",{"adyen-checkout__paypal-processing":h})},e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--paypal",ref:S}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--credit",ref:w}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--pay-later",ref:E}),e("div",{className:"adyen-checkout__paypal__button adyen-checkout__paypal__button--venmo",ref:A}),h&&e("div",{className:"adyen-checkout__paypal"},e("div",{className:"adyen-checkout__paypal__status adyen-checkout__paypal__status--processing"},e(a,{size:"medium",inline:!0}),x&&v.get("paypal.processingPayment"))))}export{s as default};
2
2
  //# sourceMappingURL=PaypalButtons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaypalButtons.js","sources":["../../../../../src/components/PayPal/components/PaypalButtons.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport classnames from 'classnames';\nimport { PayPalButtonsProps, FundingSource } from '../types';\nimport { getStyle } from '../utils';\nimport Spinner from '../../internal/Spinner';\nimport useCoreContext from '../../../core/Context/useCoreContext';\n\nexport default function PaypalButtons({\n onInit,\n onApprove,\n onClick,\n onCancel,\n onError,\n onShippingChange,\n onShippingAddressChange,\n onShippingOptionsChange,\n onSubmit,\n isProcessingPayment,\n paypalRef,\n style,\n ...props\n}: PayPalButtonsProps) {\n const { i18n } = useCoreContext();\n const isTokenize = props.configuration?.intent === 'tokenize';\n const paypalButtonRef = useRef<HTMLDivElement>(null);\n const creditButtonRef = useRef<HTMLDivElement>(null);\n const payLaterButtonRef = useRef<HTMLDivElement>(null);\n const venmoButtonRef = useRef<HTMLDivElement>(null);\n\n const createButton = (fundingSource: FundingSource, buttonRef) => {\n const configuration = {\n ...(isTokenize && { createBillingAgreement: onSubmit }),\n ...(!isTokenize && { createOrder: onSubmit }),\n ...(!isTokenize && fundingSource !== 'venmo' && onShippingChange && { onShippingChange }),\n ...(!isTokenize && fundingSource !== 'venmo' && onShippingAddressChange && { onShippingAddressChange }),\n ...(!isTokenize && fundingSource !== 'venmo' && onShippingOptionsChange && { onShippingOptionsChange }),\n fundingSource,\n style: getStyle(fundingSource, style),\n onInit,\n onClick,\n onCancel,\n onError,\n onApprove\n };\n\n const button = paypalRef.Buttons(configuration);\n\n if (button.isEligible()) {\n button.render(buttonRef.current);\n }\n };\n\n useEffect(() => {\n if (onShippingChange && onShippingAddressChange) {\n console.warn(\n 'PayPal - \"onShippingChange\" and \"onShippingAddressChange\" are defined. It is recommended to only use \"onShippingAddressChange\", as \"onShippingChange\" is getting deprecated'\n );\n }\n }, [onShippingChange, onShippingAddressChange]);\n\n useEffect(() => {\n const { PAYPAL, CREDIT, PAYLATER, VENMO } = paypalRef.FUNDING;\n createButton(PAYPAL, paypalButtonRef);\n\n if (!props.blockPayPalCreditButton) createButton(CREDIT, creditButtonRef);\n if (!props.blockPayPalPayLaterButton) createButton(PAYLATER, payLaterButtonRef);\n if (!props.blockPayPalVenmoButton) createButton(VENMO, venmoButtonRef);\n }, []);\n\n const isProcessingPaymentWithoutReviewPage = props.commit === true;\n\n return (\n <div className={classnames('adyen-checkout__paypal__buttons', { 'adyen-checkout__paypal-processing': isProcessingPayment })}>\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--paypal\" ref={paypalButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--credit\" ref={creditButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--pay-later\" ref={payLaterButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--venmo\" ref={venmoButtonRef} />\n\n {isProcessingPayment && (\n <div className=\"adyen-checkout__paypal\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--processing\">\n <Spinner size=\"medium\" inline />\n {isProcessingPaymentWithoutReviewPage && i18n.get('paypal.processingPayment')}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"names":["PaypalButtons","_param","props","onInit","onApprove","onClick","onCancel","onError","onShippingChange","onShippingAddressChange","onShippingOptionsChange","onSubmit","isProcessingPayment","paypalRef","style","_object_without_properties","i18n","useCoreContext","isTokenize","configuration","intent","paypalButtonRef","useRef","creditButtonRef","payLaterButtonRef","venmoButtonRef","createButton","fundingSource","buttonRef","_object_spread_props","createBillingAgreement","createOrder","getStyle","button","Buttons","isEligible","render","current","useEffect","console","warn","PAYPAL","CREDIT","PAYLATER","VENMO","FUNDING","blockPayPalCreditButton","blockPayPalPayLaterButton","blockPayPalVenmoButton","isProcessingPaymentWithoutReviewPage","commit","h","div","className","classnames","ref","Spinner","size","inline","get"],"mappings":"qxCAQe,SAASA,EAAcC,OAgBfC,GAhBeC,OAClCA,EAAMC,UACNA,EAASC,QACTA,EAAOC,SACPA,EAAQC,QACRA,EAAOC,iBACPA,EAAgBC,wBAChBA,EAAuBC,wBACvBA,EAAuBC,SACvBA,EAAQC,oBACRA,EAAmBC,UACnBA,EAASC,MACTA,GAZkCb,EAa/BC,EAb+Ba,EAAAd,EAAA,CAClCE,SACAC,YACAC,UACAC,WACAC,UACAC,mBACAC,0BACAC,0BACAC,WACAC,sBACAC,YACAC,UAGA,MAAME,KAAEA,GAASC,IACXC,EAA6C,cAAhChB,QAAAA,EAAAA,EAAMiB,qBAANjB,IAAAA,OAAAA,EAAAA,EAAqBkB,QAClCC,EAAkBC,EAAuB,MACzCC,EAAkBD,EAAuB,MACzCE,EAAoBF,EAAuB,MAC3CG,EAAiBH,EAAuB,MAExCI,EAAe,CAACC,EAA8BC,KAChD,MAAMT,EAAgBU,4UACdX,GAAc,CAAEY,uBAAwBnB,IACvCO,GAAc,CAAEa,YAAapB,IAC7BO,GAAgC,UAAlBS,GAA6BnB,GAAoB,CAAEA,qBACjEU,GAAgC,UAAlBS,GAA6BlB,GAA2B,CAAEA,4BACxES,GAAgC,UAAlBS,GAA6BjB,GAA2B,CAAEA,4BAAwB,CACrGiB,gBACAb,MAAOkB,EAASL,EAAeb,GAC/BX,SACAE,UACAC,WACAC,UACAH,cAGE6B,EAASpB,EAAUqB,QAAQf,GAE7Bc,EAAOE,cACPF,EAAOG,OAAOR,EAAUS,QAC5B,EAGJC,GAAU,KACF9B,GAAoBC,GACpB8B,QAAQC,KACJ,8KAER,GACD,CAAChC,EAAkBC,IAEtB6B,GAAU,KACN,MAAMG,OAAEA,EAAMC,OAAEA,EAAMC,SAAEA,EAAQC,MAAEA,GAAU/B,EAAUgC,QACtDnB,EAAae,EAAQpB,GAEhBnB,EAAM4C,yBAAyBpB,EAAagB,EAAQnB,GACpDrB,EAAM6C,2BAA2BrB,EAAaiB,EAAUnB,GACxDtB,EAAM8C,wBAAwBtB,EAAakB,EAAOnB,EAAAA,GACxD,IAEH,MAAMwB,GAAwD,IAAjB/C,EAAMgD,OAEnD,OACIC,EAACC,MAAAA,CAAIC,UAAWC,EAAW,kCAAmC,CAAE,oCAAqC1C,KACjGuC,EAACC,MAAAA,CAAIC,UAAU,wEAAwEE,IAAKlC,IAC5F8B,EAACC,MAAAA,CAAIC,UAAU,wEAAwEE,IAAKhC,IAC5F4B,EAACC,MAAAA,CAAIC,UAAU,2EAA2EE,IAAK/B,IAC/F2B,EAACC,MAAAA,CAAIC,UAAU,uEAAuEE,IAAK9B,IAE1Fb,GACGuC,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACC,MAAAA,CAAIC,UAAU,6EACXF,EAACK,EAAAA,CAAQC,KAAK,SAASC,QAAAA,IACtBT,GAAwCjC,EAAK2C,IAAI,8BAM1E"}
1
+ {"version":3,"file":"PaypalButtons.js","sources":["../../../../../src/components/PayPal/components/PaypalButtons.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport classnames from 'classnames';\nimport { getStyle } from '../utils/get-paypal-styles';\nimport Spinner from '../../internal/Spinner';\nimport useCoreContext from '../../../core/Context/useCoreContext';\n\nimport type { PayPalButtonsProps } from './types';\nimport type { FundingSource } from '../types';\n\nexport default function PaypalButtons({\n onInit,\n onApprove,\n onClick,\n onCancel,\n onError,\n onShippingAddressChange,\n onShippingOptionsChange,\n onSubmit,\n isProcessingPayment,\n paypalRef,\n style,\n ...props\n}: PayPalButtonsProps) {\n const { i18n } = useCoreContext();\n const isTokenize = props.configuration?.intent === 'tokenize';\n const paypalButtonRef = useRef<HTMLDivElement>(null);\n const creditButtonRef = useRef<HTMLDivElement>(null);\n const payLaterButtonRef = useRef<HTMLDivElement>(null);\n const venmoButtonRef = useRef<HTMLDivElement>(null);\n\n const createButton = (fundingSource: FundingSource, buttonRef) => {\n const configuration = {\n ...(isTokenize && { createBillingAgreement: onSubmit }),\n ...(!isTokenize && { createOrder: onSubmit }),\n ...(!isTokenize && fundingSource !== 'venmo' && onShippingAddressChange && { onShippingAddressChange }),\n ...(!isTokenize && fundingSource !== 'venmo' && onShippingOptionsChange && { onShippingOptionsChange }),\n fundingSource,\n style: getStyle(fundingSource, style),\n onInit,\n onClick,\n onCancel,\n onError,\n onApprove\n };\n\n const button = paypalRef.Buttons(configuration);\n\n if (button.isEligible()) {\n button.render(buttonRef.current);\n }\n };\n\n useEffect(() => {\n const { PAYPAL, CREDIT, PAYLATER, VENMO } = paypalRef.FUNDING;\n createButton(PAYPAL, paypalButtonRef);\n\n if (!props.blockPayPalCreditButton) createButton(CREDIT, creditButtonRef);\n if (!props.blockPayPalPayLaterButton) createButton(PAYLATER, payLaterButtonRef);\n if (!props.blockPayPalVenmoButton) createButton(VENMO, venmoButtonRef);\n }, []);\n\n const isProcessingPaymentWithoutReviewPage = props.commit === true;\n\n return (\n <div className={classnames('adyen-checkout__paypal__buttons', { 'adyen-checkout__paypal-processing': isProcessingPayment })}>\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--paypal\" ref={paypalButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--credit\" ref={creditButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--pay-later\" ref={payLaterButtonRef} />\n <div className=\"adyen-checkout__paypal__button adyen-checkout__paypal__button--venmo\" ref={venmoButtonRef} />\n\n {isProcessingPayment && (\n <div className=\"adyen-checkout__paypal\">\n <div className=\"adyen-checkout__paypal__status adyen-checkout__paypal__status--processing\">\n <Spinner size=\"medium\" inline />\n {isProcessingPaymentWithoutReviewPage && i18n.get('paypal.processingPayment')}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"names":["PaypalButtons","_param","props","onInit","onApprove","onClick","onCancel","onError","onShippingAddressChange","onShippingOptionsChange","onSubmit","isProcessingPayment","paypalRef","style","_object_without_properties","i18n","useCoreContext","isTokenize","configuration","intent","paypalButtonRef","useRef","creditButtonRef","payLaterButtonRef","venmoButtonRef","createButton","fundingSource","buttonRef","_object_spread_props","createBillingAgreement","createOrder","getStyle","button","Buttons","isEligible","render","current","useEffect","PAYPAL","CREDIT","PAYLATER","VENMO","FUNDING","blockPayPalCreditButton","blockPayPalPayLaterButton","blockPayPalVenmoButton","isProcessingPaymentWithoutReviewPage","commit","h","div","className","classnames","ref","Spinner","size","inline","get"],"mappings":"uyCAUe,SAASA,EAAcC,OAefC,GAfeC,OAClCA,EAAMC,UACNA,EAASC,QACTA,EAAOC,SACPA,EAAQC,QACRA,EAAOC,wBACPA,EAAuBC,wBACvBA,EAAuBC,SACvBA,EAAQC,oBACRA,EAAmBC,UACnBA,EAASC,MACTA,GAXkCZ,EAY/BC,EAZ+BY,EAAAb,EAAA,CAClCE,SACAC,YACAC,UACAC,WACAC,UACAC,0BACAC,0BACAC,WACAC,sBACAC,YACAC,UAGA,MAAME,KAAEA,GAASC,IACXC,EAA6C,cAAhCf,QAAAA,EAAAA,EAAMgB,qBAANhB,IAAAA,OAAAA,EAAAA,EAAqBiB,QAClCC,EAAkBC,EAAuB,MACzCC,EAAkBD,EAAuB,MACzCE,EAAoBF,EAAuB,MAC3CG,EAAiBH,EAAuB,MAExCI,EAAe,CAACC,EAA8BC,KAChD,MAAMT,EAAgBU,4UACdX,GAAc,CAAEY,uBAAwBnB,IACvCO,GAAc,CAAEa,YAAapB,IAC7BO,GAAgC,UAAlBS,GAA6BlB,GAA2B,CAAEA,4BACxES,GAAgC,UAAlBS,GAA6BjB,GAA2B,CAAEA,4BAAwB,CACrGiB,gBACAb,MAAOkB,EAASL,EAAeb,GAC/BV,SACAE,UACAC,WACAC,UACAH,cAGE4B,EAASpB,EAAUqB,QAAQf,GAE7Bc,EAAOE,cACPF,EAAOG,OAAOR,EAAUS,QAC5B,EAGJC,GAAU,KACN,MAAMC,OAAEA,EAAMC,OAAEA,EAAMC,SAAEA,EAAQC,MAAEA,GAAU7B,EAAU8B,QACtDjB,EAAaa,EAAQlB,GAEhBlB,EAAMyC,yBAAyBlB,EAAac,EAAQjB,GACpDpB,EAAM0C,2BAA2BnB,EAAae,EAAUjB,GACxDrB,EAAM2C,wBAAwBpB,EAAagB,EAAOjB,EAAAA,GACxD,IAEH,MAAMsB,GAAwD,IAAjB5C,EAAM6C,OAEnD,OACIC,EAACC,MAAAA,CAAIC,UAAWC,EAAW,kCAAmC,CAAE,oCAAqCxC,KACjGqC,EAACC,MAAAA,CAAIC,UAAU,wEAAwEE,IAAKhC,IAC5F4B,EAACC,MAAAA,CAAIC,UAAU,wEAAwEE,IAAK9B,IAC5F0B,EAACC,MAAAA,CAAIC,UAAU,2EAA2EE,IAAK7B,IAC/FyB,EAACC,MAAAA,CAAIC,UAAU,uEAAuEE,IAAK5B,IAE1Fb,GACGqC,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACC,MAAAA,CAAIC,UAAU,6EACXF,EAACK,EAAAA,CAAQC,KAAK,SAASC,QAAAA,IACtBT,GAAwC/B,EAAKyC,IAAI,8BAM1E"}
@@ -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 c from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as a}from"../utils.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,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(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={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[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:O,onSubmit:m}=s,j=u(s,["onApprove","onCancel","onChange","onError","onSubmit"]);const[g,d]=t("pending");this.setStatus=d;const h=r(((e,t)=>{d("processing"),y(e,t)}),[y]),v=()=>{d("ready")};return n((()=>{const e=a(j),t=i({},j.cspNonce&&{nonce:j.cspNonce}),r=i({},j.cspNonce&&{cspNonce:j.cspNonce}),n=new p(e,"body",t,r);return n.load().then(v),()=>{n.remove()}}),[]),"pending"===g?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(c,null))):e("div",{className:"adyen-checkout__paypal"},e(o,l(i({},j),{onCancel:f,onChange:b,onError:O,onSubmit:m,onApprove:h,isProcessingPayment:"processing"===g,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 c from"../../internal/Spinner/Spinner.js";import{getPaypalUrl as a}from"../utils/get-paypal-url.js";import p from"../../../utils/Script.js";function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(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){i(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,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(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={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(i){var{onApprove:y,onCancel:f,onChange:b,onError:O,onSubmit:m,onScriptLoadFailure:g}=i,j=u(i,["onApprove","onCancel","onChange","onError","onSubmit","onScriptLoadFailure"]);const[d,h]=t("pending");this.setStatus=h;const v=r(((e,t)=>{h("processing"),y(e,t)}),[y]),P=()=>{h("ready")},S=e=>{g(e)};return n((()=>{const e=a(j),t=s({},j.cspNonce&&{nonce:j.cspNonce}),r=s({},j.cspNonce&&{cspNonce:j.cspNonce}),n=new p(e,"body",t,r);return n.load().then(P).catch(S),()=>{n.remove()}}),[]),"pending"===d?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(c,null))):e("div",{className:"adyen-checkout__paypal"},e(o,l(s({},j),{onCancel:f,onChange:b,onError:O,onSubmit:m,onApprove:v,isProcessingPayment:"processing"===d,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';\nimport { PayPalComponentProps } from '../types';\nimport Script from '../../../utils/Script';\n\nexport default function PaypalComponent({ onApprove, onCancel, onChange, onError, onSubmit, ...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 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);\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","props","_object_without_properties","status","setStatus","useState","this","handleOnApprove","useCallback","data","actions","handlePaypalLoad","useEffect","src","getPaypalUrl","attributes","_object_spread","cspNonce","nonce","dataAttributes","script","Script","load","then","remove","h","div","className","aria-live","aria-busy","Spinner","PaypalButtons","isProcessingPayment","paypalRef","window","paypal"],"mappings":"klDAQe,SAASA,EAAgBC,GAAA,IAAAC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,QAAEA,EAAOC,SAAEA,GAA1CL,EAAuDM,EAAvDC,EAAAP,EAAA,CAAEC,YAAWC,WAAUC,WAAUC,UAASC,aAC9E,MAAOG,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,EAkBd,OAfAQ,GAAU,KACN,MAAMC,EAAMC,EAAab,GAEnBc,EAAaC,EAAA,GAAMf,EAAMgB,UAAY,CAAEC,MAAOjB,EAAMgB,WACtDE,EAAiBH,EAAA,CAAA,EAAMf,EAAMgB,UAAY,CAAEA,SAAUhB,EAAMgB,WAEzDG,EAAS,IAAIC,EAAOR,EAAK,OAAQE,EAAYI,GAInD,OAFAC,EAAOE,OAAOC,KAAKZ,GAEZ,KACHS,EAAOI,QAAM,CACjB,GACD,IAEY,YAAXrB,EAEIsB,EAACC,MAAAA,CAAIC,UAAU,yBAAyBC,YAAU,SAASC,YAAU,QACjEJ,EAACC,MAAAA,CAAIC,UAAU,0EACXF,EAACK,EAAAA,QAObL,EAACC,MAAAA,CAAIC,UAAU,0BACXF,EAACM,EACO9B,EAAAA,EAAAA,CAAAA,EAAAA,GAAAA,CACJJ,SAAUA,EACVC,SAAUA,EACVC,QAASA,EACTC,SAAUA,EACVJ,UAAWW,EACXyB,oBAAgC,eAAX7B,EACrB8B,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\">\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":"imDASe,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,2 +1,2 @@
1
- const n={environment:"TEST",status:"loading",userAction:"pay",merchantId:"",cspNonce:null,intent:null,commit:!0,vault:!1,style:{height:48},blockPayPalCreditButton:!1,blockPayPalPayLaterButton:!1,enableMessages:!1,blockPayPalVenmoButton:!1,isExpress:!1,configuration:{merchantId:"",intent:null},onInit:()=>{},onClick:()=>{},onError:()=>{},onShippingChange:()=>{}};export{n as default};
1
+ const t={isExpress:!1,userAction:"pay",commit:!0,vault:!1,enableMessages:!1,style:{height:50},blockPayPalCreditButton:!1,blockPayPalPayLaterButton:!1,blockPayPalVenmoButton:!1};export{t as default};
2
2
  //# sourceMappingURL=defaultProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../../../src/components/PayPal/defaultProps.ts"],"sourcesContent":["import { PayPalConfiguration } from './types';\n\nconst defaultProps: Partial<PayPalConfiguration> = {\n environment: 'TEST',\n status: 'loading',\n\n userAction: 'pay',\n\n // Config\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#merchant-id}\n */\n merchantId: '',\n\n /**\n * @see {@link https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-configuration/#csp-nonce}\n */\n cspNonce: null,\n\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#intent}\n */\n intent: null,\n\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#commit}\n */\n commit: true,\n\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#vault}\n */\n vault: false,\n\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/integration-features/customize-button/}\n */\n style: {\n /**\n * The height of the buttons is set to 48px to align with the default size of our Pay buttons.\n */\n height: 48\n },\n\n blockPayPalCreditButton: false,\n\n blockPayPalPayLaterButton: false,\n\n enableMessages: false,\n\n blockPayPalVenmoButton: false,\n\n isExpress: false,\n\n configuration: {\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#merchant-id}\n */\n merchantId: '',\n /**\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#intent}\n */\n intent: null\n },\n\n // Events\n onInit: () => {},\n onClick: () => {},\n onError: () => {},\n onShippingChange: () => {}\n};\n\nexport default defaultProps;\n"],"names":["defaultProps","environment","status","userAction","merchantId","cspNonce","intent","commit","vault","style","height","blockPayPalCreditButton","blockPayPalPayLaterButton","enableMessages","blockPayPalVenmoButton","isExpress","configuration","onInit","onClick","onError","onShippingChange"],"mappings":"AAEA,MAAMA,EAA6C,CAC/CC,YAAa,OACbC,OAAQ,UAERC,WAAY,MAMZC,WAAY,GAKZC,SAAU,KAKVC,OAAQ,KAKRC,QAAQ,EAKRC,OAAO,EAKPC,MAAO,CAIHC,OAAQ,IAGZC,yBAAyB,EAEzBC,2BAA2B,EAE3BC,gBAAgB,EAEhBC,wBAAwB,EAExBC,WAAW,EAEXC,cAAe,CAIXZ,WAAY,GAIZE,OAAQ,MAIZW,OAAQ,OACRC,QAAS,OACTC,QAAS,OACTC,iBAAkB"}
1
+ {"version":3,"file":"defaultProps.js","sources":["../../../../src/components/PayPal/defaultProps.ts"],"sourcesContent":["import { PayPalConfiguration } from './types';\n\nconst defaultProps: Partial<PayPalConfiguration> = {\n isExpress: false,\n userAction: 'pay',\n commit: true,\n vault: false,\n enableMessages: false,\n style: {\n height: 50 // The height of the buttons is set to 50px to align with the default size of our Pay buttons.\n },\n blockPayPalCreditButton: false,\n blockPayPalPayLaterButton: false,\n blockPayPalVenmoButton: false\n};\n\nexport default defaultProps;\n"],"names":["defaultProps","isExpress","userAction","commit","vault","enableMessages","style","height","blockPayPalCreditButton","blockPayPalPayLaterButton","blockPayPalVenmoButton"],"mappings":"AAEA,MAAMA,EAA6C,CAC/CC,WAAW,EACXC,WAAY,MACZC,QAAQ,EACRC,OAAO,EACPC,gBAAgB,EAChBC,MAAO,CACHC,OAAQ,IAEZC,yBAAyB,EACzBC,2BAA2B,EAC3BC,wBAAwB"}
@@ -1,2 +1,2 @@
1
- function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}const r=(r,n)=>{if(void 0===(null==r?void 0:r.address))return null;const{address:t,name:o}=r,a=((e=null,r=null)=>e&&r?`${e}, ${r}`:e||(r||null))(t.address_line_1,t.address_line_2);return function(r){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(n){e(r,n,t[n])}))}return r}({houseNumberOrName:"ZZ"},a&&{street:a},t.admin_area_1&&{stateOrProvince:t.admin_area_1},t.admin_area_2&&{city:t.admin_area_2},t.postal_code&&{postalCode:t.postal_code},t.country_code&&{country:t.country_code},n&&{firstName:o.full_name})};export{r as formatPaypalOrderContatcToAdyenFormat};
1
+ function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}const r=(r,n)=>{if(void 0===(null==r?void 0:r.address))return null;const{address:t,name:o}=r,a=((e=null,r=null)=>e&&r?`${e}, ${r}`:e||(r||null))(t.address_line_1,t.address_line_2);return function(r){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(n){e(r,n,t[n])}))}return r}({houseNumberOrName:"ZZ"},a&&{street:a},t.admin_area_1&&{stateOrProvince:t.admin_area_1},t.admin_area_2&&{city:t.admin_area_2},t.postal_code&&{postalCode:t.postal_code},t.country_code&&{country:t.country_code},n&&{firstName:o.full_name})};export{r as formatPaypalOrderContactToAdyenFormat};
2
2
  //# sourceMappingURL=format-paypal-order-contact-to-adyen-format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-paypal-order-contact-to-adyen-format.js","sources":["../../../../../src/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.ts"],"sourcesContent":["import { AddressData } from '../../../types/global-types';\n\n/**\n * This function formats PayPal contact format to Adyen address format\n */\nexport const formatPaypalOrderContatcToAdyenFormat = (paymentContact: any, isDeliveryAddress?: boolean): AddressData | null => {\n const getStreet = (addressPart1 = null, addressPart2 = null): string | null => {\n if (addressPart1 && addressPart2) return `${addressPart1}, ${addressPart2}`;\n if (addressPart1) return addressPart1;\n if (addressPart2) return addressPart2;\n return null;\n };\n\n if (paymentContact?.address === undefined) return null;\n\n const { address, name } = paymentContact;\n const street = getStreet(address.address_line_1, address.address_line_2);\n\n return {\n houseNumberOrName: 'ZZ',\n ...(street && { street }),\n ...(address.admin_area_1 && { stateOrProvince: address.admin_area_1 }),\n ...(address.admin_area_2 && { city: address.admin_area_2 }),\n ...(address.postal_code && { postalCode: address.postal_code }),\n ...(address.country_code && { country: address.country_code }),\n ...(isDeliveryAddress && {\n firstName: name.full_name\n })\n };\n};\n"],"names":["formatPaypalOrderContatcToAdyenFormat","paymentContact","isDeliveryAddress","undefined","address","name","street","addressPart1","addressPart2","getStreet","address_line_1","address_line_2","_object_spread","houseNumberOrName","admin_area_1","stateOrProvince","admin_area_2","city","postal_code","postalCode","country_code","country","firstName","full_name"],"mappings":"wHAKO,MAAMA,EAAwC,CAACC,EAAqBC,KAQvE,QAAgCC,KAA5BF,aAAAA,EAAAA,EAAgBG,SAAuB,OAAO,KAElD,MAAMA,QAAEA,EAAOC,KAAEA,GAASJ,EACpBK,EAVY,EAACC,EAAe,KAAMC,EAAe,OAC/CD,GAAgBC,EAAqB,GAAGD,MAAiBC,IACzDD,IACAC,GACG,MAMIC,CAAUL,EAAQM,eAAgBN,EAAQO,gBAEzD,6UAAOC,CAAA,CACHC,kBAAmB,MACfP,GAAU,CAAEA,UACZF,EAAQU,cAAgB,CAAEC,gBAAiBX,EAAQU,cACnDV,EAAQY,cAAgB,CAAEC,KAAMb,EAAQY,cACxCZ,EAAQc,aAAe,CAAEC,WAAYf,EAAQc,aAC7Cd,EAAQgB,cAAgB,CAAEC,QAASjB,EAAQgB,cAC3ClB,GAAqB,CACrBoB,UAAWjB,EAAKkB,WACpB"}
1
+ {"version":3,"file":"format-paypal-order-contact-to-adyen-format.js","sources":["../../../../../src/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.ts"],"sourcesContent":["import { AddressData } from '../../../types/global-types';\n\n/**\n * This function formats PayPal contact format to Adyen address format\n */\nexport const formatPaypalOrderContactToAdyenFormat = (paymentContact: any, isDeliveryAddress?: boolean): AddressData | null => {\n const getStreet = (addressPart1 = null, addressPart2 = null): string | null => {\n if (addressPart1 && addressPart2) return `${addressPart1}, ${addressPart2}`;\n if (addressPart1) return addressPart1;\n if (addressPart2) return addressPart2;\n return null;\n };\n\n if (paymentContact?.address === undefined) return null;\n\n const { address, name } = paymentContact;\n const street = getStreet(address.address_line_1, address.address_line_2);\n\n return {\n houseNumberOrName: 'ZZ',\n ...(street && { street }),\n ...(address.admin_area_1 && { stateOrProvince: address.admin_area_1 }),\n ...(address.admin_area_2 && { city: address.admin_area_2 }),\n ...(address.postal_code && { postalCode: address.postal_code }),\n ...(address.country_code && { country: address.country_code }),\n ...(isDeliveryAddress && {\n firstName: name.full_name\n })\n };\n};\n"],"names":["formatPaypalOrderContactToAdyenFormat","paymentContact","isDeliveryAddress","undefined","address","name","street","addressPart1","addressPart2","getStreet","address_line_1","address_line_2","_object_spread","houseNumberOrName","admin_area_1","stateOrProvince","admin_area_2","city","postal_code","postalCode","country_code","country","firstName","full_name"],"mappings":"wHAKO,MAAMA,EAAwC,CAACC,EAAqBC,KAQvE,QAAgCC,KAA5BF,aAAAA,EAAAA,EAAgBG,SAAuB,OAAO,KAElD,MAAMA,QAAEA,EAAOC,KAAEA,GAASJ,EACpBK,EAVY,EAACC,EAAe,KAAMC,EAAe,OAC/CD,GAAgBC,EAAqB,GAAGD,MAAiBC,IACzDD,IACAC,GACG,MAMIC,CAAUL,EAAQM,eAAgBN,EAAQO,gBAEzD,6UAAOC,CAAA,CACHC,kBAAmB,MACfP,GAAU,CAAEA,UACZF,EAAQU,cAAgB,CAAEC,gBAAiBX,EAAQU,cACnDV,EAAQY,cAAgB,CAAEC,KAAMb,EAAQY,cACxCZ,EAAQc,aAAe,CAAEC,WAAYf,EAAQc,aAC7Cd,EAAQgB,cAAgB,CAAEC,QAASjB,EAAQgB,cAC3ClB,GAAqB,CACrBoB,UAAWjB,EAAKkB,WACpB"}
@@ -0,0 +1,2 @@
1
+ import{SUPPORTED_LOCALES as n}from"../config.js";const l=l=>{const o=l?l.replace("-","_"):null;return n.includes(o)?o:null};export{l as getSupportedLocale};
2
+ //# sourceMappingURL=get-paypal-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-paypal-locale.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-locale.ts"],"sourcesContent":["import { SUPPORTED_LOCALES } from '../config';\nimport type { PayPalSupportedLocale } from './types';\n\n/**\n * Returns either a locale supported by PayPal or null, in order to let the PayPal SDK auto-detect the shopper locale.\n */\nexport const getSupportedLocale = (locale: string): PayPalSupportedLocale => {\n const formattedLocale = locale ? locale.replace('-', '_') : null;\n const supportedLocale = SUPPORTED_LOCALES.includes(formattedLocale as PayPalSupportedLocale) ? formattedLocale : null;\n return supportedLocale as PayPalSupportedLocale;\n};\n"],"names":["getSupportedLocale","locale","formattedLocale","replace","SUPPORTED_LOCALES","includes","supportedLocale"],"mappings":"iDAMaA,MAAAA,EAAsBC,IAC/B,MAAMC,EAAkBD,EAASA,EAAOE,QAAQ,IAAK,KAAO,KAE5D,OADwBC,EAAkBC,SAASH,GAA4CA,EAAkB,IAC1GI"}
@@ -0,0 +1,2 @@
1
+ import{getSupportedLocale as e}from"./get-paypal-locale.js";import{INTEGRATION_DATE as t,ADYEN_CLIENTID_TEST as r,ADYEN_CLIENTID_LIVE as n}from"../config.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const i=({amount:i,countryCode:u,debug:l,environment:a="",locale:b,configuration:s,commit:p,vault:y,enableMessages:f})=>{const O=e(b),g=i?i.currency:null,m="test"===a.toLowerCase(),j=m?r:n,{merchantId:d,intent:P}=s,w="buttons,funding-eligibility"+(f?",messages":"");return c(function(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){o(e,t,r[t])}))}return e}({},d&&{"merchant-id":d},O&&{locale:O},u&&m&&{"buyer-country":u},l&&m&&{debug:l},g&&{currency:g},P&&{intent:P}),{commit:p,vault:y,"client-id":j,"integration-date":t,"enable-funding":"paylater,venmo",components:w})};export{i as getPaypalSettings};
2
+ //# sourceMappingURL=get-paypal-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-paypal-settings.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-settings.ts"],"sourcesContent":["import { getSupportedLocale } from './get-paypal-locale';\nimport { ADYEN_CLIENTID_LIVE, ADYEN_CLIENTID_TEST, INTEGRATION_DATE } from '../config';\nimport type { PaypalSettings, PayPalSupportedLocale } from './types';\nimport type { PayPalComponentProps } from '../components/types';\n\n/**\n * Returns an object of settings for the PayPal SDK\n */\nexport const getPaypalSettings = ({\n amount,\n countryCode,\n debug,\n environment = '',\n locale,\n configuration,\n commit,\n vault,\n enableMessages\n}: Partial<PayPalComponentProps>): PaypalSettings => {\n const shopperLocale: PayPalSupportedLocale = getSupportedLocale(locale);\n const currency: string = amount ? amount.currency : null;\n const isTestEnvironment: boolean = environment.toLowerCase() === 'test';\n const clientId: string = isTestEnvironment ? ADYEN_CLIENTID_TEST : ADYEN_CLIENTID_LIVE;\n const { merchantId, intent } = configuration;\n const components = `buttons,funding-eligibility${enableMessages ? ',messages' : ''}`;\n\n return {\n ...(merchantId && { 'merchant-id': merchantId }),\n ...(shopperLocale && { locale: shopperLocale }),\n ...(countryCode && isTestEnvironment && { 'buyer-country': countryCode }),\n ...(debug && isTestEnvironment && { debug }),\n ...(currency && { currency }),\n ...(intent && { intent }),\n commit,\n vault,\n 'client-id': clientId,\n 'integration-date': INTEGRATION_DATE,\n 'enable-funding': 'paylater,venmo',\n components\n };\n};\n"],"names":["getPaypalSettings","amount","countryCode","debug","environment","locale","configuration","commit","vault","enableMessages","shopperLocale","getSupportedLocale","currency","isTestEnvironment","toLowerCase","clientId","ADYEN_CLIENTID_TEST","ADYEN_CLIENTID_LIVE","merchantId","intent","components","_object_spread_props","INTEGRATION_DATE"],"mappings":"ouBAQaA,EAAoB,EAC7BC,SACAC,cACAC,QACAC,cAAc,GACdC,SACAC,gBACAC,SACAC,QACAC,qBAEA,MAAMC,EAAuCC,EAAmBN,GAC1DO,EAAmBX,EAASA,EAAOW,SAAW,KAC9CC,EAA2D,SAA9BT,EAAYU,cACzCC,EAAmBF,EAAoBG,EAAsBC,GAC7DC,WAAEA,EAAUC,OAAEA,GAAWb,EACzBc,EAAa,+BAA8BX,EAAiB,YAAc,IAEhF,OAAOY,4UACCH,GAAc,CAAE,cAAeA,GAC/BR,GAAiB,CAAEL,OAAQK,GAC3BR,GAAeW,GAAqB,CAAE,gBAAiBX,GACvDC,GAASU,GAAqB,CAAEV,SAChCS,GAAY,CAAEA,YACdO,GAAU,CAAEA,WAAO,CACvBZ,SACAC,QACA,YAAaO,EACb,mBAAoBO,EACpB,iBAAkB,iBAClBF"}
@@ -0,0 +1,2 @@
1
+ import{SUPPORTED_COLORS_FOR_CREDIT as e}from"../config.js";function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const t=(t,n={})=>"paypal"===t?function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),o.forEach((function(t){r(e,t,n[t])}))}return e}({},n):Object.keys(n).reduce(((r,t)=>{const o=n[t];return("color"!==t||e.includes(o))&&(r[t]=o),r}),{});export{t as getStyle};
2
+ //# sourceMappingURL=get-paypal-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-paypal-styles.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-styles.ts"],"sourcesContent":["import { SUPPORTED_COLORS_FOR_CREDIT } from '../config';\nimport type { FundingSource } from '../types';\n\n/**\n * Processes and returns a new style object.\n */\nexport const getStyle = (fundingSource: FundingSource, style = {}) => {\n if (fundingSource === 'paypal') return { ...style };\n\n return Object.keys(style).reduce((acc, prop) => {\n const value = style[prop];\n if (prop !== 'color' || SUPPORTED_COLORS_FOR_CREDIT.includes(value)) {\n acc[prop] = value;\n }\n return acc;\n }, {});\n};\n"],"names":["getStyle","fundingSource","style","_object_spread","Object","keys","reduce","acc","prop","value","SUPPORTED_COLORS_FOR_CREDIT","includes"],"mappings":"mLAMaA,MAAAA,EAAW,CAACC,EAA8BC,EAAQ,CAAA,IACrC,WAAlBD,wUAAmCE,CAAKD,CAAAA,EAAAA,GAErCE,OAAOC,KAAKH,GAAOI,QAAO,CAACC,EAAKC,KACnC,MAAMC,EAAQP,EAAMM,GAIpB,OAHa,UAATA,GAAoBE,EAA4BC,SAASF,MACzDF,EAAIC,GAAQC,GAETF,CAAAA,GACR,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{getPaypalSettings as o}from"./get-paypal-settings.js";import{PAYPAL_JS_URL as t}from"../config.js";const e=e=>{const n=o(e),p=decodeURIComponent(Object.keys(n).map((o=>`${o}=${n[o]}`)).join("&"));return`${t}?${p}`};export{e as getPaypalUrl};
2
+ //# sourceMappingURL=get-paypal-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-paypal-url.js","sources":["../../../../../src/components/PayPal/utils/get-paypal-url.ts"],"sourcesContent":["import { getPaypalSettings } from './get-paypal-settings';\nimport { PAYPAL_JS_URL } from '../config';\nimport type { PayPalComponentProps } from '../components/types';\n\n/**\n * Returns the PayPal SDK script URL with query parameters\n * @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/}\n */\nexport const getPaypalUrl = (props: Partial<PayPalComponentProps>): string => {\n const settings = getPaypalSettings(props);\n const params = decodeURIComponent(\n Object.keys(settings)\n .map(key => `${key}=${settings[key]}`)\n .join('&')\n );\n return `${PAYPAL_JS_URL}?${params}`;\n};\n"],"names":["getPaypalUrl","props","settings","getPaypalSettings","params","decodeURIComponent","Object","keys","map","key","join","PAYPAL_JS_URL"],"mappings":"0GAQaA,MAAAA,EAAgBC,IACzB,MAAMC,EAAWC,EAAkBF,GAC7BG,EAASC,mBACXC,OAAOC,KAAKL,GACPM,KAAIC,GAAO,GAAGA,KAAOP,EAASO,OAC9BC,KAAK,MAEd,MAAO,GAAGC,KAAiBP,GAAQ"}
@@ -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 s from"../../internal/IssuerList/IssuerList.js";import r from"../../../utils/get-issuer-image.js";import{FALLBACK_CONTEXT as o}from"../../../core/config.js";import i from"../../../core/Context/CoreProvider.js";import n from"../../internal/RedirectButton/RedirectButton.js";import p from"../../../core/Errors/SRPanelProvider.js";function a(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function u(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),r.forEach((function(e){a(t,e,s[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class h extends e{formatProps(t){const e=t.details&&t.details.length&&(t.details.find((t=>"issuer"===t.key))||{}).items||t.issuers||[];return c(u({},t),{issuers:e})}formatData(){var t,e;return{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}}get isValid(){var t;return 0===this.props.issuers.length||!!(null===(t=this.state)||void 0===t?void 0:t.isValid)}get brands(){return this.props.showPaymentMethodItemImages?this.props.issuers.map((t=>({icon:t.icon,name:t.id}))):[]}render(){return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.issuers.length>0?t(p,{srPanel:this.props.modules.srPanel},t(s,c(u({ref:t=>{this.componentRef=t},items:this.props.issuers,highlightedIds:this.props.highlightedIssuers},this.props,this.state),{showImage:this.props.showImage,type:this.constructor.type,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,contextualText:this.props.i18n.get("issuerList.selectField.contextualText"),onSubmitAnalytics:this.submitAnalytics}))):this.props.showPayButton&&t(n,c(u({name:this.props.name},this.props),{onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})))}constructor(t,e){super(t,e);const s=t=>this.resources.getImage(t);if(this.props.showImage){const t=r({loadingContext:this.props.loadingContext},this.constructor.type,s);this.props.issuers=this.props.issuers.map((e=>c(u({},e),{icon:t(e.id)})))}}}a(h,"defaultProps",{showImage:!0,onValid:()=>{},issuers:[],highlightedIssuers:[],loadingContext:o,showPaymentMethodItemImages:!1});export{h as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import s from"../../internal/IssuerList/IssuerList.js";import r from"../../../utils/get-issuer-image.js";import{FALLBACK_CONTEXT as o}from"../../../core/config.js";import i from"../../../core/Context/CoreProvider.js";import n from"../../internal/RedirectButton/RedirectButton.js";import p from"../../../core/Errors/SRPanelProvider.js";function a(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function u(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),r.forEach((function(e){a(t,e,s[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class h extends e{formatProps(t){const e=t.details&&t.details.length&&(t.details.find((t=>"issuer"===t.key))||{}).items||t.issuers||[];return c(u({},t),{issuers:e})}formatData(){var t,e;return{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}}get isValid(){var t;return 0===this.props.issuers.length||!!(null===(t=this.state)||void 0===t?void 0:t.isValid)}get brands(){return this.props.showPaymentMethodItemImages?this.props.issuers.map((t=>({icon:t.icon,name:t.id}))):[]}render(){return t(i,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},this.props.issuers.length>0?t(p,{srPanel:this.props.modules.srPanel},t(s,c(u({ref:t=>{this.componentRef=t},items:this.props.issuers,highlightedIds:this.props.highlightedIssuers},this.props,this.state),{showImage:this.props.showImage,type:this.constructor.type,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,contextualText:this.props.i18n.get("issuerList.selectField.contextualText"),onSubmitAnalytics:this.submitAnalytics}))):this.props.showPayButton&&t(n,c(u({name:this.props.name},this.props),{onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})))}constructor(t,e){super(t,e);const s=t=>this.resources.getImage(t);if(this.props.showImage){const t=r({loadingContext:this.props.loadingContext},this.constructor.type,s);this.props.issuers=this.props.issuers.map((e=>c(u({},e),{icon:t(e.id)})))}}}a(h,"defaultProps",{showImage:!0,issuers:[],highlightedIssuers:[],loadingContext:o,showPaymentMethodItemImages:!1});export{h as default};
2
2
  //# sourceMappingURL=IssuerListContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListContainer.js","sources":["../../../../../src/components/helpers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport CoreProvider from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\n\nclass IssuerListContainer extends UIElement<IssuerListConfiguration> {\n protected static defaultProps = {\n showImage: true,\n onValid: () => {},\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: IssuerListConfiguration) {\n super(checkout, props);\n\n const getImage = props => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props) {\n const issuers = (props.details && props.details.length && (props.details.find(d => d.key === 'issuer') || {}).items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): IssuerListData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n };\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): { icon: any; name: string }[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.issuers.length > 0 ? (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <IssuerList\n ref={ref => {\n this.componentRef = ref;\n }}\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n ) : (\n this.props.showPayButton && (\n <RedirectButton\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n )\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","brands","showPaymentMethodItemImages","map","brand","icon","name","id","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","IssuerList","ref","componentRef","highlightedIds","highlightedIssuers","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","get","onSubmitAnalytics","submitAnalytics","showPayButton","RedirectButton","checkout","super","getImage","getIssuerIcon","getIssuerImageUrl","item","_define_property","defaultProps","onValid","FALLBACK_CONTEXT"],"mappings":"i2CAWA,MAAMA,UAA4BC,EAyB9BC,WAAAA,CAAYC,GACR,MAAMC,EAAWD,EAAME,SAAWF,EAAME,QAAQC,SAAWH,EAAME,QAAQE,MAAKC,GAAe,WAAVA,EAAEC,OAAqB,CAAC,GAAGC,OAAUP,EAAMC,SAAW,GACzI,OAAOO,EAAKR,EAAAA,CAAAA,EAAAA,GAAAA,CAAOC,WACvB,CAKAQ,UAAAA,OAIoBC,EAAAC,EA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,KAAKuB,aAAeD,CAAAA,KAOhD,CA/FAK,WAAAA,CAAYY,EAAiBrD,GACzBsD,MAAMD,EAAUrD,GAEhB,MAAMuD,EAAWvD,GAASc,KAAKiB,UAAUwB,SAASvD,GAElD,GAAIc,KAAKd,MAAMwC,UAAW,CACtB,MAAMgB,EAAgBC,EAAkB,CAAE3B,eAAgBhB,KAAKd,MAAM8B,gBAAkBhB,KAAK2B,iBAAqBc,GAEjHzC,KAAKd,MAAMC,QAAUa,KAAKd,MAAMC,QAAQoB,KAAIqC,GAASlD,EAC9CkD,EAAAA,CAAAA,EAAAA,GAAAA,CACHnC,KAAMiC,EAAcE,EAAKjC,OAEjC,CACJ,EAtBAkC,EADE9D,EACe+D,eAAe,CAC5BpB,WAAW,EACXqB,QAAS,OACT5D,QAAS,GACTsC,mBAAoB,GACpBT,eAAgBgC,EAChB1C,6BAA6B"}
1
+ {"version":3,"file":"IssuerListContainer.js","sources":["../../../../../src/components/helpers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport CoreProvider from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\n\nclass IssuerListContainer extends UIElement<IssuerListConfiguration> {\n protected static defaultProps = {\n showImage: true,\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: IssuerListConfiguration) {\n super(checkout, props);\n\n const getImage = props => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props) {\n const issuers = (props.details && props.details.length && (props.details.find(d => d.key === 'issuer') || {}).items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): IssuerListData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n };\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): { icon: any; name: string }[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.issuers.length > 0 ? (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <IssuerList\n ref={ref => {\n this.componentRef = ref;\n }}\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n ) : (\n this.props.showPayButton && (\n <RedirectButton\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n )\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","brands","showPaymentMethodItemImages","map","brand","icon","name","id","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","IssuerList","ref","componentRef","highlightedIds","highlightedIssuers","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","get","onSubmitAnalytics","submitAnalytics","showPayButton","RedirectButton","checkout","super","getImage","getIssuerIcon","getIssuerImageUrl","item","_define_property","defaultProps","FALLBACK_CONTEXT"],"mappings":"i2CAWA,MAAMA,UAA4BC,EAwB9BC,WAAAA,CAAYC,GACR,MAAMC,EAAWD,EAAME,SAAWF,EAAME,QAAQC,SAAWH,EAAME,QAAQE,MAAKC,GAAe,WAAVA,EAAEC,OAAqB,CAAC,GAAGC,OAAUP,EAAMC,SAAW,GACzI,OAAOO,EAAKR,EAAAA,CAAAA,EAAAA,GAAAA,CAAOC,WACvB,CAKAQ,UAAAA,OAIoBC,EAAAC,EAHhB,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKD,KACXE,OAAkB,QAAVJ,EAAAG,KAAKE,aAAL,IAAAL,GAAA,QAAAD,EAAAC,EAAYM,YAAZ,IAAAP,OAAA,EAAAA,EAAkBK,QAGtC,CAKA,WAAIG,GAIS,IAAAP,EAHT,OAAkC,IAA9BG,KAAKd,MAAMC,QAAQE,WAGJ,QAAVQ,EAAAG,KAAKE,aAAL,IAAAL,OAAA,EAAAA,EAAYO,QACzB,CAOA,UAAIC,GACA,OAAIL,KAAKd,MAAMoB,4BACJN,KAAKd,MAAMC,QAAQoB,KAAIC,IAEnB,CAAEC,KADSD,EAAMC,KACEC,KAAMF,EAAMG,OAIvC,EACX,CAEAC,MAAAA,GACI,OACIC,EAACC,EAAAA,CAAaC,KAAMf,KAAKd,MAAM6B,KAAMC,eAAgBhB,KAAKd,MAAM8B,eAAgBC,UAAWjB,KAAKiB,WAC3FjB,KAAKd,MAAMC,QAAQE,OAAS,EACzBwB,EAACK,EAAAA,CAAgBC,QAASnB,KAAKd,MAAMkC,QAAQD,SACzCN,EAACQ,EAAAA,EAAAA,EAAAA,CACGC,IAAKA,IACDtB,KAAKuB,aAAeD,CAAAA,EAExB7B,MAAOO,KAAKd,MAAMC,QAClBqC,eAAgBxB,KAAKd,MAAMuC,oBACvBzB,KAAKd,MACLc,KAAKE,OAAK,CACdwB,UAAW1B,KAAKd,MAAMwC,UACtB3B,KAAMC,KAAK2B,YAAmB,KAC9BC,SAAU5B,KAAK6B,SACfC,SAAU9B,KAAK+B,OACfC,UAAWhC,KAAKgC,UAChBC,eAAgBjC,KAAKd,MAAM6B,KAAKmB,IAAI,yCACpCC,kBAAmBnC,KAAKoC,oBAIhCpC,KAAKd,MAAMmD,eACPxB,EAACyB,EAAAA,EAAAA,EAAAA,CACG5B,KAAMV,KAAKd,MAAMwB,MACbV,KAAKd,OAAK,CACd4C,SAAU9B,KAAK+B,OACfC,UAAWhC,KAAKgC,UAChBV,IAAKA,IACDtB,KAAKuB,aAAeD,CAAAA,KAOhD,CA/FAK,WAAAA,CAAYY,EAAiBrD,GACzBsD,MAAMD,EAAUrD,GAEhB,MAAMuD,EAAWvD,GAASc,KAAKiB,UAAUwB,SAASvD,GAElD,GAAIc,KAAKd,MAAMwC,UAAW,CACtB,MAAMgB,EAAgBC,EAAkB,CAAE3B,eAAgBhB,KAAKd,MAAM8B,gBAAkBhB,KAAK2B,iBAAqBc,GAEjHzC,KAAKd,MAAMC,QAAUa,KAAKd,MAAMC,QAAQoB,KAAIqC,GAASlD,EAC9CkD,EAAAA,CAAAA,EAAAA,GAAAA,CACHnC,KAAMiC,EAAcE,EAAKjC,OAEjC,CACJ,EArBAkC,EADE9D,EACe+D,eAAe,CAC5BpB,WAAW,EACXvC,QAAS,GACTsC,mBAAoB,GACpBT,eAAgB+B,EAChBzC,6BAA6B"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{ANALYTICS_RENDERED_STR as n}from"../../../core/Analytics/constants.js";function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){s(t,e,r[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}class p{buildElementProps(t){this.props=this.formatProps(i({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}setState(t){this.state=i({},this.state,t)}get data(){var t,r;const o=e(this.props,"modules.risk.data"),n=!!(null===(t=e(this.props,"modules.analytics.getEnabled"))||void 0===t?void 0:t())?null===(r=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===r?void 0:r():"do-not-track",s=this.state.order||this.props.order,p=this.formatData();return p.paymentMethod&&n&&(p.paymentMethod.checkoutAttemptId=n),c(i({},o&&{riskData:{clientData:o}},s&&{order:{orderData:s.orderData,pspReference:s.pspReference}},p),{clientStateDataIndicator:!0})}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var s;(this._node&&this.unmount(),this._node=r,this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(s=this.constructor.analyticsType)&&void 0!==s?s:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:n})})));return this}update(t){return this.props=this.formatProps(i({},this.props,t)),this.state={},this.unmount().mount(this._node)}remount(e){if(!this._node)throw new Error("Component is not mounted.");const r=e||this.render();return t(r,this._node,null),this}unmount(){return this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){s(this,"_id",`${this.constructor.type}-${r()}`),s(this,"props",void 0),s(this,"state",{}),s(this,"_component",void 0),s(this,"_node",null),s(this,"core",void 0);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e)}}s(p,"defaultProps",{});export{p as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{ANALYTICS_RENDERED_STR as n}from"../../../core/Analytics/constants.js";function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){s(t,e,r[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}class p{buildElementProps(t){this.props=this.formatProps(i({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}setState(t){this.state=i({},this.state,t)}get data(){var t,r;const o=e(this.props,"modules.risk.data"),n=!!(null===(t=e(this.props,"modules.analytics.getEnabled"))||void 0===t?void 0:t())?null===(r=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===r?void 0:r():"do-not-track",s=this.state.order||this.props.order,p=this.formatData();return p.paymentMethod&&n&&(p.paymentMethod.checkoutAttemptId=n),c(i({},o&&{riskData:{clientData:o}},s&&{order:{orderData:s.orderData,pspReference:s.pspReference}},p),{clientStateDataIndicator:!0})}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var s;(this._node&&this.unmount(),this._node=r,this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(s=this.constructor.analyticsType)&&void 0!==s?s:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:n})})));return this}update(t){return this.props=this.formatProps(i({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){s(this,"_id",`${this.constructor.type}-${r()}`),s(this,"props",void 0),s(this,"state",{}),s(this,"_component",void 0),s(this,"_node",null),s(this,"core",void 0);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e)}}s(p,"defaultProps",{});export{p as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nclass BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n protected readonly core: ICore;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n *\n * TODO: Replace 'any' by type PaymentMethodData<T> - this change requires updating all payment methods,\n * properly adding the type of the formatData function\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const useAnalytics = !!getProp(this.props, 'modules.analytics.getEnabled')?.();\n const checkoutAttemptId = useAnalytics ? getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() : 'do-not-track';\n const order = this.state.order || this.props.order;\n\n const componentData = this.formatData();\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && (node as HTMLElement).offsetWidth,\n component: !this.props.isDropin ? this.constructor['analyticsType'] ?? this.constructor['type'] : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts an element and mounts it again on the same node i.e. allows mount w/o having to pass a node.\n * Should be \"private\" & undocumented (although being a public function is useful for testing).\n * Left in for legacy reasons\n */\n public remount(component?): this {\n if (!this._node) {\n throw new Error('Component is not mounted.');\n }\n\n const newComponent = component || this.render();\n\n render(newComponent, this._node, null);\n\n return this;\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","setState","newState","state","data","getProp","clientData","checkoutAttemptId","order","componentData","paymentMethod","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","type","ANALYTICS_RENDERED_STR","update","remount","newComponent","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance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AAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC5D,KAAKI,YAAmB,6DAIvEJ,KAAKmD,KAAOC,EACZpD,KAAKF,kBAAkBG,EAC3B,EAdAoD,EAVExD,EAUegE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nclass BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n protected readonly core: ICore;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n *\n * TODO: Replace 'any' by type PaymentMethodData<T> - this change requires updating all payment methods,\n * properly adding the type of the formatData function\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const useAnalytics = !!getProp(this.props, 'modules.analytics.getEnabled')?.();\n const checkoutAttemptId = useAnalytics ? getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() : 'do-not-track';\n const order = this.state.order || this.props.order;\n\n const componentData = this.formatData();\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && (node as HTMLElement).offsetWidth,\n component: !this.props.isDropin ? this.constructor['analyticsType'] ?? this.constructor['type'] : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","setState","newState","state","data","getProp","clientData","checkoutAttemptId","order","componentData","paymentMethod","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","type","ANALYTICS_RENDERED_STR","update","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","defaultProps"],"mappings":"gqCAsBA,MAAMA,EA0BQC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YA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