From 9cffee479640029d084ea2520df2725010d0654f Mon Sep 17 00:00:00 2001 From: Rafael Zaleski Date: Tue, 21 May 2024 16:47:37 -0300 Subject: [PATCH 1/2] Fix ECE error in the blocks checkout when PRBs are disabled. (#8854) --- ...fix-blocks-checkout-ece-error-when-prb-disabled | 4 ++++ client/express-checkout/blocks/index.js | 14 ++++++++++++-- client/payment-request/blocks/index.js | 7 +++++-- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 changelog/fix-blocks-checkout-ece-error-when-prb-disabled diff --git a/changelog/fix-blocks-checkout-ece-error-when-prb-disabled b/changelog/fix-blocks-checkout-ece-error-when-prb-disabled new file mode 100644 index 00000000000..499093828a2 --- /dev/null +++ b/changelog/fix-blocks-checkout-ece-error-when-prb-disabled @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix ECE error in the blocks checkout when PRBs are disabled. diff --git a/client/express-checkout/blocks/index.js b/client/express-checkout/blocks/index.js index e5c3b20b465..17b2c1221dd 100644 --- a/client/express-checkout/blocks/index.js +++ b/client/express-checkout/blocks/index.js @@ -1,4 +1,4 @@ -/* global wcpayConfig */ +/* global wcpayConfig, wcpayExpressCheckoutParams */ /** * Internal dependencies @@ -16,7 +16,17 @@ const expressCheckoutElementPaymentMethod = ( api ) => ( { supports: { features: getConfig( 'features' ), }, - canMakePayment: () => wcpayConfig.isExpressCheckoutElementEnabled, + canMakePayment: () => { + if ( typeof wcpayExpressCheckoutParams === 'undefined' ) { + return false; + } + + if ( typeof wcpayConfig !== 'undefined' ) { + return wcpayConfig.isExpressCheckoutElementEnabled; + } + + return false; + }, } ); export default expressCheckoutElementPaymentMethod; diff --git a/client/payment-request/blocks/index.js b/client/payment-request/blocks/index.js index 8ceda0e431a..eeb47714e60 100644 --- a/client/payment-request/blocks/index.js +++ b/client/payment-request/blocks/index.js @@ -1,4 +1,4 @@ -/* global wcpayConfig */ +/* global wcpayConfig, wcpayPaymentRequestParams */ /** * Internal dependencies @@ -28,7 +28,10 @@ const paymentRequestPaymentMethod = ( api ) => ( { return false; } - if ( wcpayConfig.isExpressCheckoutElementEnabled ) { + if ( + typeof wcpayConfig !== 'undefined' && + wcpayConfig.isExpressCheckoutElementEnabled + ) { return false; } From 80f999997e76d0e5eb589821362b91f14aa91f3d Mon Sep 17 00:00:00 2001 From: Malith Senaweera <6216000+malithsen@users.noreply.github.com> Date: Wed, 22 May 2024 11:55:10 -0500 Subject: [PATCH 2/2] Fix WooPay button in classic cart/product pages (#8861) --- changelog/fix-blocks-page-detection-for-woopay | 5 +++++ .../woopay/express-button/express-checkout-iframe.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/fix-blocks-page-detection-for-woopay diff --git a/changelog/fix-blocks-page-detection-for-woopay b/changelog/fix-blocks-page-detection-for-woopay new file mode 100644 index 00000000000..a348ffea544 --- /dev/null +++ b/changelog/fix-blocks-page-detection-for-woopay @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Fixes an unreleased bug + + diff --git a/client/checkout/woopay/express-button/express-checkout-iframe.js b/client/checkout/woopay/express-button/express-checkout-iframe.js index 779ff026f58..2454564c88c 100644 --- a/client/checkout/woopay/express-button/express-checkout-iframe.js +++ b/client/checkout/woopay/express-button/express-checkout-iframe.js @@ -172,7 +172,7 @@ export const expressCheckoutIframe = async ( api, context, emailSelector ) => { userEmail = email; urlParams.append( 'email', email ); } - urlParams.append( 'is_blocks', !! wcSettings.wcBlocksConfig ); + urlParams.append( 'is_blocks', !! window.wcSettings?.wcBlocksConfig ); urlParams.append( 'is_express', 'true' ); urlParams.append( 'express_context', context ); urlParams.append( 'source_url', window.location.href );