mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
24 lines
731 B
JavaScript
24 lines
731 B
JavaScript
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;
|