From 0c2d0680055577e25523b2a08ed13c8c62ad8624 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 2 May 2024 14:42:30 +0530 Subject: [PATCH 1/9] fix: remove expired saved cards --- src/PaymentElement.res | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 28bdbc6c2..3c722fcc6 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -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(_ => From 06fe2731fcccec09f3e963b4f5c8a310faa5b0e7 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 2 May 2024 15:19:00 +0530 Subject: [PATCH 2/9] fix: expiry checks edge cases --- src/PaymentElement.res | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 3c722fcc6..f42fca0d1 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -64,7 +64,21 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod }->Array.filter(ele => { if ele.paymentMethod === "card" { let currentDate = Date.make() - let expiryDate = Date.fromString(`${ele.card.expiryYear}-${ele.card.expiryMonth}-01`) + let expiryMonth = + ( + ele.card.expiryMonth->Int.fromString === Some(12) + ? 01 + : ele.card.expiryMonth->Int.fromString->Option.getOr(01) + 1 + )->Int.toString + + let expiryYear = + ( + ele.card.expiryMonth->Int.fromString === Some(12) + ? ele.card.expiryYear->Int.fromString->Option.getOr(0) + 1 + : ele.card.expiryYear->Int.fromString->Option.getOr(0) + )->Int.toString + + let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}-01`) expiryDate > currentDate } else { true From 8e437b027da09167dd5327adb1dad4c76e5e25c7 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 2 May 2024 15:32:46 +0530 Subject: [PATCH 3/9] Update src/PaymentElement.res Co-authored-by: Vrishab Srivatsa --- src/PaymentElement.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PaymentElement.res b/src/PaymentElement.res index f42fca0d1..7fa2013a4 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -78,7 +78,7 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod : ele.card.expiryYear->Int.fromString->Option.getOr(0) )->Int.toString - let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}-01`) + let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) expiryDate > currentDate } else { true From af28126b3d14e41daf593b3e04080ca4279aafc2 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 2 May 2024 18:52:50 +0530 Subject: [PATCH 4/9] fix: saved cards text added --- src/Components/SavedCardItem.res | 55 +++++++++++++++++++++++--------- src/PaymentElement.res | 24 +------------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index c4f9efa17..2cf9bd3fb 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -49,6 +49,22 @@ let make = ( let isCard = paymentItem.paymentMethod === "card" let isRenderCvv = isCard && paymentItem.requiresCvv + let expiryMonth = + ( + paymentItem.card.expiryMonth->Int.fromString === Some(12) + ? 01 + : paymentItem.card.expiryMonth->Int.fromString->Option.getOr(01) + 1 + )->Int.toString + let expiryYear = + ( + paymentItem.card.expiryMonth->Int.fromString === Some(12) + ? paymentItem.card.expiryYear->Int.fromString->Option.getOr(0) + 1 + : paymentItem.card.expiryYear->Int.fromString->Option.getOr(0) + )->Int.toString + let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) + let currentDate = Date.make() + let isCardExpired = expiryDate < currentDate + let paymentMethodType = switch paymentItem.paymentMethodType { | Some(paymentMethodType) => paymentMethodType | None => "debit" @@ -91,22 +107,31 @@ let make = ( />
brandIcon
-
- {isCard - ?
-
{React.string(paymentItem.card.nickname)}
-
-
{React.string(`****`)}
-
{React.string(paymentItem.card.last4Digits)}
+
+
+ {isCard + ?
+
{React.string(paymentItem.card.nickname)}
+
+
{React.string(`****`)}
+
{React.string(paymentItem.card.last4Digits)}
+
-
- :
{React.string(paymentMethodType->Utils.snakeToTitleCase)}
} - - + :
{React.string(paymentMethodType->Utils.snakeToTitleCase)}
} + + + +
+ +
+ {"*This card has expired"->React.string} +
diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 7fa2013a4..28bdbc6c2 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -61,29 +61,7 @@ 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 expiryMonth = - ( - ele.card.expiryMonth->Int.fromString === Some(12) - ? 01 - : ele.card.expiryMonth->Int.fromString->Option.getOr(01) + 1 - )->Int.toString - - let expiryYear = - ( - ele.card.expiryMonth->Int.fromString === Some(12) - ? ele.card.expiryYear->Int.fromString->Option.getOr(0) + 1 - : ele.card.expiryYear->Int.fromString->Option.getOr(0) - )->Int.toString - - let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) - expiryDate > currentDate - } else { - true - } - }) + } setSavedMethods(_ => finalSavedPaymentMethods) setLoadSavedCards(_ => From 6fd8afdf791348093436d42a890caa3e281b2c38 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 2 May 2024 18:54:02 +0530 Subject: [PATCH 5/9] fix: style removed --- src/Components/SavedCardItem.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index 2cf9bd3fb..08cb8225c 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -128,7 +128,7 @@ let make = (
{"*This card has expired"->React.string}
From 704b93042c943b71d3ef6dba0ac5b1630d802cc9 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 3 May 2024 11:35:00 +0530 Subject: [PATCH 6/9] fix: disable expiry color --- src/Components/SavedCardItem.res | 79 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index 08cb8225c..1fac3b318 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -63,7 +63,7 @@ let make = ( )->Int.toString let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) let currentDate = Date.make() - let isCardExpired = expiryDate < currentDate + let isCardExpired = isCard ? expiryDate < currentDate : false let paymentMethodType = switch paymentItem.paymentMethodType { | Some(paymentMethodType) => paymentMethodType @@ -86,6 +86,7 @@ let make = ( ~background="transparent", ~color=themeObj.colorTextSecondary, ~boxShadow="none", + ~opacity={isCardExpired ? "0.7" : "1"}, (), )} onClick={_ => setPaymentToken(_ => (paymentItem.paymentToken, paymentItem.customerId))}> @@ -126,13 +127,6 @@ let make = ( />
- -
- {"*This card has expired"->React.string} -
-
@@ -148,37 +142,44 @@ let make = (
- -
- +
+ +
+
{React.string("CVC: ")}
-
{React.string("CVC: ")}
-
- -
+ className={`flex h mx-4 justify-start w-16 ${isActive + ? "opacity-1 mt-4" + : "opacity-0"}`}> +
- +
+
+ +
+ {"*This card has expired"->React.string} +
+
+ CardUtils.getCardType} /> -
-
+ +
From eb71d53f61289337242674e0460679be6494117e Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 3 May 2024 11:51:15 +0530 Subject: [PATCH 7/9] chore: locale string added --- src/Components/SavedCardItem.res | 4 ++-- src/LocaleStrings/ArabicLocale.res | 1 + src/LocaleStrings/CatalanLocale.res | 1 + src/LocaleStrings/DeutschLocale.res | 1 + src/LocaleStrings/DutchLocale.res | 1 + src/LocaleStrings/EnglishGBLocale.res | 1 + src/LocaleStrings/EnglishLocale.res | 1 + src/LocaleStrings/FrenchBelgiumLocale.res | 1 + src/LocaleStrings/FrenchLocale.res | 1 + src/LocaleStrings/HebrewLocale.res | 1 + src/LocaleStrings/ItalianLocale.res | 1 + src/LocaleStrings/JapaneseLocale.res | 1 + src/LocaleStrings/LocaleStringTypes.res | 1 + src/LocaleStrings/PolishLocale.res | 1 + src/LocaleStrings/PortugueseLocale.res | 1 + src/LocaleStrings/RussianLocale.res | 1 + src/LocaleStrings/SpanishLocale.res | 1 + src/LocaleStrings/SwedishLocale.res | 1 + 18 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index 1fac3b318..f96fa0b08 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -11,7 +11,7 @@ let make = ( ~list, ~setRequiredFieldsBody, ) => { - let {themeObj, config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) + let {themeObj, config, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) let (cardBrand, setCardBrand) = Recoil.useRecoilState(RecoilAtoms.cardBrand) let ( isCVCValid, @@ -176,7 +176,7 @@ let make = (
- {"*This card has expired"->React.string} + {`*${localeString.cardExpiredText}`->React.string}
diff --git a/src/LocaleStrings/ArabicLocale.res b/src/LocaleStrings/ArabicLocale.res index e63cc984b..ec618d826 100644 --- a/src/LocaleStrings/ArabicLocale.res +++ b/src/LocaleStrings/ArabicLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `استخدم طرق الدفع المحفوظة`, cardNickname: `الاسم علي الكارت`, nicknamePlaceholder: `اسم البطاقة (اختياري)`, + cardExpiredText: `انتهت صلاحية هذه البطاقة`, } diff --git a/src/LocaleStrings/CatalanLocale.res b/src/LocaleStrings/CatalanLocale.res index 2b2ed500e..8d2aac81e 100644 --- a/src/LocaleStrings/CatalanLocale.res +++ b/src/LocaleStrings/CatalanLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Utilitzeu formes de pagament desades`, nicknamePlaceholder: `Àlies de la targeta (opcional)`, selectPaymentMethodText: `Seleccioneu una forma de pagament i torneu-ho a provar`, + cardExpiredText: `Aquesta targeta ha caducat`, } diff --git a/src/LocaleStrings/DeutschLocale.res b/src/LocaleStrings/DeutschLocale.res index e2735a4db..73716f866 100644 --- a/src/LocaleStrings/DeutschLocale.res +++ b/src/LocaleStrings/DeutschLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Gespeicherte Zahlungsarten nutzen`, cardNickname: `Spitzname der Karte`, nicknamePlaceholder: `Kartenname (optional)`, + cardExpiredText: `Diese Karte ist abgelaufen`, } diff --git a/src/LocaleStrings/DutchLocale.res b/src/LocaleStrings/DutchLocale.res index 774f82a09..1523076c9 100644 --- a/src/LocaleStrings/DutchLocale.res +++ b/src/LocaleStrings/DutchLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Gebruik opgeslagen betaalmethoden`, nicknamePlaceholder: `Bijnaam kaart (optioneel)`, selectPaymentMethodText: `Selecteer een betaalmethode en probeer het opnieuw`, + cardExpiredText: `Deze kaart is verlopen`, } diff --git a/src/LocaleStrings/EnglishGBLocale.res b/src/LocaleStrings/EnglishGBLocale.res index e3f70a4cc..143c1d175 100644 --- a/src/LocaleStrings/EnglishGBLocale.res +++ b/src/LocaleStrings/EnglishGBLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: "Use saved payment methods", cardNickname: "Card Nickname", nicknamePlaceholder: "Card Nickname (Optional)", + cardExpiredText: `This card has expired`, } diff --git a/src/LocaleStrings/EnglishLocale.res b/src/LocaleStrings/EnglishLocale.res index 05a1cda57..e57d0910b 100644 --- a/src/LocaleStrings/EnglishLocale.res +++ b/src/LocaleStrings/EnglishLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: "Use saved payment methods", cardNickname: "Card Nickname", nicknamePlaceholder: "Card Nickname (Optional)", + cardExpiredText: `This card has expired`, } diff --git a/src/LocaleStrings/FrenchBelgiumLocale.res b/src/LocaleStrings/FrenchBelgiumLocale.res index 4051a95d4..be4f12711 100644 --- a/src/LocaleStrings/FrenchBelgiumLocale.res +++ b/src/LocaleStrings/FrenchBelgiumLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Utiliser les modes de paiement enregistrés`, nicknamePlaceholder: `Surnom de la carte (facultatif)`, selectPaymentMethodText: `Veuillez sélectionner un mode de paiement et réessayer`, + cardExpiredText: `Cette carte a expiré`, } diff --git a/src/LocaleStrings/FrenchLocale.res b/src/LocaleStrings/FrenchLocale.res index 289b028aa..83d7350c0 100644 --- a/src/LocaleStrings/FrenchLocale.res +++ b/src/LocaleStrings/FrenchLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Utiliser les modes de paiement enregistrés`, cardNickname: `Pseudonyme de la carte`, nicknamePlaceholder: `Surnom de la carte (facultatif)`, + cardExpiredText: `Cette carte a expiré`, } diff --git a/src/LocaleStrings/HebrewLocale.res b/src/LocaleStrings/HebrewLocale.res index c8216e8f7..ed31f1388 100644 --- a/src/LocaleStrings/HebrewLocale.res +++ b/src/LocaleStrings/HebrewLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `השתמש באמצעי תשלום שמורים`, cardNickname: `כינוי לכרטיס`, nicknamePlaceholder: `כינוי לכרטיס (אופציונלי)`, + cardExpiredText: `הכרטיס הזה פג תוקף`, } diff --git a/src/LocaleStrings/ItalianLocale.res b/src/LocaleStrings/ItalianLocale.res index e15d3b905..56b8462f4 100644 --- a/src/LocaleStrings/ItalianLocale.res +++ b/src/LocaleStrings/ItalianLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Utilizza i metodi di pagamento salvati`, nicknamePlaceholder: `Soprannome della carta (facoltativo)`, selectPaymentMethodText: `Seleziona un metodo di pagamento e riprova`, + cardExpiredText: `Questa carta è scaduta`, } diff --git a/src/LocaleStrings/JapaneseLocale.res b/src/LocaleStrings/JapaneseLocale.res index 61b239dad..a43ce3a5f 100644 --- a/src/LocaleStrings/JapaneseLocale.res +++ b/src/LocaleStrings/JapaneseLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `保存した支払い方法を使用する`, cardNickname: `カードのニックネーム`, nicknamePlaceholder: `カードニックネーム(任意)`, + cardExpiredText: `このカードは期限切れです`, } diff --git a/src/LocaleStrings/LocaleStringTypes.res b/src/LocaleStrings/LocaleStringTypes.res index 884e95285..e42aec648 100644 --- a/src/LocaleStrings/LocaleStringTypes.res +++ b/src/LocaleStrings/LocaleStringTypes.res @@ -70,4 +70,5 @@ type localeStrings = { useExistingPaymentMethods: string, cardNickname: string, nicknamePlaceholder: string, + cardExpiredText: string, } diff --git a/src/LocaleStrings/PolishLocale.res b/src/LocaleStrings/PolishLocale.res index a8ebd77b5..1a0debc84 100644 --- a/src/LocaleStrings/PolishLocale.res +++ b/src/LocaleStrings/PolishLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Skorzystaj z zapisanych metod płatności`, nicknamePlaceholder: `Pseudonim karty (opcjonalnie)`, selectPaymentMethodText: `Wybierz metodę płatności i spróbuj ponownie`, + cardExpiredText: `Ta karta wygasła`, } diff --git a/src/LocaleStrings/PortugueseLocale.res b/src/LocaleStrings/PortugueseLocale.res index e1ba1d509..59c99e211 100644 --- a/src/LocaleStrings/PortugueseLocale.res +++ b/src/LocaleStrings/PortugueseLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Use métodos de pagamento salvos`, nicknamePlaceholder: `Apelido do cartão (opcional)`, selectPaymentMethodText: `Selecione uma forma de pagamento e tente novamente`, + cardExpiredText: `Este cartão expirou`, } diff --git a/src/LocaleStrings/RussianLocale.res b/src/LocaleStrings/RussianLocale.res index 3eba2661f..f16fc4d3a 100644 --- a/src/LocaleStrings/RussianLocale.res +++ b/src/LocaleStrings/RussianLocale.res @@ -82,4 +82,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Используйте сохраненные способы оплаты`, nicknamePlaceholder: `Псевдоним карты (необязательно)`, selectPaymentMethodText: `Пожалуйста, выберите способ оплаты и повторите попытку.`, + cardExpiredText: `Эта карта истекла`, } diff --git a/src/LocaleStrings/SpanishLocale.res b/src/LocaleStrings/SpanishLocale.res index 2bbc883c5..6986e92fd 100644 --- a/src/LocaleStrings/SpanishLocale.res +++ b/src/LocaleStrings/SpanishLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Utilice métodos de pago guardados`, nicknamePlaceholder: `Apodo de la tarjeta (opcional)`, selectPaymentMethodText: `Por favor seleccione un método de pago y vuelva a intentarlo`, + cardExpiredText: `Esta tarjeta ha caducado`, } diff --git a/src/LocaleStrings/SwedishLocale.res b/src/LocaleStrings/SwedishLocale.res index 6b3b3ca12..53feb3f78 100644 --- a/src/LocaleStrings/SwedishLocale.res +++ b/src/LocaleStrings/SwedishLocale.res @@ -79,4 +79,5 @@ let localeStrings: LocaleStringTypes.localeStrings = { useExistingPaymentMethods: `Använd sparade betalningsmetoder`, nicknamePlaceholder: `Kortets smeknamn (valfritt)`, selectPaymentMethodText: `Välj en betalningsmetod och försök igen`, + cardExpiredText: `Detta kort har gått ut`, } From e2945909a4fb1f98526be6f2aa2205b20c29c0ce Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 3 May 2024 12:06:47 +0530 Subject: [PATCH 8/9] fix: comments addressed --- src/Components/SavedCardItem.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index f96fa0b08..ed17b0411 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -63,7 +63,7 @@ let make = ( )->Int.toString let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) let currentDate = Date.make() - let isCardExpired = isCard ? expiryDate < currentDate : false + let isCardExpired = isCard && expiryDate < currentDate let paymentMethodType = switch paymentItem.paymentMethodType { | Some(paymentMethodType) => paymentMethodType @@ -172,7 +172,7 @@ let make = ( - +
From e76891a2849d11c6f8b83dd08bb14c1cba09fade Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 3 May 2024 15:51:22 +0530 Subject: [PATCH 9/9] fix: minimize the code --- src/Components/SavedCardItem.res | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res index ed17b0411..d1a629ed4 100644 --- a/src/Components/SavedCardItem.res +++ b/src/Components/SavedCardItem.res @@ -49,19 +49,8 @@ let make = ( let isCard = paymentItem.paymentMethod === "card" let isRenderCvv = isCard && paymentItem.requiresCvv - let expiryMonth = - ( - paymentItem.card.expiryMonth->Int.fromString === Some(12) - ? 01 - : paymentItem.card.expiryMonth->Int.fromString->Option.getOr(01) + 1 - )->Int.toString - let expiryYear = - ( - paymentItem.card.expiryMonth->Int.fromString === Some(12) - ? paymentItem.card.expiryYear->Int.fromString->Option.getOr(0) + 1 - : paymentItem.card.expiryYear->Int.fromString->Option.getOr(0) - )->Int.toString - let expiryDate = Date.fromString(`${expiryYear}-${expiryMonth}`) + let expiryDate = Date.fromString(`${paymentItem.card.expiryYear}-${paymentItem.card.expiryMonth}`) + expiryDate->Date.setMonth(expiryDate->Date.getMonth + 1) let currentDate = Date.make() let isCardExpired = isCard && expiryDate < currentDate