From 6f19013dfbf69fa3b6d6e1ca11cb142e145b9660 Mon Sep 17 00:00:00 2001 From: Arush Date: Fri, 18 Oct 2024 16:10:26 +0530 Subject: [PATCH] revert: reverted added support for cobadged cards #564 --- package-lock.json | 4 +-- package.json | 2 +- src/CardSchemeComponent.res | 51 ---------------------------- src/CardUtils.res | 16 --------- src/Components/DynamicFields.res | 2 -- src/Components/PaymentInputField.res | 2 +- src/Payment.res | 26 ++++++-------- src/Payments/CardPayment.res | 6 ++-- src/RenderPaymentMethods.res | 1 - src/SingleLineCardPayment.res | 1 - 10 files changed, 18 insertions(+), 93 deletions(-) delete mode 100644 src/CardSchemeComponent.res diff --git a/package-lock.json b/package-lock.json index 435ea7fb0..e5af40681 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.91.1", + "version": "0.91.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.91.1", + "version": "0.91.11", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", diff --git a/package.json b/package.json index d3d624eb6..1c4a6570c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.91.1", + "version": "0.91.11", "main": "index.js", "private": true, "dependencies": { diff --git a/src/CardSchemeComponent.res b/src/CardSchemeComponent.res deleted file mode 100644 index dee03adf6..000000000 --- a/src/CardSchemeComponent.res +++ /dev/null @@ -1,51 +0,0 @@ -module CoBadgeCardSchemeDropDown = { - @react.component - let make = (~eligibleCardSchemes, ~setCardBrand) => { - - } -} - -@react.component -let make = (~cardNumber, ~paymentType, ~cardBrand, ~setCardBrand) => { - let cardType = React.useMemo1(_ => cardBrand->CardUtils.getCardType, [cardBrand]) - let animate = cardType == NOTFOUND ? "animate-slideLeft" : "animate-slideRight" - let cardBrandIcon = React.useMemo1( - _ => CardUtils.getCardBrandIcon(cardType, paymentType), - [cardBrand], - ) - - let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue) - let enabledCardSchemes = - paymentMethodListValue->PaymentUtils.getSupportedCardBrands->Option.getOr([]) - - let matchedCardSchemes = cardNumber->CardUtils.getAllMatchedCardSchemes - - let eligibleCardSchemes = CardUtils.getEligibleCoBadgedCardSchemes( - ~matchedCardSchemes, - ~enabledCardSchemes, - ) - - let isCardCoBadged = eligibleCardSchemes->Array.length > 1 - - let marginLeft = isCardCoBadged ? "-ml-2" : "" - -
- cardBrandIcon - - - -
-} diff --git a/src/CardUtils.res b/src/CardUtils.res index 02a4bd55f..a20967fdc 100644 --- a/src/CardUtils.res +++ b/src/CardUtils.res @@ -26,7 +26,6 @@ type cardProps = ( string, (string => string) => unit, int, - string, ) type expiryProps = ( @@ -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) - }) -} diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 54158558f..f36b92d48 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -109,7 +109,6 @@ let make = ( "", _ => (), 0, - "", ) let defaultExpiryProps = ( @@ -164,7 +163,6 @@ let make = ( cardError, _, maxCardLength, - _, ) = switch cardProps { | Some(cardProps) => cardProps | None => defaultCardProps diff --git a/src/Components/PaymentInputField.res b/src/Components/PaymentInputField.res index 7c8b5540b..98ba1809d 100644 --- a/src/Components/PaymentInputField.res +++ b/src/Components/PaymentInputField.res @@ -131,7 +131,7 @@ let make = ( -
{rightIcon}
+
{rightIcon}
{switch errorString { diff --git a/src/Payment.res b/src/Payment.res index 9aa7ba63b..13dd3d733 100644 --- a/src/Payment.res +++ b/src/Payment.res @@ -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]) @@ -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 { [] } @@ -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(() => { - - }, (cardType, paymentType, cardBrand, cardNumber)) + let animate = cardType == NOTFOUND ? "animate-slideLeft" : "animate-slideRight" + let cardBrandIcon = getCardBrandIcon(cardType, paymentType) +
cardBrandIcon
+ }, (cardType, paymentType)) let cardProps: CardUtils.cardProps = ( isCardValid, @@ -373,7 +368,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => { cardError, setCardError, maxCardLength, - cardBrand, ) let expiryProps: CardUtils.expiryProps = ( diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 27d76278a..73edeef25 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -35,9 +35,12 @@ let make = ( cardError, setCardError, maxCardLength, - cardBrand, ) = cardProps + let cardBrand = React.useMemo(() => { + cardNumber->CardUtils.getCardBrand + }, [cardNumber]) + let ( isExpiryValid, setIsExpiryValid, @@ -204,7 +207,6 @@ let make = ( nickname, isCardBrandValid, isManualRetryEnabled, - cardProps, )) useSubmitPaymentData(submitCallback) diff --git a/src/RenderPaymentMethods.res b/src/RenderPaymentMethods.res index 368e64c5a..d2def612a 100644 --- a/src/RenderPaymentMethods.res +++ b/src/RenderPaymentMethods.res @@ -24,7 +24,6 @@ let make = ( _, _, maxCardLength, - _, ) = cardProps let ( diff --git a/src/SingleLineCardPayment.res b/src/SingleLineCardPayment.res index 7e4c3cc35..5a118442c 100644 --- a/src/SingleLineCardPayment.res +++ b/src/SingleLineCardPayment.res @@ -26,7 +26,6 @@ let make = ( _, _, maxCardLength, - _, ) = cardProps let (