Skip to content

Commit

Permalink
fix: removed wild card check
Browse files Browse the repository at this point in the history
  • Loading branch information
aritro2002 committed Jan 30, 2025
1 parent 353dea5 commit e6c9a84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
10 changes: 2 additions & 8 deletions src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,13 @@ let isCardLengthValid = (cardBrand, cardNumberLength) => {

let cardValid = (cardNumber, cardBrand) => {
let clearValueLength = cardNumber->clearSpaces->String.length
if cardBrand == "" {
((GlobalVars.isInteg || GlobalVars.isSandbox) && Utils.checkIsTestCardWildcard(cardNumber)) ||
(isCardLengthValid(cardBrand, clearValueLength) && calculateLuhn(cardNumber))
} else {
isCardLengthValid(cardBrand, clearValueLength) && calculateLuhn(cardNumber)
}
isCardLengthValid(cardBrand, clearValueLength) && calculateLuhn(cardNumber)
}

let focusCardValid = (cardNumber, cardBrand) => {
let clearValueLength = cardNumber->clearSpaces->String.length
if cardBrand == "" {
((GlobalVars.isInteg || GlobalVars.isSandbox) && Utils.checkIsTestCardWildcard(cardNumber)) ||
(clearValueLength == maxCardLength(cardBrand) && calculateLuhn(cardNumber))
clearValueLength == maxCardLength(cardBrand) && calculateLuhn(cardNumber)
} else {
(clearValueLength == maxCardLength(cardBrand) ||
(cardBrand === "Visa" && clearValueLength == 16)) && calculateLuhn(cardNumber)
Expand Down
3 changes: 1 addition & 2 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
setCardValid(clearValue, setIsCardValid)
if (
focusCardValid(clearValue, cardBrand) &&
(PaymentUtils.checkIsCardSupported(clearValue, supportedCardBrands)->Option.getOr(false) ||
Utils.checkIsTestCardWildcard(clearValue))
PaymentUtils.checkIsCardSupported(clearValue, supportedCardBrands)->Option.getOr(false)
) {
handleInputFocus(~currentRef=cardRef, ~destinationRef=expiryRef)
}
Expand Down
1 change: 0 additions & 1 deletion src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,6 @@ let getFirstAndLastNameFromFullName = fullName => {
}

let isKeyPresentInDict = (dict, key) => dict->Dict.get(key)->Option.isSome
let checkIsTestCardWildcard = val => ["1111222233334444"]->Array.includes(val)

let minorUnitToString = val => (val->Int.toFloat /. 100.)->Float.toString

Expand Down

0 comments on commit e6c9a84

Please sign in to comment.