From 976e8b90cacc0022cd2e1caa999d2221bd8f7bca Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Tue, 31 Oct 2023 15:00:05 +0000
Subject: [PATCH] Fix ApplePay and GooglePay on block pages
---
modules/ppcp-applepay/resources/js/ApplepayButton.js | 2 +-
modules/ppcp-applepay/src/ApplepayModule.php | 3 ++-
modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php | 2 ++
modules/ppcp-googlepay/src/GooglepayModule.php | 3 ++-
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/modules/ppcp-applepay/resources/js/ApplepayButton.js b/modules/ppcp-applepay/resources/js/ApplepayButton.js
index 81d2603ee..f9c188741 100644
--- a/modules/ppcp-applepay/resources/js/ApplepayButton.js
+++ b/modules/ppcp-applepay/resources/js/ApplepayButton.js
@@ -25,7 +25,7 @@ class ApplepayButton {
this.updated_contact_info = []
this.selectedShippingMethod = []
- this.nonce = document.getElementById('woocommerce-process-checkout-nonce')?.value
+ this.nonce = document.getElementById('woocommerce-process-checkout-nonce')?.value || buttonConfig.nonce
this.log = function() {
if ( this.buttonConfig.is_debug ) {
diff --git a/modules/ppcp-applepay/src/ApplepayModule.php b/modules/ppcp-applepay/src/ApplepayModule.php
index b81329811..b47409f0c 100644
--- a/modules/ppcp-applepay/src/ApplepayModule.php
+++ b/modules/ppcp-applepay/src/ApplepayModule.php
@@ -89,7 +89,8 @@ class ApplepayModule implements ModuleInterface {
$module->render_buttons( $c, $apple_payment_method );
$apple_payment_method->bootstrap_ajax_request();
- }
+ },
+ 1
);
add_filter(
diff --git a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
index 0b15fbe78..882776cf1 100644
--- a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
+++ b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
@@ -148,6 +148,7 @@ class DataToAppleButtonScripts {
'totalLabel' => $total_label,
),
'ajax_url' => admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce( 'woocommerce-process_checkout' ),
);
}
@@ -195,6 +196,7 @@ class DataToAppleButtonScripts {
'totalLabel' => $total_label,
),
'ajax_url' => admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce( 'woocommerce-process_checkout' ),
);
}
}
diff --git a/modules/ppcp-googlepay/src/GooglepayModule.php b/modules/ppcp-googlepay/src/GooglepayModule.php
index 94f70ea09..083f8eba7 100644
--- a/modules/ppcp-googlepay/src/GooglepayModule.php
+++ b/modules/ppcp-googlepay/src/GooglepayModule.php
@@ -155,7 +155,8 @@ class GooglepayModule implements ModuleInterface {
}
);
- }
+ },
+ 1
);
}