diff --git a/components/admin_console/billing/payment_info.tsx b/components/admin_console/billing/payment_info.tsx index 5b80750fbc50..11bfe22b1a31 100644 --- a/components/admin_console/billing/payment_info.tsx +++ b/components/admin_console/billing/payment_info.tsx @@ -32,6 +32,11 @@ const PaymentInfo: React.FC = () => { const expiryYear = customer.payment_method.exp_year; + // If not expiry year, or its 0, it's not expired (because it probably isn't set) + if (!expiryYear) { + return false; + } + // This works because we store the expiry month as the actual 1-12 base month, but Date uses a 0-11 base month // But credit cards expire at the end of their expiry month, so we can just use that number. const lastExpiryDate = new Date(expiryYear, customer.payment_method.exp_month, 1); diff --git a/utils/cloud_utils.ts b/utils/cloud_utils.ts index 565ee5375302..2a69837913ac 100644 --- a/utils/cloud_utils.ts +++ b/utils/cloud_utils.ts @@ -10,6 +10,11 @@ export function isCustomerCardExpired(customer?: CloudCustomer): boolean { const expiryYear = customer.payment_method.exp_year; + // If not expiry year, or its 0, it's not expired (because it probably isn't set) + if (!expiryYear) { + return false; + } + // This works because we store the expiry month as the actual 1-12 base month, but Date uses a 0-11 base month // But credit cards expire at the end of their expiry month, so we can just use that number. const lastExpiryDate = new Date(expiryYear, customer.payment_method.exp_month, 1);