Skip to content

feat(router): add three_ds decision rule execute api#8148

Merged
Gnanasundari24 merged 29 commits intomainfrom
add-three-ds-rule-execute-api-with-routing-id
Jun 6, 2025
Merged

feat(router): add three_ds decision rule execute api#8148
Gnanasundari24 merged 29 commits intomainfrom
add-three-ds-rule-execute-api-with-routing-id

Conversation

@sai-harsha-vardhan
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan commented May 26, 2025

Type of Change

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

Description

add three_ds decision rule execute api

This pull request introduces a new feature for executing 3DS decision rules, along with supporting changes across multiple modules. The changes include adding new structures for handling 3DS decision rule inputs and outputs, integrating these structures into the backend and frontend systems, and updating associated tests and documentation.

New Feature: 3DS Decision Rule Execution

  • API endpoint addition: Added a new OpenAPI endpoint for executing 3DS decision rules (post /three_ds_decision_rule/execute).
  • New module and structs: Created three_ds_decision_rule module in crates/api_models with structs for handling request and response data (ThreeDsDecisionRuleExecuteRequest and ThreeDsDecisionRuleExecuteResponse).
  • Enum updates: Added ThreeDsDecisionRule to ApiEventsType and implemented a method to retrieve decisions in ThreeDSDecisionRule. [1] [2]

Backend Integration

  • Backend input extension: Enhanced BackendInput in crates/euclid/src/backend/inputs.rs to include new fields for acquirer, customer device, and issuer data.
  • Context handling: Updated Context implementation in crates/euclid/src/backend/vir_interpreter/types.rs to process the new input fields and map them to EuclidValue.

Frontend and Testing Updates

  • Frontend enums: Added ToSchema trait to relevant enums in crates/euclid/src/frontend/dir/enums.rs for better schema integration. [1] [2]
  • Test updates: Modified multiple tests in crates/euclid/src/backend/vir_interpreter.rs to include the new input fields (acquirer_data, customer_device_data, and issuer_data). [1] [2]

Tested wasm change - get_all_keys (Not to include 3DS Decision Keys)
image

Documentation and Configuration

  • API documentation: Added a new page for the 3DS decision rule API in api-reference/mint.json.
  • Cargo.toml update: Included euclid as a dependency in crates/openapi/Cargo.toml.

Additional Changes

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

Motivation and Context

How did you test it?

Tested Manually
Create a Three DS Decision Rule using Routing Create Config API
CURL

curl --location '{{BASE_URL}}/routing' \
--header 'api-key: {{API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Three DS Decision Rule for exemption",
    "description": "This is a three_ds_decision_rule",
    "profile_id": "pro_grHb38qPPHB61ZxZQL4f",
    "transaction_type": "three_ds_authentication",
    "algorithm": {
        "type": "three_ds_decision_rule",
        "data": {
            "defaultSelection": {
            "decision": "no_three_ds"
        },
        "rules": [
            {
                "name": "rule_1",
                "connectorSelection": {
                    "decision": "challenge_requested"
                },
                "statements": [
                    {
                        "condition": [
                            {
                                "lhs": "issuer_country",
                                "comparison": "equal",
                                "value": {
                                    "type": "enum_variant",
                                    "value": "Switzerland"
                                },
                                "metadata": {}
                            },
                            {
                                "lhs": "acquirer_country",
                                "comparison": "equal",
                                "value": {
                                    "type": "enum_variant",
                                    "value": "Switzerland"
                                },
                                "metadata": {}
                            }
                        ]
                    }
                ]
            }
        ],
        "metadata": {}
        }
    }
}'

Response

{
    "id": "routing_d4PK8mS800gJWAatPRGS",
    "profile_id": "pro_grHb38qPPHB61ZxZQL4f",
    "name": "Three DS Decision Rule for exemption",
    "kind": "three_ds_decision_rule",
    "description": "This is a three_ds_decision_rule",
    "created_at": 1748276752,
    "modified_at": 1748276752,
    "algorithm_for": "three_ds_authentication",
    "decision_engine_routing_id": null
}

Call Execute API with appropriate Routing ID and Input Data
CURL

curl --location '{{BASE_URL}}/three_ds_decision/execute' \
--header 'Content-Type: application/json' \
--header 'api-key: {{API_KEY}}' \
--data '{
    "routing_id": "routing_d4PK8mS800gJWAatPRGS",
    "payment": {
        "amount": 1,
        "currency": "AMD"
    },
    "issuer": {
        "country": "Switzerland"
    },
    "acquirer": {
        "country": "Switzerland"
    }
}'

Response

{
    "decision": "challenge_requested"
}

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

