Skip to content

feat(card_info): add tenant_id to CardInfoServiceConfig and include in API request headers - #353

Merged
jagan-jaya merged 2 commits into
mainfrom
add-x-tenant-to-de
Aug 14, 2026
Merged

feat(card_info): add tenant_id to CardInfoServiceConfig and include in API request headers#353
jagan-jaya merged 2 commits into
mainfrom
add-x-tenant-to-de

Conversation

@GauravRawat369

Copy link
Copy Markdown
Contributor

This pull request adds support for specifying a tenant_id when making requests to the Card Info API, improves logging for non-successful API responses, and includes a minor code style fix. The main changes are grouped below by theme:

Card Info API configuration and usage:

  • Added a new tenant_id field to the CardInfoServiceConfig struct and its default implementation, allowing the tenant ID to be configured in both code and the development.toml config file. (src/config.rs, config/development.toml) [1] [2] [3]
  • Updated the Card Info API request to include the x-tenant-id header, using the configured tenant_id value. (src/types/card/card_info_api.rs)

Logging improvements:

  • Enhanced logging for non-2xx responses from the Card Info API to include both the HTTP status and the response body, making debugging easier. (src/types/card/card_info_api.rs)

Code style:

  • Fixed the signature of the expecting method in a serde visitor implementation for clarity and correctness. (src/config.rs)

req

curl --location 'http://localhost:8080/decide-gateway' \
--header 'Content-Type: application/json' \
--header 'x-api-key: DE_47c4cedc8bb8401d836bd8e20c02f89533852c2c1e0e45b7bca6df1487af0fb5' \
--data '{
    "paymentInfo": {
    "paymentId": "pay_123456789",
    "amount": 90,
    "currency": "USD",
    "country": null,
    "customerId": null,
    "udfs": null,
    "preferredGateway": null,
    "paymentType": "ORDER_PAYMENT",
    "metadata": null,
    "internalMetadata": null,
    "isEmi": null,
    "emiBank": null,
    "emiTenure": null,
    "paymentMethodType": "DEBIT",
    "paymentMethod": "card",
    "paymentSource": null,
    
    "cardIssuerBankName": null,
    "cardIsin": "40342151",
    "cardType": null,
    "cardSwitchProvider": null,
    "cardProgram": null,
    "cardIssuerCountry": null,
    "channel": "ecom"
  },
    "merchantId": "test_merchant_123456789",
    "eligibleGatewayList": [
        "stripe",
        "adyen"
    ],
    "rankingAlgorithm": "SR_BASED_ROUTING",
    "eliminationEnabled": false,
    "enableMultiObjective": true
}'

res

{
    "decided_gateway": "adyen",
    "fallback_gateways": [
        "stripe"
    ],
    "gateway_priority_map": {
        "adyen": 1.0,
        "stripe": 1.0
    },
    "filter_wise_gateways": null,
    "priority_logic_tag": null,
    "routing_approach": "SR_SELECTION_V3_ROUTING",
    "gateway_before_evaluation": "adyen",
    "priority_logic_output": {
        "isEnforcement": false,
        "gws": [
            "stripe",
            "adyen"
        ],
        "priorityLogicTag": null,
        "gatewayReferenceIds": {},
        "primaryLogic": null,
        "fallbackLogic": null
    },
    "debit_routing_output": null,
    "reset_approach": "NO_RESET",
    "routing_dimension": "ORDER_PAYMENT, DEBIT, card",
    "routing_dimension_level": "PM_LEVEL",
    "is_scheduled_outage": false,
    "is_dynamic_mga_enabled": false,
    "gateway_mga_id_map": null,
    "is_rust_based_decider": true,
    "latency": 215,
    "multi_objective_info": {
        "outcome": "AUTH_WON",
        "reason": "SR head retained — it is the highest expected-value PSP (2 ranked on EV).",
        "costSavedBps": null,
        "qualifiedCount": 2,
        "margin": 1.0,
        "evGapTop2": 0.010266666666666646,
        "ranked": [
            {
                "psp": "adyen",
                "authRate": 1.0,
                "costBps": 220.66666666666666,
                "costSource": "SEED",
                "costModel": {
                    "brand": "visa",
                    "ccy": "USD",
                    "pctBps": 194.0,
                    "fixedFee": 0.24
                },
                "ev": 0.9779333333333333,
                "isSrHead": true,
                "isChosen": true
            },
            {
                "psp": "stripe",
                "authRate": 1.0,
                "costBps": 323.3333333333333,
                "costSource": "SEED",
                "costModel": {
                    "brand": "visa",
                    "ccy": "USD",
                    "pctBps": 290.0,
                    "fixedFee": 0.3
                },
                "ev": 0.9676666666666667,
                "isSrHead": false,
                "isChosen": false
            }
        ]
    }
}

Copilot AI lite review requested due to automatic review settings August 14, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds tenant scoping support for outbound Card Info API calls by making the tenant ID configurable and sending it as a request header, alongside improving diagnostics for non-successful responses and a small serde visitor signature cleanup.

Changes:

  • Add tenant_id to CardInfoServiceConfig (with defaults) and wire it into development.toml.
  • Include x-tenant-id in Card Info API requests and log more detail on non-2xx responses.
  • Adjust serde visitor expecting signature for clarity/correctness.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/types/card/card_info_api.rs Sends x-tenant-id header on Card Info API calls and expands non-2xx logging.
src/config.rs Extends CardInfoServiceConfig with tenant_id + default; minor serde visitor signature fix.
config/development.toml Adds tenant_id to the card_info_service config section for dev.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/types/card/card_info_api.rs Outdated
@jagan-jaya
jagan-jaya merged commit 5ecee02 into main Aug 14, 2026
17 checks passed
@jagan-jaya
jagan-jaya deleted the add-x-tenant-to-de branch August 14, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants