woocommerce-paypal-payments/modules/ppcp-axo/resources/js/boot.js

31 lines
861 B
JavaScript
Raw Normal View History

2024-07-12 12:58:34 +02:00
import AxoManager from './AxoManager';
2024-10-08 00:41:30 +02:00
import { loadPayPalScript } from '../../../ppcp-button/resources/js/modules/Helper/PayPalScriptLoading';
import { log } from './Helper/Debug';
2024-02-08 14:37:56 +00:00
2024-07-12 12:58:34 +02:00
( function ( { axoConfig, ppcpConfig, jQuery } ) {
const namespace = 'ppcpPaypalClassicAxo';
2024-07-12 12:58:34 +02:00
const bootstrap = () => {
new AxoManager( namespace, axoConfig, ppcpConfig );
2024-07-12 12:58:34 +02:00
};
2024-02-08 14:37:56 +00:00
2024-07-12 12:58:34 +02:00
document.addEventListener( 'DOMContentLoaded', () => {
if ( typeof PayPalCommerceGateway === 'undefined' ) {
2024-07-12 12:58:34 +02:00
console.error( 'AXO could not be configured.' );
return;
}
2024-07-12 12:58:34 +02:00
// Load PayPal
2024-10-08 00:41:30 +02:00
loadPayPalScript( namespace, ppcpConfig )
.then( () => {
bootstrap();
} )
.catch( ( error ) => {
log( `Failed to load PayPal script: ${ error }`, 'error' );
} );
2024-07-12 12:58:34 +02:00
} );
} )( {
axoConfig: window.wc_ppcp_axo,
ppcpConfig: window.PayPalCommerceGateway,
jQuery: window.jQuery,
} );