All files / app/payment/storedInstrument isInstrumentFeatureAvailable.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                  41x 262x 262x 262x 262x   262x         236x     26x    
import { Customer, PaymentMethod, StoreConfig } from '@bigcommerce/checkout-sdk';
 
export interface IsInstrumentFeatureAvailableState {
    config: StoreConfig;
    customer: Customer;
    isUsingMultiShipping: boolean;
    paymentMethod: PaymentMethod;
}
 
export default function isInstrumentFeatureAvailable({
    config,
    customer,
    isUsingMultiShipping,
    paymentMethod,
}: IsInstrumentFeatureAvailableState): boolean {
    if (!config.checkoutSettings.isCardVaultingEnabled ||
        !paymentMethod.config.isVaultingEnabled ||
        customer.isGuest ||
        isUsingMultiShipping
    ) {
        return false;
    }
 
    return true;
}