2020-01-06 22:28:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-03-26 11:11:46 +00:00
|
|
|
import { usePaymentMethodDataContext } from '@woocommerce/base-context';
|
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 );
|