mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
changes to mimic google implementation
This commit is contained in:
parent
4797d53ad5
commit
63ab1e383d
20 changed files with 724 additions and 216 deletions
63
modules/ppcp-applepay/resources/js/boot.js
Normal file
63
modules/ppcp-applepay/resources/js/boot.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
import {loadCustomScript} from "@paypal/paypal-js";
|
||||
import {loadPaypalScript} from "../../../ppcp-button/resources/js/modules/Helper/ScriptLoading";
|
||||
import ApplepayManager from "./ApplepayManager";
|
||||
|
||||
(function ({
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
jQuery
|
||||
}) {
|
||||
|
||||
const bootstrap = function () {
|
||||
const manager = new ApplepayManager(buttonConfig, ppcpConfig);
|
||||
manager.init();
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
if (
|
||||
(typeof (buttonConfig) === 'undefined') ||
|
||||
(typeof (ppcpConfig) === 'undefined')
|
||||
) {
|
||||
console.error('PayPal button could not be configured.');
|
||||
return;
|
||||
}
|
||||
console.log(buttonConfig.button.wrapper)
|
||||
// If button wrapper is not present then there is no need to load the scripts.
|
||||
if (!jQuery(buttonConfig.button.wrapper).length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let bootstrapped = false;
|
||||
let paypalLoaded = false;
|
||||
let applePayLoaded = false;
|
||||
|
||||
/* const tryToBoot = () => {
|
||||
if (!bootstrapped && paypalLoaded && applePayLoaded) {
|
||||
console.log('Trying to bootstrap')
|
||||
bootstrapped = true;
|
||||
bootstrap();
|
||||
}
|
||||
}*/
|
||||
|
||||
// Load ApplePay SDK
|
||||
/*loadCustomScript({ url: buttonConfig.sdk_url }).then(() => {
|
||||
console.log('ApplePay SDK loaded', buttonConfig.sdk_url)
|
||||
applePayLoaded = true;
|
||||
//tryToBoot();
|
||||
});*/
|
||||
|
||||
// Load PayPal
|
||||
loadPaypalScript(ppcpConfig, () => {
|
||||
paypalLoaded = true;
|
||||
//tryToBoot();
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
})({
|
||||
buttonConfig: window.wc_ppcp_applepay,
|
||||
ppcpConfig: window.PayPalCommerceGateway,
|
||||
jQuery: window.jQuery
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue