Skip to content

Conversation

@ayush22667
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR adds new columns to the GSM (Gateway Status Mapping) table and updates the create/update APIs to include these new fields for better error categorization and user guidance.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

closes #10599

How did you test it?

Create Request:

curl --location 'http://localhost:8080/gsm' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
  "connector": "stripe",
  "flow": "Payment",
  "sub_flow": "Authoriz",
  "code": "card_declined",
  "message": "Your card was declined.",
  "status": "Failure",
  "router_error": "CARD_DECLINED",
  "decision": "retry",
  "step_up_possible": true,
  "unified_code": "IR_01",
  "unified_message": "Card declined by issuer",
  "error_category": "processor_downtime",
  "clear_pan_possible": false,
  "feature": "retry",
  "feature_data": {
    "retry": {
      "step_up_possible": true,
      "clear_pan_possible": false,
      "alternate_network_possible": true,
      "decision": "retry"
    }
  },
  "standardised_code": "PM_INSUFFICIENT_FUNDS",
  "description": "The card was declined due to insufficient funds in the account.",
  "user_guidance_message": "Your payment was declined due to insufficient funds. Please use a different card or add funds to your account."
}'

Response:

{
    "connector": "stripe",
    "flow": "Payment",
    "sub_flow": "Authoriz",
    "code": "card_declined",
    "message": "Your card was declined.",
    "status": "Failure",
    "router_error": "CARD_DECLINED",
    "decision": "retry",
    "step_up_possible": true,
    "unified_code": "IR_01",
    "unified_message": "Card declined by issuer",
    "error_category": "processor_downtime",
    "clear_pan_possible": false,
    "feature": "retry",
    "feature_data": {
        "retry": {
            "step_up_possible": true,
            "clear_pan_possible": false,
            "alternate_network_possible": true,
            "decision": "retry"
        }
    },
    "standardised_code": "PM_INSUFFICIENT_FUNDS",
    "description": "The card was declined due to insufficient funds in the account.",
    "user_guidance_message": "Your payment was declined due to insufficient funds. Please use a different card or add funds to your account."
}

Get Request :

curl --location 'http://localhost:8080/gsm/get' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '
{
  "connector": "stripe",
  "flow": "Payment",
  "sub_flow": "Authoriz",
  "code": "card_declined",
  "message": "Your card was declined."
}
'

Response:

{
    "connector": "stripe",
    "flow": "Payment",
    "sub_flow": "Authoriz",
    "code": "card_declined",
    "message": "Your card was declined.",
    "status": "Failure",
    "router_error": "CARD_DECLINED",
    "decision": "retry",
    "step_up_possible": true,
    "unified_code": "IR_01",
    "unified_message": "Card declined by issuer",
    "error_category": "processor_downtime",
    "clear_pan_possible": false,
    "feature": "retry",
    "feature_data": {
        "retry": {
            "step_up_possible": true,
            "clear_pan_possible": false,
            "alternate_network_possible": true,
            "decision": "retry"
        }
    },
    "standardised_code": "PM_INSUFFICIENT_FUNDS",
    "description": " was declined due to insufficient funds in the account.",
    "user_guidance_message": "Your payment was declined due to insufficient funds. Please use a different card or add funds to your account."
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@ayush22667 ayush22667 requested review from a team as code owners December 10, 2025 08:30
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 10, 2025

@ayush22667 ayush22667 self-assigned this Dec 10, 2025
@ayush22667 ayush22667 added C-refactor Category: Refactor T-Core For Work done by the core team and removed C-refactor Category: Refactor labels Dec 10, 2025
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@2543a81). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/hyperswitch_domain_models/src/gsm.rs 0.00% 9 Missing ⚠️
crates/diesel_models/src/gsm.rs 0.00% 6 Missing ⚠️
crates/router/src/types/transformers.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10600   +/-   ##
=======================================
  Coverage        ?    6.44%           
=======================================
  Files           ?     1254           
  Lines           ?   313662           
  Branches        ?        0           
=======================================
  Hits            ?    20209           
  Misses          ?   293453           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Dec 10, 2025
Comment on lines +51 to +56
/// Standardised error code for the GSM rule
#[schema(value_type = Option<StandardisedCode>)]
pub standardised_code: Option<api_enums::StandardisedCode>,
/// Description of the error
pub description: Option<String>,
/// User guidance message for the error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve the doc comments for these fields ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes T-Core For Work done by the core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add standardised fields to GSM API for error categorization

4 participants