@sai-harsha-vardhan sai-harsha-vardhan added this to the May 2025 Release milestone May 26, 2025
@sai-harsha-vardhan sai-harsha-vardhan self-assigned this May 26, 2025
@sai-harsha-vardhan sai-harsha-vardhan requested review from a team as code owners May 26, 2025 16:48
@sai-harsha-vardhan sai-harsha-vardhan added A-core Area: Core flows C-feature Category: Feature request or enhancement labels May 26, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented May 26, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/lib.rs  73% smaller
  crates/router/src/routes.rs  14% smaller
  crates/euclid/src/backend/inputs.rs  10% smaller
  crates/openapi/src/openapi.rs  4% smaller
  crates/euclid_wasm/src/lib.rs  1% smaller
  Cargo.lock Unsupported file format
  api-reference/api-reference/3ds-decision-rule/execute-a-3ds-decision-rule-based-on-the-provided-input.mdx Unsupported file format
  api-reference/mint.json  0% smaller
  api-reference/openapi_spec.json  0% smaller
  crates/api_models/src/lib.rs  0% smaller
  crates/api_models/src/three_ds_decision_rule.rs  0% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/common_types/src/three_ds_decision_rule_engine.rs  0% smaller
  crates/common_utils/src/events.rs  0% smaller
  crates/euclid/benches/backends.rs  0% smaller
  crates/euclid/src/backend.rs  0% smaller
  crates/euclid/src/backend/vir_interpreter.rs  0% smaller
  crates/euclid/src/backend/vir_interpreter/types.rs  0% smaller
  crates/euclid/src/frontend/dir/enums.rs  0% smaller
  crates/openapi/Cargo.toml Unsupported file format
  crates/openapi/src/routes.rs  0% smaller
  crates/openapi/src/routes/three_ds_decision_rule.rs  0% smaller
  crates/router/src/consts.rs  0% smaller
  crates/router/src/core.rs  0% smaller
  crates/router/src/core/payments/routing.rs  0% smaller
  crates/router/src/core/three_ds_decision_rule.rs  0% smaller
  crates/router/src/core/three_ds_decision_rule/utils.rs  0% smaller
  crates/router/src/routes/app.rs  0% smaller
  crates/router/src/routes/lock_utils.rs  0% smaller
  crates/router/src/routes/three_ds_decision_rule.rs  0% smaller
  crates/router_env/src/logger/types.rs  0% smaller

@sai-harsha-vardhan sai-harsha-vardhan requested review from a team as code owners May 28, 2025 15:07
@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 May 28, 2025
@sai-harsha-vardhan sai-harsha-vardhan changed the title feat(router): add three_ds rule execute api feat(router): add three_ds decision rule execute api May 31, 2025
prajjwalkumar17
prajjwalkumar17 previously approved these changes Jun 3, 2025
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 left a comment

Choose a reason for hiding this comment

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

Euclid integation seems fine, shall we test normal routing flows as well.

@Gnanasundari24 Gnanasundari24 enabled auto-merge June 5, 2025 15:38
@sai-harsha-vardhan sai-harsha-vardhan requested review from Aprabhat19 and removed request for Aprabhat19 June 6, 2025 05:31
payment: payment_input,
payment_method: payment_method_input,
mandate: mandate_data,
acquirer_data: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

For payments we would never pass this data is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope (let's say acquirer_data can not be used to configure connectors because we get acquirers once the connector is decided)

)
.await
.to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?;
let algorithm: Algorithm = routing_algorithm
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 check if can directly parse it as a Program, instead of deserializing it to a algo and then to a program

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While storing in routing table, we store program as key value pair (data: program). So, during read as well we can't directly parse it into program

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jun 6, 2025
Merged via the queue into main with commit e90a95d Jun 6, 2025
15 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add-three-ds-rule-execute-api-with-routing-id branch June 6, 2025 16:52
pixincreate added a commit that referenced this pull request Jun 9, 2025
…nktransfer

* 'main' of github.com:juspay/hyperswitch: (211 commits)
  feat(tokenio): Add OpenBanking Redirection Flow (#8152)
  fix: Unified scarf setup (#8238)
  feat(health): Health check for Decision engine (#8243)
  chore: Update apple pay currency filter configs (#8217)
  refactor(customers_v2): Remove merchant reference id from v2 customer update (#7879)
  chore(version): 2025.06.09.0
  chore(postman): update Postman collection files
  ci(postman): add tunnel collection to postman tests (#8269)
  feat(connector): Added recurring payments support for split payments in Stripe (#8271)
  feat(connector): [STRIPE] Added Connector Tokenization Flow for Cards (#8248)
  refactor(core): introduce new field in payment_intent to handle longer return_url (#8135)
  fix(connector): [AUTHORIZEDOTNET] Remove country PM filters (#8278)
  refactor(config): redact config urls for hyperswitch vault (#8276)
  feat(vsaas): enable onboarding of Standard Merchant Accounts in Platform Organization (#8231)
  feat(router): add three_ds decision rule execute api (#8148)
  feat(router): Save payment method on payments confirm (V2) (#8090)
  ci(cypress): Add Airwallex Connector Test (#8187)
  feat(payment_methods): add `external_vault_details` for payments v2 sdk session call (#8003)
  fix(connector): [facilitapay] cpf is a required field (#8274)
  fix: Fixed spell check (#8227)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants