@@ -52,7 +50,7 @@ module AdvanceSettings = {
- >
+
}
}
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
index 1c16dbcce..f3966caab 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
@@ -1,6 +1,3 @@
-external convertToJsonDict: 't => Js.Dict.t = "%identity"
-external asJson: 'a => ReactEvent.Form.t = "%identity"
-
module RadioSection = {
open ConnectorTypes
open FRMTypes
@@ -26,7 +23,7 @@ module RadioSection = {
| ActionType => paymentMethodTypeInfo.action = option
}
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
@@ -147,7 +144,7 @@ module CheckBoxRenderer = {
_ => {
frmConfigInfo.payment_methods = []
setIsOpen(_ => !isOpen)
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
},
},
@@ -166,7 +163,7 @@ module CheckBoxRenderer = {
switch connectorPaymentMethods {
| Some(paymentMethods) => {
frmConfigInfo.payment_methods = paymentMethods->generateFRMPaymentMethodsConfig
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
| _ => ()
}
@@ -176,7 +173,7 @@ module CheckBoxRenderer = {
showConfitmation()
} else {
frmConfigInfo.payment_methods = []
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
setIsOpen(_ => !isOpen)
}
}
@@ -188,7 +185,7 @@ module CheckBoxRenderer = {
switch connectorPaymentMethods {
| Some(paymentMethods) => {
frmConfigInfo.payment_methods = paymentMethods->generateFRMPaymentMethodsConfig
- setConfigJson(frmConfigs->asJson)
+ setConfigJson(frmConfigs->Identity.anyTypeToReactEvent)
}
| _ => ()
}
@@ -298,7 +295,7 @@ module PaymentMethodsRenderer = {
})
setConnectorConfig(_ => connectorsConfig)
- setConfigJson(updateFRMConfig->asJson)
+ setConfigJson(updateFRMConfig->Identity.anyTypeToReactEvent)
setPageState(_ => Success)
} catch {
| _ => setPageState(_ => Error("Failed to fetch"))
@@ -345,7 +342,7 @@ let make = (~setCurrentStep, ~retrivedValues=None, ~setInitialValues, ~isUpdateF
->parseFRMConfig
->Js.Array2.filter(config => config.payment_methods->Js.Array2.length > 0)
- valuesDict->Js.Dict.set("frm_configs", filteredArray->toJson)
+ valuesDict->Js.Dict.set("frm_configs", filteredArray->Identity.genericTypeToJson)
setInitialValues(_ => valuesDict->Js.Json.object_)
setCurrentStep(prev => prev->getNextStep)
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res
index 255e5eff6..a967599f2 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res
@@ -130,20 +130,6 @@ let make = (~initialValues, ~currentStep, ~setCurrentStep, ~isUpdateFlow) => {
}}
-
-
{"Processor Mode"->React.string}
-
- {if frmInfo.test_mode {
-
- {"TEST MODE"->React.string}
-
- } else {
-
- {"LIVE MODE"->React.string}
-
- }}
-
-
{"Profile id"->React.string}
{frmInfo.profile_id->React.string}
diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res b/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
index 1c8228f7e..14d5aa999 100644
--- a/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
+++ b/src/screens/HyperSwitch/FraudAndRisk/FRMUtils.res
@@ -17,8 +17,6 @@ let base64Format = (. ~value, ~name as _) => {
value->Js.Json.decodeString->Belt.Option.getWithDefault("")->atob->Js.Json.string
}
-external toJson: 'a => Js.Json.t = "%identity"
-
let toggleDefaultStyle = "mb-2 relative inline-flex flex-shrink-0 h-6 w-12 border-2 rounded-full transition-colors ease-in-out duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 items-center"
let accordionDefaultStyle = "border pointer-events-none inline-block h-3 w-3 rounded-full bg-white dark:bg-white shadow-lg transform ring-0 transition ease-in-out duration-200"
diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/HSwitchUtils.res
index 0f1fc990b..11e40900c 100644
--- a/src/screens/HyperSwitch/HSwitchUtils.res
+++ b/src/screens/HyperSwitch/HSwitchUtils.res
@@ -16,7 +16,6 @@ type browserDetailsObject = {
let feedbackModalOpenCountForConnectors = 4
-external objToJson: {..} => Js.Json.t = "%identity"
let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2"
type pageLevelVariant =
diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res
index 3f539e137..0c6ece28c 100644
--- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res
+++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res
@@ -51,6 +51,19 @@ let make = (~connectProcessorValue: connectProcessor) => {
}
}
+ React.useEffect2(() => {
+ setInitialValues(prevJson => {
+ let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject
+ prevJsonDict->Js.Dict.set(
+ "connector_label",
+ `${selectedConnector->ConnectorUtils.getConnectorNameString}_${activeBusinessProfile.profile_name}`->Js.Json.string,
+ )
+ prevJsonDict->Js.Json.object_
+ })
+
+ None
+ }, (selectedConnector, activeBusinessProfile.profile_name))
+
let volumeBasedRoutingAPICall = async () => {
try {
open LogicUtils
diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res
index 84e126a53..a1640eb9b 100644
--- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res
+++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res
@@ -133,9 +133,11 @@ module ConfigureProcessor = {
nextButton={
}>
-
+
+
+
+
}
}
diff --git a/src/screens/HyperSwitch/Home/HomeUtils.res b/src/screens/HyperSwitch/Home/HomeUtils.res
index c4eb737dd..6a8e17293 100644
--- a/src/screens/HyperSwitch/Home/HomeUtils.res
+++ b/src/screens/HyperSwitch/Home/HomeUtils.res
@@ -1,4 +1,3 @@
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
open CardUtils
open PageUtils
open HSwitchUtils
diff --git a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateFromScratch.res b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateFromScratch.res
index a85045ad2..073c4f22d 100644
--- a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateFromScratch.res
+++ b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateFromScratch.res
@@ -14,6 +14,7 @@ let make = (
let (currentStep, setCurrentStep) = React.useState(_ => DownloadTestAPIKey)
let {setQuickStartPageState} = React.useContext(GlobalProvider.defaultContext)
let isLastStep = currentStep === DisplayPaymentConfirmation
+ let updateEnumInRecoil = EnumVariantHook.useUpdateEnumInRecoil()
let theme = switch ThemeProvider.useTheme() {
| Dark => "vs-dark"
@@ -25,10 +26,18 @@ let make = (
buttonState={Normal}
buttonType={PrimaryOutline}
text="Back"
- onClick={_ =>
- currentStep === DownloadTestAPIKey
- ? setQuickStartPageState(_ => IntegrateApp(CHOOSE_INTEGRATION))
- : setCurrentStep(_ => getNavigationStepForStandardIntegration(~currentStep, ()))}
+ onClick={_ => {
+ let prevStep = getNavigationStepForStandardIntegration(~currentStep, ())
+ if currentStep === DownloadTestAPIKey {
+ setQuickStartPageState(_ => IntegrateApp(CHOOSE_INTEGRATION))
+ } else {
+ let _ = updateEnumInRecoil([
+ (String("pending"), currentStep->getPolyMorphicVariantOfIntegrationSubStep),
+ (String("ongoing"), prevStep->getPolyMorphicVariantOfIntegrationSubStep),
+ ])
+ setCurrentStep(_ => prevStep)
+ }
+ }}
buttonSize=Small
/>
@@ -40,9 +49,13 @@ let make = (
if isLastStep {
markAsDone()->ignore
} else {
- setCurrentStep(_ =>
- getNavigationStepForStandardIntegration(~currentStep, ~forward=true, ())
- )
+ let nextStep = getNavigationStepForStandardIntegration(~currentStep, ~forward=true, ())
+ let _ = updateEnumInRecoil([
+ (String("completed"), currentStep->getPolyMorphicVariantOfIntegrationSubStep),
+ (String("ongoing"), nextStep->getPolyMorphicVariantOfIntegrationSubStep),
+ ])
+
+ setCurrentStep(_ => nextStep)
}
}}
buttonSize=Small
diff --git a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateYourAppUtils.res b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateYourAppUtils.res
index 35abaf046..2b24edd6b 100644
--- a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateYourAppUtils.res
+++ b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrateYourAppUtils.res
@@ -45,3 +45,26 @@ let getNavigationStepForStandardIntegration = (
| DisplayPaymentConfirmation => forward ? DisplayPaymentConfirmation : DisplayCheckout
}
}
+
+let getPolyMorphicVariantOfIntegrationSubStep: standardIntegrationSteps => QuickStartTypes.sectionHeadingVariant = (
+ currentStep: standardIntegrationSteps,
+) => {
+ switch currentStep {
+ | DownloadTestAPIKey => #DownloadTestAPIKey
+ | CreatePayment => #CreatePayment
+ | DisplayCheckout => #DisplayCheckout
+ | DisplayPaymentConfirmation => #DisplayPaymentConfirmation
+ }
+}
+
+let getPolyMorphicVariantOfMigrateFromStripe: migrateFromStripeSteps => QuickStartTypes.sectionHeadingVariant = (
+ currentStep: migrateFromStripeSteps,
+) => {
+ switch currentStep {
+ | DownloadAPIKey => #DownloadTestAPIKeyStripe
+ | InstallDeps => #InstallDeps
+ | ReplaceAPIKeys => #ReplaceAPIKeys
+ | ReconfigureCheckout => #ReconfigureCheckout
+ | LoadCheckout => #LoadCheckout
+ }
+}
diff --git a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/MigrateFromStripe.res b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/MigrateFromStripe.res
index 0d1b1f156..562726bee 100644
--- a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/MigrateFromStripe.res
+++ b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/MigrateFromStripe.res
@@ -14,6 +14,7 @@ let make = (
let (currentStep, setCurrentStep) = React.useState(_ => DownloadAPIKey)
let {setQuickStartPageState} = React.useContext(GlobalProvider.defaultContext)
let isLastStep = currentStep === LoadCheckout
+ let updateEnumInRecoil = EnumVariantHook.useUpdateEnumInRecoil()
let theme = switch ThemeProvider.useTheme() {
| Dark => "vs-dark"
@@ -25,10 +26,18 @@ let make = (
buttonState={Normal}
buttonType={PrimaryOutline}
text="Back"
- onClick={_ =>
- currentStep === DownloadAPIKey
- ? setQuickStartPageState(_ => IntegrateApp(CHOOSE_INTEGRATION))
- : setCurrentStep(_ => getNavigationStepForMigrateFromStripe(~currentStep, ()))}
+ onClick={_ => {
+ let prevStep = getNavigationStepForMigrateFromStripe(~currentStep, ())
+ if currentStep === DownloadAPIKey {
+ setQuickStartPageState(_ => IntegrateApp(CHOOSE_INTEGRATION))
+ } else {
+ let _ = updateEnumInRecoil([
+ (String("pending"), currentStep->getPolyMorphicVariantOfMigrateFromStripe),
+ (String("ongoing"), prevStep->getPolyMorphicVariantOfMigrateFromStripe),
+ ])
+ setCurrentStep(_ => prevStep)
+ }
+ }}
buttonSize=Small
/>
@@ -40,9 +49,12 @@ let make = (
if isLastStep {
markAsDone()->ignore
} else {
- setCurrentStep(_ =>
- getNavigationStepForMigrateFromStripe(~currentStep, ~forward=true, ())
- )
+ let nextStep = getNavigationStepForMigrateFromStripe(~currentStep, ~forward=true, ())
+ let _ = updateEnumInRecoil([
+ (String("completed"), currentStep->getPolyMorphicVariantOfMigrateFromStripe),
+ (String("ongoing"), nextStep->getPolyMorphicVariantOfMigrateFromStripe),
+ ])
+ setCurrentStep(_ => nextStep)
}
}}
buttonSize=Small
diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartTypes.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartTypes.res
index 34f0e65c2..caa84a5ac 100644
--- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartTypes.res
+++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartTypes.res
@@ -47,6 +47,10 @@ type sectionHeadingVariant = [
| #TestPayment
| #IntegrationMethod
| #IntegrationCompleted
+ | #DownloadTestAPIKey
+ | #CreatePayment
+ | #DisplayCheckout
+ | #DisplayPaymentConfirmation
| #StripeConnected
| #PaypalConnected
| #SPRoutingConfigured
@@ -56,6 +60,11 @@ type sectionHeadingVariant = [
| #SetupWoocomWebhook
| #IsMultipleConfiguration
| #GoLive
+ | #DownloadTestAPIKeyStripe
+ | #InstallDeps
+ | #ReplaceAPIKeys
+ | #ReconfigureCheckout
+ | #LoadCheckout
]
type processorType = {
@@ -85,7 +94,17 @@ type responseType = {
configureWoocom: bool,
setupWoocomWebhook: bool,
isMultipleConfiguration: bool,
+ downloadTestAPIKeyStripe: string,
+ installDeps: string,
+ replaceAPIKeys: string,
+ reconfigureCheckout: string,
+ loadCheckout: string,
+ downloadTestAPIKey: string,
+ createPayment: string,
+ displayCheckout: string,
+ displayPaymentConfirmation: string,
}
+
type requestObjectType =
| ProcesorType(processorType)
| RoutingType(routingType)
@@ -93,5 +112,6 @@ type requestObjectType =
| IntegrationMethod(integrationMethod)
| ConnectorChoice(connectorChoice)
| Boolean(bool)
+ | String(string)
type valueType = String(string) | Boolean(bool)
diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res
index 4ae161e6c..7de1e90e6 100644
--- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res
+++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res
@@ -169,6 +169,13 @@ let getTypedValueFromDict = valueString => {
->getDictfromDict(#IntegrationMethod->getStringFromVariant)
->getIntegrationType,
integrationCompleted: value->getBool(#IntegrationCompleted->getStringFromVariant, false),
+ downloadTestAPIKey: value->getString(#DownloadTestAPIKey->getStringFromVariant, ""),
+ createPayment: value->getString(#CreatePayment->getStringFromVariant, ""),
+ displayCheckout: value->getString(#DisplayCheckout->getStringFromVariant, ""),
+ displayPaymentConfirmation: value->getString(
+ #DisplayPaymentConfirmation->getStringFromVariant,
+ "",
+ ),
stripeConnected: value
->getDictfromDict(#StripeConnected->getStringFromVariant)
->getProcessorType,
@@ -183,6 +190,11 @@ let getTypedValueFromDict = valueString => {
configureWoocom: value->getBool(#ConfigureWoocom->getStringFromVariant, false),
setupWoocomWebhook: value->getBool(#SetupWoocomWebhook->getStringFromVariant, false),
isMultipleConfiguration: value->getBool(#IsMultipleConfiguration->getStringFromVariant, false),
+ downloadTestAPIKeyStripe: value->getString(#DownloadTestAPIKeyStripe->getStringFromVariant, ""),
+ installDeps: value->getString(#InstallDeps->getStringFromVariant, ""),
+ replaceAPIKeys: value->getString(#ReplaceAPIKeys->getStringFromVariant, ""),
+ reconfigureCheckout: value->getString(#ReconfigureCheckout->getStringFromVariant, ""),
+ loadCheckout: value->getString(#LoadCheckout->getStringFromVariant, ""),
}
typedValue
}
@@ -231,6 +243,17 @@ let getStatusValue = (comparator: valueType, enumVariant, dashboardPageState) =>
boolValue ? COMPLETED : dashboardPageState === enumVariant ? ONGOING : PENDING
}
}
+
+let getStatusFromString = statusString => {
+ open HSSelfServeSidebar
+ switch statusString->Js.String2.toUpperCase {
+ | "PENDING" => PENDING
+ | "COMPLETED" => COMPLETED
+ | "ONGOING" => ONGOING
+ | _ => PENDING
+ }
+}
+
let sidebarTextBasedOnVariant = choiceState =>
switch choiceState {
| #MigrateFromStripe => "Hyperswitch For Stripe Users"
@@ -276,23 +299,23 @@ let getSidebarOptionsForIntegrateYourApp: (
subOptions: [
{
title: "Download Test API Keys",
- status: PENDING,
+ status: enumValue.downloadTestAPIKeyStripe->getStatusFromString,
},
{
title: "Install Dependencies",
- status: PENDING,
+ status: enumValue.installDeps->getStatusFromString,
},
{
title: "Replace API keys",
- status: PENDING,
+ status: enumValue.replaceAPIKeys->getStatusFromString,
},
{
title: "Reconfigure Checkout Form",
- status: PENDING,
+ status: enumValue.reconfigureCheckout->getStatusFromString,
},
{
title: "Load Hyperswitch Checkout",
- status: PENDING,
+ status: enumValue.loadCheckout->getStatusFromString,
},
],
},
@@ -317,19 +340,19 @@ let getSidebarOptionsForIntegrateYourApp: (
subOptions: [
{
title: "Download Test API Key",
- status: PENDING,
+ status: enumValue.downloadTestAPIKey->getStatusFromString,
},
{
title: "Create a Payment",
- status: PENDING,
+ status: enumValue.createPayment->getStatusFromString,
},
{
title: "Display Hyperswitch Checkout",
- status: PENDING,
+ status: enumValue.displayCheckout->getStatusFromString,
},
{
title: "Display Payment Confirmation",
- status: PENDING,
+ status: enumValue.displayPaymentConfirmation->getStatusFromString,
},
],
},
@@ -571,6 +594,7 @@ let generateBodyBasedOnType = (parentVariant: sectionHeadingVariant, value: requ
]->getJsonFromArrayOfJson
| Boolean(_) => (parentVariant :> string)->Js.Json.string
+ | String(str) => str->Js.Json.string
}
}
diff --git a/src/screens/HyperSwitch/Hooks/EnumVariantHook.res b/src/screens/HyperSwitch/Hooks/EnumVariantHook.res
index ae31a0902..0a7ae6a37 100644
--- a/src/screens/HyperSwitch/Hooks/EnumVariantHook.res
+++ b/src/screens/HyperSwitch/Hooks/EnumVariantHook.res
@@ -48,6 +48,10 @@ let useUpdateEnumInRecoil = () => {
let booleanDict = [((enumVariant :> string), true->Js.Json.boolean)]->Js.Dict.fromArray
enumDictsArray->Array.push(booleanDict)
}
+ | String(str) => {
+ let stringDict = [((enumVariant :> string), str->Js.Json.string)]->Js.Dict.fromArray
+ enumDictsArray->Array.push(stringDict)
+ }
| _ => enumDictsArray->Array.push(bodyValForApi->getDictFromJsonObject)
}
})
diff --git a/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res b/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res
index 7d4194246..7b3c1294e 100644
--- a/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res
+++ b/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res
@@ -6,6 +6,7 @@ type status =
| RequiresCustomerAction
| RequiresPaymentMethod
| RequiresConfirmation
+ | PartiallyCaptured
| None
type paymentAttemptStatus = [
@@ -44,6 +45,7 @@ let statusVariantMapper: string => status = statusLabel =>
| "REQUIRES_CUSTOMER_ACTION" => RequiresCustomerAction
| "REQUIRES_PAYMENT_METHOD" => RequiresPaymentMethod
| "REQUIRES_CONFIRMATION" => RequiresConfirmation
+ | "PARTIALLY_CAPTURED" => PartiallyCaptured
| _ => None
}
diff --git a/src/screens/HyperSwitch/Order/OrderEntity.res b/src/screens/HyperSwitch/Order/OrderEntity.res
index 8b8b24e33..348fe61a9 100644
--- a/src/screens/HyperSwitch/Order/OrderEntity.res
+++ b/src/screens/HyperSwitch/Order/OrderEntity.res
@@ -53,7 +53,9 @@ let getRefundCell = (refunds: refunds, refundsColType: refundsColType): Table.ce
Label({
title: refunds.status->Js.String2.toUpperCase,
color: switch refunds.status->HSwitchOrderUtils.statusVariantMapper {
- | Succeeded => LabelGreen
+ | Succeeded
+ | PartiallyCaptured =>
+ LabelGreen
| Failed => LabelRed
| Processing => LabelOrange
| Cancelled => LabelRed
@@ -488,7 +490,8 @@ let getStatus = order => {
let orderStatusLabel = order.status->Js.String2.toUpperCase
let fixedStatusCss = "text-sm text-white font-bold px-3 py-2 rounded-md"
switch order.status->HSwitchOrderUtils.statusVariantMapper {
- | Succeeded =>
+ | Succeeded
+ | PartiallyCaptured =>
{orderStatusLabel->React.string}
@@ -706,7 +709,9 @@ let getCell = (order, colType: colType): Table.cell => {
Label({
title: order.status->Js.String2.toUpperCase,
color: switch orderStatus {
- | Succeeded => LabelGreen
+ | Succeeded
+ | PartiallyCaptured =>
+ LabelGreen
| Failed
| Cancelled =>
LabelRed
diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res
index 661ca040a..2514bd116 100644
--- a/src/screens/HyperSwitch/Order/OrderUIUtils.res
+++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res
@@ -100,7 +100,6 @@ let filterUrl = `${HSwitchGlobalVars.hyperSwitchApiPrefix}/payments/filter`
let (startTimeFilterKey, endTimeFilterKey) = ("start_time", "end_time")
-external toDict: 't => Js.Dict.t
= "%identity"
let filterByData = (txnArr, value) => {
open LogicUtils
let searchText = value->getStringFromJson("")
@@ -110,7 +109,7 @@ let filterByData = (txnArr, value) => {
->Belt.Array.keepMap(data => {
let valueArr =
data
- ->toDict
+ ->Identity.genericTypeToDictOfJson
->Js.Dict.entries
->Js.Array2.map(item => {
let (_, value) = item
diff --git a/src/screens/HyperSwitch/Order/ShowOrder.res b/src/screens/HyperSwitch/Order/ShowOrder.res
index 444ea6366..a159f346f 100644
--- a/src/screens/HyperSwitch/Order/ShowOrder.res
+++ b/src/screens/HyperSwitch/Order/ShowOrder.res
@@ -25,6 +25,7 @@ module OrderInfo = {
~paymentId,
) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
+ let typedPaymentStatus = paymentStatus->statusVariantMapper
@@ -46,7 +47,7 @@ module OrderInfo = {
}}
buttonType={Secondary}
buttonState={!isNonRefundConnector &&
- paymentStatus->statusVariantMapper === Succeeded &&
+ (typedPaymentStatus === Succeeded || typedPaymentStatus === PartiallyCaptured) &&
!(paymentId->isTestPayment)
? Normal
: Disabled}
diff --git a/src/screens/HyperSwitch/Refunds/RefundUtils.res b/src/screens/HyperSwitch/Refunds/RefundUtils.res
index 99c9c4868..2421f3469 100644
--- a/src/screens/HyperSwitch/Refunds/RefundUtils.res
+++ b/src/screens/HyperSwitch/Refunds/RefundUtils.res
@@ -48,7 +48,6 @@ let customUI =
let (startTimeFilterKey, endTimeFilterKey) = ("start_time", "end_time")
-external toDict: 't => Js.Dict.t = "%identity"
let filterByData = (txnArr, value) => {
open LogicUtils
let searchText = value->getStringFromJson("")
@@ -58,7 +57,7 @@ let filterByData = (txnArr, value) => {
->Belt.Array.keepMap(data => {
let valueArr =
data
- ->toDict
+ ->Identity.genericTypeToDictOfJson
->Js.Dict.entries
->Js.Array2.map(item => {
let (_, value) = item
diff --git a/src/screens/HyperSwitch/Routing/RoutingStack.res b/src/screens/HyperSwitch/Routing/RoutingStack.res
index 0deba0211..169da83b8 100644
--- a/src/screens/HyperSwitch/Routing/RoutingStack.res
+++ b/src/screens/HyperSwitch/Routing/RoutingStack.res
@@ -1,5 +1,4 @@
open APIUtils
-external toJson: 'a => Js.Json.t = "%identity"
@react.component
let make = (~remainingPath, ~previewOnly=false) => {
let fetchDetails = useGetMethod()
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
index 63effeb51..d3ea4e15b 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
@@ -1,8 +1,3 @@
-external arrToReactEvent: array => ReactEvent.Form.t = "%identity"
-external toReactEvent: 'a => ReactEvent.Form.t = "%identity"
-external formEventToStrArr: ReactEvent.Form.t => array = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
-external toJson: 'a => Js.Json.t = "%identity"
external anyToEnum: 'a => AdvancedRoutingTypes.connectorSelectionData = "%identity"
@react.component
@@ -22,7 +17,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
} else {
"priority"
}
- gateWaysType.onChange(typeString->toReactEvent)
+ gateWaysType.onChange(typeString->Identity.anyTypeToReactEvent)
None
}, [isDistributeInput.value])
@@ -39,10 +34,10 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
name: "gateways",
onBlur: _ev => (),
onChange: ev => {
- let newSelectedOptions = ev->formEventToStrArr
+ let newSelectedOptions = ev->Identity.formReactEventToArrayOfString
if newSelectedOptions->Js.Array2.length === 0 {
- gateWaysInput.onChange([]->toReactEvent)
+ gateWaysInput.onChange([]->Identity.anyTypeToReactEvent)
} else {
let gatewaysArr = newSelectedOptions->Js.Array2.map(item => {
open AdvancedRoutingTypes
@@ -57,17 +52,17 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
merchant_connector_id: item,
},
split: sharePercent,
- }->toJson
+ }->Identity.genericTypeToJson
} else {
{
connector: (
connectorList->ConnectorTableUtils.getConnectorNameViaId(item)
).connector_name,
merchant_connector_id: item,
- }->toJson
+ }->Identity.genericTypeToJson
}
})
- gateWaysInput.onChange(gatewaysArr->toReactEvent)
+ gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
}
},
onFocus: _ev => (),
@@ -101,12 +96,12 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
merchant_connector_id: obj.merchant_connector_id,
},
split: sharePercent,
- }->toJson
+ }->Identity.genericTypeToJson
- | VolumeObject(obj) => obj.connector->toJson
+ | VolumeObject(obj) => obj.connector->Identity.genericTypeToJson
}
})
- gateWaysInput.onChange(gatewaysArr->toReactEvent)
+ gateWaysInput.onChange(gatewaysArr->Identity.anyTypeToReactEvent)
}
let updatePercentage = (item: AdvancedRoutingTypes.connectorSelectionData, value) => {
@@ -121,7 +116,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
if value < 100 {
let newList = selectedOptions->Js.Array2.map(option => {
switch option {
- | PriorityObject(obj) => obj.connector->toJson
+ | PriorityObject(obj) => obj.connector->Identity.genericTypeToJson
| VolumeObject(obj) =>
{
...obj,
@@ -131,10 +126,10 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
).merchant_connector_id
? value
: obj.split,
- }->toJson
+ }->Identity.genericTypeToJson
}
})
- gateWaysInput.onChange(newList->toReactEvent)
+ gateWaysInput.onChange(newList->Identity.anyTypeToReactEvent)
}
}
@@ -145,7 +140,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
AdvancedRoutingUtils.getConnectorStringFromConnectorSelectionData(i).merchant_connector_id
)
->Array.filterWithIndex((_, i) => i !== index)
- ->toReactEvent,
+ ->Identity.anyTypeToReactEvent,
)
}
@@ -234,7 +229,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
{
- isDistributeInput.onChange(v->toReactEvent)
+ isDistributeInput.onChange(v->Identity.anyTypeToReactEvent)
onClickDistribute(v)
}}
isDisabled=false
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
index 3ce8c81c7..076b6c8cd 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
@@ -3,9 +3,6 @@ open AdvancedRoutingTypes
open AdvancedRoutingUtils
open LogicUtils
-external toForm: string => ReactEvent.Form.t = "%identity"
-external toJson: 'a => Js.Json.t = "%identity"
-external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
external toWasm: Js.Dict.t => RoutingTypes.wasmModule = "%identity"
let defaultRule = {
@@ -124,7 +121,7 @@ module Wrapper = {
}
React.useEffect0(() => {
- name.onChange(heading->Js.String2.toLowerCase->titleToSnake->toForm)
+ name.onChange(heading->Js.String2.toLowerCase->titleToSnake->Identity.stringToFormReactEvent)
let gatewayArrPresent = gateWaysInput.value->getArrayFromJson([])->Js.Array2.length > 0
@@ -242,23 +239,23 @@ module RuleBasedUI = {
let (rules, setRules) = React.useState(_ => ruleInput.value->getArrayFromJson([]))
React.useEffect1(() => {
- ruleInput.onChange(rules->arrToFormEvent)
+ ruleInput.onChange(rules->Identity.arrayOfGenericTypeToFormReactEvent)
None
}, [rules])
let addRule = (index, copy) => {
let existingRules = ruleInput.value->getArrayFromJson([])
let newRule = copy
- ? existingRules[index]->Belt.Option.getWithDefault(defaultRule->toJson)
- : defaultRule->toJson
+ ? existingRules[index]->Belt.Option.getWithDefault(defaultRule->Identity.genericTypeToJson)
+ : defaultRule->Identity.genericTypeToJson
let newRules = existingRules->Js.Array2.concat([newRule])
- ruleInput.onChange(newRules->arrToFormEvent)
+ ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent)
}
let removeRule = index => {
let existingRules = ruleInput.value->getArrayFromJson([])
let newRules = existingRules->Array.filterWithIndex((_, i) => i !== index)
- ruleInput.onChange(newRules->arrToFormEvent)
+ ruleInput.onChange(newRules->Identity.arrayOfGenericTypeToFormReactEvent)
}
@@ -340,7 +337,9 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => {
let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom)
let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile
let (profile, setProfile) = React.useState(_ => defaultBusinessProfile.profile_id)
- let (initialValues, setInitialValues) = React.useState(_ => initialValues->toJson)
+ let (initialValues, setInitialValues) = React.useState(_ =>
+ initialValues->Identity.genericTypeToJson
+ )
let (initialRule, setInitialRule) = React.useState(() => None)
let showToast = ToastState.useShowToast()
let fetchDetails = useGetMethod()
@@ -594,7 +593,7 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => {
}
let getActivateUrl = getURL(~entityName=ROUTING, ~methodType=Post, ~id=None, ())
- let response = await updateDetails(getActivateUrl, payload->toJson, Post)
+ let response = await updateDetails(getActivateUrl, payload->Identity.genericTypeToJson, Post)
showToast(
~message="Successfully Created a new Configuration !",
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
index 28e1d3092..10d32844e 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
@@ -2,11 +2,7 @@ open AdvancedRoutingTypes
open AdvancedRoutingUtils
open FormRenderer
-external arrToFormEvent: array<'a> => ReactEvent.Form.t = "%identity"
-external toForm: 'a => ReactEvent.Form.t = "%identity"
external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
-external formEventToStrArr: ReactEvent.Form.t => array
= "%identity"
module LogicalOps = {
@react.component
@@ -55,8 +51,8 @@ module OperatorInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStr
- operator.onChange(value->toForm)
+ let value = ev->Identity.formReactEventToString
+ operator.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: operator.value,
@@ -74,7 +70,7 @@ module OperatorInp = {
setOpVals(_ => operatorVals)
if operator.value->Js.Json.decodeString->Belt.Option.isNone {
- operator.onChange(operatorVals[0]->toForm)
+ operator.onChange(operatorVals[0]->Identity.anyTypeToReactEvent)
}
None
}, (field.value, valInp.value))
@@ -139,7 +135,7 @@ module ValueInp = {
| NOT_CONTAINS => "enum_variant_array"
| _ => "number"
}
- }->toForm,
+ }->Identity.anyTypeToReactEvent,
)
None
}, [valueField.value])
@@ -148,8 +144,8 @@ module ValueInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStrArr
- valueField.onChange(value->toForm)
+ let value = ev->Identity.formReactEventToArrayOfString
+ valueField.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: valueField.value,
@@ -209,12 +205,12 @@ module MetadataInp = {
})
let finalVal = Js.Array2.joinWith(arrStr, ",")->Js.Json.string
- valueField.onChange(finalVal->toForm)
+ valueField.onChange(finalVal->Identity.anyTypeToReactEvent)
},
onChange: ev => {
let target = ReactEvent.Form.target(ev)
let value = target["value"]
- valueField.onChange(value->toForm)
+ valueField.onChange(value->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: valueField.value,
@@ -295,11 +291,11 @@ module FieldInp = {
name: "string",
onBlur: _ev => (),
onChange: ev => {
- let value = ev->formEventToStr
+ let value = ev->Identity.formReactEventToString
onChangeMethod(value)
- field.onChange(value->toForm)
- op.onChange(""->toForm)
- val.onChange(""->toForm)
+ field.onChange(value->Identity.anyTypeToReactEvent)
+ op.onChange(""->Identity.anyTypeToReactEvent)
+ val.onChange(""->Identity.anyTypeToReactEvent)
},
onFocus: _ev => (),
value: field.value,
@@ -401,12 +397,21 @@ module MakeRuleField = {
let onPlusClick = _ => {
if plusBtnEnabled {
let toAdd = Js.Dict.empty()
- conditionsInput.onChange(Js.Array2.concat(fields, [toAdd->Js.Json.object_])->arrToFormEvent)
+ conditionsInput.onChange(
+ Js.Array2.concat(
+ fields,
+ [toAdd->Js.Json.object_],
+ )->Identity.arrayOfGenericTypeToFormReactEvent,
+ )
}
}
let onCrossClick = index => {
- conditionsInput.onChange(fields->Array.filterWithIndex((_, i) => index !== i)->arrToFormEvent)
+ conditionsInput.onChange(
+ fields
+ ->Array.filterWithIndex((_, i) => index !== i)
+ ->Identity.arrayOfGenericTypeToFormReactEvent,
+ )
}
diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
index 0c342c5a1..45e55a43c 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUtils.res
@@ -1,5 +1,3 @@
-external toJson: 'a => Js.Json.t = "%identity"
-
let getCurrentDetailedUTCTime = () => {
Js.Date.fromFloat(Js.Date.now())->Js.Date.toUTCString
}
@@ -410,7 +408,7 @@ let generateRule = rulesDict => {
{
"name": ruleDict->getString("name", ""),
"connectorSelection": ruleDict->getJsonObjectFromDict("connectorSelection"),
- "statements": modifiedStatements->Js.Array2.map(toJson)->Js.Json.array,
+ "statements": modifiedStatements->Js.Array2.map(Identity.genericTypeToJson)->Js.Json.array,
}
})
modifiedRules
diff --git a/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res b/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
index 647bc5b71..ab7949efb 100644
--- a/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
+++ b/src/screens/HyperSwitch/RoutingRevamp/BasicDetailsForm.res
@@ -2,9 +2,6 @@ open FormRenderer
open LogicUtils
open AdvancedRoutingTypes
-external fromFormEvent: ReactEvent.Form.t => 'a = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
-
let configurationNameInput = makeFieldInfo(
~label="Configuration Name",
~name="name",
@@ -43,7 +40,7 @@ module BusinessProfileInp = {
value: profile->Js.Json.string,
onChange: {
ev => {
- setProfile(_ => ev->formEventToStr)
+ setProfile(_ => ev->Identity.formReactEventToString)
input.onChange(ev)
}
},
diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPage.res b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
index 2e37537e2..4c37a06ed 100644
--- a/src/screens/HyperSwitch/SDKPayment/SDKPage.res
+++ b/src/screens/HyperSwitch/SDKPayment/SDKPage.res
@@ -1,7 +1,4 @@
let h3Leading2Style = HSwitchUtils.getTextClass(~textVariant=H3, ~h3TextVariant=Leading_2, ())
-external toJson: 'a => Js.Json.t = "%identity"
-external formEventToStr: ReactEvent.Form.t => string = "%identity"
-external strToFormEvent: Js.String.t => ReactEvent.Form.t = "%identity"
module SDKConfiguarationFields = {
open MerchantAccountUtils
@@ -55,8 +52,10 @@ module SDKConfiguarationFields = {
value: (initialValues.amount / 100)->string_of_int->Js.Json.string,
onChange: {
ev => {
- let eventValueToInt = ev->formEventToStr->LogicUtils.getIntFromString(0)
- let valInCents = (eventValueToInt * 100)->string_of_int->strToFormEvent
+ let eventValueToInt =
+ ev->Identity.formReactEventToString->LogicUtils.getIntFromString(0)
+ let valInCents =
+ (eventValueToInt * 100)->string_of_int->Identity.stringToFormReactEvent
input.onChange(valInCents)
}
},
@@ -140,7 +139,7 @@ let make = () => {