mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
🐛 Fix the manual connection confirmation logic
This commit is contained in:
parent
67522b9557
commit
93f517e50f
1 changed files with 13 additions and 4 deletions
|
@ -145,18 +145,27 @@ export const useWebhooks = () => {
|
||||||
|
|
||||||
export const useMerchantInfo = () => {
|
export const useMerchantInfo = () => {
|
||||||
const { isReady, merchant, features } = useHooks();
|
const { isReady, merchant, features } = useHooks();
|
||||||
const { refreshMerchantData } = useDispatch( STORE_NAME );
|
const { refreshMerchantData, setMerchant } = useDispatch( STORE_NAME );
|
||||||
|
|
||||||
const verifyLoginStatus = useCallback( async () => {
|
const verifyLoginStatus = useCallback( async () => {
|
||||||
const result = await refreshMerchantData();
|
const result = await refreshMerchantData();
|
||||||
|
|
||||||
if ( ! result.success ) {
|
if ( ! result.success || ! result.merchant ) {
|
||||||
throw new Error( result?.message || result?.error?.message );
|
throw new Error( result?.message || result?.error?.message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newMerchant = result.merchant;
|
||||||
|
|
||||||
// Verify if the server state is "connected" and we have a merchant ID.
|
// Verify if the server state is "connected" and we have a merchant ID.
|
||||||
return merchant?.isConnected && merchant?.id;
|
if ( newMerchant?.isConnected && newMerchant?.id ) {
|
||||||
}, [ refreshMerchantData, merchant ] );
|
// Update the verified merchant details in Redux.
|
||||||
|
setMerchant( newMerchant );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}, [ refreshMerchantData, setMerchant ] );
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isReady,
|
isReady,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue