diff --git a/CHANGELOG.md b/CHANGELOG.md index 031cdd6b2..412087f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.28.0](https://github.com/juspay/hyperswitch-web/compare/v0.27.5...v0.28.0) (2024-03-08) + + +### Features + +* **PaymentElement:** moved SavedCards component outside card form ([#197](https://github.com/juspay/hyperswitch-web/issues/197)) ([8e11c40](https://github.com/juspay/hyperswitch-web/commit/8e11c4087773a0c36d82f3b63358c3e9f6a9917f)) + ## [0.27.5](https://github.com/juspay/hyperswitch-web/compare/v0.27.4...v0.27.5) (2024-03-08) ## [0.27.4](https://github.com/juspay/hyperswitch-web/compare/v0.27.3...v0.27.4) (2024-03-08) diff --git a/package-lock.json b/package-lock.json index 1d8a377a7..a711b7903 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.27.5", + "version": "0.28.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2865,6 +2865,21 @@ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -2882,6 +2897,40 @@ "strip-ansi": "^7.0.1" } }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -2891,6 +2940,23 @@ "ansi-regex": "^6.0.1" } }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + } + } + }, "wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -2901,6 +2967,60 @@ "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } } } }, @@ -20842,17 +20962,6 @@ "strip-ansi": "^6.0.1" } }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "string.prototype.matchall": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.10.tgz", @@ -20940,15 +21049,6 @@ "ansi-regex": "^5.0.1" } }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, "strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -23520,43 +23620,6 @@ } } }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 834bc5c7e..cc3241dc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.27.5", + "version": "0.28.0", "main": "index.js", "private": true, "dependencies": { diff --git a/src/CardTheme.res b/src/CardTheme.res index 6086f4362..beda1b1b3 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -77,7 +77,7 @@ let getLocaleObject = string => { } LocaleString.localeStrings ->Array.filter(item => item.locale == val) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(LocaleString.defaultLocale) } let defaultRecoilConfig: recoilConfig = { diff --git a/src/CardUtils.res b/src/CardUtils.res index 2042623c6..123209c69 100644 --- a/src/CardUtils.res +++ b/src/CardUtils.res @@ -80,9 +80,9 @@ let getQueryParamsDictforKey = (searchParams, keyName) => { ->String.split("&") ->Array.forEach(paramStr => { let keyValArr = String.split(paramStr, "=") - let key = keyValArr->Belt.Array.get(0)->Option.getOr("") + let key = keyValArr->Array.get(0)->Option.getOr("") let value = if keyValArr->Array.length > 0 { - keyValArr->Belt.Array.get(1)->Option.getOr("") + keyValArr->Array.get(1)->Option.getOr("") } else { "" } @@ -116,7 +116,7 @@ let getobjFromCardPattern = cardBrand => { ->Array.filter(item => { cardBrand === item.issuer }) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(CardPattern.defaultCardPattern) } @@ -129,7 +129,7 @@ let slice = (val, start: int, end: int) => { } let getStrFromIndex = (arr: array, index) => { - arr->Belt.Array.get(index)->Option.getOr("") + arr->Array.get(index)->Option.getOr("") } let formatCVCNumber = (val, cardType) => { @@ -145,8 +145,8 @@ let getCurrentMonthAndYear = (dateTimeIsoString: string) => { let date = tempTimeDate[0]->Option.getOr("") let dateComponents = date->String.split("-") - let currentMonth = dateComponents->Belt.Array.get(1)->Option.getOr("") - let currentYear = dateComponents->Belt.Array.get(0)->Option.getOr("") + let currentMonth = dateComponents->Array.get(1)->Option.getOr("") + let currentYear = dateComponents->Array.get(0)->Option.getOr("") (currentMonth->toInt, currentYear->toInt) } @@ -178,8 +178,8 @@ let formatCardNumber = (val, cardType) => { let splitExpiryDates = val => { let split = val->String.split("/") let value = split->Array.map(item => item->String.trim) - let month = value->Belt.Array.get(0)->Option.getOr("") - let year = value->Belt.Array.get(1)->Option.getOr("") + let month = value->Array.get(0)->Option.getOr("") + let year = value->Array.get(1)->Option.getOr("") (month, year) } let getExpiryDates = val => { @@ -274,7 +274,7 @@ let getCardBrand = cardNumber => { } }) ->Array.filter(item => item !== "") - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr("") } } catch { @@ -307,8 +307,8 @@ let calculateLuhn = value => { } }) - let sumofCheckArr = Belt.Array.reduce(checkArr, 0, (acc, val) => acc + val->toInt) - let sumofUnCheckedArr = Belt.Array.reduce(unCheckArr, 0, (acc, val) => acc + val->toInt) + let sumofCheckArr = Array.reduce(checkArr, 0, (acc, val) => acc + val->toInt) + let sumofUnCheckedArr = Array.reduce(unCheckArr, 0, (acc, val) => acc + val->toInt) let totalSum = sumofCheckArr + sumofUnCheckedArr mod(totalSum, 10) == 0 } @@ -425,7 +425,7 @@ let genreateFontsLink = (fonts: array) => { } let maxCardLength = cardBrand => { let obj = getobjFromCardPattern(cardBrand) - Belt.Array.reduce(obj.length, 0, (acc, val) => acc > val ? acc : val) + Array.reduce(obj.length, 0, (acc, val) => acc > val ? acc : val) } let cardValid = (cardNumber, cardBrand) => { @@ -513,7 +513,7 @@ let pincodeVisibility = cardNumber => { let brandPattern = CardPattern.cardPatterns ->Array.filter(obj => obj.issuer == brand) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(CardPattern.defaultCardPattern) brandPattern.pincodeRequired } diff --git a/src/Components/AccordionContainer.res b/src/Components/AccordionContainer.res index be8ef7242..bec97f578 100644 --- a/src/Components/AccordionContainer.res +++ b/src/Components/AccordionContainer.res @@ -10,7 +10,7 @@ module Loader = { open PaymentElementShimmer switch list { | SemiLoaded => - Belt.Array.make(cardShimmerCount - 1, "") + Array.make(~length=cardShimmerCount - 1, "") ->Array.mapWithIndex((_, i) => { let borderStyle = layoutClass.spacedAccordionItems ? themeObj.borderRadius diff --git a/src/Components/DropdownField.res b/src/Components/DropdownField.res index 581aa3008..52aa25327 100644 --- a/src/Components/DropdownField.res +++ b/src/Components/DropdownField.res @@ -30,7 +30,7 @@ let make = ( }, [themeObj]) React.useEffect0(() => { if value === "" { - setValue(_ => options->Belt.Array.get(0)->Option.getOr("")) + setValue(_ => options->Array.get(0)->Option.getOr("")) } None }) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 9e20c2939..bb0167d9f 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -155,7 +155,7 @@ let make = ( ) React.useEffect0(() => { - let bank = bankNames->Belt.Array.get(0)->Option.getOr("") + let bank = bankNames->Array.get(0)->Option.getOr("") setSelectedBank(_ => bank) None }) @@ -254,7 +254,7 @@ let make = ( requiredFieldType.field_type === item && requiredFieldType.display_name === "card_holder_name" ) - ->Belt.Array.length > 0 + ->Array.length > 0 ) { Some(localeString.cardHolderName) } else { diff --git a/src/Components/PaymentDropDownField.res b/src/Components/PaymentDropDownField.res index afbf05056..4b1a8d6b6 100644 --- a/src/Components/PaymentDropDownField.res +++ b/src/Components/PaymentDropDownField.res @@ -28,7 +28,7 @@ let make = ( } } React.useEffect1(() => { - let initialValue = options->Belt.Array.get(0)->Option.getOr("") + let initialValue = options->Array.get(0)->Option.getOr("") if ( value.value === "" || value.value === initialValue || @@ -41,7 +41,7 @@ let make = ( }) } None - }, [options->Belt.Array.get(0)->Option.getOr("")]) + }, [options->Array.get(0)->Option.getOr("")]) let handleFocus = _ => { setInputFocused(_ => true) // setValue(.prev => { diff --git a/src/Components/SavedMethods.res b/src/Components/SavedMethods.res index fc20cb893..afcc58a72 100644 --- a/src/Components/SavedMethods.res +++ b/src/Components/SavedMethods.res @@ -1,4 +1,5 @@ open CardUtils +open Utils @react.component let make = ( ~paymentToken, @@ -8,10 +9,16 @@ let make = ( ~cvcProps, ~paymentType, ~list, - ~setRequiredFieldsBody, ) => { let {themeObj, localeString} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) let (showFields, setShowFields) = Recoil.useRecoilState(RecoilAtoms.showCardFieldsAtom) + let areRequiredFieldsValid = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsValid) + let (requiredFieldsBody, setRequiredFieldsBody) = React.useState(_ => Dict.make()) + let setUserError = message => { + postFailedSubmitResponse(~errortype="validation_error", ~message) + } + let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom) + let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Card) let (token, _) = paymentToken let savedCardlength = savedMethods->Array.length let bottomElement = { @@ -41,6 +48,44 @@ let make = ( ->React.array } + let (isCVCValid, _, cvcNumber, _, _, _, _, _, _, setCvcError) = cvcProps + let complete = switch isCVCValid { + | Some(val) => token !== "" && val + | _ => false + } + let empty = cvcNumber == "" + + let submitCallback = React.useCallback4((ev: Window.event) => { + let json = ev.data->JSON.parseExn + let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper + let (token, customerId) = paymentToken + let savedCardBody = PaymentBody.savedCardBody(~paymentToken=token, ~customerId, ~cvcNumber) + if confirm.doSubmit { + if areRequiredFieldsValid && complete && !empty { + intent( + ~bodyArr=savedCardBody + ->Dict.fromArray + ->JSON.Encode.object + ->OrcaUtils.flattenObject(true) + ->OrcaUtils.mergeTwoFlattenedJsonDicts(requiredFieldsBody) + ->OrcaUtils.getArrayOfTupleFromDict, + ~confirmParam=confirm.confirmParams, + ~handleUserError=false, + (), + ) + } else { + if cvcNumber === "" { + setCvcError(_ => localeString.cvcNumberEmptyText) + setUserError(localeString.enterFieldsText) + } + if !(isCVCValid->Belt.Option.getWithDefault(false)) { + setUserError(localeString.enterValidDetailsText) + } + } + } + }, (areRequiredFieldsValid, requiredFieldsBody, empty, complete)) + submitPaymentData(submitCallback) + <>
{ let msgToConcat = if index === 0 { myMsg - } else if index === oneClickWalletsArr->Belt.Array.length - 1 { + } else if index === oneClickWalletsArr->Array.length - 1 { <> {React.string(`${Utils.nbsp}${localeString.\"and"}${Utils.nbsp}`)} {myMsg} diff --git a/src/PaymentElement.res b/src/PaymentElement.res index 90356e632..5eb23c6a1 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -15,9 +15,13 @@ let make = ( ~paymentType: CardThemeType.mode, ) => { let sessionsObj = Recoil.useRecoilValueFromAtom(sessions) - let {showCardFormByDefault, paymentMethodOrder, layout} = Recoil.useRecoilValueFromAtom( - optionAtom, - ) + let { + showCardFormByDefault, + paymentMethodOrder, + layout, + customerPaymentMethods, + disableSaveCards, + } = Recoil.useRecoilValueFromAtom(optionAtom) let isApplePayReady = Recoil.useRecoilValueFromAtom(isApplePayReady) let isGooglePayReady = Recoil.useRecoilValueFromAtom(isGooglePayReady) let methodslist = Recoil.useRecoilValueFromAtom(list) @@ -36,6 +40,59 @@ let make = ( let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom) let isShowOrPayUsing = Recoil.useRecoilValueFromAtom(isShowOrPayUsing) + let (showFields, setShowFields) = Recoil.useRecoilState(RecoilAtoms.showCardFieldsAtom) + let (paymentToken, setPaymentToken) = Recoil.useRecoilState(RecoilAtoms.paymentTokenAtom) + let (savedMethods, setSavedMethods) = React.useState(_ => []) + let ( + loadSavedCards: PaymentType.savedCardsLoadState, + setLoadSavedCards: (PaymentType.savedCardsLoadState => PaymentType.savedCardsLoadState) => unit, + ) = React.useState(_ => PaymentType.LoadingSavedCards) + + React.useEffect1(() => { + switch customerPaymentMethods { + | LoadingSavedCards => () + | LoadedSavedCards(arr, isGuestCustomer) => { + let savedCards = arr->Array.filter((item: PaymentType.customerMethods) => { + item.paymentMethod == "card" + }) + setSavedMethods(_ => savedCards) + setLoadSavedCards(_ => + savedCards->Array.length == 0 + ? NoResult(isGuestCustomer) + : LoadedSavedCards(savedCards, isGuestCustomer) + ) + setShowFields(.prev => savedCards->Array.length == 0 || prev) + } + | NoResult(isGuestCustomer) => { + setLoadSavedCards(_ => NoResult(isGuestCustomer)) + setShowFields(._ => true) + } + } + + None + }, [customerPaymentMethods]) + + React.useEffect1(() => { + if disableSaveCards { + setShowFields(._ => true) + setLoadSavedCards(_ => LoadedSavedCards([], true)) + } + None + }, [disableSaveCards]) + + React.useEffect1(() => { + let tokenobj = + savedMethods->Array.length > 0 + ? Some(savedMethods->Array.get(0)->Option.getOr(defaultCustomerMethods)) + : None + + switch tokenobj { + | Some(obj) => setPaymentToken(._ => (obj.paymentToken, obj.customerId)) + | None => () + } + None + }, [savedMethods]) + let (walletList, paymentOptionsList, actualList) = React.useMemo4(() => { switch methodslist { | Loaded(paymentlist) => @@ -149,8 +206,8 @@ let make = ( | Loaded(_) => paymentOptions->Array.includes(selectedOption) && showCardFormByDefault ? selectedOption - : paymentOptions->Belt.Array.get(0)->Option.getOr("") - | _ => paymentOptions->Belt.Array.get(0)->Option.getOr("") + : paymentOptions->Array.get(0)->Option.getOr("") + | _ => paymentOptions->Array.get(0)->Option.getOr("") } ) None @@ -297,7 +354,14 @@ let make = ( } <> - Array.length > 0 || walletOptions->Array.length > 0}> + + + + Array.length > 0 || walletOptions->Array.length > 0) && + showFields}>
@@ -321,8 +385,8 @@ let make = (
-
+ {switch methodslist { | LoadError(_) => React.null | _ => diff --git a/src/PaymentOptions.res b/src/PaymentOptions.res index 57192e864..79cb61be5 100644 --- a/src/PaymentOptions.res +++ b/src/PaymentOptions.res @@ -8,7 +8,7 @@ module TabLoader = { open PaymentElementShimmer switch list { | SemiLoaded => - Belt.Array.make(cardShimmerCount - 1, "") + Array.make(~length=cardShimmerCount - 1, "") ->Array.mapWithIndex((_, i) => {
{ let intervalId = setInterval(() => { - if dropDownOptionsDetails->Belt.Array.length > 1 { - setMoreIconIndex(prev => mod(prev + 1, dropDownOptionsDetails->Belt.Array.length)) + if dropDownOptionsDetails->Array.length > 1 { + setMoreIconIndex(prev => mod(prev + 1, dropDownOptionsDetails->Array.length)) setToggleIconElement(_ => true) setTimeout( @@ -128,7 +128,7 @@ let make = ( Array.length > 0}>
- {switch dropDownOptionsDetails->Belt.Array.get(moreIconIndex) { + {switch dropDownOptionsDetails->Array.get(moreIconIndex) { | Some(paymentFieldsInfo) => switch paymentFieldsInfo.miniIcon { | Some(ele) => displayIcon(ele) diff --git a/src/Payments/CardPayment.res b/src/Payments/CardPayment.res index 0a71673e0..910d6b708 100644 --- a/src/Payments/CardPayment.res +++ b/src/Payments/CardPayment.res @@ -57,19 +57,9 @@ let make = ( cvcError, setCvcError, ) = cvcProps - let {customerPaymentMethods, disableSaveCards} = Recoil.useRecoilValueFromAtom( - RecoilAtoms.optionAtom, - ) let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Card) - let (savedMethods, setSavedMethods) = React.useState(_ => []) let (showFields, setShowFields) = Recoil.useRecoilState(RecoilAtoms.showCardFieldsAtom) - let (paymentToken, setPaymentToken) = Recoil.useRecoilState(RecoilAtoms.paymentTokenAtom) - let (token, _) = paymentToken let setComplete = Recoil.useSetRecoilState(RecoilAtoms.fieldsComplete) - let ( - loadSavedCards: PaymentType.savedCardsLoadState, - setLoadSavedCards: (PaymentType.savedCardsLoadState => PaymentType.savedCardsLoadState) => unit, - ) = React.useState(_ => PaymentType.LoadingSavedCards) let (isSaveCardsChecked, setIsSaveCardsChecked) = React.useState(_ => false) let setUserError = message => { @@ -80,58 +70,8 @@ let make = ( let areRequiredFieldsValid = Recoil.useRecoilValueFromAtom(RecoilAtoms.areRequiredFieldsValid) - React.useEffect1(() => { - switch customerPaymentMethods { - | LoadingSavedCards => () - | LoadedSavedCards(arr, isGuestCustomer) => { - let savedCards = arr->Array.filter((item: PaymentType.customerMethods) => { - item.paymentMethod == "card" - }) - setSavedMethods(_ => savedCards) - setLoadSavedCards(_ => - savedCards->Array.length == 0 - ? NoResult(isGuestCustomer) - : LoadedSavedCards(savedCards, isGuestCustomer) - ) - setShowFields(.prev => savedCards->Array.length == 0 || prev) - } - | NoResult(isGuestCustomer) => { - setLoadSavedCards(_ => NoResult(isGuestCustomer)) - setShowFields(._ => true) - } - } - - None - }, [customerPaymentMethods]) - - React.useEffect1(() => { - if disableSaveCards { - setShowFields(._ => true) - setLoadSavedCards(_ => LoadedSavedCards([], true)) - } - None - }, [disableSaveCards]) - - React.useEffect1(() => { - let tokenobj = - savedMethods->Array.length > 0 - ? Some(savedMethods->Belt.Array.get(0)->Option.getOr(defaultCustomerMethods)) - : None - - switch tokenobj { - | Some(obj) => setPaymentToken(._ => (obj.paymentToken, obj.customerId)) - | None => () - } - None - }, [savedMethods]) - - let complete = showFields - ? isAllValid(isCardValid, isCVCValid, isExpiryValid, true, "payment") - : switch isCVCValid { - | Some(val) => token !== "" && !isBancontact && val - | _ => false - } - let empty = showFields ? cardNumber == "" || cardExpiry == "" || cvcNumber == "" : cvcNumber == "" + let complete = isAllValid(isCardValid, isCVCValid, isExpiryValid, true, "payment") + let empty = cardNumber == "" || cardExpiry == "" || cvcNumber == "" React.useEffect1(() => { setComplete(._ => complete) None @@ -142,14 +82,13 @@ let make = ( None }, (empty, complete)) - let isGuestCustomer = React.useMemo1(() => { - switch customerPaymentMethods { - | LoadedSavedCards(_, false) - | NoResult(false) => false - | _ => true + let (savedMethods, isGuestCustomer) = React.useMemo1(() => { + switch options.customerPaymentMethods { + | LoadedSavedCards(savedMethods, isGuest) => (savedMethods, isGuest) + | NoResult(isGuest) => ([], isGuest) + | _ => ([], true) } - }, [customerPaymentMethods]) - + }, [options.customerPaymentMethods]) let isCvcValidValue = CardUtils.getBoolOptionVal(isCVCValid) let (cardEmpty, cardComplete, cardInvalid) = CardUtils.useCardDetails( ~cvcNumber, @@ -161,9 +100,6 @@ let make = ( let json = ev.data->JSON.parseExn let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper let (month, year) = CardUtils.getExpiryDates(cardExpiry) - let (token, customerId) = paymentToken - let savedCardBody = PaymentBody.savedCardBody(~paymentToken=token, ~customerId, ~cvcNumber) - let onSessionBody = [("setup_future_usage", "on_session"->JSON.Encode.string)] let cardNetwork = { if cardBrand != "" { @@ -204,18 +140,6 @@ let make = ( ~handleUserError=false, (), ) - } else if areRequiredFieldsValid && complete && !empty { - intent( - ~bodyArr=savedCardBody - ->Dict.fromArray - ->JSON.Encode.object - ->OrcaUtils.flattenObject(true) - ->OrcaUtils.mergeTwoFlattenedJsonDicts(requiredFieldsBody) - ->OrcaUtils.getArrayOfTupleFromDict, - ~confirmParam=confirm.confirmParams, - ~handleUserError=false, - (), - ) } else { if cardNumber === "" { setCardError(_ => localeString.cardNumberEmptyText) @@ -241,18 +165,6 @@ let make = ( let paymentMethodType = isBancontact ? "bancontact_card" : "debit"
- - -
{ let getPaymentMethodsFieldTypeFromDict = dict => { let keysArr = dict->Dict.keysToArray - let key = keysArr->Belt.Array.get(0)->Option.getOr("") + let key = keysArr->Array.get(0)->Option.getOr("") switch key { | "user_currency" => { let options = dict->Utils.getArrayValFromJsonDict("user_currency", "options") @@ -533,7 +533,7 @@ let getPaymentMethodsFieldTypeFromDict = dict => { } | "user_address_country" => { let options = dict->Utils.getArrayValFromJsonDict("user_address_country", "options") - switch options->Belt.Array.get(0)->Option.getOr("") { + switch options->Array.get(0)->Option.getOr("") { | "" => None | "ALL" => AddressCountry(Country.country->Array.map(item => item.countryName)) | _ => @@ -988,7 +988,7 @@ let getPaymentMethodTypeFromList = (~list: list, ~paymentMethod, ~paymentMethodT let getCardNetwork = (~paymentMethodType, ~cardBrand) => { paymentMethodType.card_networks ->Array.filter(cardNetwork => cardNetwork.card_network === cardBrand) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(defaultCardNetworks) } diff --git a/src/Payments/PaymentMethodsWrapper.res b/src/Payments/PaymentMethodsWrapper.res index 354defdfd..89090fd01 100644 --- a/src/Payments/PaymentMethodsWrapper.res +++ b/src/Payments/PaymentMethodsWrapper.res @@ -25,7 +25,7 @@ let make = ( optionPaymentMethodDetails->Option.getOr(PaymentMethodsRecord.defaultPaymentMethodContent) let paymentFlow = paymentMethodDetails.paymentFlow - ->Belt.Array.get(0) + ->Array.get(0) ->Option.flatMap(((flow, _connector)) => { Some(flow) }) @@ -70,13 +70,13 @@ let make = ( let countryCode = Country.getCountry(paymentMethodName) ->Array.filter(item => item.countryName == country) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(Country.defaultTimeZone) let bank = Bank.getBanks(paymentMethodName) ->Array.filter(item => item.displayName == selectedBank) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(Bank.defaultBank) intent( ~bodyArr=PaymentBody.getPaymentBody( diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index cdade2288..41670757f 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -912,5 +912,5 @@ let getIsAllStoredCardsHaveName = (savedCards: array) => { | _ => true } }) - ->Belt.Array.length === savedCards->Belt.Array.length + ->Array.length === savedCards->Array.length } diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 6af7ea49f..ea40c55bd 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -1,13 +1,11 @@ let getName = (item: PaymentMethodsRecord.required_fields, field: RecoilAtomTypes.field) => { let fieldNameArr = field.value->String.split(" ") let requiredFieldsArr = item.required_field->String.split(".") - switch requiredFieldsArr - ->Belt.Array.get(requiredFieldsArr->Belt.Array.length - 1) - ->Option.getOr("") { - | "first_name" => fieldNameArr->Belt.Array.get(0)->Option.getOr(field.value) + switch requiredFieldsArr->Array.get(requiredFieldsArr->Array.length - 1)->Option.getOr("") { + | "first_name" => fieldNameArr->Array.get(0)->Option.getOr(field.value) | "last_name" => fieldNameArr - ->Belt.Array.sliceToEnd(1) + ->Array.sliceToEnd(~start=1) ->Array.reduce("", (acc, item) => { acc ++ item }) @@ -87,10 +85,10 @@ let checkIfNameIsValid = ( let fieldNameArr = field.value->String.split(" ") let requiredFieldsArr = item.required_field->String.split(".") let fieldValue = switch requiredFieldsArr - ->Belt.Array.get(requiredFieldsArr->Belt.Array.length - 1) + ->Array.get(requiredFieldsArr->Array.length - 1) ->Option.getOr("") { - | "first_name" => fieldNameArr->Belt.Array.get(0)->Option.getOr("") - | "last_name" => fieldNameArr->Belt.Array.get(1)->Option.getOr("") + | "first_name" => fieldNameArr->Array.get(0)->Option.getOr("") + | "last_name" => fieldNameArr->Array.get(1)->Option.getOr("") | _ => field.value } acc && fieldValue !== "" @@ -134,23 +132,23 @@ let useRequiredFieldsEmptyAndValid = ( switch paymentMethodFields { | Email => email.isValid->Option.getOr(false) | FullName => checkIfNameIsValid(requiredFields, paymentMethodFields, fullName) - | Country => country !== "" || countryNames->Belt.Array.length === 0 - | AddressCountry(countryArr) => country !== "" || countryArr->Belt.Array.length === 0 + | Country => country !== "" || countryNames->Array.length === 0 + | AddressCountry(countryArr) => country !== "" || countryArr->Array.length === 0 | BillingName => checkIfNameIsValid(requiredFields, paymentMethodFields, billingName) | AddressLine1 => line1.value !== "" | AddressLine2 => billingAddress.isUseBillingAddress ? true : line2.value !== "" - | Bank => selectedBank !== "" || bankNames->Belt.Array.length === 0 + | Bank => selectedBank !== "" || bankNames->Array.length === 0 | PhoneNumber => phone.value !== "" | StateAndCity => state.value !== "" && city.value !== "" | CountryAndPincode(countryArr) => - (country !== "" || countryArr->Belt.Array.length === 0) && + (country !== "" || countryArr->Array.length === 0) && postalCode.isValid->Option.getOr(false) | AddressCity => city.value !== "" | AddressPincode => postalCode.isValid->Option.getOr(false) | AddressState => state.value !== "" | BlikCode => blikCode.value !== "" - | Currency(currencyArr) => currency !== "" || currencyArr->Belt.Array.length === 0 + | Currency(currencyArr) => currency !== "" || currencyArr->Array.length === 0 | CardNumber => isCardValid->Option.getOr(false) | CardExpiryMonth | CardExpiryYear @@ -171,21 +169,21 @@ let useRequiredFieldsEmptyAndValid = ( switch paymentMethodFields { | Email => email.value === "" | FullName => fullName.value === "" - | Country => country === "" && countryNames->Belt.Array.length > 0 - | AddressCountry(countryArr) => country === "" && countryArr->Belt.Array.length > 0 + | Country => country === "" && countryNames->Array.length > 0 + | AddressCountry(countryArr) => country === "" && countryArr->Array.length > 0 | BillingName => billingName.value === "" | AddressLine1 => line1.value === "" | AddressLine2 => billingAddress.isUseBillingAddress ? false : line2.value === "" - | Bank => selectedBank === "" && bankNames->Belt.Array.length > 0 + | Bank => selectedBank === "" && bankNames->Array.length > 0 | StateAndCity => city.value === "" || state.value === "" | CountryAndPincode(countryArr) => - (country === "" && countryArr->Belt.Array.length > 0) || postalCode.value === "" + (country === "" && countryArr->Array.length > 0) || postalCode.value === "" | PhoneNumber => phone.value === "" | AddressCity => city.value === "" | AddressPincode => postalCode.value === "" | AddressState => state.value === "" | BlikCode => blikCode.value === "" - | Currency(currencyArr) => currency === "" && currencyArr->Belt.Array.length > 0 + | Currency(currencyArr) => currency === "" && currencyArr->Array.length > 0 | CardNumber => cardNumber === "" | CardExpiryMonth => let (month, _) = CardUtils.getExpiryDates(cardExpiry) @@ -284,9 +282,7 @@ let useSetInitialRequiredFields = ( ->Array.filter(requiredFields => requiredFields.field_type === item.field_type) ->Array.reduce("", (acc, item) => { let requiredFieldsArr = item.required_field->String.split(".") - switch requiredFieldsArr - ->Belt.Array.get(requiredFieldsArr->Belt.Array.length - 1) - ->Option.getOr("") { + switch requiredFieldsArr->Array.get(requiredFieldsArr->Array.length - 1)->Option.getOr("") { | "first_name" => item.value->String.concat(acc) | "last_name" => acc->String.concatMany([" ", item.value]) | _ => acc @@ -342,7 +338,7 @@ let useSetInitialRequiredFields = ( let countryCode = Country.getCountry(paymentMethodType) ->Array.filter(item => item.isoAlpha2 === value) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(Country.defaultTimeZone) setCountry(. _ => countryCode.countryName) } @@ -359,7 +355,7 @@ let useSetInitialRequiredFields = ( let defaultCountry = Country.getCountry(paymentMethodType) ->Array.filter(item => item.isoAlpha2 === value) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(Country.defaultTimeZone) setCountry(. _ => defaultCountry.countryName) } @@ -428,7 +424,7 @@ let useRequiredFieldsBody = ( let countryCode = Country.getCountry(paymentMethodType) ->Array.filter(item => item.countryName === country) - ->Belt.Array.get(0) + ->Array.get(0) ->Option.getOr(Country.defaultTimeZone) countryCode.isoAlpha2 } @@ -460,11 +456,11 @@ let useRequiredFieldsBody = ( let arr = value->String.split(" ") acc->Dict.set( "billing.address.first_name", - arr->Belt.Array.get(0)->Option.getOr("")->JSON.Encode.string, + arr->Array.get(0)->Option.getOr("")->JSON.Encode.string, ) acc->Dict.set( "billing.address.last_name", - arr->Belt.Array.get(1)->Option.getOr("")->JSON.Encode.string, + arr->Array.get(1)->Option.getOr("")->JSON.Encode.string, ) } else { let path = item->getBillingAddressPathFromFieldType diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index de982917b..5176007ad 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -206,7 +206,7 @@ let rec intentCall = ( } } else { let paymentIntentID = - String.split(clientSecret, "_secret_")->Belt.Array.get(0)->Option.getOr("") + String.split(clientSecret, "_secret_")->Array.get(0)->Option.getOr("") let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey=confirmParam.publishableKey, ()) let retrieveUri = `${endpoint}/payments/${paymentIntentID}?client_secret=${clientSecret}` intentCall( @@ -467,8 +467,7 @@ let rec intentCall = ( openUrl(url.href) } } else { - let paymentIntentID = - String.split(clientSecret, "_secret_")->Belt.Array.get(0)->Option.getOr("") + let paymentIntentID = String.split(clientSecret, "_secret_")->Array.get(0)->Option.getOr("") let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey=confirmParam.publishableKey, ()) let retrieveUri = `${endpoint}/payments/${paymentIntentID}?client_secret=${clientSecret}` intentCall( @@ -742,7 +741,7 @@ let useSessions = ( ) => { open Promise let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] - let paymentIntentID = String.split(clientSecret, "_secret_")->Belt.Array.get(0)->Option.getOr("") + let paymentIntentID = String.split(clientSecret, "_secret_")->Array.get(0)->Option.getOr("") let body = [ ("payment_id", paymentIntentID->JSON.Encode.string), diff --git a/src/Utilities/PaymentUtils.res b/src/Utilities/PaymentUtils.res index 6ac106756..13f9b80e7 100644 --- a/src/Utilities/PaymentUtils.res +++ b/src/Utilities/PaymentUtils.res @@ -193,7 +193,7 @@ let getDisplayNameAndIcon = ( ->Array.filter((item: PaymentType.alias) => { item.paymentMethodName === paymentMethodName }) - ->Belt.Array.get(0) + ->Array.get(0) switch customNameObj { | Some(val) => val.paymentMethodName === "classic" || val.paymentMethodName === "evoucher" @@ -204,7 +204,7 @@ let getDisplayNameAndIcon = ( let id = aliasName->String.split(" ") ( aliasName, - Some(PaymentMethodsRecord.icon(id->Belt.Array.get(0)->Option.getOr(""), ~size=19)), + Some(PaymentMethodsRecord.icon(id->Array.get(0)->Option.getOr(""), ~size=19)), ) } } diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index eb76ff1fa..23ae30c4f 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -164,14 +164,14 @@ let getStrArray = (dict, key) => { dict ->getOptionalArrayFromDict(key) ->Option.getOr([]) - ->Belt.Array.map(json => json->JSON.Decode.string->Option.getOr("")) + ->Array.map(json => json->JSON.Decode.string->Option.getOr("")) } let getOptionalStrArray: (Dict.t, string) => option> = (dict, key) => { switch dict->getOptionalArrayFromDict(key) { | Some(val) => val->Array.length === 0 ? None - : Some(val->Belt.Array.map(json => json->JSON.Decode.string->Option.getOr(""))) + : Some(val->Array.map(json => json->JSON.Decode.string->Option.getOr(""))) | None => None } } @@ -570,7 +570,7 @@ let getOptionalArr = arr => { } let checkPriorityList = paymentMethodOrder => { - paymentMethodOrder->getOptionalArr->Belt.Array.get(0)->Option.getOr("") == "card" || + paymentMethodOrder->getOptionalArr->Array.get(0)->Option.getOr("") == "card" || paymentMethodOrder->Option.isNone } type sizeunit = Pixel | Rem | Em @@ -710,7 +710,7 @@ let formatIBAN = iban => { | Some(matches) => matches | None => [] } - `${countryCode}${codeLastTwo} ${chunks->Js.Array2.joinWith(" ")}`->String.trim + `${countryCode}${codeLastTwo} ${chunks->Array.joinWith(" ")}`->String.trim } let formatBSB = bsb => { @@ -741,9 +741,9 @@ let rgbaTorgb = bgColor => { if colorArr->Array.length === 3 { cleanBgColor } else { - let red = colorArr->Belt.Array.get(0)->Option.getOr("0") - let green = colorArr->Belt.Array.get(1)->Option.getOr("0") - let blue = colorArr->Belt.Array.get(2)->Option.getOr("0") + let red = colorArr->Array.get(0)->Option.getOr("0") + let green = colorArr->Array.get(1)->Option.getOr("0") + let blue = colorArr->Array.get(2)->Option.getOr("0") `rgba(${red}, ${green}, ${blue})` } } else { diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index fd9314c79..163422f88 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -202,7 +202,7 @@ let make = (publishableKey, options: option, analyticsInfo: optionthen(resp => { let statusCode = resp->Fetch.Response.status->string_of_int - if statusCode->Js.String2.charAt(0) !== "2" { + if statusCode->String.charAt(0) !== "2" { resp ->Fetch.Response.json ->then(data => { diff --git a/src/orca-loader/LoaderPaymentElement.res b/src/orca-loader/LoaderPaymentElement.res index b771d62fc..af9ac095f 100644 --- a/src/orca-loader/LoaderPaymentElement.res +++ b/src/orca-loader/LoaderPaymentElement.res @@ -156,7 +156,7 @@ let make = (componentType, options, setIframeRef, iframeRef, mountPostMessage) = let mount = selector => { mountId := selector let localSelectorArr = selector->String.split("#") - let localSelectorString = localSelectorArr->Belt.Array.get(1)->Option.getOr("someString") + let localSelectorString = localSelectorArr->Array.get(1)->Option.getOr("someString") let iframeHeightRef = ref(25.0) let currentClass = ref("base") let fullscreen = ref(false) diff --git a/src/orca-loader/OrcaUtils.res b/src/orca-loader/OrcaUtils.res index 1d5ab5221..81aa95361 100644 --- a/src/orca-loader/OrcaUtils.res +++ b/src/orca-loader/OrcaUtils.res @@ -191,7 +191,7 @@ let unflattenObject = obj => { ->Dict.toArray ->Array.forEach(entry => { let (key, value) = entry - setNested(newDict, key->Js.String2.split("."), value) + setNested(newDict, key->String.split("."), value) }) | None => () } @@ -324,7 +324,7 @@ let mergeTwoFlattenedJsonDicts = (dict1, dict2) => { let getArrayOfTupleFromDict = dict => { dict ->Dict.keysToArray - ->Belt.Array.map(key => (key, Dict.get(dict, key)->Option.getOr(JSON.Encode.null))) + ->Array.map(key => (key, Dict.get(dict, key)->Option.getOr(JSON.Encode.null))) } let makeOneClickHandlerPromise = sdkHandleOneClickConfirmPayment => { diff --git a/src/orca-log-catcher/ErrorBoundary.res b/src/orca-log-catcher/ErrorBoundary.res index 169d07bc8..5c61d86f2 100644 --- a/src/orca-log-catcher/ErrorBoundary.res +++ b/src/orca-log-catcher/ErrorBoundary.res @@ -118,8 +118,8 @@ module ErrorCard = { category: USER_ERROR, paymentId: "", merchantId: "", - browserName: OrcaLogger.arrayOfNameAndVersion->Belt.Array.get(0)->Option.getOr("Others"), - browserVersion: OrcaLogger.arrayOfNameAndVersion->Belt.Array.get(1)->Option.getOr("0"), + browserName: OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), + browserVersion: OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.platform, userAgent: Window.userAgent, appId: "", diff --git a/src/orca-log-catcher/OrcaLogger.res b/src/orca-log-catcher/OrcaLogger.res index fb6b03d5a..e85d12907 100644 --- a/src/orca-log-catcher/OrcaLogger.res +++ b/src/orca-log-catcher/OrcaLogger.res @@ -316,7 +316,7 @@ let browserDetect = content => { if RegExp.test("Edg"->RegExp.fromString, content) { let re = %re("/Edg\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -326,7 +326,7 @@ let browserDetect = content => { } else if RegExp.test("Chrome"->RegExp.fromString, content) { let re = %re("/Chrome\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -336,7 +336,7 @@ let browserDetect = content => { } else if RegExp.test("Safari"->RegExp.fromString, content) { let re = %re("/Safari\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -346,7 +346,7 @@ let browserDetect = content => { } else if RegExp.test("opera"->RegExp.fromString, content) { let re = %re("/Opera\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -360,7 +360,7 @@ let browserDetect = content => { if RegExp.test("Firefox"->RegExp.fromString, content) { let re = %re("/Firefox\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -370,7 +370,7 @@ let browserDetect = content => { } else { let re = %re("/fxios\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) - ->Belt.Array.get(1) + ->Array.get(1) ->Option.getOr(Nullable.null) ->Nullable.toOption { | Some(a) => a @@ -575,12 +575,10 @@ let make = ( value, internalMetadata, category: logCategory, - paymentId: String.split(clientSecret.contents, "_secret_") - ->Belt.Array.get(0) - ->Option.getOr(""), + paymentId: String.split(clientSecret.contents, "_secret_")->Array.get(0)->Option.getOr(""), merchantId: merchantId.contents, - browserName: arrayOfNameAndVersion->Belt.Array.get(0)->Option.getOr("Others"), - browserVersion: arrayOfNameAndVersion->Belt.Array.get(1)->Option.getOr("0"), + browserName: arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), + browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.platform, userAgent: Window.userAgent, appId: "", @@ -633,12 +631,10 @@ let make = ( | StringValue(a) => a }, category: logCategory, - paymentId: String.split(clientSecret.contents, "_secret_") - ->Belt.Array.get(0) - ->Option.getOr(""), + paymentId: String.split(clientSecret.contents, "_secret_")->Array.get(0)->Option.getOr(""), merchantId: merchantId.contents, - browserName: arrayOfNameAndVersion->Belt.Array.get(0)->Option.getOr("Others"), - browserVersion: arrayOfNameAndVersion->Belt.Array.get(1)->Option.getOr("0"), + browserName: arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), + browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.platform, userAgent: Window.userAgent, appId: "", @@ -678,12 +674,10 @@ let make = ( value, internalMetadata, category: logCategory, - paymentId: String.split(clientSecret.contents, "_secret_") - ->Belt.Array.get(0) - ->Option.getOr(""), + paymentId: String.split(clientSecret.contents, "_secret_")->Array.get(0)->Option.getOr(""), merchantId: merchantId.contents, - browserName: arrayOfNameAndVersion->Belt.Array.get(0)->Option.getOr("Others"), - browserVersion: arrayOfNameAndVersion->Belt.Array.get(1)->Option.getOr("0"), + browserName: arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), + browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.platform, userAgent: Window.userAgent, appId: "", @@ -714,12 +708,10 @@ let make = ( category: USER_EVENT, value: "log initiated", internalMetadata: "", - paymentId: String.split(clientSecret.contents, "_secret_") - ->Belt.Array.get(0) - ->Option.getOr(""), + paymentId: String.split(clientSecret.contents, "_secret_")->Array.get(0)->Option.getOr(""), merchantId: merchantId.contents, - browserName: arrayOfNameAndVersion->Belt.Array.get(0)->Option.getOr("Others"), - browserVersion: arrayOfNameAndVersion->Belt.Array.get(1)->Option.getOr("0"), + browserName: arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), + browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.platform, userAgent: Window.userAgent, appId: "",