Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Automated cherry pick of #7101 (#7104)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0595ff3)

Co-authored-by: Nick Misasi <nick.misasi@mattermost.com>
  • Loading branch information
mattermost-build and nickmisasi authored Nov 19, 2020
1 parent c6ea89c commit 7d7be06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/admin_console/billing/payment_info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const PaymentInfo: React.FC<Props> = () => {

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);
Expand Down
5 changes: 5 additions & 0 deletions utils/cloud_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7d7be06

Please sign in to comment.