From 84c283b8092e3296dc97c87725966d540f490d5b Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:33:32 +0530 Subject: [PATCH 1/6] fix: changes for supporting form data type in api (#257) Co-authored-by: Pritish Budhiraja <1805317@kiit.ac.in> --- src/hooks/AuthHooks.res | 57 +++++++------------ src/screens/HyperSwitch/APIUtils/APIUtils.res | 19 ++++++- .../HyperSwitch/Order/OrderUIUtils.res | 9 ++- .../HyperSwitch/Refunds/RefundUtils.res | 9 ++- 4 files changed, 52 insertions(+), 42 deletions(-) diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index bd4440a0b..61ec1c785 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -14,47 +14,23 @@ let getHeaders = (~uri, ~headers, ()) => { let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption let isMixpanel = uri->String.includes("mixpanel") - if isMixpanel { - let headerObj = { - "Content-Type": "application/x-www-form-urlencoded", - "accept": "application/json", - } - Fetch.HeadersInit.make(headerObj) + let headerObj = if isMixpanel { + [ + ("Content-Type", "application/x-www-form-urlencoded"), + ("accept", "application/json"), + ]->Dict.fromArray } else { - let headerObj = headers->Dict.get("api-key")->Option.getWithDefault("")->String.length > 0 - - if headerObj { - let headerObj = { - "Content-Type": "application/json", - "api-key": headers->Dict.get("api-key")->Option.getWithDefault(""), + let res = switch hyperSwitchToken { + | Some(token) => { + headers->Dict.set("authorization", `Bearer ${token}`) + headers } - Fetch.HeadersInit.make(headerObj) - } else { - switch hyperSwitchToken { - | Some(token) => - if token !== "" { - let headerObj = { - "Content-Type": "application/json", - "Authorization": `Bearer ${hyperSwitchToken->Option.getWithDefault("")}`, - "api-key": "hyperswitch", - } - - Fetch.HeadersInit.make(headerObj) - } else { - let headerObj = { - "Content-Type": "application/json", - } - Fetch.HeadersInit.make(headerObj) - } - | None => - let headerObj = { - "Content-Type": "application/json", - } - Fetch.HeadersInit.make(headerObj) - } + | None => headers } + res } + Fetch.HeadersInit.make(headerObj->dictToObj) } @val @scope(("window", "location")) @@ -81,7 +57,8 @@ let useApiFetcher = () => { ( uri, ~bodyStr: string="", - ~headers=Dict.make(), + ~bodyFormData=None, + ~headers=[("Content-Type", "application/json")]->Dict.fromArray, ~bodyHeader as _=?, ~method_: Fetch.requestMethod, ~authToken as _=?, @@ -98,7 +75,11 @@ let useApiFetcher = () => { let body = switch method_ { | Get => resolve(None) - | _ => resolve(Some(Fetch.BodyInit.make(bodyStr))) + | _ => + switch bodyFormData { + | Some(formDataVal) => resolve(Some(Fetch.BodyInit.makeWithFormData(formDataVal))) + | None => resolve(Some(Fetch.BodyInit.make(bodyStr))) + } } body->then(body => { diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res index b466c8d4a..c3195c77e 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtils.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res @@ -203,6 +203,7 @@ let handleLogout = async ( ~fetchApi as _: ( Js.String2.t, ~bodyStr: string=?, + ~bodyFormData: option=?, ~headers: Js.Dict.t=?, ~bodyHeader: Js.Dict.t=?, ~method_: Fetch.requestMethod, @@ -387,9 +388,23 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { }, }) - async (url, body, method, ()) => { + async ( + url, + body, + method, + ~bodyFormData=?, + ~headers=[("Content-Type", "application/json")]->Dict.fromArray, + (), + ) => { try { - let res = await fetchApi(url, ~method_=method, ~bodyStr=body->Js.Json.stringify, ()) + let res = await fetchApi( + url, + ~method_=method, + ~bodyStr=body->Js.Json.stringify, + ~bodyFormData, + ~headers, + (), + ) await responseHandler( ~res, ~showErrorToast, diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res index a0b9174f5..f34906551 100644 --- a/src/screens/HyperSwitch/Order/OrderUIUtils.res +++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res @@ -213,7 +213,14 @@ let setData = ( let getOrdersList = async ( filterValueJson, - ~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise, + ~updateDetails: ( + string, + Js.Json.t, + Fetch.requestMethod, + ~bodyFormData: Fetch.formData=?, + ~headers: Js.Dict.t<'a>=?, + unit, + ) => promise, ~setOrdersData, ~previewOnly, ~setScreenState, diff --git a/src/screens/HyperSwitch/Refunds/RefundUtils.res b/src/screens/HyperSwitch/Refunds/RefundUtils.res index c7b786427..e0267d442 100644 --- a/src/screens/HyperSwitch/Refunds/RefundUtils.res +++ b/src/screens/HyperSwitch/Refunds/RefundUtils.res @@ -1,6 +1,13 @@ let getRefundsList = async ( filterValueJson, - ~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise, + ~updateDetails: ( + string, + Js.Json.t, + Fetch.requestMethod, + ~bodyFormData: Fetch.formData=?, + ~headers: Js.Dict.t<'a>=?, + unit, + ) => promise, ~setRefundsData, ~setScreenState, ~offset, From f35bcc524184c0c1bcc84a41198e81424bef7cc4 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 23 Jan 2024 16:37:50 +0530 Subject: [PATCH 2/6] fix: Access Control Issue (#284) Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- src/entryPoints/hyperswitch/HyperSwitchApp.res | 7 ++++--- src/utils/AccessControl.res | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res index 8f90ad3b9..929e51945 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchApp.res +++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res @@ -361,11 +361,11 @@ let make = () => { /> | list{"recon"} => - + | list{"sdk"} => - + | list{"3ds"} => @@ -397,7 +397,8 @@ let make = () => { | list{"business-profiles"} => - + | list{"quick-start"} => determineQuickStartPageState() diff --git a/src/utils/AccessControl.res b/src/utils/AccessControl.res index 9e4f772e4..23705a541 100644 --- a/src/utils/AccessControl.res +++ b/src/utils/AccessControl.res @@ -1,6 +1,6 @@ open AuthTypes @react.component -let make = (~isEnabled=true, ~permission=NoAccess, ~children) => { +let make = (~isEnabled=true, ~permission, ~children) => { let isAccessAllowed = permission === Access isEnabled && isAccessAllowed ? children : } From 608e436d23b01863594937179318d05ec73eaed8 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:34:28 +0000 Subject: [PATCH 3/6] chore(version): v1.28.1 --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 261ce2aa8..227656b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [conven - - - +## 1.28.1 (2024-01-23) + +### Bug Fixes + +- Use apifetcher function update ([#283](https://github.com/juspay/hyperswitch-control-center/pull/283)) ([`d587598`](https://github.com/juspay/hyperswitch-control-center/commit/d587598a1f13a234b68b5bc204780fda3c773e0e)) +- Changes for supporting form data type in api ([#257](https://github.com/juspay/hyperswitch-control-center/pull/257)) ([`84c283b`](https://github.com/juspay/hyperswitch-control-center/commit/84c283b8092e3296dc97c87725966d540f490d5b)) +- Access Control Issue ([#284](https://github.com/juspay/hyperswitch-control-center/pull/284)) ([`f35bcc5`](https://github.com/juspay/hyperswitch-control-center/commit/f35bcc524184c0c1bcc84a41198e81424bef7cc4)) + +**Full Changelog:** [`v1.28.0...v1.28.1`](https://github.com/juspay/hyperswitch-control-center/compare/v1.28.0...v1.28.1) + +- - - + + ## 1.28.0 (2024-01-22) ### Features From 40954d25e225520d41bd2585f2b0fbfc4d9ee965 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 24 Jan 2024 10:57:34 +0530 Subject: [PATCH 4/6] chore: utils refactor (#282) --- src/hooks/ListHooks.res | 11 +- .../HomePageOverviewComponent.res | 14 +- .../Connectors/ConnectorAccountDetails.res | 7 +- .../HyperSwitch/Connectors/ConnectorList.res | 29 ++-- .../Connectors/ConnectorPaymentMethod.res | 4 +- .../Connectors/ConnectorTableUtils.res | 4 +- .../HyperSwitch/Connectors/ConnectorTypes.res | 2 + .../ConnectorUIUtils/PaymentMethod.res | 12 +- .../HyperSwitch/Connectors/ConnectorUtils.res | 81 +++++---- .../CommonConnectorFlow/SetupConnector.res | 20 ++- .../Home/QuickStart/QuickStartUIUtils.res | 2 +- .../Home/QuickStart/QuickStartUtils.res | 6 - .../HyperSwitch/Routing/PriorityRouting.res | 2 +- .../SetupConnectorCredentials.res | 10 +- .../SetupAccount/HSwitchSetupAccountUtils.res | 5 +- .../HyperSwitch/{ => Utils}/HSwitchUtils.res | 158 ++++++------------ src/screens/HyperSwitch/Utils/UtilsTypes.res | 34 ++++ .../HSwitchLoginFlow/HyperSwitchAuth.res | 1 - 18 files changed, 189 insertions(+), 213 deletions(-) rename src/screens/HyperSwitch/{ => Utils}/HSwitchUtils.res (83%) create mode 100644 src/screens/HyperSwitch/Utils/UtilsTypes.res diff --git a/src/hooks/ListHooks.res b/src/hooks/ListHooks.res index 26931e8f9..038e96b48 100644 --- a/src/hooks/ListHooks.res +++ b/src/hooks/ListHooks.res @@ -1,5 +1,6 @@ open APIUtils let useListCount = (~entityName) => { + open ConnectorUtils let fetchDetails = useGetMethod() let (count, setCount) = React.useState(() => 0) @@ -11,15 +12,9 @@ let useListCount = (~entityName) => { let count = switch entityName { | ROUTING => response->getDictFromJsonObject->getArrayFromDict("records", [])->Array.length | CONNECTOR => - response - ->getObjectArrayFromJson - ->HSwitchUtils.filterList(~removeFromList=FRMPlayer) - ->Array.length + response->getObjectArrayFromJson->filterList(~removeFromList=FRMPlayer)->Array.length | FRAUD_RISK_MANAGEMENT => - response - ->getObjectArrayFromJson - ->HSwitchUtils.filterList(~removeFromList=Connector) - ->Array.length + response->getObjectArrayFromJson->filterList(~removeFromList=Connector)->Array.length | _ => response->getArrayFromJson([])->Array.length } setCount(_ => count) diff --git a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res index 056a0dcfd..eeca86bb1 100644 --- a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res +++ b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res @@ -3,25 +3,21 @@ open HomeUtils module ConnectorOverview = { @react.component let make = () => { + open ConnectorUtils let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (configuredConnectors, setConfiguredConnectors) = React.useState(_ => []) - let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList() + let fetchConnectorListResponse = useFetchConnectorList() let getConnectorList = async () => { open LogicUtils try { let response = await fetchConnectorListResponse() let connectorsList = - response->HSwitchUtils.getProcessorsListFromJson( - ~removeFromList=HSwitchUtils.FRMPlayer, - (), - ) + response->getProcessorsListFromJson(~removeFromList=ConnectorTypes.FRMPlayer, ()) let arr = connectorsList->Array.map(paymentMethod => - paymentMethod - ->getString("connector_name", "") - ->ConnectorUtils.getConnectorNameTypeFromString + paymentMethod->getString("connector_name", "")->getConnectorNameTypeFromString ) setConfiguredConnectors(_ => arr) setScreenState(_ => Success) @@ -42,7 +38,7 @@ module ConnectorOverview = { ->Array.mapWithIndex((connector, index) => { let iconStyle = `${index === 0 ? "" : "-ml-4"} z-${(30 - index * 10)->Js.Int.toString}` ConnectorUtils.getConnectorNameString->String.toUpperCase} + gateway={connector->getConnectorNameString->String.toUpperCase} className={`w-12 h-12 rounded-full border-3 border-white ${iconStyle} bg-white`} /> }) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 9d577d105..28f247756 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -202,16 +202,13 @@ let make = (~setCurrentStep, ~setInitialValues, ~initialValues, ~isUpdateFlow, ~ | _ => "Loading..." } - let (suggestedAction, suggestedActionExists) = ConnectorUtils.getSuggestedAction( - ~verifyErrorMessage, - ~connector, - ) + let (suggestedAction, suggestedActionExists) = getSuggestedAction(~verifyErrorMessage, ~connector)
- ConnectorUtils.onSubmit( + onSubmit( ~values, ~onSubmitVerify, ~onSubmitMain, diff --git a/src/screens/HyperSwitch/Connectors/ConnectorList.res b/src/screens/HyperSwitch/Connectors/ConnectorList.res index 0250e758b..cb8ad12c5 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorList.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorList.res @@ -27,13 +27,14 @@ module NewProcessorCards = { ~showIcons: bool, ~isPayoutFlow: bool, ) => { + open ConnectorUtils let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let connectorsAvailableForIntegration = featureFlagDetails.isLiveMode - ? ConnectorUtils.connectorListForLive + ? connectorListForLive : isPayoutFlow - ? ConnectorUtils.payoutConnectorList - : ConnectorUtils.connectorList + ? payoutConnectorList + : connectorList let unConfiguredConnectors = connectorsAvailableForIntegration->Array.filter(total => @@ -91,8 +92,8 @@ module NewProcessorCards = { className="grid gap-x-5 gap-y-6 2xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2 grid-cols-1 mb-5"> {connectorList ->Array.mapWithIndex((connector, i) => { - let connectorName = connector->ConnectorUtils.getConnectorNameString - let connectorInfo = connector->ConnectorUtils.getConnectorInfo + let connectorName = connector->getConnectorNameString + let connectorInfo = connector->getConnectorInfo let size = "w-14 h-14 rounded-sm"
{connectorList ->Array.mapWithIndex((connector, i) => { - let connectorName = connector->ConnectorUtils.getConnectorNameString + let connectorName = connector->getConnectorNameString let size = "w-14 h-14 rounded-sm" string_of_int} @@ -181,9 +182,7 @@ module NewProcessorCards = { let connectorListFiltered = { if searchedConnector->String.length > 0 { connectorsAvailableForIntegration->Array.filter(item => - item - ->ConnectorUtils.getConnectorNameString - ->String.includes(searchedConnector->String.toLowerCase) + item->getConnectorNameString->String.includes(searchedConnector->String.toLowerCase) ) } else { connectorsAvailableForIntegration @@ -196,7 +195,7 @@ module NewProcessorCards = { {connectorListFiltered->iconsConnectors("Connect a new connector", true, ())} { {featureFlagDetails.testProcessors - ->ConnectorUtils.dummyConnectorList + ->dummyConnectorList ->iconsConnectors("Connect a test connector", false, ~showSearch=false, ())} } @@ -204,7 +203,7 @@ module NewProcessorCards = { <> {featureFlagDetails.testProcessors - ->ConnectorUtils.dummyConnectorList + ->dummyConnectorList ->descriptedConnectors("Connect a test connector", false, ~showSearch=false, ())} {connectorListFiltered->descriptedConnectors("Connect a new connector", true, ())} @@ -234,16 +233,16 @@ let make = (~isPayoutFlow=false) => { let (filteredConnectorData, setFilteredConnectorData) = React.useState(_ => []) let (offset, setOffset) = React.useState(_ => 0) let detailedCardCount = 5 - let showConnectorIcons = configuredConnectors->len > detailedCardCount + let showConnectorIcons = configuredConnectors->Array.length > detailedCardCount let (searchText, setSearchText) = React.useState(_ => "") - let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList() + let fetchConnectorListResponse = useFetchConnectorList() let getConnectorListAndUpdateState = async () => { open LogicUtils try { let response = await fetchConnectorListResponse() - let removeFromList = isPayoutFlow ? HSwitchUtils.PayoutConnector : HSwitchUtils.FRMPlayer - let connectorsList = response->HSwitchUtils.getProcessorsListFromJson(~removeFromList, ()) + let removeFromList = isPayoutFlow ? ConnectorTypes.PayoutConnector : ConnectorTypes.FRMPlayer + let connectorsList = response->getProcessorsListFromJson(~removeFromList, ()) let previousData = connectorsList->Array.map(ConnectorTableUtils.getProcessorPayloadType) setFilteredConnectorData(_ => previousData->Array.map(Js.Nullable.return)) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res index df5e51956..ed85f5ea3 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res @@ -28,7 +28,7 @@ let make = ( React.useEffect1(() => { setScreenState(_ => Loading) initialValues - ->ConnectorUtils.getConnectorPaymentMethodDetails( + ->getConnectorPaymentMethodDetails( setPaymentMethods, setMetaData, setScreenState, @@ -52,7 +52,7 @@ let make = ( let body = constructConnectorRequestBody(obj, initialValues)->ignoreFields( connectorID->Option.getWithDefault(""), - ConnectorUtils.connectorIgnoredField, + connectorIgnoredField, ) let connectorUrl = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=connectorID, ()) let response = await updateAPIHook(connectorUrl, body, Post, ()) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res index c3f4e93c9..ace7fd93d 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res @@ -208,11 +208,9 @@ let getCell = (connector: connectorPayload, colType): Table.cell => { } } -let connectorsTableDefaultColumns = Recoil.atom(. "connectorsTableDefaultColumns", defaultColumns) - let getArrayDataFromJson = (json, itemToObjMapper: Js.Dict.t => connectorPayload) => { json - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(itemToObjMapper) ->Array.filter(item => !(item.connector_name->String.includes("apple"))) } diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res index 9f01bbd29..b259a90cb 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res @@ -211,3 +211,5 @@ type connectorPayload = { frm_configs?: array, status: string, } + +type processors = FRMPlayer | Connector | PayoutConnector diff --git a/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res b/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res index 3a469e1d3..9f7dccdf5 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res @@ -6,8 +6,12 @@ let isSelectedAll = ( open ConnectorUtils let paymentMethodObj = selectedPaymentMethod->getSelectedPaymentObj(paymentMethod) switch paymentMethod->getPaymentMethodFromString { - | Card => paymentMethodObj.card_provider->Option.getWithDefault([])->len == allPaymentMethods->len - | _ => paymentMethodObj.provider->Option.getWithDefault([])->len == allPaymentMethods->len + | Card => + paymentMethodObj.card_provider->Option.getWithDefault([])->Array.length == + allPaymentMethods->Array.length + | _ => + paymentMethodObj.provider->Option.getWithDefault([])->Array.length == + allPaymentMethods->Array.length } } @@ -76,13 +80,13 @@ module CardRenderer = { if val.payment_method_type === paymentMethod { switch paymentMethod->getPaymentMethodTypeFromString { | Credit | Debit => - let length = val.card_provider->Option.getWithDefault([])->len + let length = val.card_provider->Option.getWithDefault([])->Array.length val.card_provider ->Option.getWithDefault([]) ->Array.splice(~start=0, ~remove=length, ~insert=arr) ->ignore | _ => - let length = val.provider->Option.getWithDefault([])->len + let length = val.provider->Option.getWithDefault([])->Array.length val.provider ->Option.getWithDefault([]) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res index ef6983e16..470b5aa2d 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res @@ -17,9 +17,6 @@ let getStepName = step => { } } -let toLCase = str => str->String.toLowerCase -let len = arr => arr->Array.length - let payoutConnectorList: array = [ADYEN, WISE] let connectorList: array = [ @@ -88,7 +85,7 @@ let connectorListForLive: array = [ ] let getPaymentMethodFromString = paymentMethod => { - switch paymentMethod->toLCase { + switch paymentMethod->String.toLowerCase { | "card" => Card | "debit" | "credit" => Card | "paylater" => PayLater @@ -102,7 +99,7 @@ let getPaymentMethodFromString = paymentMethod => { } let getPaymentMethodTypeFromString = paymentMethodType => { - switch paymentMethodType->toLCase { + switch paymentMethodType->String.toLowerCase { | "credit" => Credit | "debit" => Debit | "google_pay" => GooglePay @@ -613,7 +610,7 @@ let ignoreFields = (json, id, fields) => { } let mapAuthType = (authType: string) => { - switch authType->toLCase { + switch authType->String.toLowerCase { | "bodykey" => #BodyKey | "headerkey" => #HeaderKey | "signaturekey" => #SignatureKey @@ -634,7 +631,9 @@ let getConnectorType = (connector, ~isPayoutFlow, ()) => { let getSelectedPaymentObj = (paymentMethodsEnabled: array, paymentMethod) => { paymentMethodsEnabled - ->Array.find(item => item.payment_method_type->toLCase == paymentMethod->toLCase) + ->Array.find(item => + item.payment_method_type->String.toLowerCase == paymentMethod->String.toLowerCase + ) ->Option.getWithDefault({ payment_method: "unknown", payment_method_type: "unkonwn", @@ -646,7 +645,7 @@ let addMethod = (paymentMethodsEnabled, paymentMethod, method) => { switch paymentMethod->getPaymentMethodFromString { | Card => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.push(method) @@ -654,7 +653,7 @@ let addMethod = (paymentMethodsEnabled, paymentMethod, method) => { }) | _ => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.push(method) @@ -669,7 +668,7 @@ let removeMethod = (paymentMethodsEnabled, paymentMethod, method: paymentMethodC switch paymentMethod->getPaymentMethodFromString { | Card => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { let indexOfRemovalItem = val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) @@ -688,7 +687,7 @@ let removeMethod = (paymentMethodsEnabled, paymentMethod, method: paymentMethodC | _ => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { let indexOfRemovalItem = val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) @@ -845,8 +844,8 @@ let validateConnectorRequiredFields = ( let walletType = fieldName->getPaymentMethodTypeFromString if walletType !== GooglePay && walletType !== ApplePay { let key = `metadata.${fieldName}` - let errorKey = connectorMetaDataFields->LogicUtils.getString(fieldName, "") - let value = valuesFlattenJson->LogicUtils.getString(`metadata.${fieldName}`, "") + let errorKey = connectorMetaDataFields->getString(fieldName, "") + let value = valuesFlattenJson->getString(`metadata.${fieldName}`, "") if value->String.length === 0 && connector->getMetaDataRequiredFields(fieldName) { Dict.set(newDict, key, `Please enter ${errorKey}`->Js.Json.string) } @@ -857,9 +856,8 @@ let validateConnectorRequiredFields = ( ->Dict.keysToArray ->Array.forEach(fieldName => { let key = `connector_webhook_details.${fieldName}` - let errorKey = connectorWebHookDetails->LogicUtils.getString(fieldName, "") - let value = - valuesFlattenJson->LogicUtils.getString(`connector_webhook_details.${fieldName}`, "") + let errorKey = connectorWebHookDetails->getString(fieldName, "") + let value = valuesFlattenJson->getString(`connector_webhook_details.${fieldName}`, "") if value->String.length === 0 && connector->getWebHookRequiredFields(fieldName) { Dict.set(newDict, key, `Please enter ${errorKey}`->Js.Json.string) } @@ -867,8 +865,8 @@ let validateConnectorRequiredFields = ( connectorLabelDetailField ->Dict.keysToArray ->Array.forEach(fieldName => { - let errorKey = connectorLabelDetailField->LogicUtils.getString(fieldName, "") - let value = valuesFlattenJson->LogicUtils.getString(fieldName, "") + let errorKey = connectorLabelDetailField->getString(fieldName, "") + let value = valuesFlattenJson->getString(fieldName, "") if value->String.length === 0 { Dict.set(newDict, fieldName, `Please enter ${errorKey}`->Js.Json.string) } @@ -883,7 +881,7 @@ let getPlaceHolder = (connector: connectorName, fieldName, label) => { } } -let getConnectorDetailsValue = (connectorInfo: ConnectorTypes.connectorPayload, str) => { +let getConnectorDetailsValue = (connectorInfo: connectorPayload, str) => { switch str { | "api_key" => connectorInfo.connector_account_details.api_key | "api_secret" => connectorInfo.connector_account_details.api_secret @@ -895,19 +893,16 @@ let getConnectorDetailsValue = (connectorInfo: ConnectorTypes.connectorPayload, } let getConnectorFields = connectorDetails => { + open LogicUtils let connectorAccountDict = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getDictfromDict("connector_auth") + connectorDetails->getDictFromJsonObject->getDictfromDict("connector_auth") let bodyType = connectorAccountDict->Dict.keysToArray->Belt.Array.get(0)->Option.getWithDefault("") - let connectorAccountFields = connectorAccountDict->LogicUtils.getDictfromDict(bodyType) - let connectorMetaDataFields = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getDictfromDict("metadata") - let isVerifyConnector = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getBool("is_verifiable", false) + let connectorAccountFields = connectorAccountDict->getDictfromDict(bodyType) + let connectorMetaDataFields = connectorDetails->getDictFromJsonObject->getDictfromDict("metadata") + let isVerifyConnector = connectorDetails->getDictFromJsonObject->getBool("is_verifiable", false) let connectorWebHookDetails = - connectorDetails - ->LogicUtils.getDictFromJsonObject - ->LogicUtils.getDictfromDict("connector_webhook_details") + connectorDetails->getDictFromJsonObject->getDictfromDict("connector_webhook_details") let connectorLabelDetailField = Dict.fromArray([ ("connector_label", "Connector label"->Js.Json.string), ]) @@ -1082,7 +1077,7 @@ let useFetchConnectorList = () => { } let defaultSelectAllCards = ( - pmts: array, + pmts: array, isUpdateFlow, isPayoutFlow, connector, @@ -1106,7 +1101,9 @@ let defaultSelectAllCards = ( ->getPaymentMethodMapper let length = - val.card_provider->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper)->len + val.card_provider + ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) + ->Array.length val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.splice(~start=0, ~remove=length, ~insert=arr) @@ -1119,7 +1116,9 @@ let defaultSelectAllCards = ( ->getPaymentMethodMapper let length = - val.provider->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper)->len + val.provider + ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) + ->Array.length val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.splice(~start=0, ~remove=length, ~insert=arr) @@ -1167,3 +1166,23 @@ let getConnectorPaymentMethodDetails = async ( } } } + +let filterList = (items, ~removeFromList: processors) => { + open LogicUtils + items->Array.filter(dict => { + let connectorType = dict->getString("connector_type", "") + let isPayoutConnector = connectorType == "payout_processor" + let isConnector = connectorType !== "payment_vas" && !isPayoutConnector + + switch removeFromList { + | Connector => !isConnector + | FRMPlayer => isConnector + | PayoutConnector => isPayoutConnector + } + }) +} + +let getProcessorsListFromJson = (json, ~removeFromList: processors=FRMPlayer, ()) => { + open LogicUtils + json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) +} diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index ad471f576..72b00334e 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -7,9 +7,10 @@ module SelectProcessor = { ~setConnectorConfigureState, ~connectorArray, ) => { + open ConnectorUtils let url = RescriptReactRouter.useUrl() let mixpanelEvent = MixpanelHook.useSendEvent() - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let {setQuickStartPageState} = React.useContext(GlobalProvider.defaultContext) Array.filter(value => - !(connectorArray->Array.includes(value->ConnectorUtils.getConnectorNameString)) + connectorList={connectorList->Array.filter(value => + !(connectorArray->Array.includes(value->getConnectorNameString)) )} /> @@ -61,7 +62,7 @@ module ConfigureProcessor = { open ConnectorUtils let mixpanelEvent = MixpanelHook.useSendEvent() let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let connectorDetails = React.useMemo1(() => { try { @@ -85,7 +86,7 @@ module ConfigureProcessor = { ) = getConnectorFields(connectorDetails) let onSubmit = async (values, _) => { - let body = ConnectorUtils.generateInitialValuesDict( + let body = generateInitialValuesDict( ~values, ~connector=connectorName, ~bodyType, @@ -167,15 +168,16 @@ module SelectPaymentMethods = { ~setButtonState: (Button.buttonState => Button.buttonState) => unit, ~buttonState, ) => { + open ConnectorUtils let {quickStartPageState} = React.useContext(GlobalProvider.defaultContext) let updateAPIHook = APIUtils.useUpdateMethod() let showToast = ToastState.useShowToast() let mixpanelEvent = MixpanelHook.useSendEvent() let usePostEnumDetails = EnumVariantHook.usePostEnumDetails() - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let (paymentMethodsEnabled, setPaymentMethods) = React.useState(_ => - Dict.make()->Js.Json.object_->ConnectorUtils.getPaymentMethodEnabled + Dict.make()->Js.Json.object_->getPaymentMethodEnabled ) let (metaData, setMetaData) = React.useState(_ => Dict.make()->Js.Json.object_) @@ -205,7 +207,7 @@ module SelectPaymentMethods = { payment_methods_enabled: paymentMethodsEnabled, metadata: metaData, } - let body = ConnectorUtils.constructConnectorRequestBody(obj, initialValues) + let body = constructConnectorRequestBody(obj, initialValues) let connectorUrl = APIUtils.getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=None, ()) let response = await updateAPIHook(connectorUrl, body, Post, ()) @@ -229,7 +231,7 @@ module SelectPaymentMethods = { React.useEffect1(() => { initialValues - ->ConnectorUtils.getConnectorPaymentMethodDetails( + ->getConnectorPaymentMethodDetails( setPaymentMethods, setMetaData, _ => (), diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res index fdeb48537..fffa1464c 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res +++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res @@ -219,7 +219,7 @@ module SelectConnectorGrid = { HyperswitchAtom.connectorListAtom ->Recoil.useRecoilValueFromAtom ->LogicUtils.safeParse - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(connectorDict => connectorDict ->LogicUtils.getString("connector_name", "") diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res index ecb4eb918..032278ef1 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res +++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res @@ -44,12 +44,6 @@ let connectorChoiceVariantToString = variantValue => | _ => "" } -let defaultChoiceStateValue: landingChoiceType = { - displayText: "Not Selected", - description: "Not Selected", - variantType: #NotSelected, -} - let connectorChoiceArray: array = [ { displayText: "Single Payment Processor", diff --git a/src/screens/HyperSwitch/Routing/PriorityRouting.res b/src/screens/HyperSwitch/Routing/PriorityRouting.res index 8e68de137..73fddc448 100644 --- a/src/screens/HyperSwitch/Routing/PriorityRouting.res +++ b/src/screens/HyperSwitch/Routing/PriorityRouting.res @@ -267,7 +267,7 @@ let make = (~routingRuleId, ~isActive) => { let getConnectorsList = () => { let arr = connectorListJson - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(connectorDict => connectorDict->getString("connector_name", "")) ->Array.filter(x => x !== "applepay") ->getUniqueArray diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index aa2365c1c..ab4361d2c 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -31,7 +31,7 @@ module ConnectorDetailsForm = { connectorVariant->getConnectorInfo }, [connectorName]) - let (suggestedAction, suggestedActionExists) = ConnectorUtils.getSuggestedAction( + let (suggestedAction, suggestedActionExists) = getSuggestedAction( ~verifyErrorMessage, ~connector={connectorName}, ) @@ -84,7 +84,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { open APIUtils let showToast = ToastState.useShowToast() let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (isCheckboxSelected, setIsCheckboxSelected) = React.useState(_ => false) let connectorVariant = connectorName->getConnectorNameTypeFromString @@ -135,7 +135,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject prevJsonDict->Dict.set( "connector_label", - `${selectedConnector->ConnectorUtils.getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string, + `${selectedConnector->getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string, ) prevJsonDict->Dict.set("profile_id", defaultBusinessProfile.profile_id->Js.Json.string) prevJsonDict->Js.Json.object_ @@ -203,7 +203,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { (), ) - let body = requestPayload->ConnectorUtils.constructConnectorRequestBody(payload) + let body = requestPayload->constructConnectorRequestBody(payload) let res = await updateDetails(url, body, Post, ()) let connectorId = res->getDictFromJsonObject->getString("merchant_connector_id", "") @@ -342,7 +342,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let dict = values->getDictFromJsonObject dict->Dict.set("profile_id", profile_id->Js.Json.string) - ConnectorUtils.onSubmit( + onSubmit( ~values={dict->Js.Json.object_}, ~onSubmitVerify, ~onSubmitMain, diff --git a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res index d08a0ceff..4489cdf61 100644 --- a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res +++ b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res @@ -28,7 +28,7 @@ let constructBody = (~connectorName, ~json, ~profileId) => { ->Dict.fromArray ->Js.Json.object_ - let initialValueForPayload = ConnectorUtils.generateInitialValuesDict( + let initialValueForPayload = generateInitialValuesDict( ~values=[ ("profile_id", profileId->Js.Json.string), ("connector_account_details", connectorAccountDetails), @@ -100,8 +100,7 @@ let constructBody = (~connectorName, ~json, ~profileId) => { metadata: Dict.make()->Js.Json.object_, } - let requestPayloadDict = - requestPayload->ConnectorUtils.constructConnectorRequestBody(initialValueForPayload) + let requestPayloadDict = requestPayload->constructConnectorRequestBody(initialValueForPayload) requestPayloadDict } diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/Utils/HSwitchUtils.res similarity index 83% rename from src/screens/HyperSwitch/HSwitchUtils.res rename to src/screens/HyperSwitch/Utils/HSwitchUtils.res index b36cc13d9..84eb0ba0f 100644 --- a/src/screens/HyperSwitch/HSwitchUtils.res +++ b/src/screens/HyperSwitch/Utils/HSwitchUtils.res @@ -1,34 +1,8 @@ open LogicUtils open HSLocalStorage open HyperswitchAtom +open UtilsTypes -type browserDetailsObject = { - userAgent: string, - browserVersion: string, - platform: string, - browserName: string, - browserLanguage: string, - screenHeight: string, - screenWidth: string, - timeZoneOffset: string, - clientCountry: Country.timezoneType, -} - -let feedbackModalOpenCountForConnectors = 4 - -let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2" - -type pageLevelVariant = - | HOME - | PAYMENTS - | REFUNDS - | DISPUTES - | CONNECTOR - | ROUTING - | ANALYTICS_PAYMENTS - | ANALYTICS_REFUNDS - | SETTINGS - | DEVELOPERS module TextFieldRow = { @react.component let make = (~label, ~children, ~isRequired=true, ~labelWidth="w-72") => { @@ -36,17 +10,56 @@ module TextFieldRow = {
{label->React.string} - {if isRequired { + {"*"->React.string} - } else { - React.null - }} +
children
} } +module ConnectorCustomCell = { + @react.component + let make = (~connectorName) => { + if connectorName->String.length > 0 { +
+ String.toUpperCase} className="w-6 h-6 mr-2" /> +
{connectorName->React.string}
+
+ } else { + "NA"->React.string + } + } +} + +module BackgroundImageWrapper = { + @react.component + let make = ( + ~children=?, + ~backgroundImageUrl="/images/hyperswitchImages/PostLoginBackground.svg", + ~customPageCss="", + ~isBackgroundFullScreen=true, + ) => { + let heightWidthCss = isBackgroundFullScreen ? "h-screen w-screen" : "h-full w-full" + Option.isSome}> +
+ {children->Option.getWithDefault(React.null)} +
+
+ } +} + +let feedbackModalOpenCountForConnectors = 4 + +let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2" + let setMerchantDetails = (key, value) => { let localStorageData = getInfoFromLocalStorage(~lStorageKey="merchant") localStorageData->Dict.set(key, value) @@ -71,20 +84,6 @@ let getSearchOptionsForProcessors = (~processorList, ~getNameFromString) => { searchOptionsForProcessors } -module ConnectorCustomCell = { - @react.component - let make = (~connectorName) => { - if connectorName->String.length > 0 { -
- String.toUpperCase} className="w-6 h-6 mr-2" /> -
{connectorName->React.string}
-
- } else { - "NA"->React.string - } - } -} - let isValidEmail = value => !Js.Re.test_( %re(`/^(([^<>()[\]\.,;:\s@"]+(\.[^<>()[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/`), @@ -119,53 +118,6 @@ let getBrowswerDetails = () => { } } -module BackgroundImageWrapper = { - @react.component - let make = ( - ~children=?, - ~backgroundImageUrl="/images/hyperswitchImages/PostLoginBackground.svg", - ~customPageCss="", - ~isBackgroundFullScreen=true, - ) => { - let heightWidthCss = isBackgroundFullScreen ? "h-screen w-screen" : "h-full w-full" - Option.isSome}> -
- {children->Option.getWithDefault(React.null)} -
-
- } -} - -type processors = FRMPlayer | Connector | PayoutConnector - -let filterList = (items, ~removeFromList) => { - items->Array.filter(dict => { - let connectorType = dict->getString("connector_type", "") - let isPayoutConnector = connectorType == "payout_processor" - let isConnector = connectorType !== "payment_vas" && !isPayoutConnector - - switch removeFromList { - | Connector => !isConnector - | FRMPlayer => isConnector - | PayoutConnector => isPayoutConnector - } - }) -} - -let getProcessorsListFromJson = (json, ~removeFromList=FRMPlayer, ()) => { - json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) -} - -let getPageNameFromUrl = url => { - url->LogicUtils.getListHead -} - let getBodyForFeedBack = (values, ~modalType=HSwitchFeedBackModalUtils.FeedBackModal, ()) => { open HSwitchFeedBackModalUtils let email = getFromMerchantDetails("email") @@ -209,10 +161,10 @@ let getMetaData = (newMetadata, metaData) => { } let returnIntegrationJson = (integrationData: ProviderTypes.integration): Js.Json.t => { - Dict.fromArray([ + [ ("is_done", integrationData.is_done->Js.Json.boolean), ("metadata", integrationData.metadata), - ])->Js.Json.object_ + ]->getJsonFromArrayOfJson } let constructOnboardingBody = ( @@ -256,7 +208,7 @@ let constructOnboardingBody = ( | _ => () } - Dict.fromArray([ + [ ( "integration_checklist", copyOfIntegrationDetails.integration_checklist->returnIntegrationJson, @@ -267,19 +219,9 @@ let constructOnboardingBody = ( ), ("pricing_plan", copyOfIntegrationDetails.pricing_plan->returnIntegrationJson), ("account_activation", copyOfIntegrationDetails.account_activation->returnIntegrationJson), - ])->Js.Json.object_ + ]->getJsonFromArrayOfJson } -type textVariantType = - | H1 - | H2 - | H3 - | P1 - | P2 - | P3 -type paragraphTextType = Regular | Medium -type h3TextType = Leading_1 | Leading_2 - let getTextClass = (~textVariant, ~h3TextVariant=Leading_1, ~paragraphTextVariant=Regular, ()) => { switch (textVariant, h3TextVariant, paragraphTextVariant) { | (H1, _, _) => "text-fs-28 font-semibold leading-10" @@ -302,13 +244,9 @@ let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => { enumDetails.stripeConnected.processorID->String.length > 0 && enumDetails.paypalConnected.processorID->String.length > 0 && enumDetails.sPTestPayment - ? true - : false } let checkWooCommerce = (enumDetails: QuickStartTypes.responseType) => { enumDetails.setupWoocomWebhook && enumDetails.firstProcessorConnected.processorID->String.length > 0 - ? true - : false } diff --git a/src/screens/HyperSwitch/Utils/UtilsTypes.res b/src/screens/HyperSwitch/Utils/UtilsTypes.res new file mode 100644 index 000000000..b234961e2 --- /dev/null +++ b/src/screens/HyperSwitch/Utils/UtilsTypes.res @@ -0,0 +1,34 @@ +type browserDetailsObject = { + userAgent: string, + browserVersion: string, + platform: string, + browserName: string, + browserLanguage: string, + screenHeight: string, + screenWidth: string, + timeZoneOffset: string, + clientCountry: Country.timezoneType, +} + +type pageLevelVariant = + | HOME + | PAYMENTS + | REFUNDS + | DISPUTES + | CONNECTOR + | ROUTING + | ANALYTICS_PAYMENTS + | ANALYTICS_REFUNDS + | SETTINGS + | DEVELOPERS + +type textVariantType = + | H1 + | H2 + | H3 + | P1 + | P2 + | P3 +type paragraphTextType = Regular | Medium + +type h3TextType = Leading_1 | Leading_2 diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res index 024230023..2da15c7fd 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res @@ -2,7 +2,6 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, ~setAuthType) => { open HyperSwitchAuthUtils open APIUtils - open HSwitchUtils open HyperSwitchAuthForm open HSwitchGlobalVars open LogicUtils From 91f98c4aedb7b744043e63405ed9189b14103fb9 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 24 Jan 2024 12:42:35 +0530 Subject: [PATCH 5/6] fix: headers issue (#295) --- src/hooks/AuthHooks.res | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index 61ec1c785..fce80749f 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -23,6 +23,7 @@ let getHeaders = (~uri, ~headers, ()) => { let res = switch hyperSwitchToken { | Some(token) => { headers->Dict.set("authorization", `Bearer ${token}`) + headers->Dict.set("api-key", `hyperswitch`) headers } From 0ce1d055066453338b98b725fef5dcb5c8a402b6 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 24 Jan 2024 12:43:28 +0530 Subject: [PATCH 6/6] fix: quick start default selection issue (#287) --- .../ConfigureConnector.res | 22 +++++++++++++++++++ .../QuickStartConnectorFlow.res | 11 ++++++++++ .../CommonConnectorFlow/SetupConnector.res | 8 +++++++ .../IntegrateYourAppLanding.res | 11 ++++++++++ 4 files changed, 52 insertions(+) diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res index f83651a1b..bdc0fe990 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res @@ -48,6 +48,24 @@ let make = (~connectProcessorValue: connectProcessor) => { } } + React.useEffect1(() => { + if choiceState === #NotSelected { + setButtonState(_ => Button.Disabled) + } else { + setButtonState(_ => Button.Normal) + } + None + }, [choiceState]) + + React.useEffect1(() => { + if smartRoutingChoiceState === #NotSelected { + setButtonState(_ => Button.Disabled) + } else { + setButtonState(_ => Button.Normal) + } + None + }, [smartRoutingChoiceState]) + React.useEffect2(() => { setInitialValues(prevJson => { let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject @@ -185,6 +203,8 @@ let make = (~connectProcessorValue: connectProcessor) => { listChoices={connectorChoiceArray} nextButton={