diff --git a/src/screens/Connectors/ConnectorTypes.res b/src/screens/Connectors/ConnectorTypes.res index 7bab101c4..fa61123c2 100644 --- a/src/screens/Connectors/ConnectorTypes.res +++ b/src/screens/Connectors/ConnectorTypes.res @@ -220,13 +220,14 @@ type payment_methods_enabled = array type frm_payment_method_type = { payment_method_type: string, - mutable flow: string, - mutable action: string, + flow: string, + action: string, } type frm_payment_method = { payment_method: string, - payment_method_types: array, + payment_method_types?: array, + flow: string, } type frm_config = { diff --git a/src/screens/FraudAndRisk/FRMPaymentMethods.res b/src/screens/FraudAndRisk/FRMPaymentMethods.res index 8050dc9ff..db658e87f 100644 --- a/src/screens/FraudAndRisk/FRMPaymentMethods.res +++ b/src/screens/FraudAndRisk/FRMPaymentMethods.res @@ -1,44 +1,3 @@ -module RadioSection = { - open ConnectorTypes - open FRMTypes - open FRMInfo - @react.component - let make = (~option, ~frmConfigs, ~paymentMethodTypeInfo, ~sectionType, ~setConfigJson) => { - let isOptionSelected = - switch sectionType { - | FlowType => paymentMethodTypeInfo.flow - | ActionType => paymentMethodTypeInfo.action - } === option - - let handleOnClick = () => { - switch sectionType { - | FlowType => - if paymentMethodTypeInfo.flow !== option { - switch option->getFlowTypeVariantFromString { - | PreAuth => paymentMethodTypeInfo.action = CancelTxn->getActionTypeNameString - | PostAuth => paymentMethodTypeInfo.action = ManualReview->getActionTypeNameString - } - paymentMethodTypeInfo.flow = option - } - | ActionType => paymentMethodTypeInfo.action = option - } - setConfigJson(frmConfigs->Identity.anyTypeToReactEvent) - } - -
-
-
handleOnClick()}> - -
- {switch sectionType { - | FlowType => option->getFlowTypeLabel->React.string - | ActionType => option->getActionTypeLabel->LogicUtils.snakeToTitle->React.string - }} -
-
- } -} - module ToggleSwitch = { open FRMUtils @react.component @@ -68,19 +27,9 @@ module ToggleSwitch = { } module FormField = { - open ConnectorTypes open FRMInfo - open FRMTypes @react.component - let make = ( - ~options, - ~label, - ~paymentMethodTypeInfo, - ~frmConfigs, - ~sectionType, - ~setConfigJson, - ~description, - ) => { + let make = (~fromConfigIndex, ~paymentMethodIndex, ~options, ~label, ~description) => {

@@ -96,25 +45,23 @@ module FormField = {

- -
- {paymentMethodTypeInfo.action->getActionTypeLabel->Jsx.string} -
-
- - {options - ->Array.mapWithIndex((option, i) => { - Int.toString} - option - paymentMethodTypeInfo - frmConfigs - sectionType - setConfigJson - /> - }) - ->React.array} - + Array.map((item): SelectBox.dropdownOption => { + { + label: item->getFlowTypeLabel, + value: item, + } + }), + ~buttonText="options", + ~baseComponentCustomStyle="flex", + ~customStyle="flex gap-2 !overflow-visible", + ), + )} + />
} @@ -123,9 +70,9 @@ module FormField = { module CheckBoxRenderer = { open FRMUtils open FRMInfo - open FRMTypes @react.component let make = ( + ~fromConfigIndex, ~frmConfigInfo: ConnectorTypes.frm_config, ~frmConfigs, ~connectorPaymentMethods, @@ -229,49 +176,32 @@ module CheckBoxRenderer = { {frmConfigInfo.payment_methods ->Array.mapWithIndex((paymentMethodInfo, index) => { Int.toString}> - {paymentMethodInfo.payment_method_types - ->Array.mapWithIndex((paymentMethodTypeInfo, i) => { - Int.toString} - initialExpandedArray=[0] - accordion={[ - { - title: paymentMethodTypeInfo.payment_method_type->LogicUtils.snakeToTitle, - renderContent: () => { -
- Int.toString} + initialExpandedArray=[0] + accordion={[ + { + title: paymentMethodInfo.payment_method->LogicUtils.snakeToTitle, + renderContent: () => { +
+ Int.toString} + description="i. \"PreAuth\" - facilitate transaction verification prior to payment authorization. ii. \"PostAuth\" - facilitate transaction validation post-authorization, before amount capture." - /> - getActionTypeAllOptions} - label="Preferred Action" - paymentMethodTypeInfo - frmConfigs - sectionType={ActionType} - setConfigJson - description={paymentMethodTypeInfo.flow - ->getFlowTypeVariantFromString - ->actionDescriptionForFlow} - /> -
- }, - renderContentOnTop: None, + /> +
}, - ]} - accordianTopContainerCss="border" - accordianBottomContainerCss="p-5" - contentExpandCss="px-10 pb-6 pt-3 !border-t-0" - titleStyle="font-semibold text-bold text-md" - /> - }) - ->React.array} + renderContentOnTop: None, + }, + ]} + accordianTopContainerCss="border" + accordianBottomContainerCss="p-5" + contentExpandCss="px-10 pb-6 pt-3 !border-t-0" + titleStyle="font-semibold text-bold text-md" + />
}) ->React.array} @@ -335,6 +265,7 @@ module PaymentMethodsRenderer = { frmConfigs connectorPaymentMethods={connectorConfig->Dict.get(configInfo.gateway)} isUpdateFlow + fromConfigIndex={i->Int.toString} /> }) ->React.array} @@ -363,7 +294,12 @@ let make = (~setCurrentStep, ~retrivedValues=None, ~setInitialValues, ~isUpdateF ->parseFRMConfig ->Array.filter(config => config.payment_methods->Array.length > 0) - valuesDict->Dict.set("frm_configs", filteredArray->Identity.genericTypeToJson) + valuesDict->Dict.set( + "frm_configs", + filteredArray->Array.length > 0 + ? filteredArray->Identity.genericTypeToJson + : JSON.Encode.null, + ) setInitialValues(_ => valuesDict->JSON.Encode.object) setCurrentStep(prev => prev->getNextStep) diff --git a/src/screens/FraudAndRisk/FRMSummary.res b/src/screens/FraudAndRisk/FRMSummary.res index 6ba554d58..8d4df3cbd 100644 --- a/src/screens/FraudAndRisk/FRMSummary.res +++ b/src/screens/FraudAndRisk/FRMSummary.res @@ -1,18 +1,13 @@ module InfoField = { open LogicUtils - open FRMInfo @react.component - let make = (~label, ~flowTypeValue, ~actionTypeValue) => { + let make = (~label, ~flowTypeValue) => {

{label->snakeToTitle->React.string}

{"Flow :"->React.string} - {flowTypeValue->getFlowTypeLabel->React.string} -

-

- {"Action :"->React.string} - {actionTypeValue->getActionTypeLabel->React.string} + {flowTypeValue->React.string}

@@ -22,6 +17,7 @@ module InfoField = { module ConfigInfo = { open LogicUtils open ConnectorTypes + open FRMInfo @react.component let make = (~frmConfigs) => { frmConfigs @@ -31,20 +27,28 @@ module ConfigInfo = {
{config.payment_methods ->Array.mapWithIndex((paymentMethod, ind) => { -
Int.toString}> - {paymentMethod.payment_method_types + if paymentMethod.payment_method_types->Option.getOr([])->Array.length == 0 { + Int.toString} + label={paymentMethod.payment_method} + flowTypeValue={paymentMethod.flow->getFlowTypeLabel} + /> + } else { + paymentMethod.payment_method_types + ->Option.getOr([]) ->Array.mapWithIndex( (paymentMethodType, index) => { - Int.toString} - label={paymentMethodType.payment_method_type} - flowTypeValue={paymentMethodType.flow} - actionTypeValue={paymentMethodType.action} - /> + + Int.toString} + label={paymentMethod.payment_method} + flowTypeValue={paymentMethodType.flow->getFlowTypeLabel} + /> + }, ) - ->React.array} -
+ ->React.array + } }) ->React.array}
diff --git a/src/screens/FraudAndRisk/FRMTypes.res b/src/screens/FraudAndRisk/FRMTypes.res index 64396ac90..3e8e92b92 100644 --- a/src/screens/FraudAndRisk/FRMTypes.res +++ b/src/screens/FraudAndRisk/FRMTypes.res @@ -1,7 +1,5 @@ type filterType = Connector | FRMPlayer | ThreedsAuthenticator -type frmPaymentMethodsSectionType = FlowType | ActionType - type flowType = PreAuth | PostAuth type frmActionType = CancelTxn | AutoRefund | ManualReview | Process diff --git a/src/screens/FraudAndRisk/FRMUtils.res b/src/screens/FraudAndRisk/FRMUtils.res index 6ff4804ba..fc63899bf 100644 --- a/src/screens/FraudAndRisk/FRMUtils.res +++ b/src/screens/FraudAndRisk/FRMUtils.res @@ -134,26 +134,16 @@ let createAllOptions = connectorsConfig => { }) } -let generateFRMPaymentMethodsConfig = paymentMethodsDict => { +let generateFRMPaymentMethodsConfig = (paymentMethodsDict): array< + ConnectorTypes.frm_payment_method, +> => { open ConnectorTypes paymentMethodsDict ->Dict.keysToArray ->Array.map(paymentMethodName => { - let paymentMethodTypesArr = - paymentMethodsDict - ->Dict.get(paymentMethodName) - ->Option.getOr([]) - ->Array.map(paymentMethodType => { - { - payment_method_type: paymentMethodType, - flow: "pre", - action: "cancel_txn", - } - }) - { payment_method: paymentMethodName, - payment_method_types: paymentMethodTypesArr, + flow: getFlowTypeNameString(PreAuth), } }) } diff --git a/src/utils/Mappers/ConnectorListMapper.res b/src/utils/Mappers/ConnectorListMapper.res index 3189c0d7c..947e623f6 100644 --- a/src/utils/Mappers/ConnectorListMapper.res +++ b/src/utils/Mappers/ConnectorListMapper.res @@ -9,7 +9,7 @@ let parsePaymentMethodType = paymentMethodType => { action: paymentMethodTypeDict->getString("action", ""), } } -let parsePaymentMethod = paymentMethod => { +let parsePaymentMethodResponse = paymentMethod => { open LogicUtils let paymentMethodDict = paymentMethod->getDictFromJsonObject @@ -18,12 +18,42 @@ let parsePaymentMethod = paymentMethod => { ->getArrayFromDict("payment_method_types", []) ->Array.map(parsePaymentMethodType) + let flow = paymentMethodDict->getString("flow", "") + { payment_method: paymentMethodDict->getString("payment_method", ""), payment_method_types, + flow, } } +let parsePaymentMethod = paymentMethod => { + open LogicUtils + + let paymentMethodDict = paymentMethod->getDictFromJsonObject + let flow = paymentMethodDict->getString("flow", "") + + { + payment_method: paymentMethodDict->getString("payment_method", ""), + flow, + } +} + +let convertFRMConfigJsonToObjResponse = json => { + open LogicUtils + + json->Array.map(config => { + let configDict = config->getDictFromJsonObject + let payment_methods = + configDict->getArrayFromDict("payment_methods", [])->Array.map(parsePaymentMethodResponse) + + { + gateway: configDict->getString("gateway", ""), + payment_methods, + } + }) +} + let convertFRMConfigJsonToObj = json => { open LogicUtils @@ -93,7 +123,7 @@ let getProcessorPayloadType = dict => { ->getArrayDataFromJson(getPaymentMethodsEnabled), profile_id: dict->getString("profile_id", ""), merchant_connector_id: dict->getString("merchant_connector_id", ""), - frm_configs: dict->getArrayFromDict("frm_configs", [])->convertFRMConfigJsonToObj, + frm_configs: dict->getArrayFromDict("frm_configs", [])->convertFRMConfigJsonToObjResponse, status: dict->getString("status", "inactive"), } }