woocommerce-paypal-payments/modules/ppcp-applepay/resources/js/ApplepayManagerBlockEditor.js
Emili Castells 8592213b9a
Merge pull request #2464 from woocommerce/PCP-3374-google-pay-button-not-displayed-in-the-word-press-editor
Fix the Google Pay button in the block Checkout in the editor (3374)
2024-10-03 10:39:01 +02:00

36 lines
727 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 ppcpBlocksEditorPaypalApplepay.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;