Skip to content

Commit

Permalink
Revert "feat: added support for cobadged cards (#564)"
Browse files Browse the repository at this point in the history
This reverts commit 9deb94b.
  • Loading branch information
ArushKapoorJuspay committed Oct 18, 2024
1 parent 458ee87 commit 47871cc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 90 deletions.
51 changes: 0 additions & 51 deletions src/CardSchemeComponent.res

This file was deleted.

16 changes: 0 additions & 16 deletions src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type cardProps = (
string,
(string => string) => unit,
int,
string,
)

type expiryProps = (
Expand Down Expand Up @@ -656,18 +655,3 @@ let getPaymentMethodBrand = (customerMethod: PaymentType.customerMethods) => {
)
}
}

let getAllMatchedCardSchemes = cardNumber => {
CardPattern.cardPatterns->Array.reduce([], (acc, item) => {
if String.match(cardNumber, item.pattern)->Option.isSome {
acc->Array.push(item.issuer)
}
acc
})
}

let getEligibleCoBadgedCardSchemes = (~matchedCardSchemes, ~enabledCardSchemes) => {
matchedCardSchemes->Array.filter(ele => {
enabledCardSchemes->Array.includes(ele->String.toLowerCase)
})
}
2 changes: 0 additions & 2 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ let make = (
"",
_ => (),
0,
"",
)

let defaultExpiryProps = (
Expand Down Expand Up @@ -164,7 +163,6 @@ let make = (
cardError,
_,
maxCardLength,
_,
) = switch cardProps {
| Some(cardProps) => cardProps
| None => defaultCardProps
Expand Down
2 changes: 1 addition & 1 deletion src/Components/PaymentInputField.res
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ let make = (
</div>
</RenderIf>
</div>
<div className="relative flex -ml-10 items-center"> {rightIcon} </div>
<div className={`relative flex -ml-10 items-center`}> {rightIcon} </div>
</div>
<RenderIf condition={innerLayout === Spaced}>
{switch errorString {
Expand Down
26 changes: 10 additions & 16 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
let (isZipValid, setIsZipValid) = React.useState(_ => None)
let (isCardSupported, setIsCardSupported) = React.useState(_ => None)

let maxCardLength = React.useMemo(() => {
getMaxLength(cardNumber)
let (cardBrand, maxCardLength) = React.useMemo(() => {
let brand = getCardBrand(cardNumber)
let maxLength = getMaxLength(cardNumber)
let isNotBancontact = selectedOption !== "bancontact_card" && brand == ""
!showFields && isNotBancontact ? (cardScheme, maxLength) : (brand, maxLength)
}, (cardNumber, cardScheme, showFields))

let cardBrand = getCardBrand(cardNumber)
let isNotBancontact = selectedOption !== "bancontact_card" && cardBrand == ""
let (cardBrand, setCardBrand) = React.useState(_ =>
!showFields && isNotBancontact ? cardScheme : cardBrand
)
let supportedCardBrands = React.useMemo(() => {
paymentMethodListValue->PaymentUtils.getSupportedCardBrands
}, [paymentMethodListValue])
Expand Down Expand Up @@ -221,7 +219,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
}
let cardNetwork = {
if cardBrand != "" {
[("card_network", cardBrand->JSON.Encode.string)]
[("card_network", cardNumber->CardUtils.getCardBrand->JSON.Encode.string)]
} else {
[]
}
Expand Down Expand Up @@ -352,14 +350,11 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
None
}, (isExpiryValid, isExpiryComplete(cardExpiry)))

React.useEffect(() => {
setCardBrand(_ => cardNumber->CardUtils.getCardBrand)
None
}, [cardNumber])

let icon = React.useMemo(() => {
<CardSchemeComponent cardNumber paymentType cardBrand setCardBrand />
}, (cardType, paymentType, cardBrand, cardNumber))
let animate = cardType == NOTFOUND ? "animate-slideLeft" : "animate-slideRight"
let cardBrandIcon = getCardBrandIcon(cardType, paymentType)
<div className=animate> cardBrandIcon </div>
}, (cardType, paymentType))

let cardProps: CardUtils.cardProps = (
isCardValid,
Expand All @@ -373,7 +368,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
cardError,
setCardError,
maxCardLength,
cardBrand,
)

let expiryProps: CardUtils.expiryProps = (
Expand Down
6 changes: 4 additions & 2 deletions src/Payments/CardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ let make = (
cardError,
setCardError,
maxCardLength,
cardBrand,
) = cardProps

let cardBrand = React.useMemo(() => {
cardNumber->CardUtils.getCardBrand
}, [cardNumber])

let (
isExpiryValid,
setIsExpiryValid,
Expand Down Expand Up @@ -204,7 +207,6 @@ let make = (
nickname,
isCardBrandValid,
isManualRetryEnabled,
cardProps,
))
useSubmitPaymentData(submitCallback)

Expand Down
1 change: 0 additions & 1 deletion src/RenderPaymentMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ let make = (
_,
_,
maxCardLength,
_,
) = cardProps

let (
Expand Down
1 change: 0 additions & 1 deletion src/SingleLineCardPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ let make = (
_,
_,
maxCardLength,
_,
) = cardProps

let (
Expand Down

0 comments on commit 47871cc

Please sign in to comment.