Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(gsm): add `error_category` column to gsm table (#6648)

Chethan Raofd82cf610a15
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index d9c27a2f01..1af9284596 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -7776,6 +7776,16 @@
}
}
},
+ "ErrorCategory": {
+ "type": "string",
+ "enum": [
+ "frm_decline",
+ "processor_downtime",
+ "processor_decline_unauthorized",
+ "issue_with_payment_method",
+ "processor_decline_incorrect_data"
+ ]
+ },
"ErrorDetails": {
"type": "object",
"description": "Error details for the payment",
@@ -9162,6 +9172,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -9295,6 +9313,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -9391,6 +9417,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 56b77bff1a..f2904dd478 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -10296,6 +10296,16 @@
}
}
},
+ "ErrorCategory": {
+ "type": "string",
+ "enum": [
+ "frm_decline",
+ "processor_downtime",
+ "processor_decline_unauthorized",
+ "issue_with_payment_method",
+ "processor_decline_incorrect_data"
+ ]
+ },
"EventClass": {
"type": "string",
"enum": [
@@ -11639,6 +11649,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -11772,6 +11790,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -11868,6 +11894,14 @@
"type": "string",
"description": "error message unified across the connectors",
"nullable": true
+ },
+ "error_category": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ErrorCategory"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/gsm.rs b/crates/api_models/src/gsm.rs
index 30e4906243..b95794ef70 100644
--- a/crates/api_models/src/gsm.rs
+++ b/crates/api_models/src/gsm.rs
@@ -1,3 +1,4 @@
+use common_enums::ErrorCategory;
use utoipa::ToSchema;
use crate::enums::Connector;
@@ -26,6 +27,8 @@ pub struct GsmCreateRequest {
pub unified_code: Option<String>,
/// error message unified across the connectors
pub unified_message: Option<String>,
+ /// category in which error belongs to
+ pub error_category: Option<ErrorCategory>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@@ -88,6 +91,8 @@ pub struct GsmUpdateRequest {
pub unified_code: Option<String>,
/// error message unified across the connectors
pub unified_message: Option<String>,
+ /// category in which error belongs to
+ pub error_category: Option<ErrorCategory>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@@ -141,4 +146,6 @@ pub struct GsmResponse {
pub unified_code: Option<String>,
/// error message unified across the connectors
pub unified_message: Option<String>,
+ /// category in which error belongs to
+ pub error_category: Option<ErrorCategory>,
}
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 844e9d0194..d966902af8 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -3372,3 +3372,28 @@ pub enum ConnectorMandateStatus {
/// Indicates that the connector mandate is not active and hence cannot be used for payments.
Inactive,
}
+
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ strum::Display,
+ PartialEq,
+ Eq,
+ serde::Serialize,
+ serde::Deserialize,
+ strum::EnumString,
+ ToSchema,
+ PartialOrd,
+ Ord,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum ErrorCategory {
+ FrmDecline,
+ ProcessorDowntime,
+ ProcessorDeclineUnauthorized,
+ IssueWithPaymentMethod,
+ ProcessorDeclineIncorrectData,
+}
diff --git a/crates/diesel_models/src/gsm.rs b/crates/diesel_models/src/gsm.rs
index 6a444410fa..aba8d75a6e 100644
--- a/crates/diesel_models/src/gsm.rs
+++ b/crates/diesel_models/src/gsm.rs
@@ -1,5 +1,6 @@
//! Gateway status mapping
+use common_enums::ErrorCategory;
use common_utils::{
custom_serde,
events::{ApiEventMetric, ApiEventsType},
@@ -39,6 +40,7 @@ pub struct GatewayStatusMap {
pub step_up_possible: bool,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
+ pub error_category: Option<ErrorCategory>,
}
#[derive(Clone, Debug, Eq, PartialEq, Insertable)]
@@ -55,17 +57,11 @@ pub struct GatewayStatusMappingNew {
pub step_up_possible: bool,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
+ pub error_category: Option<ErrorCategory>,
}
#[derive(
- Clone,
- Debug,
- PartialEq,
- Eq,
- AsChangeset,
- router_derive::DebugAsDisplay,
- Default,
- serde::Deserialize,
+ Clone, Debug, PartialEq, Eq, AsChangeset, router_derive::DebugAsDisplay, serde::Deserialize,
)]
#[diesel(table_name = gateway_status_map)]
pub struct GatewayStatusMapperUpdateInternal {
@@ -80,6 +76,8 @@ pub struct GatewayStatusMapperUpdateInternal {
pub step_up_possible: Option<bool>,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
+ pub error_category: Option<ErrorCategory>,
+ pub last_modified: PrimitiveDateTime,
}
#[derive(Debug)]
@@ -90,6 +88,7 @@ pub struct GatewayStatusMappingUpdate {
pub step_up_possible: Option<bool>,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
+ pub error_category: Option<ErrorCategory>,
}
impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
@@ -101,6 +100,7 @@ impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
step_up_possible,
unified_code,
unified_message,
+ error_category,
} = value;
Self {
status,
@@ -109,7 +109,13 @@ impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
step_up_possible,
unified_code,
unified_message,
- ..Default::default()
+ error_category,
+ last_modified: common_utils::date_time::now(),
+ connector: None,
+ flow: None,
+ sub_flow: None,
+ code: None,
+ message: None,
}
}
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index d3e560fc04..b6f1a4f8d0 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -508,6 +508,8 @@ diesel::table! {
unified_code -> Nullable<Varchar>,
#[max_length = 1024]
unified_message -> Nullable<Varchar>,
+ #[max_length = 64]
+ error_category -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index f6bab9071c..470868ed82 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -520,6 +520,8 @@ diesel::table! {
unified_code -> Nullable<Varchar>,
#[max_length = 1024]
unified_message -> Nullable<Varchar>,
+ #[max_length = 64]
+ error_category -> Nullable<Varchar>,
}
}
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 4ec1bb22b4..c7fa29a1b2 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -605,6 +605,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::blocklist::ToggleBlocklistResponse,
api_models::blocklist::ListBlocklistQuery,
api_models::enums::BlocklistDataKind,
+ api_models::enums::ErrorCategory,
api_models::webhook_events::EventListItemResponse,
api_models::webhook_events::EventRetrieveResponse,
api_models::webhook_events::OutgoingWebhookRequestContent,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index a756d9fb1b..2221055be5 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -569,6 +569,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::blocklist::ToggleBlocklistResponse,
api_models::blocklist::ListBlocklistQuery,
api_models::enums::BlocklistDataKind,
+ api_models::enums::ErrorCategory,
api_models::webhook_events::EventListItemResponse,
api_models::webhook_events::EventRetrieveResponse,
api_models::webhook_events::OutgoingWebhookRequestContent,
diff --git a/crates/router/src/core/gsm.rs b/crates/router/src/core/gsm.rs
index 4a678a5c40..c7daee111a 100644
--- a/crates/router/src/core/gsm.rs
+++ b/crates/router/src/core/gsm.rs
@@ -67,6 +67,7 @@ pub async fn update_gsm_rule(
step_up_possible,
unified_code,
unified_message,
+ error_category,
} = gsm_request;
GsmInterface::update_gsm_rule(
db,
@@ -82,6 +83,7 @@ pub async fn update_gsm_rule(
step_up_possible,
unified_code,
unified_message,
+ error_category,
},
)
.await
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index c16ead40d1..55a523b528 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -1690,6 +1690,7 @@ impl ForeignFrom<gsm_api_types::GsmCreateRequest> for storage::GatewayStatusMapp
step_up_possible: value.step_up_possible,
unified_code: value.unified_code,
unified_message: value.unified_message,
+ error_category: value.error_category,
}
}
}
@@ -1708,6 +1709,7 @@ impl ForeignFrom<storage::GatewayStatusMap> for gsm_api_types::GsmResponse {
step_up_possible: value.step_up_possible,
unified_code: value.unified_code,
unified_message: value.unified_message,
+ error_category: value.error_category,
}
}
}
diff --git a/migrations/2024-11-24-104438_add_error_category_col_to_gsm/down.sql b/migrations/2024-11-24-104438_add_error_category_col_to_gsm/down.sql
new file mode 100644
index 0000000000..609afbdfd7
--- /dev/null
+++ b/migrations/2024-11-24-104438_add_error_category_col_to_gsm/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE gateway_status_map DROP COLUMN error_category;
diff --git a/migrations/2024-11-24-104438_add_error_category_col_to_gsm/up.sql b/migrations/2024-11-24-104438_add_error_category_col_to_gsm/up.sql
new file mode 100644
index 0000000000..298f6d263a
--- /dev/null
+++ b/migrations/2024-11-24-104438_add_error_category_col_to_gsm/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TABLE gateway_status_map ADD COLUMN error_category VARCHAR(64);