Skip to content

Commit

Permalink
fix: remove expired saved cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed May 2, 2024
1 parent f8443c3 commit 0c2d068
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
| Some(defaultPaymentMethod) =>
[defaultPaymentMethod]->Array.concat(savedCardsWithoutDefaultPaymentMethod)
| None => savedCardsWithoutDefaultPaymentMethod
}
}->Array.filter(ele => {
if ele.paymentMethod === "card" {
let currentDate = Date.make()
let expiryDate = Date.fromString(`${ele.card.expiryYear}-${ele.card.expiryMonth}-01`)
expiryDate > currentDate
} else {
true
}
})

setSavedMethods(_ => finalSavedPaymentMethods)
setLoadSavedCards(_ =>
Expand Down

0 comments on commit 0c2d068

Please sign in to comment.