2020-01-06 22:28:09 +00:00
|
|
|
/**
|
2021-04-08 12:31:12 +00:00
|
|
|
* Internal dependencies
|
2020-01-06 22:28:09 +00:00
|
|
|
*/
|
2021-04-08 12:31:12 +00:00
|
|
|
import { usePaymentMethodDataContext } from '../../providers/cart-checkout/payment-methods';
|
2020-01-06 22:28:09 +00:00
|
|
|
|
2020-03-26 11:11:46 +00:00
|
|
|
const usePaymentMethodState = ( express = false ) => {
|
|
|
|
const {
|
|
|
|
paymentMethods,
|
|
|
|
expressPaymentMethods,
|
|
|
|
paymentMethodsInitialized,
|
|
|
|
expressPaymentMethodsInitialized,
|
|
|
|
} = usePaymentMethodDataContext();
|
|
|
|
return express
|
|
|
|
? {
|
|
|
|
paymentMethods: expressPaymentMethods,
|
|
|
|
isInitialized: expressPaymentMethodsInitialized,
|
|
|
|
}
|
|
|
|
: { paymentMethods, isInitialized: paymentMethodsInitialized };
|
2020-01-06 22:28:09 +00:00
|
|
|
};
|
|
|
|
|
2020-03-26 11:11:46 +00:00
|
|
|
export const usePaymentMethods = () => usePaymentMethodState();
|
|
|
|
export const useExpressPaymentMethods = () => usePaymentMethodState( true );
|