All files / app/payment getPreselectedPayment.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    14x   14x   14x 59x   59x 1x          
import { Checkout, CheckoutPayment } from '@bigcommerce/checkout-sdk';
 
import { isGiftCertificatePayment } from '../giftCertificate';
 
import { isStoreCreditPayment } from './storeCredit';
 
export default function getPreselectedPayment(checkout: Checkout): CheckoutPayment | undefined {
    const payments = checkout && checkout.payments ? checkout.payments : [];
 
    return payments.find(payment =>
        !isGiftCertificatePayment(payment)
        && !isStoreCreditPayment(payment)
        && !!payment.providerId
    );
}