mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
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:
commit
75c808216c
8 changed files with 250 additions and 79 deletions
|
@ -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;
|
Loading…
Add table
Add a link
Reference in a new issue