Skip to content

Commit b32a7d3

Browse files
committed
fix(pay-later-messaging): read merchantClientId from Redux store after manual connection
The merchantClientId was read from the static PHP-localized window.ppcpSettings value, which is set at page load and never updated in memory. After a manual connection the Redux store is refreshed but the window value stays empty, causing the PayPal configurator to show a merchant_identifier error until the page is reloaded.
1 parent 5e04228 commit b32a7d3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

modules/ppcp-settings/resources/js/Components/Screens/Settings/Tabs/TabPayLaterMessaging.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PayLaterMessagingHooks } from '@ppcp-settings/data';
1+
import { PayLaterMessagingHooks, CommonHooks } from '@ppcp-settings/data';
22
import { useEffect } from '@wordpress/element';
33

44
const TabPayLaterMessaging = () => {
@@ -11,14 +11,15 @@ const TabPayLaterMessaging = () => {
1111
setHome,
1212
setCustom_placement,
1313
} = PayLaterMessagingHooks.usePayLaterMessaging();
14+
const { clientId: merchantClientId } = CommonHooks.useMerchant();
1415
const PcpPayLaterConfigurator =
1516
window.ppcpSettings?.PcpPayLaterConfigurator;
1617

1718
useEffect( () => {
1819
if ( window.merchantConfigurators && PcpPayLaterConfigurator ) {
1920
window.merchantConfigurators.Messaging( {
2021
config,
21-
merchantClientId: PcpPayLaterConfigurator.merchantClientId,
22+
merchantClientId,
2223
partnerClientId: PcpPayLaterConfigurator.partnerClientId,
2324
partnerName: 'WooCommerce',
2425
bnCode: PcpPayLaterConfigurator.bnCode,
@@ -45,7 +46,7 @@ const TabPayLaterMessaging = () => {
4546
},
4647
} );
4748
}
48-
}, [ PcpPayLaterConfigurator, config ] );
49+
}, [ PcpPayLaterConfigurator, config, merchantClientId ] );
4950

5051
return (
5152
<div

0 commit comments

Comments
 (0)