Int.toString}
className={`px-3 py-2 ${tabValue.value->getStyle(index)} selection:bg-white`}
onClick={_ => setOption(tabValue)}>
{tabValue.label->React.string}
@@ -172,6 +173,7 @@ module StatisticsCard = {
let (bgColor, textColor) = switch direction {
| Upward => ("bg-green-light", "text-green-dark")
| Downward => ("bg-red-light", "text-red-dark")
+ | No_Change => ("bg-gray-100", "text-gray-500")
}
diff --git a/src/screens/NewAnalytics/NewAnalyticsTypes.res b/src/screens/NewAnalytics/NewAnalyticsTypes.res
index 7ce136704..229217cfd 100644
--- a/src/screens/NewAnalytics/NewAnalyticsTypes.res
+++ b/src/screens/NewAnalytics/NewAnalyticsTypes.res
@@ -1,6 +1,6 @@
type analyticsPages = Payment
type viewType = Graph | Table
-type statisticsDirection = Upward | Downward
+type statisticsDirection = Upward | Downward | No_Change
type analyticsPagesRoutes = | @as("new-analytics-payment") NewAnalyticsPayment
@@ -23,10 +23,12 @@ type metrics = [
| #payment_method_type
| #card_network
| #authentication_type
+ | #payments_distribution
| #smart_retried_amount
| #payments_success_rate
| #refund_success_count
| #dispute_status_metric
+ | #payment_failed_rate
]
type granularity = [
| #G_ONEDAY
diff --git a/src/screens/NewAnalytics/NewAnalyticsUtils.res b/src/screens/NewAnalytics/NewAnalyticsUtils.res
index 0c808f2a2..df5994073 100644
--- a/src/screens/NewAnalytics/NewAnalyticsUtils.res
+++ b/src/screens/NewAnalytics/NewAnalyticsUtils.res
@@ -55,6 +55,7 @@ let requestBody = (
~applyFilterFor as _: option
>=None,
~delta: option=None,
~granularity: option=None,
+ ~distributionValues: option=None,
) => {
let metrics = metrics->Array.map(v => (v: metrics :> string))
let filter = Dict.make()->JSON.Encode.object->Some
@@ -68,6 +69,7 @@ let requestBody = (
~startDateTime=startTime,
~endDateTime=endTime,
~granularity,
+ ~distributionValues,
)->JSON.Encode.object,
]->JSON.Encode.array
}
@@ -98,3 +100,73 @@ let getComparisionTimePeriod = (~startDate, ~endDate) => {
(startTimeValue, endTimeVal)
}
+
+let getMonthName = month => {
+ switch month {
+ | 0 => "Jan"
+ | 1 => "Feb"
+ | 2 => "Mar"
+ | 3 => "Apr"
+ | 4 => "May"
+ | 5 => "Jun"
+ | 6 => "Jul"
+ | 7 => "Aug"
+ | 8 => "Sep"
+ | 9 => "Oct"
+ | 10 => "Nov"
+ | 11 => "Dec"
+ | _ => ""
+ }
+}
+
+let getLabelName = (~key, ~index, ~points) => {
+ open LogicUtils
+ let getDateObject = (array, index) => {
+ array
+ ->getValueFromArray(index, Dict.make()->JSON.Encode.object)
+ ->getDictFromJsonObject
+ ->getString(key, "")
+ ->DayJs.getDayJsForString
+ }
+
+ if key === "time_bucket" {
+ let pointsArray = points->getArrayFromJson([])
+ let startPoint = pointsArray->getDateObject(0)
+ let endPoint = pointsArray->getDateObject(1)
+
+ let startDate = `${startPoint.month()->getMonthName} ${startPoint.format("DD")}`
+ let endDate = `${endPoint.month()->getMonthName} ${endPoint.format("DD")}`
+
+ `${startDate}-${endDate}`
+ } else {
+ `Series ${(index + 1)->Int.toString}`
+ }
+}
+let calculatePercentageChange = (~primaryValue, ~secondaryValue) => {
+ open NewAnalyticsTypes
+ let change = secondaryValue -. primaryValue
+
+ if primaryValue === 0.0 || change === 0.0 {
+ (0.0, No_Change)
+ } else if change > 0.0 {
+ let diff = change /. primaryValue
+ let percentage = diff *. 100.0
+ (percentage, Upward)
+ } else {
+ let diff = change *. -1.0 /. primaryValue
+ let percentage = diff *. 100.0
+ (percentage, Downward)
+ }
+}
+
+let getToolTipConparision = (~primaryValue, ~secondaryValue) => {
+ let (value, direction) = calculatePercentageChange(~primaryValue, ~secondaryValue)
+
+ let (textColor, icon) = switch direction {
+ | Upward => ("#12B76A", "▲")
+ | Downward => ("#F04E42", "▼")
+ | No_Change => ("#A0A0A0", "")
+ }
+
+ `${icon}${value->valueFormatter(Rate)}`
+}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res
new file mode 100644
index 000000000..5c5f6609b
--- /dev/null
+++ b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res
@@ -0,0 +1,155 @@
+open NewAnalyticsTypes
+open NewAnalyticsHelper
+open NewPaymentAnalyticsEntity
+open BarGraphTypes
+open FailedPaymentsDistributionUtils
+
+module TableModule = {
+ @react.component
+ let make = (~data, ~className="", ~selectedTab: string) => {
+ let (offset, setOffset) = React.useState(_ => 0)
+ let defaultSort: Table.sortedObject = {
+ key: "",
+ order: Table.INC,
+ }
+ let tableBorderClass = "border-2 border-solid border-jp-gray-940 border-collapse border-opacity-30 dark:border-jp-gray-dark_table_border_color dark:border-opacity-30"
+ let visibleColumns = visibleColumns->Array.concat([selectedTab->getDimentionType])
+ let tableData = getTableData(data)
+
+
+ Array.length}
+ offset
+ setOffset
+ defaultSort
+ currrentFetchCount={tableData->Array.length}
+ tableLocalFilter=false
+ tableheadingClass=tableBorderClass
+ tableBorderClass
+ ignoreHeaderBg=true
+ tableDataBorderClass=tableBorderClass
+ isAnalyticsModule=true
+ />
+
+ }
+}
+
+module FailedPaymentsDistributionHeader = {
+ @react.component
+ let make = (~viewType, ~setViewType, ~groupBy, ~setGroupBy) => {
+ let setViewType = value => {
+ setViewType(_ => value)
+ }
+
+ let setGroupBy = value => {
+ setGroupBy(_ => value)
+ }
+
+
+ }
+}
+
+@react.component
+let make = (
+ ~entity: moduleEntity,
+ ~chartEntity: chartEntity,
+) => {
+ open LogicUtils
+ open APIUtils
+ let getURL = useGetURL()
+ let updateDetails = useUpdateMethod()
+ let {filterValueJson} = React.useContext(FilterContext.filterContext)
+ let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Success)
+ let (failedPaymentsDistribution, setfailedPaymentsDistribution) = React.useState(_ =>
+ JSON.Encode.array([])
+ )
+ let (viewType, setViewType) = React.useState(_ => Graph)
+ let (groupBy, setGroupBy) = React.useState(_ => defaulGroupBy)
+ let startTimeVal = filterValueJson->getString("startTime", "")
+ let endTimeVal = filterValueJson->getString("endTime", "")
+
+ let getFailedPaymentsDistribution = async () => {
+ try {
+ setScreenState(_ => PageLoaderWrapper.Loading)
+ let url = getURL(
+ ~entityName=ANALYTICS_PAYMENTS,
+ ~methodType=Post,
+ ~id=Some((entity.domain: domain :> string)),
+ )
+
+ let body = NewAnalyticsUtils.requestBody(
+ ~dimensions=[],
+ ~startTime=startTimeVal,
+ ~endTime=endTimeVal,
+ ~delta=entity.requestBodyConfig.delta,
+ ~filters=entity.requestBodyConfig.filters,
+ ~metrics=entity.requestBodyConfig.metrics,
+ ~groupByNames=[groupBy.value]->Some,
+ ~customFilter=entity.requestBodyConfig.customFilter,
+ ~applyFilterFor=entity.requestBodyConfig.applyFilterFor,
+ )
+
+ let response = await updateDetails(url, body, Post)
+ let responseData = response->getDictFromJsonObject->getArrayFromDict("queryData", [])
+ let arr =
+ response
+ ->getDictFromJsonObject
+ ->getArrayFromDict("queryData", [])
+
+ if arr->Array.length > 0 {
+ setfailedPaymentsDistribution(_ => responseData->JSON.Encode.array)
+ setScreenState(_ => PageLoaderWrapper.Success)
+ } else {
+ setScreenState(_ => PageLoaderWrapper.Custom)
+ }
+ } catch {
+ | _ => setScreenState(_ => PageLoaderWrapper.Custom)
+ }
+ }
+
+ React.useEffect(() => {
+ if startTimeVal->isNonEmptyString && endTimeVal->isNonEmptyString {
+ getFailedPaymentsDistribution()->ignore
+ }
+ None
+ }, [startTimeVal, endTimeVal, groupBy.value])
+
+
+
+
+ } customUI={}>
+
+
+ {switch viewType {
+ | Graph =>
+
+ | Table =>
+
+ }}
+
+
+
+
+}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionTypes.res b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionTypes.res
new file mode 100644
index 000000000..4dc451670
--- /dev/null
+++ b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionTypes.res
@@ -0,0 +1,5 @@
+type failedPaymentsDistributionObject = {
+ payments_failure_rate_distribution: int,
+ connector: string,
+ payment_method: string,
+}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res
new file mode 100644
index 000000000..cc457f7f5
--- /dev/null
+++ b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res
@@ -0,0 +1,117 @@
+open NewPaymentAnalyticsUtils
+open FailedPaymentsDistributionTypes
+open LogicUtils
+
+let getDimentionType = string => {
+ switch string {
+ | "connector" => #connector
+ | "payment_method" => #payment_method
+ | "payment_method_type" => #payment_method_type
+ | "card_network" => #card_network
+ | "authentication_type" | _ => #authentication_type
+ }
+}
+
+let getXKey = (~isSmartRetry) => {
+ switch isSmartRetry {
+ | true => "payments_failure_rate_distribution"
+ | false => "payments_failure_rate_distribution_without_smart_retries"
+ }
+}
+
+let failedPaymentsDistributionMapper = (
+ ~data: JSON.t,
+ ~xKey: string,
+ ~yKey: string,
+): BarGraphTypes.barGraphPayload => {
+ open BarGraphTypes
+ let categories = [data]->JSON.Encode.array->getCategories(0, yKey)
+ let barGraphData = getBarGraphObj(
+ ~array=data->getArrayFromJson([]),
+ ~key=xKey,
+ ~name=xKey->snakeToTitle,
+ ~color="#BA3535",
+ )
+ let title = {
+ text: "",
+ }
+ {categories, data: [barGraphData], title}
+}
+
+open NewAnalyticsTypes
+let visibleColumns: array = [#payment_failed_rate]
+
+let tableItemToObjMapper: Dict.t => failedPaymentsDistributionObject = dict => {
+ {
+ payments_failure_rate_distribution: dict->getInt("payments_failure_rate_distribution", 0),
+ connector: dict->getString((#connector: metrics :> string), ""),
+ payment_method: dict->getString((#payment_method: metrics :> string), ""),
+ }
+}
+
+let getObjects: JSON.t => array = json => {
+ json
+ ->LogicUtils.getArrayFromJson([])
+ ->Array.map(item => {
+ tableItemToObjMapper(item->getDictFromJsonObject)
+ })
+}
+
+let getHeading = (colType: metrics) => {
+ switch colType {
+ | #payment_failed_rate =>
+ Table.makeHeaderInfo(
+ ~key=(#payment_failed_rate: metrics :> string),
+ ~title="Payments Failed Rate",
+ ~dataType=TextType,
+ )
+ | #connector =>
+ Table.makeHeaderInfo(
+ ~key=(#connector: metrics :> string),
+ ~title="Connector",
+ ~dataType=TextType,
+ )
+ | #payment_method | _ =>
+ Table.makeHeaderInfo(
+ ~key=(#payment_method: metrics :> string),
+ ~title="Payment Method",
+ ~dataType=TextType,
+ )
+ }
+}
+
+let getCell = (obj, colType: metrics): Table.cell => {
+ switch colType {
+ | #payment_failed_rate => Text(obj.payments_failure_rate_distribution->Int.toString)
+ | #connector => Text(obj.connector)
+ | #payment_method | _ => Text(obj.payment_method)
+ }
+}
+
+let getTableData = json => {
+ json->getArrayDataFromJson(tableItemToObjMapper)->Array.map(Nullable.make)
+}
+
+let tabs = [
+ {
+ label: "Connector",
+ value: (#connector: dimension :> string),
+ },
+ {
+ label: "Payment Method",
+ value: (#payment_method: dimension :> string),
+ },
+ {
+ label: "Payment Method Type",
+ value: (#payment_method_type: dimension :> string),
+ },
+ {
+ label: "Authentication Type",
+ value: (#authentication_type: dimension :> string),
+ },
+]
+
+let defaulGroupBy = {
+ label: "Connector",
+ value: (#connector: dimension :> string),
+}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res
index 2c741f08d..792161264 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res
@@ -17,5 +17,8 @@ let make = () => {
entity={successfulPaymentsDistributionEntity}
chartEntity={successfulPaymentsDistributionChartEntity}
/>
+
}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsEntity.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsEntity.res
index b5117cd2f..76dbc3a6e 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsEntity.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsEntity.res
@@ -80,13 +80,13 @@ let paymentsSuccessRateChartEntity: chartEntity<
getChatOptions: LineGraphUtils.getLineGraphOptions,
}
-// Payments Distribution
+// Successful Payments Distribution
let successfulPaymentsDistributionEntity: moduleEntity = {
requestBodyConfig: {
delta: false,
- metrics: [#payment_success_rate],
+ metrics: [#payments_distribution],
},
- title: "Payments Distribution",
+ title: "Successful Payments Distribution",
domain: #payments,
}
@@ -112,3 +112,36 @@ let successfulPaymentsDistributionTableEntity = {
~getHeading,
)
}
+
+// Failed Payments Distribution
+let failedPaymentsDistributionEntity: moduleEntity = {
+ requestBodyConfig: {
+ delta: false,
+ metrics: [#payments_distribution],
+ },
+ title: "Failed Payments Distribution",
+ domain: #payments,
+}
+
+let failedPaymentsDistributionChartEntity: chartEntity<
+ BarGraphTypes.barGraphPayload,
+ BarGraphTypes.barGraphOptions,
+ JSON.t,
+> = {
+ getObjects: FailedPaymentsDistributionUtils.failedPaymentsDistributionMapper,
+ getChatOptions: BarGraphUtils.getBarGraphOptions,
+}
+
+let failedPaymentsDistributionTableEntity = {
+ open FailedPaymentsDistributionUtils
+ EntityType.makeEntity(
+ ~uri=``,
+ ~getObjects,
+ ~dataKey="queryData",
+ ~defaultColumns=visibleColumns,
+ ~requiredSearchFieldsList=[],
+ ~allColumns=visibleColumns,
+ ~getCell,
+ ~getHeading,
+ )
+}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res
index c4ebedb1b..38e49e26d 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res
@@ -1,30 +1,16 @@
open LogicUtils
-let getMonthName = month => {
- switch month {
- | 0 => "Jan"
- | 1 => "Feb"
- | 2 => "Mar"
- | 3 => "Apr"
- | 4 => "May"
- | 5 => "Jun"
- | 6 => "Jul"
- | 7 => "Aug"
- | 8 => "Sep"
- | 9 => "Oct"
- | 10 => "Nov"
- | 11 => "Dec"
- | _ => ""
- }
-}
-
-let getCategories = (data: array
, key: string) => {
- data->Array.map(item => {
+let getCategories = (data: JSON.t, index: int, key: string) => {
+ data
+ ->getArrayFromJson([])
+ ->getValueFromArray(index, []->JSON.Encode.array)
+ ->getArrayFromJson([])
+ ->Array.map(item => {
let value = item->getDictFromJsonObject->getString(key, "")
if value->isNonEmptyString && key == "time_bucket" {
let dateObj = value->DayJs.getDayJsForString
- `${dateObj.month()->getMonthName} ${dateObj.format("DD")}`
+ `${dateObj.month()->NewAnalyticsUtils.getMonthName} ${dateObj.format("DD")}`
} else {
value
}
@@ -45,7 +31,7 @@ let getLineGraphObj = (
item->getDictFromJsonObject->getInt(key, 0)
})
let dataObj: LineGraphTypes.dataObj = {
- showInLegend: false,
+ showInLegend: true,
name,
data,
color,
@@ -71,7 +57,7 @@ let getBarGraphObj = (
dataObj
}
-let getBarGraphData = (json: JSON.t, key: string): BarGraphTypes.data => {
+let getBarGraphData = (json: JSON.t, key: string, barColor: string): BarGraphTypes.data => {
json
->getArrayFromJson([])
->Array.mapWithIndex((item, index) => {
@@ -86,7 +72,7 @@ let getBarGraphData = (json: JSON.t, key: string): BarGraphTypes.data => {
showInLegend: false,
name: `Series ${(index + 1)->Int.toString}`,
data,
- color: "#7CC88F",
+ color: barColor,
}
dataObj
})
@@ -127,19 +113,71 @@ let getMetaDataValue = (~data, ~index, ~key) => {
->getFloat(key, 0.0)
}
-let calculatePercentageChange = (~primaryValue, ~secondaryValue) => {
- open NewAnalyticsTypes
- let change = secondaryValue -. primaryValue
+open LineGraphTypes
+let tooltipFormatter = (~secondaryCategories, ~title, ~metricType) => {
+ open NewAnalyticsUtils
- if primaryValue === 0.0 || change === 0.0 {
- (0.0, Upward)
- } else if change > 0.0 {
- let diff = change /. primaryValue
- let percentage = diff *. 100.0
- (percentage, Upward)
- } else {
- let diff = change *. -1.0 /. primaryValue
- let percentage = diff *. 100.0
- (percentage, Downward)
- }
+ (
+ @this
+ (this: pointFormatter) => {
+ let title = `${title}
`
+
+ let defaultValue = {color: "", x: "", y: 0.0, point: {index: 0}}
+ let primartPoint = this.points->getValueFromArray(0, defaultValue)
+ let secondaryPoint = this.points->getValueFromArray(1, defaultValue)
+
+ let getRowsHtml = (~iconColor, ~date, ~value, ~comparisionComponent="") => {
+ let valueString = valueFormatter(value, metricType)
+ `
+
+
${date}${comparisionComponent}
+
${valueString}
+
`
+ }
+
+ let tableItems =
+ [
+ getRowsHtml(~iconColor=primartPoint.color, ~date=primartPoint.x, ~value=primartPoint.y),
+ getRowsHtml(
+ ~iconColor=secondaryPoint.color,
+ ~date=secondaryCategories->getValueFromArray(secondaryPoint.point.index, ""),
+ ~value=secondaryPoint.y,
+ ~comparisionComponent=getToolTipConparision(
+ ~primaryValue=primartPoint.y,
+ ~secondaryValue=secondaryPoint.y,
+ ),
+ ),
+ ]->Array.joinWith("")
+
+ let content = `
+
+ ${title}
+
+ ${tableItems}
+
+
`
+
+ `
+ ${content}
+
`
+ }
+ )->asTooltipPointFormatter
}
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
index 1da581b6c..da5e98053 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
@@ -34,7 +34,7 @@ let paymentsLifeCycleMapper = (
let customerAwaited = data.customerAwaited // DropOff2
let attemptedPayments = pending + customerAwaited + success + failure
let pmAwaited = data.pmAwaited // Dropoff1
- let totalPayment = pmAwaited + attemptedPayments + cancelled
+ let _totalPayment = pmAwaited + attemptedPayments + cancelled
let disputed = data.disputed
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res
index 74c2ed387..c5b2abd54 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res
@@ -4,7 +4,6 @@ module SmartRetryCard = {
open NewAnalyticsHelper
open NewPaymentsOverviewSectionTypes
open NewPaymentsOverviewSectionUtils
- open NewPaymentAnalyticsUtils
open NewAnalyticsUtils
@react.component
let make = (~metric, ~data) => {
@@ -38,7 +37,6 @@ module SmartRetryCard = {
module OverViewStat = {
open NewAnalyticsHelper
open NewAnalyticsUtils
- open NewPaymentAnalyticsUtils
open NewPaymentsOverviewSectionTypes
open NewPaymentsOverviewSectionUtils
@react.component
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res
index af930d7b1..c0074d531 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res
@@ -47,6 +47,7 @@ module TableModule = {
module PaymentsProcessedHeader = {
open NewAnalyticsTypes
+ open NewAnalyticsUtils
open NewPaymentAnalyticsUtils
@react.component
let make = (
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res
index de1fc8321..4eae44ca4 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res
@@ -8,25 +8,30 @@ let paymentsProcessedMapper = (
~yKey: string,
): LineGraphTypes.lineGraphPayload => {
open LineGraphTypes
- let categories =
- data
- ->getArrayFromJson([])
- ->getValueFromArray(0, []->JSON.Encode.array)
- ->getArrayFromJson([])
- ->getCategories(yKey)
+ let primaryCategories = data->getCategories(0, yKey)
+ let secondaryCategories = data->getCategories(1, yKey)
let lineGraphData =
data
->getArrayFromJson([])
->Array.mapWithIndex((item, index) => {
- let name = `Series ${(index + 1)->Int.toString}`
+ let name = NewAnalyticsUtils.getLabelName(~key=yKey, ~index, ~points=item)
let color = index->getColor
getLineGraphObj(~array=item->getArrayFromJson([]), ~key=xKey, ~name, ~color)
})
let title = {
text: "Payments Processed",
}
- {categories, data: lineGraphData, title}
+ {
+ categories: primaryCategories,
+ data: lineGraphData,
+ title,
+ tooltipFormatter: tooltipFormatter(
+ ~secondaryCategories,
+ ~title="Payments Processed",
+ ~metricType=Amount,
+ ),
+ }
}
// Need to modify
let getMetaData = json =>
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res
index 919d02308..273b20b75 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res
@@ -5,6 +5,7 @@ open PaymentsSuccessRateUtils
module PaymentsSuccessRateHeader = {
open NewPaymentAnalyticsUtils
+ open NewAnalyticsUtils
@react.component
let make = (~data, ~keyValue, ~granularity, ~setGranularity) => {
let setGranularity = value => {
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res
index 32df32822..07db96e7b 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res
@@ -19,25 +19,30 @@ let paymentsSuccessRateMapper = (
~yKey: string,
): LineGraphTypes.lineGraphPayload => {
open LineGraphTypes
- let categories =
- data
- ->getArrayFromJson([])
- ->getValueFromArray(0, []->JSON.Encode.array)
- ->getArrayFromJson([])
- ->getCategories(yKey)
+ let primaryCategories = data->getCategories(0, yKey)
+ let secondaryCategories = data->getCategories(1, yKey)
let lineGraphData =
data
->getArrayFromJson([])
->Array.mapWithIndex((item, index) => {
- let name = `Series ${(index + 1)->Int.toString}`
+ let name = NewAnalyticsUtils.getLabelName(~key=yKey, ~index, ~points=item)
let color = index->getColor
getLineGraphObj(~array=item->getArrayFromJson([]), ~key=xKey, ~name, ~color)
})
let title = {
text: "Payments Success Rate",
}
- {categories, data: lineGraphData, title}
+ {
+ categories: primaryCategories,
+ data: lineGraphData,
+ title,
+ tooltipFormatter: tooltipFormatter(
+ ~secondaryCategories,
+ ~title="Payments Success Rate",
+ ~metricType=Rate,
+ ),
+ }
}
open NewAnalyticsTypes
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res
index a727add6a..1fa98cb51 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res
@@ -137,7 +137,7 @@ let make = (
entity={chartEntity}
object={chartEntity.getObjects(
~data=paymentsDistribution,
- ~xKey=(#payment_success_rate: metrics :> string),
+ ~xKey=getXKey(~isSmartRetry=true),
~yKey=groupBy.value,
)}
className="mr-3"
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res
index c7d1f9770..8f084c3fb 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res
@@ -12,16 +12,20 @@ let getDimentionType = string => {
}
}
+let getXKey = (~isSmartRetry) => {
+ switch isSmartRetry {
+ | true => "payments_success_rate_distribution"
+ | false => "payments_success_rate_distribution_without_smart_retries"
+ }
+}
+
let successfulPaymentsDistributionMapper = (
~data: JSON.t,
~xKey: string,
~yKey: string,
): BarGraphTypes.barGraphPayload => {
open BarGraphTypes
- let categories =
- data
- ->getArrayFromJson([])
- ->getCategories(yKey)
+ let categories = [data]->JSON.Encode.array->getCategories(0, yKey)
let barGraphData = getBarGraphObj(
~array=data->getArrayFromJson([]),
@@ -32,6 +36,7 @@ let successfulPaymentsDistributionMapper = (
let title = {
text: "",
}
+
{categories, data: [barGraphData], title}
}
@@ -40,7 +45,7 @@ let visibleColumns: array = [#payment_success_rate]
let tableItemToObjMapper: Dict.t => successfulPaymentsDistributionObject = dict => {
{
- payments_success_rate: dict->getInt((#payment_success_rate: metrics :> string), 0),
+ payments_success_rate: dict->getInt("payments_success_rate_distribution", 0),
connector: dict->getString((#connector: metrics :> string), ""),
payment_method: dict->getString((#payment_method: metrics :> string), ""),
}
@@ -85,15 +90,9 @@ let getCell = (obj, colType: metrics): Table.cell => {
}
}
-let getTableData = json =>
- json
- ->getArrayFromJson([])
- ->getValueFromArray(0, []->JSON.Encode.array)
- ->getDictFromJsonObject
- ->getArrayFromDict("queryData", [])
- ->JSON.Encode.array
- ->getArrayDataFromJson(tableItemToObjMapper)
- ->Array.map(Nullable.make)
+let getTableData = json => {
+ json->getArrayDataFromJson(tableItemToObjMapper)->Array.map(Nullable.make)
+}
let tabs = [
{
diff --git a/src/screens/PMAuthenticationProcessor/PMAuthenticationHome.res b/src/screens/PMAuthenticationProcessor/PMAuthenticationHome.res
index da6e8b5de..e6003ea34 100644
--- a/src/screens/PMAuthenticationProcessor/PMAuthenticationHome.res
+++ b/src/screens/PMAuthenticationProcessor/PMAuthenticationHome.res
@@ -326,8 +326,6 @@ let make = () => {
()}
- isPayoutFlow=false
getConnectorDetails={Some(getConnectorDetails)}
setCurrentStep={_ => ()}
/>
diff --git a/src/screens/TaxProcessor/TaxProcessorHome.res b/src/screens/TaxProcessor/TaxProcessorHome.res
index 0b3a1c981..3e90e8ad1 100644
--- a/src/screens/TaxProcessor/TaxProcessorHome.res
+++ b/src/screens/TaxProcessor/TaxProcessorHome.res
@@ -344,8 +344,6 @@ let make = () => {
->LogicUtils.getDictFromJsonObject
->ConnectorListMapper.getProcessorPayloadType}
connector=connectorName
- setScreenState={_ => ()}
- isPayoutFlow=false
setCurrentStep
getConnectorDetails={Some(getConnectorDetails)}
/>
diff --git a/src/screens/ThreeDsProcessors/ThreeDsProcessorHome.res b/src/screens/ThreeDsProcessors/ThreeDsProcessorHome.res
index a66723bc6..a0fd3ac06 100644
--- a/src/screens/ThreeDsProcessors/ThreeDsProcessorHome.res
+++ b/src/screens/ThreeDsProcessors/ThreeDsProcessorHome.res
@@ -106,8 +106,6 @@ let make = () => {
React.useEffect(() => {
if connectorName->LogicUtils.isNonEmptyString {
getDetails()->ignore
- } else {
- setScreenState(_ => Error("Connector name not found"))
}
None
}, [connectorName])
@@ -241,8 +239,6 @@ let make = () => {
->LogicUtils.getDictFromJsonObject
->ConnectorListMapper.getProcessorPayloadType}
connector=connectorName
- setScreenState={_ => ()}
- isPayoutFlow=false
setCurrentStep={_ => ()}
getConnectorDetails={Some(getConnectorDetails)}
/>
diff --git a/src/utils/Mappers/ConnectorListMapper.res b/src/utils/Mappers/ConnectorListMapper.res
index f71ba5d1e..94a07dc20 100644
--- a/src/utils/Mappers/ConnectorListMapper.res
+++ b/src/utils/Mappers/ConnectorListMapper.res
@@ -1,7 +1,6 @@
open ConnectorTypes
+open LogicUtils
let parsePaymentMethodType = paymentMethodType => {
- open LogicUtils
-
let paymentMethodTypeDict = paymentMethodType->getDictFromJsonObject
{
payment_method_type: paymentMethodTypeDict->getString("payment_method_type", ""),
@@ -10,8 +9,6 @@ let parsePaymentMethodType = paymentMethodType => {
}
}
let parsePaymentMethodResponse = paymentMethod => {
- open LogicUtils
-
let paymentMethodDict = paymentMethod->getDictFromJsonObject
let payment_method_types =
paymentMethodDict
@@ -28,8 +25,6 @@ let parsePaymentMethodResponse = paymentMethod => {
}
let parsePaymentMethod = paymentMethod => {
- open LogicUtils
-
let paymentMethodDict = paymentMethod->getDictFromJsonObject
let flow = paymentMethodDict->getString("flow", "")
@@ -40,8 +35,6 @@ let parsePaymentMethod = paymentMethod => {
}
let convertFRMConfigJsonToObjResponse = json => {
- open LogicUtils
-
json->Array.map(config => {
let configDict = config->getDictFromJsonObject
let payment_methods =
@@ -55,8 +48,6 @@ let convertFRMConfigJsonToObjResponse = json => {
}
let convertFRMConfigJsonToObj = json => {
- open LogicUtils
-
json->Array.map(config => {
let configDict = config->getDictFromJsonObject
let payment_methods =
@@ -70,7 +61,6 @@ let convertFRMConfigJsonToObj = json => {
}
let getPaymentMethodTypes = dict => {
- open LogicUtils
open ConnectorUtils
{
payment_method_type: dict->getString("payment_method_type", ""),
@@ -86,7 +76,6 @@ let getPaymentMethodTypes = dict => {
}
let getPaymentMethodsEnabled: Dict.t => paymentMethodEnabledType = dict => {
- open LogicUtils
{
payment_method: dict->getString("payment_method", ""),
payment_method_types: dict
@@ -97,7 +86,6 @@ let getPaymentMethodsEnabled: Dict.t => paymentMethodEnabledType = dict
}
let getConnectorAccountDetails = dict => {
- open LogicUtils
{
auth_type: dict->getString("auth_type", ""),
api_secret: dict->getString("api_secret", ""),
@@ -106,15 +94,73 @@ let getConnectorAccountDetails = dict => {
}
}
+let connectorAuthTypeMapper = (str): connectorAuthType => {
+ switch str->String.toLowerCase {
+ | "headerkey" => HeaderKey
+ | "bodykey" => BodyKey
+ | "signaturekey" => SignatureKey
+ | "multiauthkey" => MultiAuthKey
+ | "currencyauthkey" => CurrencyAuthKey
+ | "certificateauth" => CertificateAuth
+ | _ => UnKnownAuthType
+ }
+}
+
+let getHeaderAuth = (dict): headerKey => {
+ auth_type: dict->getString("auth_type", ""),
+ api_key: dict->getString("api_key", ""),
+}
+let getBodyKeyAuth = (dict): bodyKey => {
+ auth_type: dict->getString("auth_type", ""),
+ api_key: dict->getString("api_key", ""),
+ key1: dict->getString("key1", ""),
+}
+let getSignatureKeyAuth = (dict): signatureKey => {
+ auth_type: dict->getString("auth_type", ""),
+ api_key: dict->getString("api_key", ""),
+ key1: dict->getString("key1", ""),
+ api_secret: dict->getString("api_secret", ""),
+}
+let getMultiAuthKeyAuth = (dict): multiAuthKey => {
+ auth_type: dict->getString("auth_type", ""),
+ api_key: dict->getString("api_key", ""),
+ key1: dict->getString("key1", ""),
+ api_secret: dict->getString("api_secret", ""),
+ key2: dict->getString("key2", ""),
+}
+
+let getCurrencyAuthKey = (dict): currencyAuthKey => {
+ auth_type: dict->getString("auth_type", ""),
+ auth_key_map: dict->getDictfromDict("auth_key_map"),
+}
+let getCertificateAuth = (dict): certificateAuth => {
+ auth_type: dict->getString("auth_type", ""),
+ certificate: dict->getString("certificate", ""),
+ private_key: dict->getString("private_key", ""),
+}
+
+let getAccountDetails = (dict): connectorAuthTypeObj => {
+ let authType = dict->getString("auth_type", "")->connectorAuthTypeMapper
+ let d = switch authType {
+ | HeaderKey => HeaderKey(dict->getHeaderAuth)
+ | BodyKey => BodyKey(dict->getBodyKeyAuth)
+ | SignatureKey => SignatureKey(dict->getSignatureKeyAuth)
+ | MultiAuthKey => MultiAuthKey(dict->getMultiAuthKeyAuth)
+ | CurrencyAuthKey => CurrencyAuthKey(dict->getCurrencyAuthKey)
+ | CertificateAuth => CertificateAuth(dict->getCertificateAuth)
+ | UnKnownAuthType => UnKnownAuthType(JSON.Encode.null)
+ }
+ d
+}
+
let getProcessorPayloadType = dict => {
- open LogicUtils
{
connector_type: dict->getString("connector_type", ""),
connector_name: dict->getString("connector_name", ""),
connector_label: dict->getString("connector_label", ""),
connector_account_details: dict
->getObj("connector_account_details", Dict.make())
- ->getConnectorAccountDetails,
+ ->getAccountDetails,
test_mode: dict->getBool("test_mode", true),
disabled: dict->getBool("disabled", true),
payment_methods_enabled: dict
@@ -136,7 +182,6 @@ let getProcessorPayloadType = dict => {
}
let getArrayOfConnectorListPayloadType = json => {
- open LogicUtils
json
->getArrayFromJson([])
->Array.map(connectorJson => {