woocommerce-paypal-payments/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js
2024-07-23 17:42:24 +02:00

36 lines
703 B
JavaScript

/* global paypal */
import ApplePayButton from './ApplepayButton';
class ApplePayManagerBlockEditor {
constructor( buttonConfig, ppcpConfig ) {
this.buttonConfig = buttonConfig;
this.ppcpConfig = ppcpConfig;
this.applePayConfig = null;
}
init() {
( async () => {
await this.config();
} )();
}
async config() {
try {
this.applePayConfig = await paypal.Applepay().config();
const button = new ApplePayButton(
this.ppcpConfig.context,
null,
this.buttonConfig,
this.ppcpConfig
);
button.init( this.applePayConfig );
} catch ( error ) {
console.error( 'Failed to initialize Apple Pay:', error );
}
}
}
export default ApplePayManagerBlockEditor;