mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +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 = () => {
|
||||
const { isReady, merchant, features } = useHooks();
|
||||
const { refreshMerchantData } = useDispatch( STORE_NAME );
|
||||
const { refreshMerchantData, setMerchant } = useDispatch( STORE_NAME );
|
||||
|
||||
const verifyLoginStatus = useCallback( async () => {
|
||||
const result = await refreshMerchantData();
|
||||
|
||||
if ( ! result.success ) {
|
||||
if ( ! result.success || ! result.merchant ) {
|
||||
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.
|
||||
return merchant?.isConnected && merchant?.id;
|
||||
}, [ refreshMerchantData, merchant ] );
|
||||
if ( newMerchant?.isConnected && newMerchant?.id ) {
|
||||
// Update the verified merchant details in Redux.
|
||||
setMerchant( newMerchant );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, [ refreshMerchantData, setMerchant ] );
|
||||
|
||||
return {
|
||||
isReady,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue