mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Refactor script loading to allow for adding custom namespaces
This commit is contained in:
parent
d769acf144
commit
09ff65aba4
6 changed files with 101 additions and 11 deletions
|
@ -15,7 +15,7 @@ class ApplepayManagerBlockEditor {
|
|||
|
||||
async config() {
|
||||
try {
|
||||
this.applePayConfig = await paypal.Applepay().config();
|
||||
this.applePayConfig = await ppcpBlocksEditorPaypalApplepay.Applepay().config();
|
||||
|
||||
const button = new ApplepayButton(
|
||||
this.ppcpConfig.context,
|
||||
|
|
|
@ -12,6 +12,7 @@ const ppcpConfig = ppcpData.scriptData;
|
|||
|
||||
const buttonData = wc.wcSettings.getSetting( 'ppcp-applepay_data' );
|
||||
const buttonConfig = buttonData.scriptData;
|
||||
const dataNamespace = 'ppcpBlocksEditorPaypalApplepay';
|
||||
|
||||
if ( typeof window.PayPalCommerceGateway === 'undefined' ) {
|
||||
window.PayPalCommerceGateway = ppcpConfig;
|
||||
|
@ -38,6 +39,10 @@ const ApplePayComponent = ( props ) => {
|
|||
|
||||
ppcpConfig.url_params.components += ',applepay';
|
||||
|
||||
if ( props.isEditing ) {
|
||||
ppcpConfig.data_namespace = dataNamespace;
|
||||
}
|
||||
|
||||
// Load PayPal
|
||||
loadPaypalScript( ppcpConfig, () => {
|
||||
setPaypalLoaded( true );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue