Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
optometrists
/
cache
/
cache
/
cache
/
cache
/
cache
/
cache
/
cache
/
.wp-cli
/
wp-content
/
plugins
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
base
/
context
/
providers
/
cart-checkout
/
payment-methods
:
utils.ts
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/** * External dependencies */ import { getSetting } from '@woocommerce/settings'; /** * Internal dependencies */ import type { PaymentMethods, CustomerPaymentMethod } from './types'; /** * Gets the payment methods saved for the current user after filtering out disabled ones. */ export const getCustomerPaymentMethods = ( availablePaymentMethods: PaymentMethods = {} ): Record< string, CustomerPaymentMethod > => { const customerPaymentMethods = getSetting( 'customerPaymentMethods', {} ); const paymentMethodKeys = Object.keys( customerPaymentMethods ); const enabledCustomerPaymentMethods = {} as Record< string, CustomerPaymentMethod >; paymentMethodKeys.forEach( ( type ) => { const methods = customerPaymentMethods[ type ].filter( ( { method: { gateway }, }: { method: { gateway: string; }; } ) => gateway in availablePaymentMethods && availablePaymentMethods[ gateway ].supports?.showSavedCards ); if ( methods.length ) { enabledCustomerPaymentMethods[ type ] = methods; } } ); return enabledCustomerPaymentMethods; };