Skip to content

Conversation

@ayush22667
Copy link
Contributor

@ayush22667 ayush22667 commented Dec 9, 2025

Type of Change

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

Description

Refactored GSM (Gateway Status Map) lookup system to properly model flow and subflow parameters instead of using hardcoded values.
Previously, the GSM table lookup used a hardcoded string "sub_flow" for the subflow parameter. This has been refactored to properly model the flow hierarchy where:

  • flow = High-level payment domain (e.g., "Payment", "Payout", "Refund")
  • subflow = Payment operation within that flow (e.g., "Authorize", "SetupMandate")

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 #10584

How did you test it?

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_rUWV8FwfoMHv2h6K1SSgDhdO3NE7zTarSJO6pu54U7gzSUpDff07iMTUINzUAj4J' \
--data-raw '{
    "amount": 200,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "sakilmostak",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "online"
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "127.0.0.1"
    },
    "shipping": {
        "address": {
            
            
            
            
            
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    
    
    
    
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4532111111111112",
            "card_exp_month": "08",
            "card_exp_year": "29",
            "card_holder_name": "jos'\''eph Doe",
            "card_cvc": "199"
        }
    },
    "billing": {
        "address": {
            
            
            
            
            
            "zip": "560095",
            "country": "IN",
            "first_name": "Ti`nu",
            "last_name": "Hareess war"
        }
    }
    
}
'

Response:

{
    "payment_id": "pay_DYLwArLlj0rCzlf6pWtn",
    "merchant_id": "merchant_1765261733",
    "status": "failed",
    "amount": 200,
    "net_amount": 200,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "stripe",
    "client_secret": "pay_DYLwArLlj0rCzlf6pWtn_secret_dfhwStE3AOQQxBUQVHNR",
    "created": "2025-12-09T10:09:38.495Z",
    "modified_at": "2025-12-09T10:09:39.835Z",
    "currency": "USD",
    "customer_id": "sakilmostak",
    "customer": {
        "id": "sakilmostak",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1112",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "453211",
            "card_extended_bin": null,
            "card_exp_month": "08",
            "card_exp_year": "29",
            "card_holder_name": "jos'eph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": null,
            "country": "US",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "94122",
            "state": null,
            "first_name": "John",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": null,
            "country": "IN",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "560095",
            "state": null,
            "first_name": "Ti`nu",
            "last_name": "Hareess war",
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": "card_declined",
    "error_message": "message - Your card was declined. Your request used a real card while testing. For a list of valid test cards, visit: https://stripe.com/docs/testing., decline_code - test_mode_live_card",
    "unified_code": "UE2000",
    "unified_message": "<string>",
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "sakilmostak",
        "created_at": 1765274978,
        "expires": 1765278578,
        "secret": "epk_34df8c6a5af54169b3af243165067353"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3ScNrTD5R7gDAGff1OsOMpMo",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_G2Pcm6072xgSrGL9MOyh",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_ZlKnHI9B57mzHEFyeyVD",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-12-09T10:24:38.494Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "127.0.0.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-12-09T10:09:39.835Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "extended_authorization_last_applied_at": null,
    "request_extended_authorization": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": "test_mode_live_card",
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null,
    "enable_overcapture": null,
    "is_overcapture_enabled": null,
    "network_details": {
        "network_advice_code": null
    },
    "is_stored_credential": null,
    "mit_category": null,
    "billing_descriptor": null,
    "tokenization": null,
    "partner_merchant_identifier_details": null,
    "payment_method_tokenization_details": null
}
image

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

…low identifiers and change lookup for find gsm code and message
@ayush22667 ayush22667 requested review from a team as code owners December 9, 2025 10:41
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 9, 2025

@ayush22667 ayush22667 changed the title feat(payments): introduce constants for payment flow and default subflow identifiers and change lookup for find gsm code and message feat(payments): change lookup for find gsm code and message Dec 9, 2025
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

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

Files with missing lines Patch % Lines
crates/router/src/core/payouts.rs 0.00% 6 Missing ⚠️
crates/router/src/core/payments/helpers.rs 0.00% 5 Missing ⚠️
crates/router/src/core/refunds_v2.rs 0.00% 4 Missing ⚠️
crates/router/src/core/payouts/helpers.rs 0.00% 3 Missing ⚠️
crates/router/src/core/revenue_recovery/types.rs 0.00% 2 Missing ⚠️
...ates/router/src/core/webhooks/recovery_incoming.rs 0.00% 2 Missing ⚠️
crates/router/src/workflows/revenue_recovery.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10585   +/-   ##
=======================================
  Coverage        ?    6.45%           
=======================================
  Files           ?     1254           
  Lines           ?   313246           
  Branches        ?        0           
=======================================
  Hits            ?    20205           
  Misses          ?   293041           
  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.

@ayush22667 ayush22667 self-assigned this Dec 9, 2025
@ayush22667 ayush22667 added C-refactor Category: Refactor T-Core For Work done by the core team labels Dec 9, 2025
connector_name,
REVENUE_RECOVERY.to_string(),
REVENUE_RECOVERY,
crate::consts::DEFAULT_SUBFLOW_STR,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we add GSM records for REVENUE_RECOVERY flow as well? cc: @srujanchikke

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we did in v2 prod.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we modifying the GSM fetch logic for V2 as well? @ayush22667

error_message.clone(),
payout_data.payout_attempt.connector.clone(),
consts::PAYOUT_FLOW_STR,
crate::consts::DEFAULT_SUBFLOW_STR,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we add GSM records for Paupits flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In prod we don't have gsm records for but in sandbox we have gsm records for payout flow

Copy link
Contributor

Choose a reason for hiding this comment

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

We may have to add those records as well then

Some(err.message.clone()),
connector.connector_name.to_string(),
consts::REFUND_FLOW_STR.to_string(),
consts::REFUND_FLOW_STR,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we add GSM records for Refunds flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In prod we don't have gsm records for but in sandbox we have gsm records for refunds flow

Copy link
Contributor

Choose a reason for hiding this comment

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

We may have to add those records as well then

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

Labels

C-refactor Category: Refactor T-Core For Work done by the core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Change lookup for finding gsm rule

4 participants