Skip to content

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Oct 13, 2025

Type of Change

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

Description

This PR introduces a new "decide flow" mechanism for payment authorization that enhances the flexibility and intelligence of connector routing. The key improvements include:

Core Changes:

  • Pre-Decide Flow: Added a new pre_decide_flows method that allows connectors to determine the optimal flow path before making authorization calls
  • Connector Specifications Enhancement: Extended ConnectorSpecifications trait with methods like should_call_connector_service_with_pre_decide_flow(), get_preprocessing_flow_if_needed(), and get_alternate_flow_if_needed()
  • Unified Connector Interface: Improved ConnectorIntegrationInterface to support both old and new connector architectures seamlessly
  • Flow Orchestration: Enhanced the authorize flow with better access token management, order creation, and payment method tokenization

Additional Changes

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

Key files modified:

  • crates/hyperswitch_interfaces/src/connector_integration_interface.rs - New integration interface
  • crates/hyperswitch_interfaces/src/api.rs - Enhanced connector specifications
  • crates/router/src/core/payments/flows/authorize_flow.rs - Pre-decide flow implementation
  • crates/router/src/core/payments.rs - Core payment flow updates
  • Multiple connector flow files updated for consistency

Motivation and Context

This change addresses the need for more intelligent and flexible payment flow routing in Hyperswitch. Previously, the payment authorization flow was rigid and couldn't adapt to different connector requirements or preprocessing needs. The new decide flow mechanism:

  1. Enables Smart Routing: Allows connectors to determine if preprocessing or alternate flows are needed
  2. Improves Efficiency: Reduces unnecessary API calls by making informed decisions upfront
  3. Enhances Flexibility: Supports both legacy and new connector architectures
  4. Better Error Handling: Provides more granular control over flow execution and error scenarios

How did you test it?

The changes have been tested through:

  • Unit tests for the new pre_decide_flows method
  • Integration tests with various connector implementations
  • Manual testing of payment authorization flows with different connector types
  • Validation of both old and new connector architecture compatibility

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

@hrithikesh026 hrithikesh026 self-assigned this Oct 13, 2025
@hrithikesh026 hrithikesh026 requested review from a team as code owners October 13, 2025 06:03
Copy link

semanticdiff-com bot commented Oct 13, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/access_token.rs  95% smaller
  crates/router/src/core/payments/flows/external_proxy_flow.rs  94% smaller
  crates/hyperswitch_interfaces/src/connector_integration_v2.rs  76% smaller
  crates/router/src/core/payments/flows/authorize_flow.rs  40% smaller
  crates/hyperswitch_connectors/src/default_implementations_v2.rs  27% smaller
  crates/router/src/core/payments.rs  25% smaller
  crates/hyperswitch_interfaces/src/api.rs  8% smaller
  crates/hyperswitch_interfaces/src/api/payments.rs  7% smaller
  crates/hyperswitch_interfaces/src/api/payments_v2.rs  7% smaller
  crates/hyperswitch_connectors/src/default_implementations.rs  3% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/cybersource.rs  0% smaller
  crates/hyperswitch_interfaces/src/connector_integration_interface.rs Unsupported file format
  crates/router/src/core/payments/flows.rs  0% smaller
  crates/router/src/core/payments/flows/approve_flow.rs  0% smaller
  crates/router/src/core/payments/flows/cancel_flow.rs  0% smaller
  crates/router/src/core/payments/flows/cancel_post_capture_flow.rs  0% smaller
  crates/router/src/core/payments/flows/capture_flow.rs  0% smaller
  crates/router/src/core/payments/flows/complete_authorize_flow.rs  0% smaller
  crates/router/src/core/payments/flows/incremental_authorization_flow.rs  0% smaller
  crates/router/src/core/payments/flows/post_session_tokens_flow.rs  0% smaller
  crates/router/src/core/payments/flows/psync_flow.rs  0% smaller
  crates/router/src/core/payments/flows/reject_flow.rs  0% smaller
  crates/router/src/core/payments/flows/session_flow.rs  0% smaller
  crates/router/src/core/payments/flows/session_update_flow.rs  0% smaller
  crates/router/src/core/payments/flows/setup_mandate_flow.rs  0% smaller
  crates/router/src/core/payments/flows/update_metadata_flow.rs  0% smaller
  crates/router/src/core/refunds.rs  0% smaller
  crates/router/src/core/refunds_v2.rs Unsupported file format

@hrithikesh026 hrithikesh026 changed the title chore: Introduce new decide flow for authorize feat(core): Introduce new decide flow mechanism for payment authorization Oct 13, 2025
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.

1 participant