Merge branch 'PCP-3649-fastlane-backend-logic-for-blocks' of github.com:woocommerce/woocommerce-paypal-payments into PCP-3380-prepare-fastlane-integration-on-block-checkout

This commit is contained in:
Daniel Dudzic 2024-09-14 00:21:27 +02:00
commit 75c808216c
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
8 changed files with 250 additions and 79 deletions

View file

@ -0,0 +1,24 @@
import { useEffect, useCallback } from '@wordpress/element';
const usePaymentSetupEffect = ( onPaymentSetup, handlePaymentSetup ) => {
/**
* `onPaymentSetup()` fires when we enter the "PROCESSING" state in the checkout flow.
* It pre-processes the payment details and returns data for server-side processing.
*/
useEffect( () => {
const unsubscribe = onPaymentSetup( handlePaymentSetup );
return () => {
unsubscribe();
};
}, [ onPaymentSetup, handlePaymentSetup ] );
const handlePaymentLoad = useCallback( ( component ) => {
// We'll return this function instead of calling setPaymentComponent directly
return component;
}, [] );
return { handlePaymentLoad };
};
export default usePaymentSetupEffect;