import { useMemo } from '@wordpress/element';
import { FastlaneWatermark } from './FastlaneWatermark';
const cardIcons = {
VISA: 'visa-light.svg',
MASTER_CARD: 'mastercard-light.svg',
AMEX: 'amex-light.svg',
DISCOVER: 'discover-light.svg',
DINERS: 'dinersclub-light.svg',
JCB: 'jcb-light.svg',
UNIONPAY: 'unionpay-light.svg',
};
export const CreditCard = ( {
card,
shippingAddress,
fastlaneSdk,
showWatermark = true,
} ) => {
const { brand, lastDigits, expiry } = card?.paymentSource?.card ?? {};
const { fullName } = shippingAddress?.name ?? {};
const cardLogo = useMemo( () => {
return cardIcons[ brand ] ? (
) : (
{ brand }
);
}, [ brand ] );
const formattedExpiry = expiry
? `${ expiry.split( '-' )[ 1 ] }/${ expiry.split( '-' )[ 0 ] }`
: '';
return (