@adyen/adyen-web 6.9.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adyen.css +13 -13
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +54 -23
- package/dist/es/adyen.css +13 -13
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ApplePay/ApplePay.js +1 -1
- package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es/components/ApplePay/components/ApplePayButton.js +1 -1
- package/dist/es/components/ApplePay/components/ApplePayButton.js.map +1 -1
- package/dist/es/components/ApplePay/defaultProps.js +1 -1
- package/dist/es/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es/components/ApplePay/services/ApplePaySdkLoader.js +2 -0
- package/dist/es/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -0
- package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -0
- package/dist/es/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js +2 -0
- package/dist/es/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js.map +1 -0
- package/dist/es/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js +2 -0
- package/dist/es/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -0
- package/dist/es/components/ApplePay/utils/payment-request.js +2 -0
- package/dist/es/components/ApplePay/utils/payment-request.js.map +1 -0
- package/dist/es/components/ApplePay/utils/resolve-supported-version.js +2 -0
- package/dist/es/components/ApplePay/utils/resolve-supported-version.js.map +1 -0
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVCHint.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/internal/ExpandButton/ExpandButton.js +1 -1
- package/dist/es/components/internal/ExpandButton/ExpandButton.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/index.d.ts +54 -23
- package/dist/es/utils/inIframe.js +2 -0
- package/dist/es/utils/inIframe.js.map +1 -0
- package/dist/es-legacy/adyen.css +13 -13
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js +1 -1
- package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/services/ApplePaySdkLoader.js +2 -0
- package/dist/es-legacy/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/format-applepay-contact-to-adyen-format.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -0
- package/dist/es-legacy/components/ApplePay/utils/resolve-supported-version.js +2 -0
- package/dist/es-legacy/components/ApplePay/utils/resolve-supported-version.js.map +1 -0
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/internal/ExpandButton/ExpandButton.js +1 -1
- package/dist/es-legacy/components/internal/ExpandButton/ExpandButton.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/utils/inIframe.js +2 -0
- package/dist/es-legacy/utils/inIframe.js.map +1 -0
- package/package.json +12 -12
- package/styles/adyen.css +13 -13
- package/dist/es/components/ApplePay/ApplePayService.js.map +0 -1
- package/dist/es/components/ApplePay/config.js +0 -2
- package/dist/es/components/ApplePay/config.js.map +0 -1
- package/dist/es/components/ApplePay/payment-request.js +0 -2
- package/dist/es/components/ApplePay/payment-request.js.map +0 -1
- package/dist/es/components/ApplePay/utils.js +0 -2
- package/dist/es/components/ApplePay/utils.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/ApplePayService.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/config.js +0 -2
- package/dist/es-legacy/components/ApplePay/config.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/payment-request.js +0 -2
- package/dist/es-legacy/components/ApplePay/payment-request.js.map +0 -1
- package/dist/es-legacy/components/ApplePay/utils.js +0 -2
- package/dist/es-legacy/components/ApplePay/utils.js.map +0 -1
- /package/dist/es/components/ApplePay/{ApplePayService.js → services/ApplePayService.js} +0 -0
- /package/dist/es-legacy/components/ApplePay/{ApplePayService.js → services/ApplePayService.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import s from"./components/ApplePayButton.js";import
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import s from"./components/ApplePayButton.js";import i from"./services/ApplePayService.js";import o from"../../utils/base64.js";import r from"./defaultProps.js";import{httpPost as n}from"../../core/Services/http.js";import{preparePaymentRequest as a}from"./utils/payment-request.js";import p from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as l}from"../tx-variants.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as c}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as h,ANALYTICS_INSTANT_PAYMENT_BUTTON as u}from"../../core/Analytics/constants.js";import{resolveSupportedVersion as y}from"./utils/resolve-supported-version.js";import{formatApplePayContactToAdyenAddressFormat as m}from"./utils/format-applepay-contact-to-adyen-format.js";import{mapBrands as P}from"./utils/map-adyen-brands-to-applepay-brands.js";import A from"./services/ApplePaySdkLoader.js";function b(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class f extends t{formatProps(e){const t=e.brands?.length?P(e.brands):e.supportedNetworks;return{...e,configuration:e.configuration,supportedNetworks:t,buttonLocale:e.buttonLocale??e.i18n?.locale,totalPriceLabel:e.totalPriceLabel||e.configuration?.merchantName}}formatData(){const{applePayToken:e,billingAddress:t,deliveryAddress:s}=this.state,{isExpress:i}=this.props;return{paymentMethod:{type:f.type,applePayToken:e,...i&&{subtype:"express"}},...t&&{billingAddress:t},...s&&{deliveryAddress:s}}}submitAnalytics(e){super.submitAnalytics({...e},this.props)}get isValid(){return!0}async applePayCapabilities(e){const t=e||this.props.configuration.merchantId;try{return await this.sdkLoader.isSdkLoaded(),await(ApplePaySession?.applePayCapabilities(t))}catch(e){throw new p("ERROR","Apple Pay: Error when requesting applePayCapabilities()",{cause:e})}}async isAvailable(){if("https:"!==window.location.protocol)return Promise.reject(new p("IMPLEMENTATION_ERROR","Trying to start an Apple Pay session from an insecure document"));try{return await this.sdkLoader.isSdkLoaded(),ApplePaySession?.canMakePayments()?Promise.resolve():Promise.reject(new p("ERROR","Apple Pay is not available on this device"))}catch(e){return Promise.reject(new p("ERROR","Apple Pay SDK failed to load",{cause:e}))}}defineApplePayVersionNumber(){"https:"===window.location.protocol&&(this.applePayVersionNumber=this.props.version||y(14))}configureApplePayWebOptions(){if(window.ApplePayWebOptions){const{renderApplePayCodeAs:e,onApplePayCodeClose:t}=this.props;window.ApplePayWebOptions.set({renderApplePayCodeAs:e,...t&&{onApplePayCodeClose:t}})}}startSession(){const{onValidateMerchant:e,onPaymentMethodSelected:t,onShippingMethodSelected:s,onShippingContactSelected:o}=this.props,r=a({companyName:this.props.configuration.merchantName,countryCode:this.core.options.countryCode,...this.props}),n=new i(r,{version:this.applePayVersionNumber,onError:e=>{this.handleError(new p("ERROR","ApplePay - Something went wrong on ApplePayService",{cause:e}))},onCancel:e=>{this.handleError(new p("CANCEL","ApplePay UI dismissed",{cause:e}))},onPaymentMethodSelected:t,onShippingMethodSelected:s,onShippingContactSelected:o,onValidateMerchant:e||this.validateMerchant,onPaymentAuthorized:(e,t,s)=>{const i=m(s.payment.billingContact),o=m(s.payment.shippingContact,!0);this.setState({applePayToken:btoa(JSON.stringify(s.payment.token.paymentData)),authorizedEvent:s,...i&&{billingAddress:i},...o&&{deliveryAddress:o}}),this.handleAuthorization().then(this.makePaymentsCall).then(d).then(c).then(this.collectOrderTrackingDetailsIfNeeded).then((({paymentResponse:t,orderDetails:s})=>(e({status:ApplePaySession.STATUS_SUCCESS,...s&&{orderDetails:s}}),t))).then((e=>{this.handleResponse(e)})).catch((e=>{const s=e?.error?.applePayError;t({status:ApplePaySession.STATUS_FAILURE,errors:s?Array.isArray(s)?s:[s]:void 0});const i={...e,error:{applePayError:s}};this.handleFailedResult(i)}))}});return new Promise(((e,t)=>this.props.onClick(e,t))).then((()=>{n.begin()})).catch((()=>({})))}async handleAuthorization(){return new Promise(((e,t)=>{this.props.onAuthorized||e();const{authorizedEvent:s,billingAddress:i,deliveryAddress:o}=this.state;this.props.onAuthorized({authorizedEvent:s,...i&&{billingAddress:i},...o&&{deliveryAddress:o}},{resolve:e,reject:t})})).catch((e=>{const t={error:{applePayError:e}};return Promise.reject(t)}))}async collectOrderTrackingDetailsIfNeeded(e){return new Promise(((e,t)=>{if(!this.props.onOrderTrackingRequest)return e();this.props.onOrderTrackingRequest(e,t)})).then((t=>({paymentResponse:e,...t&&{orderDetails:t}}))).catch((()=>({paymentResponse:e})))}async validateMerchant(e,t){const{hostname:s}=window.location,{clientKey:i,configuration:r,loadingContext:a,initiative:p}=this.props,{merchantName:l,merchantId:d}=r,c={loadingContext:a,path:`v1/applePay/sessions?clientKey=${i}`},h={displayName:l,domainName:s,initiative:p,merchantIdentifier:d};try{const s=await n(c,h),i=o.decode(s.data);if(i.success){e(JSON.parse(i.data))}else t("Could not decode Apple Pay session")}catch(e){t("Could not get Apple Pay session")}}render(){return this.props.showPayButton?e(s,{buttonStyle:this.props.buttonColor,buttonType:this.props.buttonType,buttonLocale:this.props.buttonLocale,onClick:this.submit}):null}constructor(e,t){super(e,t),b(this,"sdkLoader",void 0),b(this,"applePayVersionNumber",void 0),b(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:h,target:u}),this.startSession()}));const{isExpress:s,onShippingContactSelected:i,onShippingMethodSelected:o}=this.props;if(!1===s&&(i||o))throw new p("IMPLEMENTATION_ERROR",'ApplePay - You must set "isExpress" flag to "true" in order to use "onShippingContactSelected" and/or "onShippingMethodSelected" callbacks');this.startSession=this.startSession.bind(this),this.submit=this.submit.bind(this),this.validateMerchant=this.validateMerchant.bind(this),this.collectOrderTrackingDetailsIfNeeded=this.collectOrderTrackingDetailsIfNeeded.bind(this),this.handleAuthorization=this.handleAuthorization.bind(this),this.defineApplePayVersionNumber=this.defineApplePayVersionNumber.bind(this),this.configureApplePayWebOptions=this.configureApplePayWebOptions.bind(this),this.sdkLoader=new A,this.sdkLoader.load().then(this.defineApplePayVersionNumber).then(this.configureApplePayWebOptions).catch((e=>{this.handleError(e)}))}}b(f,"type",l.applepay),b(f,"defaultProps",r);export{f as default};
|
|
2
2
|
//# sourceMappingURL=ApplePay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplePay.js","sources":["../../../../src/components/ApplePay/ApplePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ApplePayButton from './components/ApplePayButton';\nimport ApplePayService from './ApplePayService';\nimport base64 from '../../utils/base64';\nimport defaultProps from './defaultProps';\nimport { httpPost } from '../../core/Services/http';\nimport { APPLEPAY_SESSION_ENDPOINT } from './config';\nimport { preparePaymentRequest } from './payment-request';\nimport { resolveSupportedVersion, mapBrands, formatApplePayContactToAdyenAddressFormat } from './utils';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { DecodeObject } from '../../types/global-types';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\nimport { ANALYTICS_INSTANT_PAYMENT_BUTTON, ANALYTICS_SELECTED_STR } from '../../core/Analytics/constants';\n\nimport type { ApplePayConfiguration, ApplePayElementData, ApplePayPaymentOrderDetails, ApplePaySessionRequest } from './types';\nimport type { ICore } from '../../core/types';\nimport type { PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport { SendAnalyticsObject } from '../../core/Analytics/types';\n\nconst latestSupportedVersion = 14;\n\nclass ApplePayElement extends UIElement<ApplePayConfiguration> {\n public static type = TxVariants.applepay;\n protected static defaultProps = defaultProps;\n\n constructor(checkout: ICore, props?: ApplePayConfiguration) {\n super(checkout, props);\n\n const { isExpress, onShippingContactSelected, onShippingMethodSelected } = this.props;\n\n if (isExpress === false && (onShippingContactSelected || onShippingMethodSelected)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'ApplePay - You must set \"isExpress\" flag to \"true\" in order to use \"onShippingContactSelected\" and/or \"onShippingMethodSelected\" callbacks'\n );\n }\n\n this.startSession = this.startSession.bind(this);\n this.submit = this.submit.bind(this);\n this.validateMerchant = this.validateMerchant.bind(this);\n this.collectOrderTrackingDetailsIfNeeded = this.collectOrderTrackingDetailsIfNeeded.bind(this);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n }\n\n /**\n * Formats the component props\n */\n protected override formatProps(props) {\n const version = props.version || resolveSupportedVersion(latestSupportedVersion);\n const supportedNetworks = props.brands?.length ? mapBrands(props.brands) : props.supportedNetworks;\n\n return {\n ...props,\n configuration: props.configuration,\n supportedNetworks,\n version,\n totalPriceLabel: props.totalPriceLabel || props.configuration?.merchantName\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData(): ApplePayElementData {\n const { applePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: ApplePayElement.type,\n applePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n // Analytics will need to know about this.props.isExpress & this.props.expressPage\n super.submitAnalytics({ ...analyticsObj }, this.props);\n }\n\n public override submit = (): void => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n void this.startSession();\n };\n\n private startSession() {\n const { version, onValidateMerchant, onPaymentMethodSelected, onShippingMethodSelected, onShippingContactSelected } = this.props;\n\n const paymentRequest = preparePaymentRequest({\n companyName: this.props.configuration.merchantName,\n countryCode: this.core.options.countryCode,\n ...this.props\n });\n\n const session = new ApplePayService(paymentRequest, {\n version,\n onError: (error: unknown) => {\n this.handleError(\n new AdyenCheckoutError('ERROR', 'ApplePay - Something went wrong on ApplePayService', {\n cause: error\n })\n );\n },\n onCancel: event => {\n this.handleError(new AdyenCheckoutError('CANCEL', 'ApplePay UI dismissed', { cause: event }));\n },\n onPaymentMethodSelected,\n onShippingMethodSelected,\n onShippingContactSelected,\n onValidateMerchant: onValidateMerchant || this.validateMerchant,\n onPaymentAuthorized: (resolve, reject, event) => {\n const billingAddress = formatApplePayContactToAdyenAddressFormat(event.payment.billingContact);\n const deliveryAddress = formatApplePayContactToAdyenAddressFormat(event.payment.shippingContact, true);\n\n this.setState({\n applePayToken: btoa(JSON.stringify(event.payment.token.paymentData)),\n authorizedEvent: event,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.collectOrderTrackingDetailsIfNeeded)\n .then(({ paymentResponse, orderDetails }) => {\n resolve({\n status: ApplePaySession.STATUS_SUCCESS,\n ...(orderDetails && { orderDetails })\n });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n const errors = paymentResponse?.error?.applePayError;\n\n reject({\n status: ApplePaySession.STATUS_FAILURE,\n errors: errors ? (Array.isArray(errors) ? errors : [errors]) : undefined\n });\n\n const responseWithError: RawPaymentResponse = {\n ...paymentResponse,\n error: {\n applePayError: errors\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n }\n });\n\n return new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => {\n session.begin();\n })\n .catch(() => ({\n // Swallow exception triggered by onClick reject\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\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?: ApplePayJS.ApplePayError) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { applePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Verify if the 'onOrderTrackingRequest' is provided. If so, triggers the callback expecting an\n * Apple Pay order details back\n *\n * @private\n */\n private async collectOrderTrackingDetailsIfNeeded(\n paymentResponse: PaymentResponseData\n ): Promise<{ orderDetails?: ApplePayPaymentOrderDetails; paymentResponse: PaymentResponseData }> {\n return new Promise<ApplePayPaymentOrderDetails | void>((resolve, reject) => {\n if (!this.props.onOrderTrackingRequest) {\n return resolve();\n }\n\n this.props.onOrderTrackingRequest(resolve, reject);\n })\n .then(orderDetails => {\n return {\n paymentResponse,\n ...(orderDetails && { orderDetails })\n };\n })\n .catch(() => {\n return { paymentResponse };\n });\n }\n\n private async validateMerchant(resolve, reject) {\n const { hostname: domainName } = window.location;\n const { clientKey, configuration, loadingContext, initiative } = this.props;\n const { merchantName, merchantId } = configuration;\n const path = `${APPLEPAY_SESSION_ENDPOINT}?clientKey=${clientKey}`;\n const options = { loadingContext, path };\n const request: ApplePaySessionRequest = {\n displayName: merchantName,\n domainName,\n initiative,\n merchantIdentifier: merchantId\n };\n\n try {\n const response = await httpPost(options, request);\n const decodedData: DecodeObject = base64.decode(response.data);\n if (!decodedData.success) {\n reject('Could not decode Apple Pay session');\n } else {\n const session = JSON.parse(decodedData.data);\n resolve(session);\n }\n } catch (e) {\n reject('Could not get Apple Pay session');\n }\n }\n\n /**\n * Validation\n *\n * @remarks\n * Apple Pay does not require any specific validation\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from Apple Pay.\n * @returns Promise Resolve/Reject whether the shopper can use Apple Pay\n */\n public override async isAvailable(): Promise<void> {\n if (document.location.protocol !== 'https:') {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'Trying to start an Apple Pay session from an insecure document'));\n }\n\n if (!this.props.onValidateMerchant && !this.props.clientKey) {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'clientKey was not provided'));\n }\n\n try {\n if (window.ApplePaySession && ApplePaySession.canMakePayments() && ApplePaySession.supportsVersion(this.props.version)) {\n return Promise.resolve();\n }\n } catch (error) {\n console.warn(error);\n }\n\n return Promise.reject(new AdyenCheckoutError('ERROR', 'Apple Pay is not available on this device'));\n }\n\n /**\n * Renders the Apple Pay button or nothing in the Dropin\n */\n render() {\n if (this.props.showPayButton) {\n return (\n <ApplePayButton\n i18n={this.props.i18n}\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n onClick={e => {\n e.preventDefault();\n this.submit();\n }}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default ApplePayElement;\n"],"names":["ApplePayElement","UIElement","formatProps","props","version","resolveSupportedVersion","supportedNetworks","brands","length","mapBrands","configuration","totalPriceLabel","merchantName","formatData","applePayToken","billingAddress","deliveryAddress","this","state","isExpress","paymentMethod","type","subtype","submitAnalytics","analyticsObj","super","startSession","onValidateMerchant","onPaymentMethodSelected","onShippingMethodSelected","onShippingContactSelected","paymentRequest","preparePaymentRequest","companyName","countryCode","core","options","session","ApplePayService","onError","error","handleError","AdyenCheckoutError","cause","onCancel","event","validateMerchant","onPaymentAuthorized","resolve","reject","formatApplePayContactToAdyenAddressFormat","payment","billingContact","shippingContact","setState","btoa","JSON","stringify","token","paymentData","authorizedEvent","handleAuthorization","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","collectOrderTrackingDetailsIfNeeded","paymentResponse","orderDetails","status","ApplePaySession","STATUS_SUCCESS","handleResponse","catch","errors","applePayError","STATUS_FAILURE","Array","isArray","undefined","responseWithError","handleFailedResult","Promise","onClick","begin","onAuthorized","data","onOrderTrackingRequest","hostname","domainName","window","location","clientKey","loadingContext","initiative","merchantId","path","APPLEPAY_SESSION_ENDPOINT","request","displayName","merchantIdentifier","response","httpPost","decodedData","base64","decode","success","parse","e","isValid","isAvailable","document","protocol","canMakePayments","supportsVersion","console","warn","render","showPayButton","h","ApplePayButton","i18n","buttonColor","buttonType","preventDefault","submit","constructor","checkout","_define_property","isInstantPayment","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","bind","TxVariants","applepay","defaultProps"],"mappings":"y+BAuBA,MAAMA,UAAwBC,EA0BPC,WAAAA,CAAYC,GAC3B,MAAMC,EAAUD,EAAMC,SAAWC,EA7BV,IA8BjBC,EAAoBH,EAAMI,QAAQC,OAASC,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AK4G,QAAM,IAMpB,IACX,CA1RAC,WAAAA,CAAYC,EAAiB5H,GACzBsB,MAAMsG,EAAU5H,GAyDpB6H,EAAA/G,KAAgB4G,UAAS,KAEjB5G,KAAKd,MAAM8H,kBACXhH,KAAKM,gBAAgB,CAAEF,KAAM6G,EAAwBC,OAAQC,IAE5DnH,KAAKS,cAAY,IA5DtB,MAAMP,UAAEA,EAASW,0BAAEA,EAAyBD,yBAAEA,GAA6BZ,KAAKd,MAEhF,IAAkB,IAAdgB,IAAwBW,GAA6BD,GACrD,MAAM,IAAIa,EACN,uBACA,8IAIRzB,KAAKS,aAAeT,KAAKS,aAAa2G,KAAKpH,MAC3CA,KAAK4G,OAAS5G,KAAK4G,OAAOQ,KAAKpH,MAC/BA,KAAK6B,iBAAmB7B,KAAK6B,iBAAiBuF,KAAKpH,MACnDA,KAAKiD,oCAAsCjD,KAAKiD,oCAAoCmE,KAAKpH,MACzFA,KAAK4C,oBAAsB5C,KAAK4C,oBAAoBwE,KAAKpH,KAC7D,EApBA+G,EADEhI,EACYqB,OAAOiH,EAAWC,UAChCP,EAFEhI,EAEewI,eAAeA"}
|
|
1
|
+
{"version":3,"file":"ApplePay.js","sources":["../../../../src/components/ApplePay/ApplePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport ApplePayButton from './components/ApplePayButton';\nimport ApplePayService from './services/ApplePayService';\nimport base64 from '../../utils/base64';\nimport defaultProps from './defaultProps';\nimport { httpPost } from '../../core/Services/http';\nimport { preparePaymentRequest } from './utils/payment-request';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { DecodeObject } from '../../types/global-types';\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 { resolveSupportedVersion } from './utils/resolve-supported-version';\nimport { formatApplePayContactToAdyenAddressFormat } from './utils/format-applepay-contact-to-adyen-format';\nimport { mapBrands } from './utils/map-adyen-brands-to-applepay-brands';\nimport ApplePaySdkLoader from './services/ApplePaySdkLoader';\n\nimport type { SendAnalyticsObject } from '../../core/Analytics/types';\nimport type { ApplePayConfiguration, ApplePayElementData, ApplePayPaymentOrderDetails, ApplePaySessionRequest } from './types';\nimport type { ICore } from '../../core/types';\nimport type { PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\n\nconst LATEST_APPLE_PAY_VERSION = 14;\n\nclass ApplePayElement extends UIElement<ApplePayConfiguration> {\n public static type = TxVariants.applepay;\n\n protected static defaultProps = defaultProps;\n\n private sdkLoader: ApplePaySdkLoader;\n private applePayVersionNumber: number = undefined;\n\n constructor(checkout: ICore, props?: ApplePayConfiguration) {\n super(checkout, props);\n\n const { isExpress, onShippingContactSelected, onShippingMethodSelected } = this.props;\n\n if (isExpress === false && (onShippingContactSelected || onShippingMethodSelected)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'ApplePay - You must set \"isExpress\" flag to \"true\" in order to use \"onShippingContactSelected\" and/or \"onShippingMethodSelected\" callbacks'\n );\n }\n\n this.startSession = this.startSession.bind(this);\n this.submit = this.submit.bind(this);\n this.validateMerchant = this.validateMerchant.bind(this);\n this.collectOrderTrackingDetailsIfNeeded = this.collectOrderTrackingDetailsIfNeeded.bind(this);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n this.defineApplePayVersionNumber = this.defineApplePayVersionNumber.bind(this);\n this.configureApplePayWebOptions = this.configureApplePayWebOptions.bind(this);\n\n this.sdkLoader = new ApplePaySdkLoader();\n\n void this.sdkLoader\n .load()\n .then(this.defineApplePayVersionNumber)\n .then(this.configureApplePayWebOptions)\n .catch(error => {\n this.handleError(error);\n });\n }\n\n /**\n * Formats the component props\n */\n protected override formatProps(props): ApplePayConfiguration {\n const supportedNetworks = props.brands?.length ? mapBrands(props.brands) : props.supportedNetworks;\n\n return {\n ...props,\n configuration: props.configuration,\n supportedNetworks,\n buttonLocale: props.buttonLocale ?? props.i18n?.locale,\n totalPriceLabel: props.totalPriceLabel || props.configuration?.merchantName\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData(): ApplePayElementData {\n const { applePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: ApplePayElement.type,\n applePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n // Analytics will need to know about this.props.isExpress & this.props.expressPage\n super.submitAnalytics({ ...analyticsObj }, this.props);\n }\n\n public override submit = (): void => {\n // Analytics\n if (this.props.isInstantPayment) {\n this.submitAnalytics({ type: ANALYTICS_SELECTED_STR, target: ANALYTICS_INSTANT_PAYMENT_BUTTON });\n }\n void this.startSession();\n };\n\n public get isValid(): boolean {\n return true;\n }\n\n /**\n * This API is only intended for upstreaming or defaulting to Apple Pay, all other scenarios should continue to\n * use canMakePayments(). For Safari browsers, this API will indicate whether there is a card available to make\n * payments. For third-party browsers a new status of paymentCredentialStatusUnknown will be returned. This does\n * not mean there are no cards available, it means the status cannot be determined and as such defaulting\n * and upstreaming should still be considered.\n *\n * {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/4440085-applepaycapabilities}\n * @param merchantIdentifier\n */\n public async applePayCapabilities(merchantIdentifier?: string): Promise<ApplePayJS.PaymentCredentialStatusResponse> {\n const identifier = merchantIdentifier || this.props.configuration.merchantId;\n\n try {\n await this.sdkLoader.isSdkLoaded();\n return await ApplePaySession?.applePayCapabilities(identifier);\n } catch (error) {\n throw new AdyenCheckoutError('ERROR', 'Apple Pay: Error when requesting applePayCapabilities()', { cause: error });\n }\n }\n\n /**\n * Determines if Apple Pay component can be displayed or not\n */\n public override async isAvailable(): Promise<void> {\n if (window.location.protocol !== 'https:') {\n return Promise.reject(new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'Trying to start an Apple Pay session from an insecure document'));\n }\n\n try {\n await this.sdkLoader.isSdkLoaded();\n\n if (ApplePaySession?.canMakePayments()) {\n return Promise.resolve();\n }\n\n return Promise.reject(new AdyenCheckoutError('ERROR', 'Apple Pay is not available on this device'));\n } catch (error) {\n return Promise.reject(new AdyenCheckoutError('ERROR', 'Apple Pay SDK failed to load', { cause: error }));\n }\n }\n\n /**\n * Sets the Apple Pay version available for the shopper.\n * This code needs to be executed once the Apple Pay SDK is fully loaded\n * @private\n */\n private defineApplePayVersionNumber() {\n if (window.location.protocol !== 'https:') return;\n this.applePayVersionNumber = this.props.version || resolveSupportedVersion(LATEST_APPLE_PAY_VERSION);\n }\n\n /**\n * Sets the configuration/callbacks that pertain to the Apple Pay code overlay/modal.\n * @private\n */\n private configureApplePayWebOptions() {\n if (window.ApplePayWebOptions) {\n const { renderApplePayCodeAs, onApplePayCodeClose } = this.props;\n\n window.ApplePayWebOptions.set({\n renderApplePayCodeAs,\n ...(onApplePayCodeClose && { onApplePayCodeClose })\n });\n }\n }\n\n private startSession() {\n const { onValidateMerchant, onPaymentMethodSelected, onShippingMethodSelected, onShippingContactSelected } = this.props;\n\n const paymentRequest = preparePaymentRequest({\n companyName: this.props.configuration.merchantName,\n countryCode: this.core.options.countryCode,\n ...this.props\n });\n\n const session = new ApplePayService(paymentRequest, {\n version: this.applePayVersionNumber,\n onError: (error: unknown) => {\n this.handleError(\n new AdyenCheckoutError('ERROR', 'ApplePay - Something went wrong on ApplePayService', {\n cause: error\n })\n );\n },\n onCancel: event => {\n this.handleError(new AdyenCheckoutError('CANCEL', 'ApplePay UI dismissed', { cause: event }));\n },\n onPaymentMethodSelected,\n onShippingMethodSelected,\n onShippingContactSelected,\n onValidateMerchant: onValidateMerchant || this.validateMerchant,\n onPaymentAuthorized: (resolve, reject, event) => {\n const billingAddress = formatApplePayContactToAdyenAddressFormat(event.payment.billingContact);\n const deliveryAddress = formatApplePayContactToAdyenAddressFormat(event.payment.shippingContact, true);\n\n this.setState({\n applePayToken: btoa(JSON.stringify(event.payment.token.paymentData)),\n authorizedEvent: event,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.collectOrderTrackingDetailsIfNeeded)\n .then(({ paymentResponse, orderDetails }) => {\n resolve({\n status: ApplePaySession.STATUS_SUCCESS,\n ...(orderDetails && { orderDetails })\n });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n const errors = paymentResponse?.error?.applePayError;\n\n reject({\n status: ApplePaySession.STATUS_FAILURE,\n errors: errors ? (Array.isArray(errors) ? errors : [errors]) : undefined\n });\n\n const responseWithError: RawPaymentResponse = {\n ...paymentResponse,\n error: {\n applePayError: errors\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n }\n });\n\n return new Promise((resolve, reject) => this.props.onClick(resolve, reject))\n .then(() => {\n session.begin();\n })\n .catch(() => ({\n // Swallow exception triggered by onClick reject\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\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?: ApplePayJS.ApplePayError) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { applePayError: error } };\n return Promise.reject(data);\n });\n }\n\n /**\n * Verify if the 'onOrderTrackingRequest' is provided. If so, triggers the callback expecting an\n * Apple Pay order details back\n *\n * @private\n */\n private async collectOrderTrackingDetailsIfNeeded(\n paymentResponse: PaymentResponseData\n ): Promise<{ orderDetails?: ApplePayPaymentOrderDetails; paymentResponse: PaymentResponseData }> {\n return new Promise<ApplePayPaymentOrderDetails | void>((resolve, reject) => {\n if (!this.props.onOrderTrackingRequest) {\n return resolve();\n }\n\n this.props.onOrderTrackingRequest(resolve, reject);\n })\n .then(orderDetails => {\n return {\n paymentResponse,\n ...(orderDetails && { orderDetails })\n };\n })\n .catch(() => {\n return { paymentResponse };\n });\n }\n\n private async validateMerchant(resolve, reject) {\n const { hostname: domainName } = window.location;\n const { clientKey, configuration, loadingContext, initiative } = this.props;\n const { merchantName, merchantId } = configuration;\n const path = `v1/applePay/sessions?clientKey=${clientKey}`;\n const options = { loadingContext, path };\n const request: ApplePaySessionRequest = {\n displayName: merchantName,\n domainName,\n initiative,\n merchantIdentifier: merchantId\n };\n\n try {\n const response = await httpPost(options, request);\n const decodedData: DecodeObject = base64.decode(response.data);\n if (!decodedData.success) {\n reject('Could not decode Apple Pay session');\n } else {\n const session = JSON.parse(decodedData.data);\n resolve(session);\n }\n } catch (e) {\n reject('Could not get Apple Pay session');\n }\n }\n\n render() {\n if (!this.props.showPayButton) {\n return null;\n }\n\n return (\n <ApplePayButton\n buttonStyle={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonLocale={this.props.buttonLocale}\n onClick={this.submit}\n />\n );\n }\n}\n\nexport default ApplePayElement;\n"],"names":["ApplePayElement","UIElement","formatProps","props","supportedNetworks","brands","length","mapBrands","configuration","buttonLocale","i18n","locale","totalPriceLabel","merchantName","formatData","applePayToken","billingAddress","deliveryAddress","this","state","isExpress","paymentMethod","type","subtype","submitAnalytics","analyticsObj","super","isValid","applePayCapabilities","merchantIdentifier","identifier","merchantId","sdkLoader","isSdkLoaded","ApplePaySession","error","AdyenCheckoutError","cause","isAvailable","window","location","protocol","Promise","reject","canMakePayments","resolve","defineApplePayVersionNumber","applePayVersionNumber","version","resolveSupportedVersion","configureApplePayWebOptions","ApplePayWebOptions","renderApplePayCodeAs","onApplePayCodeClose","set","startSession","onValidateMerchant","onPaymentMethodSelected","onShippingMethodSelected","onShippingContactSelected","paymentRequest","preparePaymentRequest","companyName","countryCode","core","options","session","ApplePayService","onError","handleError","onCancel","event","validateMerchant","onPaymentAuthorized","formatApplePayContactToAdyenAddressFormat","payment","billingContact","shippingContact","setState","btoa","JSON","stringify","token","paymentData","authorizedEvent","handleAuthorization","then","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","collectOrderTrackingDetailsIfNeeded","paymentResponse","orderDetails","status","STATUS_SUCCESS","handleResponse","catch","errors","applePayError","STATUS_FAILURE","Array","isArray","undefined","responseWithError","handleFailedResult","onClick","begin","onAuthorized","data","onOrderTrackingRequest","hostname","domainName","clientKey","loadingContext","initiative","path","request","displayName","response","httpPost","decodedData","base64","decode","success","parse","e","render","showPayButton","h","ApplePayButton","buttonStyle","buttonColor","buttonType","submit","constructor","checkout","_define_property","isInstantPayment","ANALYTICS_SELECTED_STR","target","ANALYTICS_INSTANT_PAYMENT_BUTTON","bind","ApplePaySdkLoader","load","TxVariants","applepay","defaultProps"],"mappings":"qoCAyBA,MAAMA,UAAwBC,EA0CPC,WAAAA,CAAYC,GAC3B,MAAMC,EAAoBD,EAAME,QAAQC,OAASC,EAAUJ,EAAME,QAAUF,EAAMC,kBAEjF,MAAO,IACAD,EACHK,cAAeL,EAAMK,cACrBJ,oBACAK,aAAcN,EAAMM,cAAgBN,EAAMO,MAAMC,OAChDC,gBAAiBT,EAAMS,iBAAmBT,EAAMK,eAAeK,aAEvE,CAKA,UAAAC,GACI,MAAMC,cAAEA,EAAaC,eAAEA,EAAcC,gBAAEA,GAAoBC,KAAKC,OAC1DC,UAAEA,GAAcF,KAAKf,MAE3B,MAAO,CACHkB,cAAe,CACXC,KAAMtB,EAAgBsB,KACtBP,mBACIK,GAAa,CAAEG,QAAS,eAE5BP,GAAkB,CAAEA,qBACpBC,GAAmB,CAAEA,mBAE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CApUAC,WAAAA,CAAYC,EAAiBpI,GACzBuB,MAAM6G,EAAUpI,GAJpBqI,EAAQxG,KAAAA,iBAAR,GACAwG,EAAQzF,KAAAA,6BAAgCuD,GAuExCkC,EAAAtH,KAAgBmH,UAAS,KAEjBnH,KAAKf,MAAMsI,kBACXvH,KAAKM,gBAAgB,CAAEF,KAAMoH,EAAwBC,OAAQC,IAE5D1H,KAAKqC,cAAY,IAvEtB,MAAMnC,UAAEA,EAASuC,0BAAEA,EAAyBD,yBAAEA,GAA6BxC,KAAKf,MAEhF,IAAkB,IAAdiB,IAAwBuC,GAA6BD,GACrD,MAAM,IAAItB,EACN,uBACA,8IAIRlB,KAAKqC,aAAerC,KAAKqC,aAAasF,KAAK3H,MAC3CA,KAAKmH,OAASnH,KAAKmH,OAAOQ,KAAK3H,MAC/BA,KAAKsD,iBAAmBtD,KAAKsD,iBAAiBqE,KAAK3H,MACnDA,KAAKwE,oCAAsCxE,KAAKwE,oCAAoCmD,KAAK3H,MACzFA,KAAKmE,oBAAsBnE,KAAKmE,oBAAoBwD,KAAK3H,MACzDA,KAAK4B,4BAA8B5B,KAAK4B,4BAA4B+F,KAAK3H,MACzEA,KAAKgC,4BAA8BhC,KAAKgC,4BAA4B2F,KAAK3H,MAEzEA,KAAKc,UAAY,IAAI8G,EAEhB5H,KAAKc,UACL+G,OACAzD,KAAKpE,KAAK4B,6BACVwC,KAAKpE,KAAKgC,6BACV8C,OAAM7D,IACHjB,KAAKmD,YAAYlC,EAAAA,GAE7B,EApCAqG,EADExI,EACYsB,OAAO0H,EAAWC,UAEhCT,EAHExI,EAGekJ,eAAeA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createElement as t}from"../../../external/preact/dist/preact.js";const e=({buttonStyle:e,buttonType:a,buttonLocale:o,onClick:l})=>t("apple-pay-button",{"data-testid":"apple-pay-button",buttonstyle:e,type:a,locale:o,onclick:l});export{e as default};
|
|
2
2
|
//# sourceMappingURL=ApplePayButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplePayButton.js","sources":["../../../../../src/components/ApplePay/components/ApplePayButton.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ApplePayButton.js","sources":["../../../../../src/components/ApplePay/components/ApplePayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport type { ApplePayButtonStyle, ApplePayButtonType } from '../types';\nimport './ApplePayButton.scss';\n\ninterface ApplePayButtonProps {\n buttonStyle: ApplePayButtonStyle;\n buttonType: ApplePayButtonType;\n buttonLocale: string;\n onClick(): void;\n}\n\nconst ApplePayButton = ({ buttonStyle, buttonType, buttonLocale, onClick }: ApplePayButtonProps) => {\n return <apple-pay-button data-testid=\"apple-pay-button\" buttonstyle={buttonStyle} type={buttonType} locale={buttonLocale} onclick={onClick} />;\n};\n\nexport default ApplePayButton;\n"],"names":["ApplePayButton","buttonStyle","buttonType","buttonLocale","onClick","h","apple-pay-button","data-testid","buttonstyle","type","locale","onclick"],"mappings":"wEAWMA,MAAAA,EAAiB,EAAGC,cAAaC,aAAYC,eAAcC,aACtDC,EAACC,mBAAAA,CAAiBC,cAAY,mBAAmBC,YAAaP,EAAaQ,KAAMP,EAAYQ,OAAQP,EAAcQ,QAASP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{inIframe as t}from"../../utils/inIframe.js";const e={isExpress:!1,amount:{currency:"USD",value:0},totalPriceStatus:"final",initiative:"web",merchantCapabilities:["supports3DS"],supportedNetworks:["amex","discover","masterCard","visa"],buttonType:"plain",buttonColor:"black",renderApplePayCodeAs:t()?"window":"modal",onClick:t=>t()};export{e as default};
|
|
2
2
|
//# sourceMappingURL=defaultProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultProps.js","sources":["../../../../src/components/ApplePay/defaultProps.ts"],"sourcesContent":["import { ApplePayConfiguration } from './types';\n\nconst defaultProps: ApplePayConfiguration = {\n isExpress: false,\n amount: { currency: 'USD', value: 0 },\n totalPriceStatus: 'final',\n initiative: 'web',\n merchantCapabilities: ['supports3DS'],\n supportedNetworks: ['amex', 'discover', 'masterCard', 'visa'],\n buttonType: 'plain',\n buttonColor: 'black',\n onClick: resolve => resolve()\n};\n\nexport default defaultProps;\n"],"names":["defaultProps","isExpress","amount","currency","value","totalPriceStatus","initiative","merchantCapabilities","supportedNetworks","buttonType","buttonColor","onClick","resolve"],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaultProps.js","sources":["../../../../src/components/ApplePay/defaultProps.ts"],"sourcesContent":["import { ApplePayConfiguration } from './types';\nimport { inIframe } from '../../utils/inIframe';\n\nconst defaultProps: ApplePayConfiguration = {\n isExpress: false,\n amount: { currency: 'USD', value: 0 },\n totalPriceStatus: 'final',\n initiative: 'web',\n merchantCapabilities: ['supports3DS'],\n supportedNetworks: ['amex', 'discover', 'masterCard', 'visa'],\n buttonType: 'plain',\n buttonColor: 'black',\n renderApplePayCodeAs: inIframe() ? 'window' : 'modal',\n onClick: resolve => resolve()\n};\n\nexport default defaultProps;\n"],"names":["defaultProps","isExpress","amount","currency","value","totalPriceStatus","initiative","merchantCapabilities","supportedNetworks","buttonType","buttonColor","renderApplePayCodeAs","inIframe","onClick","resolve"],"mappings":"mDAGA,MAAMA,EAAsC,CACxCC,WAAW,EACXC,OAAQ,CAAEC,SAAU,MAAOC,MAAO,GAClCC,iBAAkB,QAClBC,WAAY,MACZC,qBAAsB,CAAC,eACvBC,kBAAmB,CAAC,OAAQ,WAAY,aAAc,QACtDC,WAAY,QACZC,YAAa,QACbC,qBAAsBC,IAAa,SAAW,QAC9CC,QAASC,GAAWA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"../../../utils/Script.js";import s from"../../../core/Errors/AdyenCheckoutError.js";const e="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";class r{async load(){try{const s=new o(e,"body",{crossOrigin:"anonymous"});return this.sdkLoadingPromise=s.load(),await this.sdkLoadingPromise,window?.ApplePaySession}catch(o){throw new s("SCRIPT_ERROR","ApplePaySDK failed to load",{cause:o})}}isSdkLoaded(){return void 0===this.sdkLoadingPromise?Promise.reject():this.sdkLoadingPromise}constructor(){var o,s,e;e=void 0,(s="sdkLoadingPromise")in(o=this)?Object.defineProperty(o,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[s]=e}}export{e as APPLE_PAY_SDK_URL,r as default};
|
|
2
|
+
//# sourceMappingURL=ApplePaySdkLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplePaySdkLoader.js","sources":["../../../../../src/components/ApplePay/services/ApplePaySdkLoader.ts"],"sourcesContent":["import Script from '../../../utils/Script';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nexport const APPLE_PAY_SDK_URL = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js';\n\nclass ApplePaySdkLoader {\n private sdkLoadingPromise: Promise<void>;\n\n public async load(): Promise<ApplePaySession> {\n try {\n const scriptElement = new Script(APPLE_PAY_SDK_URL, 'body', { crossOrigin: 'anonymous' });\n this.sdkLoadingPromise = scriptElement.load();\n await this.sdkLoadingPromise;\n return window?.ApplePaySession;\n } catch (error) {\n throw new AdyenCheckoutError('SCRIPT_ERROR', 'ApplePaySDK failed to load', { cause: error });\n }\n }\n\n public isSdkLoaded(): Promise<void> {\n if (this.sdkLoadingPromise === undefined) {\n return Promise.reject();\n }\n\n return this.sdkLoadingPromise;\n }\n}\n\nexport default ApplePaySdkLoader;\n"],"names":["APPLE_PAY_SDK_URL","ApplePaySdkLoader","load","scriptElement","Script","crossOrigin","this","sdkLoadingPromise","window","ApplePaySession","error","AdyenCheckoutError","cause","isSdkLoaded","undefined","Promise","reject"],"mappings":"kGAGO,MAAMA,EAAoB,iEAEjC,MAAMC,EAGF,UAAaC,GACT,IACI,MAAMC,EAAgB,IAAIC,EAAOJ,EAAmB,OAAQ,CAAEK,YAAa,cAG3E,OAFAC,KAAKC,kBAAoBJ,EAAcD,aACjCI,KAAKC,kBACJC,QAAQC,eACnB,CAAE,MAAOC,GACL,MAAM,IAAIC,EAAmB,eAAgB,6BAA8B,CAAEC,MAAOF,GACxF,CACJ,CAEOG,WAAAA,GACH,YAA+BC,IAA3BR,KAAKC,kBACEQ,QAAQC,SAGZV,KAAKC,iBAChB,gCAnBA,KAAQA,yBAARD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplePayService.js","sources":["../../../../../src/components/ApplePay/services/ApplePayService.ts"],"sourcesContent":["import { ApplePayPaymentAuthorizationResult } from '../types';\n\nexport interface ApplePayServiceOptions {\n version: number;\n onValidateMerchant: (resolve, reject, url) => void;\n onError: (error?: unknown) => void;\n onCancel?: (event: ApplePayJS.Event) => void;\n onPaymentMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayPaymentMethodSelectedEvent) => void;\n onShippingMethodSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingMethodSelectedEvent) => void;\n onShippingContactSelected?: (resolve, reject, event: ApplePayJS.ApplePayShippingContactSelectedEvent) => void;\n onPaymentAuthorized: (\n resolve: (result: ApplePayPaymentAuthorizationResult) => void,\n reject: (result: ApplePayPaymentAuthorizationResult) => void,\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent\n ) => void;\n}\n\nclass ApplePayService {\n private session: ApplePaySession;\n private readonly options: ApplePayServiceOptions;\n\n constructor(paymentRequest: ApplePayJS.ApplePayPaymentRequest, options: ApplePayServiceOptions) {\n this.options = options;\n\n this.session = new ApplePaySession(options.version, paymentRequest);\n this.session.onvalidatemerchant = event => {\n void this.onvalidatemerchant(event, options.onValidateMerchant);\n };\n this.session.onpaymentauthorized = event => {\n void this.onpaymentauthorized(event, options.onPaymentAuthorized);\n };\n\n this.session.oncancel = event => {\n this.oncancel(event, options.onCancel);\n };\n\n if (typeof options.onPaymentMethodSelected === 'function') {\n this.session.onpaymentmethodselected = event => {\n void this.onpaymentmethodselected(event, options.onPaymentMethodSelected);\n };\n }\n\n if (typeof options.onShippingContactSelected === 'function') {\n this.session.onshippingcontactselected = event => {\n void this.onshippingcontactselected(event, options.onShippingContactSelected);\n };\n }\n\n if (typeof options.onShippingMethodSelected === 'function') {\n this.session.onshippingmethodselected = event => {\n void this.onshippingmethodselected(event, options.onShippingMethodSelected);\n };\n }\n }\n\n /**\n * Begins the merchant validation process.\n * When this method is called, the payment sheet is presented and the merchant validation process is initiated.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778001-begin}\n */\n begin() {\n return this.session.begin();\n }\n\n /**\n * An event handler that is called when the payment sheet is displayed.\n * Use this attribute to request and return a merchant session.\n * @param event - An ApplePayValidateMerchantEvent object (contains validationURL)\n * @param onValidateMerchant - A promise implemented by the merchant that will resolve with the merchantSession\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/providing_merchant_validation}\n */\n onvalidatemerchant(event: ApplePayJS.ApplePayValidateMerchantEvent, onValidateMerchant) {\n return new Promise((resolve, reject) => onValidateMerchant(resolve, reject, event.validationURL))\n .then(response => {\n this.session.completeMerchantValidation(response);\n })\n .catch(error => {\n console.error(error);\n this.session.abort();\n this.options.onError(error);\n });\n }\n\n /**\n * An event handler that is called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode.\n * The onpaymentauthorized function must complete the payment and respond by calling completePayment before the 30 second timeout.\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentAuthorized - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized}\n */\n onpaymentauthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n onPaymentAuthorized: ApplePayServiceOptions['onPaymentAuthorized']\n ): Promise<void> {\n return new Promise((resolve, reject) => onPaymentAuthorized(resolve, reject, event))\n .then((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n })\n .catch((result: ApplePayPaymentAuthorizationResult) => {\n this.session.completePayment(result);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n *\n * @param event - The event parameter contains the payment (ApplePayPayment) attribute.\n * @param onPaymentMethodSelected - A promise that will complete the payment when resolved. Use this promise to process the payment.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778013-onpaymentmethodselected}\n */\n onpaymentmethodselected(event: ApplePayJS.ApplePayPaymentMethodSelectedEvent, onPaymentMethodSelected) {\n return new Promise((resolve, reject) => onPaymentMethodSelected(resolve, reject, event))\n .then((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n })\n .catch((paymentMethodUpdate: ApplePayJS.ApplePayPaymentMethodUpdate) => {\n this.session.completePaymentMethodSelection(paymentMethodUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingContact attribute.\n * @param onShippingContactSelected - A promise that will complete the selection of a shipping contact with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingcontactselected(event: ApplePayJS.ApplePayShippingContactSelectedEvent, onShippingContactSelected) {\n return new Promise((resolve, reject) => onShippingContactSelected(resolve, reject, event))\n .then((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n })\n .catch((shippingContactUpdate: ApplePayJS.ApplePayShippingContactUpdate) => {\n this.session.completeShippingContactSelection(shippingContactUpdate);\n });\n }\n\n /**\n * An event handler that is called when a new payment method is selected.\n * The onpaymentmethodselected function must resolve before the 30 second timeout\n * @param event - The event parameter contains the shippingMethod attribute.\n * @param onShippingMethodSelected - A promise that will complete the selection of a shipping method with an update.\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778009-onshippingcontactselected}\n */\n onshippingmethodselected(event: ApplePayJS.ApplePayShippingMethodSelectedEvent, onShippingMethodSelected) {\n return new Promise((resolve, reject) => onShippingMethodSelected(resolve, reject, event))\n .then((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n })\n .catch((shippingMethodUpdate: ApplePayJS.ApplePayShippingMethodUpdate) => {\n this.session.completeShippingMethodSelection(shippingMethodUpdate);\n });\n }\n\n /**\n * An event handler that is automatically called when the payment UI is dismissed.\n * This function can be called even after an onpaymentauthorized event has been dispatched.\n * @param event -\n * @param onCancel -\n * @see {@link https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778029-oncancel}\n */\n oncancel(event: ApplePayJS.Event, onCancel): void {\n onCancel(event);\n }\n}\n\nexport default ApplePayService;\n"],"names":["ApplePayService","begin","this","session","onvalidatemerchant","event","onValidateMerchant","Promise","resolve","reject","validationURL","then","response","completeMerchantValidation","catch","error","console","abort","options","onError","onpaymentauthorized","onPaymentAuthorized","result","completePayment","onpaymentmethodselected","onPaymentMethodSelected","paymentMethodUpdate","completePaymentMethodSelection","onshippingcontactselected","onShippingContactSelected","shippingContactUpdate","completeShippingContactSelection","onshippingmethodselected","onShippingMethodSelected","shippingMethodUpdate","completeShippingMethodSelection","oncancel","onCancel","constructor","paymentRequest","_define_property","ApplePaySession","version"],"mappings":"wHAiBA,MAAMA,EA2CFC,KAAAA,GACI,OAAOC,KAAKC,QAAQF,OACxB,CASAG,kBAAAA,CAAmBC,EAAiDC,GAChE,OAAO,IAAIC,SAAQ,CAACC,EAASC,IAAWH,EAAmBE,EAASC,EAAQJ,EAAMK,iBAC7EC,MAAKC,IACFV,KAAKC,QAAQU,2BAA2BD,EAAAA,IAE3CE,OAAMC,IACHC,QAAQD,MAAMA,GACdb,KAAKC,QAAQc,QACbf,KAAKgB,QAAQ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B,EAElEJ,KAAKC,QAAQiB,oBAAsBf,IAC1BH,KAAKkB,oBAAoBf,EAAOa,EAAQG,oBAAmB,EAGpEnB,KAAKC,QAAQiC,SAAW/B,IACpBH,KAAKkC,SAAS/B,EAAOa,EAAQmB,SAAQ,EAGM,mBAApCnB,EAAQO,0BACfvB,KAAKC,QAAQqB,wBAA0BnB,IAC9BH,KAAKsB,wBAAwBnB,EAAOa,EAAQO,wBAAuB,GAI/B,mBAAtCP,EAAQW,4BACf3B,KAAKC,QAAQyB,0BAA4BvB,IAChCH,KAAK0B,0BAA0BvB,EAAOa,EAAQW,0BAAyB,GAIpC,mBAArCX,EAAQe,2BACf/B,KAAKC,QAAQ6B,yBAA2B3B,IAC/BH,KAAK8B,yBAAyB3B,EAAOa,EAAQe,yBAAwB,EAGtF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t){if(e)return{city:e.locality,country:e.countryCode,houseNumberOrName:"ZZ",postalCode:e.postalCode,street:e.addressLines?.join(" ").trim(),...e.administrativeArea&&{stateOrProvince:e.administrativeArea},...t&&{firstName:e.givenName,lastName:e.familyName}}}export{e as formatApplePayContactToAdyenAddressFormat};
|
|
2
|
+
//# sourceMappingURL=format-applepay-contact-to-adyen-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-applepay-contact-to-adyen-format.js","sources":["../../../../../src/components/ApplePay/utils/format-applepay-contact-to-adyen-format.ts"],"sourcesContent":["import { AddressData } from '../../../types/global-types';\n\n/**\n * This function formats Apple Pay contact format to Adyen address format\n *\n * Setting 'houseNumberOrName' to ZZ won't affect the AVS check, and it will make the algorithm take the\n * house number from the 'street' property.\n */\nexport function formatApplePayContactToAdyenAddressFormat(\n paymentContact: ApplePayJS.ApplePayPaymentContact,\n isDeliveryAddress?: boolean\n): AddressData | undefined {\n if (!paymentContact) {\n return;\n }\n\n return {\n city: paymentContact.locality,\n country: paymentContact.countryCode,\n houseNumberOrName: 'ZZ',\n postalCode: paymentContact.postalCode,\n street: paymentContact.addressLines?.join(' ').trim(),\n ...(paymentContact.administrativeArea && { stateOrProvince: paymentContact.administrativeArea }),\n ...(isDeliveryAddress && {\n firstName: paymentContact.givenName,\n lastName: paymentContact.familyName\n })\n };\n}\n"],"names":["formatApplePayContactToAdyenAddressFormat","paymentContact","isDeliveryAddress","city","locality","country","countryCode","houseNumberOrName","postalCode","street","addressLines","join","trim","administrativeArea","stateOrProvince","firstName","givenName","lastName","familyName"],"mappings":"AAQO,SAASA,EACZC,EACAC,GAEA,GAAKD,EAIL,MAAO,CACHE,KAAMF,EAAeG,SACrBC,QAASJ,EAAeK,YACxBC,kBAAmB,KACnBC,WAAYP,EAAeO,WAC3BC,OAAQR,EAAeS,cAAcC,KAAK,KAAKC,UAC3CX,EAAeY,oBAAsB,CAAEC,gBAAiBb,EAAeY,uBACvEX,GAAqB,CACrBa,UAAWd,EAAee,UAC1BC,SAAUhB,EAAeiB,YAGrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){const r={mc:"masterCard",amex:"amex",visa:"visa",elodebit:"elo",elo:"elo",interac:"interac",discover:"discover",jcb:"jcb",electron:"electron",maestro:"maestro",girocard:"girocard",cartebancaire:"cartesBancaires",eftpos_australia:"eftpos"};return e.reduce(((e,a)=>(r[a]&&!e.includes(r[a])&&e.push(r[a]),e)),[])}export{e as mapBrands};
|
|
2
|
+
//# sourceMappingURL=map-adyen-brands-to-applepay-brands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-adyen-brands-to-applepay-brands.js","sources":["../../../../../src/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.ts"],"sourcesContent":["export function mapBrands(brands) {\n const brandMapping = {\n mc: 'masterCard',\n amex: 'amex',\n visa: 'visa',\n elodebit: 'elo',\n elo: 'elo',\n interac: 'interac',\n discover: 'discover',\n jcb: 'jcb',\n electron: 'electron',\n maestro: 'maestro',\n girocard: 'girocard',\n cartebancaire: 'cartesBancaires',\n eftpos_australia: 'eftpos'\n };\n\n return brands.reduce((accumulator, item) => {\n if (!!brandMapping[item] && !accumulator.includes(brandMapping[item])) {\n accumulator.push(brandMapping[item]);\n }\n return accumulator;\n }, []);\n}\n"],"names":["mapBrands","brands","brandMapping","mc","amex","visa","elodebit","elo","interac","discover","jcb","electron","maestro","girocard","cartebancaire","eftpos_australia","reduce","accumulator","item","includes","push"],"mappings":"AAAO,SAASA,EAAUC,GACtB,MAAMC,EAAe,CACjBC,GAAI,aACJC,KAAM,OACNC,KAAM,OACNC,SAAU,MACVC,IAAK,MACLC,QAAS,UACTC,SAAU,WACVC,IAAK,MACLC,SAAU,WACVC,QAAS,UACTC,SAAU,WACVC,cAAe,kBACfC,iBAAkB,UAGtB,OAAOd,EAAOe,QAAO,CAACC,EAAaC,KACzBhB,EAAagB,KAAUD,EAAYE,SAASjB,EAAagB,KAC3DD,EAAYG,KAAKlB,EAAagB,IAE3BD,IACR,GACP"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getDecimalAmount as t}from"../../../utils/amount-util.js";const e=e=>{const{countryCode:i,companyName:n,amount:o,...r}=e,a=(e=>String(t(e.value,e.currency)))(o);return i||console.warn("Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation"),{countryCode:i,currencyCode:o.currency,total:{label:r.totalPriceLabel,amount:a,type:r.totalPriceStatus},lineItems:r.lineItems,shippingMethods:r.shippingMethods,shippingType:r.shippingType,recurringPaymentRequest:r.recurringPaymentRequest,merchantCapabilities:r.merchantCapabilities,supportedCountries:r.supportedCountries,supportedNetworks:r.supportedNetworks,requiredShippingContactFields:r.requiredShippingContactFields,requiredBillingContactFields:r.requiredBillingContactFields,billingContact:r.billingContact,shippingContact:r.shippingContact,applicationData:r.applicationData}};export{e as default,e as preparePaymentRequest};
|
|
2
|
+
//# sourceMappingURL=payment-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-request.js","sources":["../../../../../src/components/ApplePay/utils/payment-request.ts"],"sourcesContent":["import { getDecimalAmount } from '../../../utils/amount-util';\nimport { PaymentAmount } from '../../../types/global-types';\n\nconst formatAmount = (amount: PaymentAmount) => String(getDecimalAmount(amount.value, amount.currency));\n\nexport const preparePaymentRequest = (paymentRequest): ApplePayJS.ApplePayPaymentRequest => {\n const { countryCode, companyName, amount, ...props } = paymentRequest;\n const formattedAmount = formatAmount(amount);\n\n if (!countryCode) {\n console.warn('Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation');\n }\n\n return {\n countryCode,\n currencyCode: amount.currency,\n\n total: {\n label: props.totalPriceLabel,\n amount: formattedAmount,\n type: props.totalPriceStatus\n },\n\n lineItems: props.lineItems,\n shippingMethods: props.shippingMethods,\n shippingType: props.shippingType,\n\n recurringPaymentRequest: props.recurringPaymentRequest,\n\n merchantCapabilities: props.merchantCapabilities,\n supportedCountries: props.supportedCountries,\n supportedNetworks: props.supportedNetworks,\n\n requiredShippingContactFields: props.requiredShippingContactFields,\n requiredBillingContactFields: props.requiredBillingContactFields,\n\n billingContact: props.billingContact,\n shippingContact: props.shippingContact,\n\n applicationData: props.applicationData\n };\n};\n\nexport default preparePaymentRequest;\n"],"names":["preparePaymentRequest","paymentRequest","countryCode","companyName","amount","props","formattedAmount","String","getDecimalAmount","value","currency","formatAmount","console","warn","currencyCode","total","label","totalPriceLabel","type","totalPriceStatus","lineItems","shippingMethods","shippingType","recurringPaymentRequest","merchantCapabilities","supportedCountries","supportedNetworks","requiredShippingContactFields","requiredBillingContactFields","billingContact","shippingContact","applicationData"],"mappings":"iEAGA,MAEaA,EAAyBC,IAClC,MAAMC,YAAEA,EAAWC,YAAEA,EAAWC,OAAEA,KAAWC,GAAUJ,EACjDK,EAJW,CAACF,GAA0BG,OAAOC,EAAiBJ,EAAOK,MAAOL,EAAOM,WAIjEC,CAAaP,GAMrC,OAJKF,GACDU,QAAQC,KAAK,uHAGV,CACHX,cACAY,aAAcV,EAAOM,SAErBK,MAAO,CACHC,MAAOX,EAAMY,gBACbb,OAAQE,EACRY,KAAMb,EAAMc,kBAGhBC,UAAWf,EAAMe,UACjBC,gBAAiBhB,EAAMgB,gBACvBC,aAAcjB,EAAMiB,aAEpBC,wBAAyBlB,EAAMkB,wBAE/BC,qBAAsBnB,EAAMmB,qBAC5BC,mBAAoBpB,EAAMoB,mBAC1BC,kBAAmBrB,EAAMqB,kBAEzBC,8BAA+BtB,EAAMsB,8BACrCC,6BAA8BvB,EAAMuB,6BAEpCC,eAAgBxB,EAAMwB,eACtBC,gBAAiBzB,EAAMyB,gBAEvBC,gBAAiB1B,EAAM0B,gBAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-supported-version.js","sources":["../../../../../src/components/ApplePay/utils/resolve-supported-version.ts"],"sourcesContent":["export function resolveSupportedVersion(latestVersion: number): number | null {\n try {\n for (let v = latestVersion; v > 0; v--) {\n if (ApplePaySession?.supportsVersion(v)) {\n return v;\n }\n }\n } catch (error) {\n console.warn(error);\n }\n return null;\n}\n"],"names":["resolveSupportedVersion","latestVersion","v","ApplePaySession","supportsVersion","error","console","warn"],"mappings":"AAAO,SAASA,EAAwBC,GACpC,IACI,IAAK,IAAIC,EAAID,EAAeC,EAAI,EAAGA,IAC/B,GAAIC,iBAAiBC,gBAAgBF,GACjC,OAAOA,CAGnB,CAAE,MAAOG,GACLC,QAAQC,KAAKF,EACjB,CACA,OAAO,IACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import o from"./CVCHint.js";import i from"../../../../internal/FormFields/Field/Field.js";import{useCoreContext as r}from"../../../../../core/Context/CoreProvider.js";import{CVC_POLICY_HIDDEN as a,CVC_POLICY_OPTIONAL as c,ENCRYPTED_SECURITY_CODE as l,CVC_POLICY_REQUIRED as n}from"../../../../internal/SecuredFields/lib/constants.js";import d from"./DataSfSpan.js";import{alternativeLabelContent as s}from"./FieldLabelAlternative.js";function u(u){const{label:_,onFocusField:m=()=>{},error:f="",className:p="",classNameModifiers:y=[],focused:C,filled:h,isValid:x,frontCVC:F=!1,cvcPolicy:v=n,showContextualElement:b,contextualText:k}=u,{i18n:j}=r(),V=t(p,{"adyen-checkout__field__cvc":!0,"adyen-checkout__card__cvc__input--hidden":v===a,"adyen-checkout__field__cvc--optional":v===c}),N=t({"adyen-checkout__input":!0,"adyen-checkout__input--small":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":f,"adyen-checkout__input--focus":C,"adyen-checkout__input--valid":x}),T=v!==c?_:j.get("creditCard.securityCode.label.optional")
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import o from"./CVCHint.js";import i from"../../../../internal/FormFields/Field/Field.js";import{useCoreContext as r}from"../../../../../core/Context/CoreProvider.js";import{CVC_POLICY_HIDDEN as a,CVC_POLICY_OPTIONAL as c,ENCRYPTED_SECURITY_CODE as l,CVC_POLICY_REQUIRED as n}from"../../../../internal/SecuredFields/lib/constants.js";import d from"./DataSfSpan.js";import{alternativeLabelContent as s}from"./FieldLabelAlternative.js";function u(u){const{label:_,onFocusField:m=()=>{},error:f="",className:p="",classNameModifiers:y=[],focused:C,filled:h,isValid:x,frontCVC:F=!1,cvcPolicy:v=n,showContextualElement:b,contextualText:k}=u,{i18n:j}=r(),V=t(p,{"adyen-checkout__field__cvc":!0,"adyen-checkout__card__cvc__input--hidden":v===a,"adyen-checkout__field__cvc--optional":v===c}),N=t({"adyen-checkout__input":!0,"adyen-checkout__input--small":!0,"adyen-checkout__card__cvc__input":!0,"adyen-checkout__input--error":f,"adyen-checkout__input--focus":C,"adyen-checkout__input--valid":x}),T=v!==c?_:j.get("creditCard.securityCode.label.optional"),E=`${T} ${k}`;return e(i,{label:T,focused:C,filled:h,classNameModifiers:[...y,"securityCode"],onFocusField:()=>m(l),className:V,errorMessage:f,isValid:x,dir:"ltr",name:l,i18n:j,contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:s,showContextualElement:b,contextualText:k},e(d,{encryptedFieldType:l,className:N}),e(o,{frontCVC:F,fieldLabel:E}))}export{u as default};
|
|
2
2
|
//# sourceMappingURL=CVC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CVC.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/CVC.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport CVCHint from './CVCHint';\nimport Field from '../../../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { CVCProps } from './types';\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n CVC_POLICY_REQUIRED,\n ENCRYPTED_SECURITY_CODE\n} from '../../../../internal/SecuredFields/lib/constants';\nimport DataSfSpan from './DataSfSpan';\nimport { alternativeLabelContent } from './FieldLabelAlternative';\n\nexport default function CVC(props: CVCProps) {\n const {\n label,\n onFocusField = () => {},\n error = '',\n className = '',\n classNameModifiers = [],\n focused,\n filled,\n isValid,\n frontCVC = false,\n cvcPolicy = CVC_POLICY_REQUIRED,\n showContextualElement,\n contextualText\n } = props;\n const { i18n } = useCoreContext();\n\n const fieldClassnames = classNames(className, {\n 'adyen-checkout__field__cvc': true,\n 'adyen-checkout__card__cvc__input--hidden': cvcPolicy === CVC_POLICY_HIDDEN,\n 'adyen-checkout__field__cvc--optional': cvcPolicy === CVC_POLICY_OPTIONAL\n });\n\n const cvcClassnames = classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--small': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': error,\n 'adyen-checkout__input--focus': focused,\n 'adyen-checkout__input--valid': isValid\n });\n\n const fieldLabel = cvcPolicy !== CVC_POLICY_OPTIONAL ? label : i18n.get('creditCard.securityCode.label.optional');\n\n return (\n <Field\n label={fieldLabel}\n focused={focused}\n filled={filled}\n classNameModifiers={[...classNameModifiers, 'securityCode']}\n onFocusField={() => onFocusField(ENCRYPTED_SECURITY_CODE)}\n className={fieldClassnames}\n errorMessage={error}\n isValid={isValid}\n dir={'ltr'}\n name={ENCRYPTED_SECURITY_CODE}\n i18n={i18n}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <DataSfSpan encryptedFieldType={ENCRYPTED_SECURITY_CODE} className={cvcClassnames} />\n\n <CVCHint frontCVC={frontCVC} fieldLabel={
|
|
1
|
+
{"version":3,"file":"CVC.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/CVC.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport CVCHint from './CVCHint';\nimport Field from '../../../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { CVCProps } from './types';\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n CVC_POLICY_REQUIRED,\n ENCRYPTED_SECURITY_CODE\n} from '../../../../internal/SecuredFields/lib/constants';\nimport DataSfSpan from './DataSfSpan';\nimport { alternativeLabelContent } from './FieldLabelAlternative';\n\nexport default function CVC(props: CVCProps) {\n const {\n label,\n onFocusField = () => {},\n error = '',\n className = '',\n classNameModifiers = [],\n focused,\n filled,\n isValid,\n frontCVC = false,\n cvcPolicy = CVC_POLICY_REQUIRED,\n showContextualElement,\n contextualText\n } = props;\n const { i18n } = useCoreContext();\n\n const fieldClassnames = classNames(className, {\n 'adyen-checkout__field__cvc': true,\n 'adyen-checkout__card__cvc__input--hidden': cvcPolicy === CVC_POLICY_HIDDEN,\n 'adyen-checkout__field__cvc--optional': cvcPolicy === CVC_POLICY_OPTIONAL\n });\n\n const cvcClassnames = classNames({\n 'adyen-checkout__input': true,\n 'adyen-checkout__input--small': true,\n 'adyen-checkout__card__cvc__input': true,\n 'adyen-checkout__input--error': error,\n 'adyen-checkout__input--focus': focused,\n 'adyen-checkout__input--valid': isValid\n });\n\n const fieldLabel = cvcPolicy !== CVC_POLICY_OPTIONAL ? label : i18n.get('creditCard.securityCode.label.optional');\n\n const imageDescription = `${fieldLabel} ${contextualText}`;\n\n return (\n <Field\n label={fieldLabel}\n focused={focused}\n filled={filled}\n classNameModifiers={[...classNameModifiers, 'securityCode']}\n onFocusField={() => onFocusField(ENCRYPTED_SECURITY_CODE)}\n className={fieldClassnames}\n errorMessage={error}\n isValid={isValid}\n dir={'ltr'}\n name={ENCRYPTED_SECURITY_CODE}\n i18n={i18n}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <DataSfSpan encryptedFieldType={ENCRYPTED_SECURITY_CODE} className={cvcClassnames} />\n\n <CVCHint frontCVC={frontCVC} fieldLabel={imageDescription} />\n </Field>\n );\n}\n"],"names":["CVC","props","label","onFocusField","error","className","classNameModifiers","focused","filled","isValid","frontCVC","cvcPolicy","CVC_POLICY_REQUIRED","showContextualElement","contextualText","i18n","useCoreContext","fieldClassnames","classNames","CVC_POLICY_HIDDEN","CVC_POLICY_OPTIONAL","cvcClassnames","fieldLabel","get","imageDescription","h","Field","ENCRYPTED_SECURITY_CODE","errorMessage","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","CVCHint"],"mappings":"gjBAee,SAASA,EAAIC,GACxB,MAAMC,MACFA,EAAKC,aACLA,EAAe,OAAQC,MACvBA,EAAQ,GAAEC,UACVA,EAAY,GAAEC,mBACdA,EAAqB,GAAEC,QACvBA,EAAOC,OACPA,EAAMC,QACNA,EAAOC,SACPA,GAAW,EAAKC,UAChBA,EAAYC,EAAmBC,sBAC/BA,EAAqBC,eACrBA,GACAb,GACEc,KAAEA,GAASC,IAEXC,EAAkBC,EAAWb,EAAW,CAC1C,8BAA8B,EAC9B,2CAA4CM,IAAcQ,EAC1D,uCAAwCR,IAAcS,IAGpDC,EAAgBH,EAAW,CAC7B,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,+BAAgCd,EAChC,+BAAgCG,EAChC,+BAAgCE,IAG9Ba,EAAaX,IAAcS,EAAsBlB,EAAQa,EAAKQ,IAAI,0CAElEC,EAAmB,GAAGF,KAAcR,IAE1C,OACIW,EAACC,EAAAA,CACGxB,MAAOoB,EACPf,QAASA,EACTC,OAAQA,EACRF,mBAAoB,IAAIA,EAAoB,gBAC5CH,aAAc,IAAMA,EAAawB,GACjCtB,UAAWY,EACXW,aAAcxB,EACdK,QAASA,EACToB,IAAK,MACLC,KAAMH,EACNZ,KAAMA,EACNgB,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,EAC1BrB,sBAAuBA,EACvBC,eAAgBA,GAEhBW,EAACU,EAAAA,CAAWC,mBAAoBT,EAAyBtB,UAAWgB,IAEpEI,EAACY,EAAAA,CAAQ3B,SAAUA,EAAUY,WAAYE,IAGrD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as
|
|
1
|
+
import{createElement as t}from"../../../../../external/preact/dist/preact.js";import c from"../../../../../_virtual/index.js";function e({frontCVC:e=!1,fieldLabel:_}){const i=c({"adyen-checkout__card__cvc__hint__wrapper":!0,"adyen-checkout__field__cvc--front-hint":!!e,"adyen-checkout__field__cvc--back-hint":!e});return t("span",{className:i},t("svg",{className:"adyen-checkout__card__cvc__hint adyen-checkout__card__cvc__hint--front",width:"27",height:"18",viewBox:"0 0 27 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!e,role:"img"},t("title",{id:"adyen-checkout__cvc__front-hint-img"},_),t("path",{d:"M0 3C0 1.34315 1.34315 0 3 0H24C25.6569 0 27 1.34315 27 3V15C27 16.6569 25.6569 18 24 18H3C1.34315 18 0 16.6569 0 15V3Z",fill:"#E6E9EB"}),t("rect",{x:"4",y:"12",width:"19",height:"2",fill:"#B9C4C9"}),t("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1",fill:"white"}),t("rect",{className:"adyen-checkout__card__cvc__hint__location",x:"16.5",y:"4.5",width:"7",height:"5",rx:"2.5",stroke:"#C12424"})),t("svg",{className:"adyen-checkout__card__cvc__hint adyen-checkout__card__cvc__hint--back",width:"27",height:"18",viewBox:"0 0 27 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!!e,role:"img"},t("title",{id:"adyen-checkout__cvc__back-hint-img"},_),t("path",{d:"M27 4.00001V3.37501C27 2.4799 26.6444 1.62146 26.0115 0.988518C25.3786 0.355581 24.5201 0 23.625 0H3.375C2.47989 0 1.62145 0.355581 0.988514 0.988518C0.355579 1.62146 0 2.4799 0 3.37501V4.00001H27Z",fill:"#E6E9EB"}),t("path",{d:"M0 6.99994V14.6666C0 15.5507 0.355579 16.3985 0.988514 17.0237C1.62145 17.6488 2.47989 18 3.375 18H23.625C24.5201 18 25.3786 17.6488 26.0115 17.0237C26.6444 16.3985 27 15.5507 27 14.6666V6.99994H0Z",fill:"#E6E9EB"}),t("rect",{y:"4.00012",width:"27",height:"3.00001",fill:"#687282"}),t("path",{d:"M4 11C4 10.4477 4.44772 10 5 10H21C22.1046 10 23 10.8954 23 12C23 13.1046 22.1046 14 21 14H5C4.44771 14 4 13.5523 4 13V11Z",fill:"white"}),t("rect",{className:"adyen-checkout__card__cvc__hint__location",x:"16.5",y:"9.5",width:"7",height:"5",rx:"2.5",stroke:"#C12424"})))}export{e as default};
|
|
2
2
|
//# sourceMappingURL=CVCHint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CVCHint.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/CVCHint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { CVCHintProps } from './types';\n\nexport default function CVCHint({ frontCVC = false, fieldLabel }: CVCHintProps) {\n const hintClassnames = classNames({\n 'adyen-checkout__card__cvc__hint__wrapper': true,\n 'adyen-checkout__field__cvc--front-hint': !!frontCVC,\n 'adyen-checkout__field__cvc--back-hint': !frontCVC\n });\n\n return (\n <span className={hintClassnames}>\n <svg\n className={'adyen-checkout__card__cvc__hint adyen-checkout__card__cvc__hint--front'}\n width=\"27\"\n height=\"18\"\n viewBox=\"0 0 27 18\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden={!frontCVC}\n
|
|
1
|
+
{"version":3,"file":"CVCHint.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/CVCHint.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { CVCHintProps } from './types';\n\nexport default function CVCHint({ frontCVC = false, fieldLabel }: CVCHintProps) {\n const hintClassnames = classNames({\n 'adyen-checkout__card__cvc__hint__wrapper': true,\n 'adyen-checkout__field__cvc--front-hint': !!frontCVC,\n 'adyen-checkout__field__cvc--back-hint': !frontCVC\n });\n\n return (\n <span className={hintClassnames}>\n <svg\n className={'adyen-checkout__card__cvc__hint adyen-checkout__card__cvc__hint--front'}\n width=\"27\"\n height=\"18\"\n viewBox=\"0 0 27 18\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden={!frontCVC}\n role={'img'}\n >\n <title id={'adyen-checkout__cvc__front-hint-img'}>{fieldLabel}</title>\n <path\n d=\"M0 3C0 1.34315 1.34315 0 3 0H24C25.6569 0 27 1.34315 27 3V15C27 16.6569 25.6569 18 24 18H3C1.34315 18 0 16.6569 0 15V3Z\"\n fill=\"#E6E9EB\"\n />\n <rect x=\"4\" y=\"12\" width=\"19\" height=\"2\" fill=\"#B9C4C9\" />\n <rect x=\"4\" y=\"4\" width=\"4\" height=\"4\" rx=\"1\" fill=\"white\" />\n <rect className={'adyen-checkout__card__cvc__hint__location'} x=\"16.5\" y=\"4.5\" width=\"7\" height=\"5\" rx=\"2.5\" stroke=\"#C12424\" />\n </svg>\n\n <svg\n className={'adyen-checkout__card__cvc__hint adyen-checkout__card__cvc__hint--back'}\n width=\"27\"\n height=\"18\"\n viewBox=\"0 0 27 18\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden={!!frontCVC}\n role={'img'}\n >\n <title id={'adyen-checkout__cvc__back-hint-img'}>{fieldLabel}</title>\n <path\n d=\"M27 4.00001V3.37501C27 2.4799 26.6444 1.62146 26.0115 0.988518C25.3786 0.355581 24.5201 0 23.625 0H3.375C2.47989 0 1.62145 0.355581 0.988514 0.988518C0.355579 1.62146 0 2.4799 0 3.37501V4.00001H27Z\"\n fill=\"#E6E9EB\"\n />\n <path\n d=\"M0 6.99994V14.6666C0 15.5507 0.355579 16.3985 0.988514 17.0237C1.62145 17.6488 2.47989 18 3.375 18H23.625C24.5201 18 25.3786 17.6488 26.0115 17.0237C26.6444 16.3985 27 15.5507 27 14.6666V6.99994H0Z\"\n fill=\"#E6E9EB\"\n />\n <rect y=\"4.00012\" width=\"27\" height=\"3.00001\" fill=\"#687282\" />\n <path\n d=\"M4 11C4 10.4477 4.44772 10 5 10H21C22.1046 10 23 10.8954 23 12C23 13.1046 22.1046 14 21 14H5C4.44771 14 4 13.5523 4 13V11Z\"\n fill=\"white\"\n />\n <rect className={'adyen-checkout__card__cvc__hint__location'} x=\"16.5\" y=\"9.5\" width=\"7\" height=\"5\" rx=\"2.5\" stroke=\"#C12424\" />\n </svg>\n </span>\n );\n}\n"],"names":["CVCHint","frontCVC","fieldLabel","hintClassnames","classNames","h","span","className","svg","width","height","viewBox","fill","xmlns","aria-hidden","role","title","id","path","d","rect","x","y","rx","stroke"],"mappings":"8HAIe,SAASA,GAAQC,SAAEA,GAAW,EAAKC,WAAEA,IAChD,MAAMC,EAAiBC,EAAW,CAC9B,4CAA4C,EAC5C,2CAA4CH,EAC5C,yCAA0CA,IAG9C,OACII,EAACC,OAAAA,CAAKC,UAAWJ,GACbE,EAACG,MAAAA,CACGD,UAAW,yEACXE,MAAM,KACNC,OAAO,KACPC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BACNC,eAAcb,EACdc,KAAM,OAENV,EAACW,QAAAA,CAAMC,GAAI,uCAAwCf,GACnDG,EAACa,OAAAA,CACGC,EAAE,0HACFP,KAAK,YAETP,EAACe,OAAAA,CAAKC,EAAE,IAAIC,EAAE,KAAKb,MAAM,KAAKC,OAAO,IAAIE,KAAK,YAC9CP,EAACe,OAAAA,CAAKC,EAAE,IAAIC,EAAE,IAAIb,MAAM,IAAIC,OAAO,IAAIa,GAAG,IAAIX,KAAK,UACnDP,EAACe,OAAAA,CAAKb,UAAW,4CAA6Cc,EAAE,OAAOC,EAAE,MAAMb,MAAM,IAAIC,OAAO,IAAIa,GAAG,MAAMC,OAAO,aAGxHnB,EAACG,MAAAA,CACGD,UAAW,wEACXE,MAAM,KACNC,OAAO,KACPC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BACNC,gBAAeb,EACfc,KAAM,OAENV,EAACW,QAAAA,CAAMC,GAAI,sCAAuCf,GAClDG,EAACa,OAAAA,CACGC,EAAE,wMACFP,KAAK,YAETP,EAACa,OAAAA,CACGC,EAAE,wMACFP,KAAK,YAETP,EAACe,OAAAA,CAAKE,EAAE,UAAUb,MAAM,KAAKC,OAAO,UAAUE,KAAK,YACnDP,EAACa,OAAAA,CACGC,EAAE,6HACFP,KAAK,UAETP,EAACe,OAAAA,CAAKb,UAAW,4CAA6Cc,EAAE,OAAOC,EAAE,MAAMb,MAAM,IAAIC,OAAO,IAAIa,GAAG,MAAMC,OAAO,aAIpI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../internal/FormFields/Field/Field.js";import{useCoreContext as i}from"../../../../../core/Context/CoreProvider.js";import o from"./DataSfSpan.js";import{DATE_POLICY_HIDDEN as n,DATE_POLICY_OPTIONAL as r,ENCRYPTED_EXPIRY_DATE as l,DATE_POLICY_REQUIRED as d}from"../../../../internal/SecuredFields/lib/constants.js";import c from"../../../../../core/Context/useImage.js";import{alternativeLabelContent as _}from"./FieldLabelAlternative.js";function s(s){const{label:p,focused:u,filled:m,onFocusField:f,className:x="",error:h="",isValid:y=!1,expiryDatePolicy:k=d,showContextualElement:F,contextualText:j}=s,{i18n:b}=i(),N=c(),g=t(x,{"adyen-checkout__field__exp-date":!0,"adyen-checkout__card__exp-date__input--hidden":k===n,"adyen-checkout__field__exp-date--optional":k===r}),v=k!==r?p:`${p} ${b.get("field.title.optional")}`;return e(a,{label:v,classNameModifiers:["expiryDate"],className:g,focused:u,filled:m,onFocusField:()=>f(l),errorMessage:h,isValid:y,dir:"ltr",name:"encryptedExpiryDate",i18n:b,contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:_,showContextualElement:F,contextualText:j},e(o,{encryptedFieldType:l,className:t("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":h,"adyen-checkout__input--focus":u,"adyen-checkout__input--valid":y})}),e("span",{className:t("adyen-checkout__field__exp-date_hint_wrapper",{"adyen-checkout__field__exp-date_hint_wrapper--hidden":h||y})},e("img",{src:N({imageFolder:"components/"})("expiry_date_hint"),className:"adyen-checkout__field__exp-date_hint",alt:
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../internal/FormFields/Field/Field.js";import{useCoreContext as i}from"../../../../../core/Context/CoreProvider.js";import o from"./DataSfSpan.js";import{DATE_POLICY_HIDDEN as n,DATE_POLICY_OPTIONAL as r,ENCRYPTED_EXPIRY_DATE as l,DATE_POLICY_REQUIRED as d}from"../../../../internal/SecuredFields/lib/constants.js";import c from"../../../../../core/Context/useImage.js";import{alternativeLabelContent as _}from"./FieldLabelAlternative.js";function s(s){const{label:p,focused:u,filled:m,onFocusField:f,className:x="",error:h="",isValid:y=!1,expiryDatePolicy:k=d,showContextualElement:F,contextualText:j}=s,{i18n:b}=i(),N=c(),g=t(x,{"adyen-checkout__field__exp-date":!0,"adyen-checkout__card__exp-date__input--hidden":k===n,"adyen-checkout__field__exp-date--optional":k===r}),v=k!==r?p:`${p} ${b.get("field.title.optional")}`,C=`${v} ${j}`;return e(a,{label:v,classNameModifiers:["expiryDate"],className:g,focused:u,filled:m,onFocusField:()=>f(l),errorMessage:h,isValid:y,dir:"ltr",name:"encryptedExpiryDate",i18n:b,contextVisibleToScreenReader:!1,useLabelElement:!1,renderAlternativeToLabel:_,showContextualElement:F,contextualText:j},e(o,{encryptedFieldType:l,className:t("adyen-checkout__input","adyen-checkout__input--small","adyen-checkout__card__exp-date__input",{"adyen-checkout__input--error":h,"adyen-checkout__input--focus":u,"adyen-checkout__input--valid":y})}),e("span",{className:t("adyen-checkout__field__exp-date_hint_wrapper",{"adyen-checkout__field__exp-date_hint_wrapper--hidden":h||y})},e("img",{src:N({imageFolder:"components/"})("expiry_date_hint"),className:"adyen-checkout__field__exp-date_hint",alt:C})))}export{s as default};
|
|
2
2
|
//# sourceMappingURL=ExpirationDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpirationDate.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/ExpirationDate.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport Field from '../../../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { ExpirationDateProps } from './types';\nimport DataSfSpan from './DataSfSpan';\n\nimport {\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE\n} from '../../../../internal/SecuredFields/lib/constants';\nimport useImage from '../../../../../core/Context/useImage';\nimport { alternativeLabelContent } from './FieldLabelAlternative';\n\nexport default function ExpirationDate(props: ExpirationDateProps) {\n const {\n label,\n focused,\n filled,\n onFocusField,\n className = '',\n error = '',\n isValid = false,\n expiryDatePolicy = DATE_POLICY_REQUIRED,\n showContextualElement,\n contextualText\n } = props;\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const fieldClassnames = classNames(className, {\n 'adyen-checkout__field__exp-date': true,\n 'adyen-checkout__card__exp-date__input--hidden': expiryDatePolicy === DATE_POLICY_HIDDEN,\n 'adyen-checkout__field__exp-date--optional': expiryDatePolicy === DATE_POLICY_OPTIONAL\n });\n\n const fieldLabel = expiryDatePolicy !== DATE_POLICY_OPTIONAL ? label : `${label} ${i18n.get('field.title.optional')}`;\n\n return (\n <Field\n label={fieldLabel}\n classNameModifiers={['expiryDate']}\n className={fieldClassnames}\n focused={focused}\n filled={filled}\n onFocusField={() => onFocusField(ENCRYPTED_EXPIRY_DATE)}\n errorMessage={error}\n isValid={isValid}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n i18n={i18n}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <DataSfSpan\n encryptedFieldType={ENCRYPTED_EXPIRY_DATE}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': error,\n 'adyen-checkout__input--focus': focused,\n 'adyen-checkout__input--valid': isValid\n })}\n />\n <span\n className={classNames('adyen-checkout__field__exp-date_hint_wrapper', {\n 'adyen-checkout__field__exp-date_hint_wrapper--hidden': error || isValid\n })}\n >\n <img\n src={getImage({ imageFolder: 'components/' })('expiry_date_hint')}\n className=\"adyen-checkout__field__exp-date_hint\"\n alt={
|
|
1
|
+
{"version":3,"file":"ExpirationDate.js","sources":["../../../../../../../src/components/Card/components/CardInput/components/ExpirationDate.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport Field from '../../../../internal/FormFields/Field';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { ExpirationDateProps } from './types';\nimport DataSfSpan from './DataSfSpan';\n\nimport {\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE\n} from '../../../../internal/SecuredFields/lib/constants';\nimport useImage from '../../../../../core/Context/useImage';\nimport { alternativeLabelContent } from './FieldLabelAlternative';\n\nexport default function ExpirationDate(props: ExpirationDateProps) {\n const {\n label,\n focused,\n filled,\n onFocusField,\n className = '',\n error = '',\n isValid = false,\n expiryDatePolicy = DATE_POLICY_REQUIRED,\n showContextualElement,\n contextualText\n } = props;\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const fieldClassnames = classNames(className, {\n 'adyen-checkout__field__exp-date': true,\n 'adyen-checkout__card__exp-date__input--hidden': expiryDatePolicy === DATE_POLICY_HIDDEN,\n 'adyen-checkout__field__exp-date--optional': expiryDatePolicy === DATE_POLICY_OPTIONAL\n });\n\n const fieldLabel = expiryDatePolicy !== DATE_POLICY_OPTIONAL ? label : `${label} ${i18n.get('field.title.optional')}`;\n\n const imageDescription = `${fieldLabel} ${contextualText}`;\n\n return (\n <Field\n label={fieldLabel}\n classNameModifiers={['expiryDate']}\n className={fieldClassnames}\n focused={focused}\n filled={filled}\n onFocusField={() => onFocusField(ENCRYPTED_EXPIRY_DATE)}\n errorMessage={error}\n isValid={isValid}\n dir={'ltr'}\n name={'encryptedExpiryDate'}\n i18n={i18n}\n contextVisibleToScreenReader={false}\n useLabelElement={false}\n renderAlternativeToLabel={alternativeLabelContent}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <DataSfSpan\n encryptedFieldType={ENCRYPTED_EXPIRY_DATE}\n className={classNames('adyen-checkout__input', 'adyen-checkout__input--small', 'adyen-checkout__card__exp-date__input', {\n 'adyen-checkout__input--error': error,\n 'adyen-checkout__input--focus': focused,\n 'adyen-checkout__input--valid': isValid\n })}\n />\n <span\n className={classNames('adyen-checkout__field__exp-date_hint_wrapper', {\n 'adyen-checkout__field__exp-date_hint_wrapper--hidden': error || isValid\n })}\n >\n <img\n src={getImage({ imageFolder: 'components/' })('expiry_date_hint')}\n className=\"adyen-checkout__field__exp-date_hint\"\n alt={imageDescription}\n />\n </span>\n </Field>\n );\n}\n"],"names":["ExpirationDate","props","label","focused","filled","onFocusField","className","error","isValid","expiryDatePolicy","DATE_POLICY_REQUIRED","showContextualElement","contextualText","i18n","useCoreContext","getImage","useImage","fieldClassnames","classNames","DATE_POLICY_HIDDEN","DATE_POLICY_OPTIONAL","fieldLabel","get","imageDescription","h","Field","classNameModifiers","ENCRYPTED_EXPIRY_DATE","errorMessage","dir","name","contextVisibleToScreenReader","useLabelElement","renderAlternativeToLabel","alternativeLabelContent","DataSfSpan","encryptedFieldType","span","img","src","imageFolder","alt"],"mappings":"4kBAgBe,SAASA,EAAeC,GACnC,MAAMC,MACFA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,aACNA,EAAYC,UACZA,EAAY,GAAEC,MACdA,EAAQ,GAAEC,QACVA,GAAU,EAAKC,iBACfA,EAAmBC,EAAoBC,sBACvCA,EAAqBC,eACrBA,GACAX,GACEY,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAkBC,EAAWZ,EAAW,CAC1C,mCAAmC,EACnC,gDAAiDG,IAAqBU,EACtE,4CAA6CV,IAAqBW,IAGhEC,EAAaZ,IAAqBW,EAAuBlB,EAAQ,GAAGA,KAASW,EAAKS,IAAI,0BAEtFC,EAAmB,GAAGF,KAAcT,IAE1C,OACIY,EAACC,EAAAA,CACGvB,MAAOmB,EACPK,mBAAoB,CAAC,cACrBpB,UAAWW,EACXd,QAASA,EACTC,OAAQA,EACRC,aAAc,IAAMA,EAAasB,GACjCC,aAAcrB,EACdC,QAASA,EACTqB,IAAK,MACLC,KAAM,sBACNjB,KAAMA,EACNkB,8BAA8B,EAC9BC,iBAAiB,EACjBC,yBAA0BC,EAC1BvB,sBAAuBA,EACvBC,eAAgBA,GAEhBY,EAACW,EAAAA,CACGC,mBAAoBT,EACpBrB,UAAWY,EAAW,wBAAyB,+BAAgC,wCAAyC,CACpH,+BAAgCX,EAChC,+BAAgCJ,EAChC,+BAAgCK,MAGxCgB,EAACa,OAAAA,CACG/B,UAAWY,EAAW,+CAAgD,CAClE,uDAAwDX,GAASC,KAGrEgB,EAACc,MAAAA,CACGC,IAAKxB,EAAS,CAAEyB,YAAa,eAAxBzB,CAAyC,oBAC9CT,UAAU,uCACVmC,IAAKlB,KAKzB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";function t({paymentMethods:t,onSelect:a}){return e("ul",{className:"adyen-checkout__instant-payment-methods-list"},t.map((t=>e("li",{key:t._id,"data-testid":t.type,onClick:()=>a(t)},t.render()))))}export{t as default};
|
|
2
2
|
//# sourceMappingURL=InstantPaymentMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstantPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/InstantPaymentMethods.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"InstantPaymentMethods.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/InstantPaymentMethods.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../../internal/UIElement/UIElement';\nimport './InstantPaymentMethods.scss';\n\ninterface InstantPaymentMethodsProps {\n paymentMethods: UIElement[];\n onSelect: (paymentMethod: UIElement) => void;\n}\n\nfunction InstantPaymentMethods({ paymentMethods, onSelect }: InstantPaymentMethodsProps) {\n return (\n <ul className=\"adyen-checkout__instant-payment-methods-list\">\n {paymentMethods.map(pm => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n <li key={pm._id} data-testid={pm.type} onClick={() => onSelect(pm)}>\n {pm.render()}\n </li>\n ))}\n </ul>\n );\n}\n\nexport default InstantPaymentMethods;\n"],"names":["InstantPaymentMethods","paymentMethods","onSelect","h","ul","className","map","pm","li","key","_id","data-testid","type","onClick","render"],"mappings":"2EASA,SAASA,GAAsBC,eAAEA,EAAcC,SAAEA,IAC7C,OACIC,EAACC,KAAAA,CAAGC,UAAU,gDACTJ,EAAeK,KAAIC,GAEhBJ,EAACK,KAAAA,CAAGC,IAAKF,EAAGG,IAAKC,cAAaJ,EAAGK,KAAMC,QAAS,IAAMX,EAASK,IAC1DA,EAAGO,YAKxB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import o from"../../../../utils/getProp.js";import{OrderPaymentMethods as
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import o from"../../../../utils/getProp.js";import{OrderPaymentMethods as n}from"./OrderPaymentMethods.js";import r from"./InstantPaymentMethods.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import{useBrandLogoConfiguration as a}from"./useBrandLogoConfiguration.js";import m from"./PaymentMethodsContainer.js";import{useEffect as d}from"../../../../external/preact/hooks/dist/hooks.js";const i=({paymentMethods:i=[],instantPaymentMethods:p=[],storedPaymentMethods:l=[],openFirstStoredPaymentMethod:y,openFirstPaymentMethod:h,openPaymentMethod:f,order:c,orderStatus:M=null,onOrderCancel:u,onSelect:P=()=>{},...g})=>{const{i18n:j}=s(),C=a(i),S=p.length>0,b=l.length>0,x=S||b?j.get("paymentMethodsList.otherPayments.label"):"";return d((()=>{if(f?.type){const e=i.find((e=>e.type===f?.type));if(e)return void P(e);console.warn(`Drop-in: payment method type "${f?.type}" not found`)}const e=l[0],t=i[0];if(e||t){if(y&&!0===o(e,"props.oneClick"))return void P(e);h&&P(t)}}),[l,i,y,h,f]),e(t,null,M&&e(n,{order:c,orderStatus:M,onOrderCancel:u,brandLogoConfiguration:C}),S&&e(r,{paymentMethods:p,onSelect:P}),b&&e(m,{...g,label:j.get("paymentMethodsList.storedPayments.label"),classNameModifiers:["storedPayments"],paymentMethods:l,onSelect:P}),!!i.length&&e(m,{...g,label:x,classNameModifiers:["otherPayments"],paymentMethods:i,onSelect:P}))};export{i as default};
|
|
2
2
|
//# sourceMappingURL=PaymentMethodList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentMethodList.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport getProp from '../../../../utils/getProp';\nimport UIElement from '../../../internal/UIElement/UIElement';\nimport { Order, OrderStatus } from '../../../../types/global-types';\nimport OrderPaymentMethods from './OrderPaymentMethods';\nimport InstantPaymentMethods from './InstantPaymentMethods';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useBrandLogoConfiguration } from './useBrandLogoConfiguration';\nimport PaymentMethodsContainer, { PaymentMethodsContainerProps } from './PaymentMethodsContainer';\nimport { useEffect } from 'preact/hooks';\n\ninterface PaymentMethodListProps extends Omit<PaymentMethodsContainerProps, 'label' | 'classNameModifiers'> {\n instantPaymentMethods?: UIElement[];\n storedPaymentMethods?: UIElement[];\n openFirstStoredPaymentMethod?: boolean;\n openFirstPaymentMethod?: boolean;\n openPaymentMethod?: {\n type: string;\n };\n order?: Order;\n orderStatus?: OrderStatus;\n onOrderCancel?: (order) => void;\n}\n\nconst PaymentMethodList = ({\n paymentMethods = [], // Non-stored payments\n instantPaymentMethods = [],\n storedPaymentMethods = [],\n openFirstStoredPaymentMethod,\n openFirstPaymentMethod,\n openPaymentMethod,\n order,\n orderStatus = null,\n onOrderCancel,\n onSelect = () => {},\n ...rest\n}: PaymentMethodListProps) => {\n const { i18n } = useCoreContext();\n const brandLogoConfiguration = useBrandLogoConfiguration(paymentMethods);\n const hasInstantPaymentMethods = instantPaymentMethods.length > 0;\n const hasStoredPaymentMethods = storedPaymentMethods.length > 0;\n const pmListLabel = hasInstantPaymentMethods || hasStoredPaymentMethods ? i18n.get('paymentMethodsList.otherPayments.label') : '';\n\n useEffect(() => {\n if (openPaymentMethod?.type) {\n const paymentMethod = paymentMethods.find(paymentMethod => paymentMethod.type === openPaymentMethod?.type);\n if (!paymentMethod) {\n console.warn(`Drop-in: payment method type \"${openPaymentMethod?.type}\" not found`);\n } else {\n onSelect(paymentMethod);\n return;\n }\n }\n\n // Open first PaymentMethodItem\n const firstStoredPayment = storedPaymentMethods[0];\n const firstNonStoredPayment = paymentMethods[0];\n\n if (firstStoredPayment || firstNonStoredPayment) {\n const shouldOpenFirstStored = openFirstStoredPaymentMethod && getProp(firstStoredPayment, 'props.oneClick') === true;\n if (shouldOpenFirstStored) {\n onSelect(firstStoredPayment);\n return;\n }\n\n if (openFirstPaymentMethod) {\n onSelect(firstNonStoredPayment);\n }\n }\n }, [storedPaymentMethods, paymentMethods, openFirstStoredPaymentMethod, openFirstPaymentMethod, openPaymentMethod]);\n\n return (\n <Fragment>\n {orderStatus && (\n <OrderPaymentMethods\n order={order}\n orderStatus={orderStatus}\n onOrderCancel={onOrderCancel}\n brandLogoConfiguration={brandLogoConfiguration}\n />\n )}\n\n {hasInstantPaymentMethods && <InstantPaymentMethods paymentMethods={instantPaymentMethods} />}\n\n {hasStoredPaymentMethods && (\n <PaymentMethodsContainer\n {...rest}\n label={i18n.get('paymentMethodsList.storedPayments.label')}\n classNameModifiers={['storedPayments']}\n paymentMethods={storedPaymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n\n {!!paymentMethods.length && (\n <PaymentMethodsContainer\n {...rest}\n label={pmListLabel}\n classNameModifiers={['otherPayments']}\n paymentMethods={paymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n </Fragment>\n );\n};\n\nexport default PaymentMethodList;\n"],"names":["PaymentMethodList","paymentMethods","instantPaymentMethods","storedPaymentMethods","openFirstStoredPaymentMethod","openFirstPaymentMethod","openPaymentMethod","order","orderStatus","onOrderCancel","onSelect","rest","i18n","useCoreContext","brandLogoConfiguration","useBrandLogoConfiguration","hasInstantPaymentMethods","length","hasStoredPaymentMethods","pmListLabel","get","useEffect","type","paymentMethod","find","console","warn","firstStoredPayment","firstNonStoredPayment","getProp","h","Fragment","OrderPaymentMethods","InstantPaymentMethods","PaymentMethodsContainer","label","classNameModifiers"],"mappings":"2fAwBA,MAAMA,EAAoB,EACtBC,iBAAiB,GACjBC,wBAAwB,GACxBC,uBAAuB,GACvBC,+BACAC,yBACAC,oBACAC,QACAC,cAAc,KACdC,gBACAC,WAAW,UACRC,MAEH,MAAMC,KAAEA,GAASC,IACXC,EAAyBC,EAA0Bd,GACnDe,EAA2Bd,EAAsBe,OAAS,EAC1DC,EAA0Bf,EAAqBc,OAAS,EACxDE,EAAcH,GAA4BE,EAA0BN,EAAKQ,IAAI,0CAA4C,GA8B/H,OA5BAC,GAAU,KACN,GAAIf,GAAmBgB,KAAM,CACzB,MAAMC,EAAgBtB,EAAeuB,MAAKD,GAAiBA,EAAcD,OAAShB,GAAmBgB,OACrG,GAAKC,EAID,YADAb,EAASa,GAFTE,QAAQC,KAAK,iCAAiCpB,GAAmBgB,kBAKzE,CAGA,MAAMK,EAAqBxB,EAAqB,GAC1CyB,EAAwB3B,EAAe,GAE7C,GAAI0B,GAAsBC,EAAuB,CAE7C,GAD8BxB,IAAkF,IAAlDyB,EAAQF,EAAoB,kBAGtF,YADAjB,EAASiB,GAITtB,GACAK,EAASkB,EAEjB,IACD,CAACzB,EAAsBF,EAAgBG,EAA8BC,EAAwBC,IAG5FwB,EAACC,EACIvB,KAAAA,GACGsB,EAACE,EAAAA,CACGzB,MAAOA,EACPC,YAAaA,EACbC,cAAeA,EACfK,uBAAwBA,IAI/BE,GAA4Bc,EAACG,EAAAA,CAAsBhC,eAAgBC,
|
|
1
|
+
{"version":3,"file":"PaymentMethodList.js","sources":["../../../../../../src/components/Dropin/components/PaymentMethod/PaymentMethodList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport getProp from '../../../../utils/getProp';\nimport UIElement from '../../../internal/UIElement/UIElement';\nimport { Order, OrderStatus } from '../../../../types/global-types';\nimport OrderPaymentMethods from './OrderPaymentMethods';\nimport InstantPaymentMethods from './InstantPaymentMethods';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { useBrandLogoConfiguration } from './useBrandLogoConfiguration';\nimport PaymentMethodsContainer, { PaymentMethodsContainerProps } from './PaymentMethodsContainer';\nimport { useEffect } from 'preact/hooks';\n\ninterface PaymentMethodListProps extends Omit<PaymentMethodsContainerProps, 'label' | 'classNameModifiers'> {\n instantPaymentMethods?: UIElement[];\n storedPaymentMethods?: UIElement[];\n openFirstStoredPaymentMethod?: boolean;\n openFirstPaymentMethod?: boolean;\n openPaymentMethod?: {\n type: string;\n };\n order?: Order;\n orderStatus?: OrderStatus;\n onOrderCancel?: (order) => void;\n}\n\nconst PaymentMethodList = ({\n paymentMethods = [], // Non-stored payments\n instantPaymentMethods = [],\n storedPaymentMethods = [],\n openFirstStoredPaymentMethod,\n openFirstPaymentMethod,\n openPaymentMethod,\n order,\n orderStatus = null,\n onOrderCancel,\n onSelect = () => {},\n ...rest\n}: PaymentMethodListProps) => {\n const { i18n } = useCoreContext();\n const brandLogoConfiguration = useBrandLogoConfiguration(paymentMethods);\n const hasInstantPaymentMethods = instantPaymentMethods.length > 0;\n const hasStoredPaymentMethods = storedPaymentMethods.length > 0;\n const pmListLabel = hasInstantPaymentMethods || hasStoredPaymentMethods ? i18n.get('paymentMethodsList.otherPayments.label') : '';\n\n useEffect(() => {\n if (openPaymentMethod?.type) {\n const paymentMethod = paymentMethods.find(paymentMethod => paymentMethod.type === openPaymentMethod?.type);\n if (!paymentMethod) {\n console.warn(`Drop-in: payment method type \"${openPaymentMethod?.type}\" not found`);\n } else {\n onSelect(paymentMethod);\n return;\n }\n }\n\n // Open first PaymentMethodItem\n const firstStoredPayment = storedPaymentMethods[0];\n const firstNonStoredPayment = paymentMethods[0];\n\n if (firstStoredPayment || firstNonStoredPayment) {\n const shouldOpenFirstStored = openFirstStoredPaymentMethod && getProp(firstStoredPayment, 'props.oneClick') === true;\n if (shouldOpenFirstStored) {\n onSelect(firstStoredPayment);\n return;\n }\n\n if (openFirstPaymentMethod) {\n onSelect(firstNonStoredPayment);\n }\n }\n }, [storedPaymentMethods, paymentMethods, openFirstStoredPaymentMethod, openFirstPaymentMethod, openPaymentMethod]);\n\n return (\n <Fragment>\n {orderStatus && (\n <OrderPaymentMethods\n order={order}\n orderStatus={orderStatus}\n onOrderCancel={onOrderCancel}\n brandLogoConfiguration={brandLogoConfiguration}\n />\n )}\n\n {hasInstantPaymentMethods && <InstantPaymentMethods paymentMethods={instantPaymentMethods} onSelect={onSelect} />}\n\n {hasStoredPaymentMethods && (\n <PaymentMethodsContainer\n {...rest}\n label={i18n.get('paymentMethodsList.storedPayments.label')}\n classNameModifiers={['storedPayments']}\n paymentMethods={storedPaymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n\n {!!paymentMethods.length && (\n <PaymentMethodsContainer\n {...rest}\n label={pmListLabel}\n classNameModifiers={['otherPayments']}\n paymentMethods={paymentMethods}\n onSelect={onSelect}\n ></PaymentMethodsContainer>\n )}\n </Fragment>\n );\n};\n\nexport default PaymentMethodList;\n"],"names":["PaymentMethodList","paymentMethods","instantPaymentMethods","storedPaymentMethods","openFirstStoredPaymentMethod","openFirstPaymentMethod","openPaymentMethod","order","orderStatus","onOrderCancel","onSelect","rest","i18n","useCoreContext","brandLogoConfiguration","useBrandLogoConfiguration","hasInstantPaymentMethods","length","hasStoredPaymentMethods","pmListLabel","get","useEffect","type","paymentMethod","find","console","warn","firstStoredPayment","firstNonStoredPayment","getProp","h","Fragment","OrderPaymentMethods","InstantPaymentMethods","PaymentMethodsContainer","label","classNameModifiers"],"mappings":"2fAwBA,MAAMA,EAAoB,EACtBC,iBAAiB,GACjBC,wBAAwB,GACxBC,uBAAuB,GACvBC,+BACAC,yBACAC,oBACAC,QACAC,cAAc,KACdC,gBACAC,WAAW,UACRC,MAEH,MAAMC,KAAEA,GAASC,IACXC,EAAyBC,EAA0Bd,GACnDe,EAA2Bd,EAAsBe,OAAS,EAC1DC,EAA0Bf,EAAqBc,OAAS,EACxDE,EAAcH,GAA4BE,EAA0BN,EAAKQ,IAAI,0CAA4C,GA8B/H,OA5BAC,GAAU,KACN,GAAIf,GAAmBgB,KAAM,CACzB,MAAMC,EAAgBtB,EAAeuB,MAAKD,GAAiBA,EAAcD,OAAShB,GAAmBgB,OACrG,GAAKC,EAID,YADAb,EAASa,GAFTE,QAAQC,KAAK,iCAAiCpB,GAAmBgB,kBAKzE,CAGA,MAAMK,EAAqBxB,EAAqB,GAC1CyB,EAAwB3B,EAAe,GAE7C,GAAI0B,GAAsBC,EAAuB,CAE7C,GAD8BxB,IAAkF,IAAlDyB,EAAQF,EAAoB,kBAGtF,YADAjB,EAASiB,GAITtB,GACAK,EAASkB,EAEjB,IACD,CAACzB,EAAsBF,EAAgBG,EAA8BC,EAAwBC,IAG5FwB,EAACC,EACIvB,KAAAA,GACGsB,EAACE,EAAAA,CACGzB,MAAOA,EACPC,YAAaA,EACbC,cAAeA,EACfK,uBAAwBA,IAI/BE,GAA4Bc,EAACG,EAAAA,CAAsBhC,eAAgBC,EAAuBQ,SAAUA,IAEpGQ,GACGY,EAACI,EAAAA,IACOvB,EACJwB,MAAOvB,EAAKQ,IAAI,2CAChBgB,mBAAoB,CAAC,kBACrBnC,eAAgBE,EAChBO,SAAUA,MAIfT,EAAegB,QACda,EAACI,EAAAA,IACOvB,EACJwB,MAAOhB,EACPiB,mBAAoB,CAAC,iBACrBnC,eAAgBA,EAChBS,SAAUA"}
|
|
@@ -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 o from"./GooglePayService.js";import s from"./components/GooglePayButton.js";import r from"./defaultProps.js";import{getGooglePayLocale as n,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import h from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as l}from"../tx-variants.js";import{sanitizeResponse as p,verifyPaymentDidNotFail as d}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as y,ANALYTICS_INSTANT_PAYMENT_BUTTON as u}from"../../core/Analytics/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class
|
|
1
|
+
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./GooglePayService.js";import s from"./components/GooglePayButton.js";import r from"./defaultProps.js";import{getGooglePayLocale as n,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import h from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as l}from"../tx-variants.js";import{sanitizeResponse as p,verifyPaymentDidNotFail as d}from"../internal/UIElement/utils.js";import{ANALYTICS_SELECTED_STR as y,ANALYTICS_INSTANT_PAYMENT_BUTTON as u}from"../../core/Analytics/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class c extends e{formatProps(t){const e=t.buttonSizeMode??(t.isDropin?"fill":"static"),o=n(t.buttonLocale??t.i18n?.locale),s=[...t.callbackIntents,"PAYMENT_AUTHORIZATION"];return{...t,configuration:t.configuration,buttonSizeMode:e,buttonLocale:o,callbackIntents:s}}formatData(){const{googlePayCardNetwork:t,googlePayToken:e,billingAddress:o,deliveryAddress:s}=this.state,{isExpress:r}=this.props;return{paymentMethod:{type:this.type,googlePayCardNetwork:t,googlePayToken:e,...r&&{subtype:"express"}},browserInfo:this.browserInfo,origin:!!window&&window.location.origin,...o&&{billingAddress:o},...s&&{deliveryAddress:s}}}submitAnalytics(t){super.submitAnalytics({...t},this.props)}showGooglePayPaymentSheet(){this.googlePay.initiatePayment(this.props,this.core.options.countryCode).catch((t=>{this.handleError(new h("CANCELED"===t.statusCode?"CANCEL":"ERROR",t.toString(),{cause:t}))}))}async handleAuthorization(){return new Promise(((t,e)=>{this.props.onAuthorized||t();const{authorizedEvent:o,billingAddress:s,deliveryAddress:r}=this.state;this.props.onAuthorized({authorizedEvent:o,...s&&{billingAddress:s},...r&&{deliveryAddress:r}},{resolve:t,reject:e})})).catch((t=>{const e={error:{googlePayError:t}};return Promise.reject(e)}))}get isValid(){return!!this.state.googlePayToken}async isAvailable(){return this.isReadyToPay().then((t=>{if(!t.result)throw new h("ERROR","GooglePay is not available");if(!1===t.paymentMethodPresent)throw new h("ERROR","GooglePay - No paymentMethodPresent");return Promise.resolve()})).catch((t=>Promise.reject(t)))}get browserInfo(){return a()}get icon(){return this.props.icon??this.resources.getImage()("googlepay")}render(){return this.props.showPayButton?t(s,{buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,buttonSizeMode:this.props.buttonSizeMode,buttonLocale:this.props.buttonLocale,buttonRootNode:this.props.buttonRootNode,buttonRadius:this.props.buttonRadius,paymentsClient:this.googlePay.paymentsClient,onClick:this.submit}):null}constructor(t,e){super(t,e),g(this,"googlePay",void 0),g(this,"submit",(()=>{this.props.isInstantPayment&&this.submitAnalytics({type:y,target:u}),new Promise(((t,e)=>this.props.onClick(t,e))).then(this.showGooglePayPaymentSheet).catch((()=>{}))})),g(this,"onPaymentAuthorized",(async t=>{const e=i(t.paymentMethodData.info.billingAddress),o=i(t.shippingAddress,!0);return this.setState({authorizedEvent:t,googlePayToken:t.paymentMethodData.tokenizationData.token,googlePayCardNetwork:t.paymentMethodData.info.cardNetwork,...e&&{billingAddress:e},...o&&{deliveryAddress:o}}),new Promise((t=>{this.handleAuthorization().then(this.makePaymentsCall).then(p).then(d).then((e=>(t({transactionState:"SUCCESS"}),e))).then((t=>{this.handleResponse(t)})).catch((e=>{this.setElementStatus("ready");const o=e?.error?.googlePayError,s=this.props.i18n.get("error.subtitle.payment"),r="string"==typeof o?{intent:"PAYMENT_AUTHORIZATION",reason:"OTHER_ERROR",message:o||s}:{intent:o?.intent||"PAYMENT_AUTHORIZATION",reason:o?.reason||"OTHER_ERROR",message:o?.message||s};t({transactionState:"ERROR",error:r});const n={...e,error:{googlePayError:r}};this.handleFailedResult(n)}))}))})),g(this,"isReadyToPay",(()=>this.googlePay.isReadyToPay(this.props))),g(this,"prefetch",(()=>this.googlePay.prefetchPaymentData(this.props,this.core.options.countryCode))),this.handleAuthorization=this.handleAuthorization.bind(this),this.showGooglePayPaymentSheet=this.showGooglePayPaymentSheet.bind(this);const{isExpress:s,paymentDataCallbacks:r}=this.props;if(!1===s&&r?.onPaymentDataChanged)throw new h("IMPLEMENTATION_ERROR",'GooglePay - You must set "isExpress" flag to "true" in order to use "onPaymentDataChanged" callback');if(!this.props.configuration.merchantId)throw new h("IMPLEMENTATION_ERROR","GooglePay - Missing merchantId. Please ensure that it is correctly configured in your customer area.");this.googlePay=new o(this.props.environment,{...s&&r?.onPaymentDataChanged&&{onPaymentDataChanged:r.onPaymentDataChanged},onPaymentAuthorized:this.onPaymentAuthorized})}}g(c,"type",l.googlepay),g(c,"txVariants",[l.googlepay,l.paywithgoogle]),g(c,"defaultProps",r);export{c as default};
|
|
2
2
|
//# sourceMappingURL=GooglePay.js.map
|