woocommerce-paypal-payments/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js

35 lines
682 B
JavaScript
Raw Normal View History

2024-07-12 12:58:34 +02:00
import ApplepayButton from './ApplepayButton';
2024-04-23 15:00:05 +02:00
class ApplepayManagerBlockEditor {
2024-07-12 12:58:34 +02:00
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 );
}
}
2024-04-23 15:00:05 +02:00
}
export default ApplepayManagerBlockEditor;