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';
|
2024-10-07 10:42:56 +02:00
|
|
|
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 } ) {
|
2024-10-05 02:26:09 +02:00
|
|
|
const namespace = 'ppcpPaypalClassicAxo';
|
2024-07-12 12:58:34 +02:00
|
|
|
const bootstrap = () => {
|
2024-10-05 02:26:09 +02:00
|
|
|
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', () => {
|
2024-10-05 02:26:09 +02:00
|
|
|
if ( typeof PayPalCommerceGateway === 'undefined' ) {
|
2024-07-12 12:58:34 +02:00
|
|
|
console.error( 'AXO could not be configured.' );
|
|
|
|
return;
|
|
|
|
}
|
2024-02-15 17:58:56 +00:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
// Load PayPal
|
2024-10-08 00:41:30 +02:00
|
|
|
loadPayPalScript( namespace, ppcpConfig )
|
2024-10-05 02:26:09 +02:00
|
|
|
.then( () => {
|
|
|
|
bootstrap();
|
|
|
|
} )
|
|
|
|
.catch( ( error ) => {
|
2024-10-07 10:42:56 +02:00
|
|
|
log( `Failed to load PayPal script: ${ error }`, 'error' );
|
2024-10-05 02:26:09 +02:00
|
|
|
} );
|
2024-07-12 12:58:34 +02:00
|
|
|
} );
|
|
|
|
} )( {
|
|
|
|
axoConfig: window.wc_ppcp_axo,
|
|
|
|
ppcpConfig: window.PayPalCommerceGateway,
|
|
|
|
jQuery: window.jQuery,
|
|
|
|
} );
|