Skip to content

Commit

Permalink
revert: reverted added support for cobadged cards #564
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay committed Oct 18, 2024
1 parent 458ee87 commit 6f19013
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 93 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.91.1",
"version": "0.91.11",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
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 6f19013

Please sign in to comment.