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

feat(gsm): add standardised error fields to GSM models and database schema (#10600)

Ayush Anandae9fdfba0486
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 0d6806fdd0..0e9b64b4b1 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -19710,6 +19710,24 @@
}
],
"nullable": true
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -19886,6 +19904,24 @@
},
"feature_data": {
"$ref": "#/components/schemas/GsmFeatureData"
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -20013,6 +20049,24 @@
}
],
"nullable": true
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -35992,6 +36046,56 @@
],
"description": "Charge specific fields for controlling the revert of funds from either platform or connected account. Check sub-fields for more details."
},
+ "StandardisedCode": {
+ "type": "string",
+ "enum": [
+ "account_closed_or_invalid",
+ "authentication_failed",
+ "authentication_required",
+ "authorization_missing_or_revoked",
+ "card_lost_or_stolen",
+ "card_not_supported_restricted",
+ "cfg_pm_not_enabled_or_misconfigured",
+ "compliance_or_sanctions_restriction",
+ "configuration_issue",
+ "credit_limit_exceeded",
+ "currency_or_corridor_not_enabled",
+ "do_not_honor",
+ "downstream_technical_issue",
+ "duplicate_request",
+ "generic_unknown_error",
+ "incorrect_authentication_code",
+ "insufficient_funds",
+ "integ_cryptographic_issue",
+ "integration_issue",
+ "invalid_card_number",
+ "invalid_credentials",
+ "invalid_cvv",
+ "invalid_expiry_date",
+ "invalid_state",
+ "issuer_unavailable",
+ "merchant_inactive",
+ "missing_or_invalid_param",
+ "operation_not_allowed",
+ "payment_cancelled_by_user",
+ "payment_method_issue",
+ "payment_session_timeout",
+ "pm_address_mismatch",
+ "psp_acquirer_error",
+ "psp_fraud_engine_decline",
+ "rate_limit",
+ "stored_credential_or_mit_not_enabled",
+ "subscription_plan_inactive",
+ "suspected_fraud",
+ "three_ds_authentication_service_issue",
+ "three_ds_configuration_issue",
+ "three_ds_data_or_protocol_invalid",
+ "transaction_not_permitted",
+ "transaction_timed_out",
+ "velocity_limit_exceeded",
+ "wallet_or_token_config_issue"
+ ]
+ },
"StaticRoutingAlgorithm": {
"oneOf": [
{
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index a97c0b7504..858fef7e54 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -13355,6 +13355,24 @@
}
],
"nullable": true
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -13531,6 +13549,24 @@
},
"feature_data": {
"$ref": "#/components/schemas/GsmFeatureData"
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -13658,6 +13694,24 @@
}
],
"nullable": true
+ },
+ "standardised_code": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/StandardisedCode"
+ }
+ ],
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "A detailed description of the error intended for debugging, analytics, and support teams.",
+ "nullable": true
+ },
+ "user_guidance_message": {
+ "type": "string",
+ "description": "A user-friendly message that can be safely displayed to the customer.\nThis message provides guidance on what the user should do to\nresolve the issue.",
+ "nullable": true
}
}
},
@@ -26249,6 +26303,56 @@
"skip"
]
},
+ "StandardisedCode": {
+ "type": "string",
+ "enum": [
+ "account_closed_or_invalid",
+ "authentication_failed",
+ "authentication_required",
+ "authorization_missing_or_revoked",
+ "card_lost_or_stolen",
+ "card_not_supported_restricted",
+ "cfg_pm_not_enabled_or_misconfigured",
+ "compliance_or_sanctions_restriction",
+ "configuration_issue",
+ "credit_limit_exceeded",
+ "currency_or_corridor_not_enabled",
+ "do_not_honor",
+ "downstream_technical_issue",
+ "duplicate_request",
+ "generic_unknown_error",
+ "incorrect_authentication_code",
+ "insufficient_funds",
+ "integ_cryptographic_issue",
+ "integration_issue",
+ "invalid_card_number",
+ "invalid_credentials",
+ "invalid_cvv",
+ "invalid_expiry_date",
+ "invalid_state",
+ "issuer_unavailable",
+ "merchant_inactive",
+ "missing_or_invalid_param",
+ "operation_not_allowed",
+ "payment_cancelled_by_user",
+ "payment_method_issue",
+ "payment_session_timeout",
+ "pm_address_mismatch",
+ "psp_acquirer_error",
+ "psp_fraud_engine_decline",
+ "rate_limit",
+ "stored_credential_or_mit_not_enabled",
+ "subscription_plan_inactive",
+ "suspected_fraud",
+ "three_ds_authentication_service_issue",
+ "three_ds_configuration_issue",
+ "three_ds_data_or_protocol_invalid",
+ "transaction_not_permitted",
+ "transaction_timed_out",
+ "velocity_limit_exceeded",
+ "wallet_or_token_config_issue"
+ ]
+ },
"StaticRoutingAlgorithm": {
"oneOf": [
{
diff --git a/crates/api_models/src/gsm.rs b/crates/api_models/src/gsm.rs
index 1b2800d11e..f5c1698937 100644
--- a/crates/api_models/src/gsm.rs
+++ b/crates/api_models/src/gsm.rs
@@ -48,6 +48,15 @@ pub struct GsmCreateRequest {
/// details specific to the retry behavior.
#[schema(value_type = Option<GsmFeatureData>)]
pub feature_data: Option<common_types::domain::GsmFeatureData>,
+ /// Code that identifies the specific cause for a failure within a broader error category such as `INVALID_EXPIRY_DATE`, `INVALID_CARD_NUMBER`, or `INSUFFICIENT_FUNDS`.
+ #[schema(value_type = Option<StandardisedCode>)]
+ pub standardised_code: Option<api_enums::StandardisedCode>,
+ /// A detailed description of the error intended for debugging, analytics, and support teams.
+ pub description: Option<String>,
+ /// A user-friendly message that can be safely displayed to the customer.
+ /// This message provides guidance on what the user should do to
+ /// resolve the issue.
+ pub user_guidance_message: Option<String>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@@ -110,6 +119,15 @@ pub struct GsmUpdateRequest {
/// details specific to the retry behavior.
#[schema(value_type = Option<GsmFeatureData>)]
pub feature_data: Option<common_types::domain::GsmFeatureData>,
+ /// Code that identifies the specific cause for a failure within a broader error category such as `INVALID_EXPIRY_DATE`, `INVALID_CARD_NUMBER`, or `INSUFFICIENT_FUNDS`.
+ #[schema(value_type = Option<StandardisedCode>)]
+ pub standardised_code: Option<api_enums::StandardisedCode>,
+ /// A detailed description of the error intended for debugging, analytics, and support teams.
+ pub description: Option<String>,
+ /// A user-friendly message that can be safely displayed to the customer.
+ /// This message provides guidance on what the user should do to
+ /// resolve the issue.
+ pub user_guidance_message: Option<String>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@@ -184,4 +202,13 @@ pub struct GsmResponse {
/// details specific to the retry behavior.
#[schema(value_type = GsmFeatureData)]
pub feature_data: Option<common_types::domain::GsmFeatureData>,
+ /// Code that identifies the specific cause for a failure within a broader error category such as `INVALID_EXPIRY_DATE`, `INVALID_CARD_NUMBER`, or `INSUFFICIENT_FUNDS`.
+ #[schema(value_type = Option<StandardisedCode>)]
+ pub standardised_code: Option<api_enums::StandardisedCode>,
+ /// A detailed description of the error intended for debugging, analytics, and support teams.
+ pub description: Option<String>,
+ /// A user-friendly message that can be safely displayed to the customer.
+ /// This message provides guidance on what the user should do to
+ /// resolve the issue.
+ pub user_guidance_message: Option<String>,
}
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 10676dc0cb..1906645b7c 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -361,6 +361,68 @@ pub enum GsmDecision {
pub enum GsmFeature {
Retry,
}
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ strum::Display,
+ PartialEq,
+ Eq,
+ serde::Serialize,
+ serde::Deserialize,
+ strum::EnumString,
+ ToSchema,
+)]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+#[router_derive::diesel_enum(storage_type = "text")]
+pub enum StandardisedCode {
+ AccountClosedOrInvalid,
+ AuthenticationFailed,
+ AuthenticationRequired,
+ AuthorizationMissingOrRevoked,
+ CardLostOrStolen,
+ CardNotSupportedRestricted,
+ CfgPmNotEnabledOrMisconfigured,
+ ComplianceOrSanctionsRestriction,
+ ConfigurationIssue,
+ CreditLimitExceeded,
+ CurrencyOrCorridorNotEnabled,
+ DoNotHonor,
+ DownstreamTechnicalIssue,
+ DuplicateRequest,
+ GenericUnknownError,
+ IncorrectAuthenticationCode,
+ InsufficientFunds,
+ IntegCryptographicIssue,
+ IntegrationIssue,
+ InvalidCardNumber,
+ InvalidCredentials,
+ InvalidCvv,
+ InvalidExpiryDate,
+ InvalidState,
+ IssuerUnavailable,
+ MerchantInactive,
+ MissingOrInvalidParam,
+ OperationNotAllowed,
+ PaymentCancelledByUser,
+ PaymentMethodIssue,
+ PaymentSessionTimeout,
+ PmAddressMismatch,
+ PspAcquirerError,
+ PspFraudEngineDecline,
+ RateLimit,
+ StoredCredentialOrMitNotEnabled,
+ SubscriptionPlanInactive,
+ SuspectedFraud,
+ ThreeDsAuthenticationServiceIssue,
+ ThreeDsConfigurationIssue,
+ ThreeDsDataOrProtocolInvalid,
+ TransactionNotPermitted,
+ TransactionTimedOut,
+ VelocityLimitExceeded,
+ WalletOrTokenConfigIssue,
+}
/// Specifies the type of cardholder authentication to be applied for a payment.
///
diff --git a/crates/diesel_models/src/gsm.rs b/crates/diesel_models/src/gsm.rs
index b75b0e6ce8..191ff55fea 100644
--- a/crates/diesel_models/src/gsm.rs
+++ b/crates/diesel_models/src/gsm.rs
@@ -41,6 +41,9 @@ pub struct GatewayStatusMap {
pub clear_pan_possible: bool,
pub feature_data: Option<common_types::domain::GsmFeatureData>,
pub feature: Option<common_enums::GsmFeature>,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, Insertable)]
@@ -61,6 +64,9 @@ pub struct GatewayStatusMappingNew {
pub clear_pan_possible: bool,
pub feature_data: Option<common_types::domain::GsmFeatureData>,
pub feature: Option<common_enums::GsmFeature>,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
#[derive(
@@ -84,6 +90,9 @@ pub struct GatewayStatusMapperUpdateInternal {
pub clear_pan_possible: Option<bool>,
pub feature_data: Option<common_types::domain::GsmFeatureData>,
pub feature: Option<common_enums::GsmFeature>,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
#[derive(Debug)]
@@ -98,6 +107,9 @@ pub struct GatewayStatusMappingUpdate {
pub clear_pan_possible: Option<bool>,
pub feature_data: Option<common_types::domain::GsmFeatureData>,
pub feature: Option<common_enums::GsmFeature>,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
@@ -113,6 +125,9 @@ impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
clear_pan_possible,
feature_data,
feature,
+ standardised_code,
+ description,
+ user_guidance_message,
} = value;
Self {
status,
@@ -131,6 +146,9 @@ impl From<GatewayStatusMappingUpdate> for GatewayStatusMapperUpdateInternal {
clear_pan_possible,
feature_data,
feature,
+ standardised_code,
+ description,
+ user_guidance_message,
}
}
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index cac9fcf117..0e1595b67d 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -619,6 +619,12 @@ diesel::table! {
feature_data -> Nullable<Jsonb>,
#[max_length = 64]
feature -> Nullable<Varchar>,
+ #[max_length = 64]
+ standardised_code -> Nullable<Varchar>,
+ #[max_length = 1024]
+ description -> Nullable<Varchar>,
+ #[max_length = 1024]
+ user_guidance_message -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index ff5d7383d1..1fcad72832 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -631,6 +631,12 @@ diesel::table! {
feature_data -> Nullable<Jsonb>,
#[max_length = 64]
feature -> Nullable<Varchar>,
+ #[max_length = 64]
+ standardised_code -> Nullable<Varchar>,
+ #[max_length = 1024]
+ description -> Nullable<Varchar>,
+ #[max_length = 1024]
+ user_guidance_message -> Nullable<Varchar>,
}
}
diff --git a/crates/hyperswitch_domain_models/src/gsm.rs b/crates/hyperswitch_domain_models/src/gsm.rs
index 59319c89e5..60de89bd3c 100644
--- a/crates/hyperswitch_domain_models/src/gsm.rs
+++ b/crates/hyperswitch_domain_models/src/gsm.rs
@@ -15,6 +15,9 @@ pub struct GatewayStatusMap {
pub error_category: Option<common_enums::ErrorCategory>,
pub feature_data: common_types::domain::GsmFeatureData,
pub feature: common_enums::GsmFeature,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -29,6 +32,9 @@ pub struct GatewayStatusMappingUpdate {
pub clear_pan_possible: Option<bool>,
pub feature_data: Option<common_types::domain::GsmFeatureData>,
pub feature: Option<common_enums::GsmFeature>,
+ pub standardised_code: Option<common_enums::StandardisedCode>,
+ pub description: Option<String>,
+ pub user_guidance_message: Option<String>,
}
impl TryFrom<GatewayStatusMap> for diesel_models::gsm::GatewayStatusMappingNew {
@@ -59,6 +65,9 @@ impl TryFrom<GatewayStatusMap> for diesel_models::gsm::GatewayStatusMappingNew {
.unwrap_or(false),
feature_data: Some(value.feature_data),
feature: Some(value.feature),
+ standardised_code: value.standardised_code,
+ description: value.description,
+ user_guidance_message: value.user_guidance_message,
})
}
}
@@ -78,6 +87,9 @@ impl TryFrom<GatewayStatusMappingUpdate> for diesel_models::gsm::GatewayStatusMa
clear_pan_possible: value.clear_pan_possible,
feature_data: value.feature_data,
feature: value.feature,
+ standardised_code: value.standardised_code,
+ description: value.description,
+ user_guidance_message: value.user_guidance_message,
})
}
}
@@ -124,6 +136,9 @@ impl TryFrom<diesel_models::gsm::GatewayStatusMap> for GatewayStatusMap {
error_category: item.error_category,
feature_data,
feature,
+ standardised_code: item.standardised_code,
+ description: item.description,
+ user_guidance_message: item.user_guidance_message,
})
}
}
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index f5fa8b4c3f..221caadea8 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -461,6 +461,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::gsm::GsmResponse,
api_models::enums::GsmDecision,
api_models::enums::GsmFeature,
+ api_models::enums::StandardisedCode,
common_types::domain::GsmFeatureData,
common_types::domain::RetryFeatureData,
api_models::payments::AddressDetails,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 0cf67c7ba3..68624028cb 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -385,6 +385,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::gsm::GsmResponse,
api_models::enums::GsmDecision,
api_models::enums::GsmFeature,
+ api_models::enums::StandardisedCode,
common_types::domain::GsmFeatureData,
common_types::domain::RetryFeatureData,
api_models::payments::NullObject,
diff --git a/crates/router/src/core/gsm.rs b/crates/router/src/core/gsm.rs
index 4bd93a4e0e..fd5f8623c8 100644
--- a/crates/router/src/core/gsm.rs
+++ b/crates/router/src/core/gsm.rs
@@ -85,6 +85,9 @@ pub async fn update_gsm_rule(
clear_pan_possible,
feature,
feature_data,
+ standardised_code,
+ description,
+ user_guidance_message,
} = gsm_request;
GsmInterface::update_gsm_rule(
db,
@@ -112,6 +115,9 @@ pub async fn update_gsm_rule(
.or(clear_pan_possible),
feature_data: feature_data.or(Some(inferred_feature_info.1)),
feature: feature.or(Some(inferred_feature_info.0)),
+ standardised_code,
+ description,
+ user_guidance_message,
},
)
.await
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 32a0b5c4eb..30ef24a0be 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -1669,6 +1669,9 @@ impl ForeignFrom<gsm_api_types::GsmCreateRequest>
error_category: value.error_category,
feature_data: value.feature_data.unwrap_or(inferred_feature_data),
feature: value.feature.unwrap_or(api_enums::GsmFeature::Retry),
+ standardised_code: value.standardised_code,
+ description: value.description,
+ user_guidance_message: value.user_guidance_message,
}
}
}
@@ -1774,6 +1777,9 @@ impl ForeignFrom<hyperswitch_domain_models::gsm::GatewayStatusMap> for gsm_api_t
.unwrap_or(false),
feature_data: Some(value.feature_data),
feature: value.feature,
+ standardised_code: value.standardised_code,
+ description: value.description,
+ user_guidance_message: value.user_guidance_message,
}
}
}
diff --git a/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/down.sql b/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/down.sql
new file mode 100644
index 0000000000..6638f0c7fc
--- /dev/null
+++ b/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/down.sql
@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE gateway_status_map
+ DROP COLUMN IF EXISTS standardised_code,
+ DROP COLUMN IF EXISTS description,
+ DROP COLUMN IF EXISTS user_guidance_message;
diff --git a/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/up.sql b/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/up.sql
new file mode 100644
index 0000000000..e43f0bf766
--- /dev/null
+++ b/migrations/2025-12-10-114754_add_standardised_fields_to_gsm/up.sql
@@ -0,0 +1,5 @@
+-- Your SQL goes here
+ALTER TABLE gateway_status_map
+ ADD COLUMN IF NOT EXISTS standardised_code VARCHAR(64),
+ ADD COLUMN IF NOT EXISTS description VARCHAR(1024),
+ ADD COLUMN IF NOT EXISTS user_guidance_message VARCHAR(1024);