Explore the hyperswitch codebase to understand the structure, particularly looking for refund handling, connector logic, and Cypress test files.
Assistant
I'll explore the hyperswitch codebase to understand its structure, focusing on refund handling, connector logic, and Cypress test files. Let me start by examining the overall structure of the repository.
Assistant
Let me focus on finding the core structure of the hyperswitch codebase, particularly looking for refund handling, connector logic, and Cypress test files.
Assistant
Now let me look for the main crates directory structure to understand the core components:
Assistant
Let me check what's in the main crates directory:
Assistant
Now I can see the main crates directory structure. Let me look for refund handling, connector logic, and Cypress test files. First, let me search for refund-related code:
Assistant
Great! Now let me search for connector-related files and Cypress test files:
Assistant
Let me look for Cypress test files:
Assistant
(no content)
Assistant
Let me also check for the refund test files specifically:
Assistant
Perfect! Now let me also check the connectors directory to understand the structure:
Assistant
Let me now look at some key refund and connector implementation files to better understand the structure:
Assistant
Let me also look at the refund core implementation:
Assistant
Now let me look at a connector implementation to understand the structure:
Assistant
Let me check what connectors exist:
Assistant
Let me also check a basic refund test file to understand how they're structured:
Assistant
Let me check the structure of the codebase and summarize what I've found:
Assistant
Based on my exploration of the hyperswitch codebase, I've identified the key areas related to refund handling, connector logic, and Cypress test files. Here's my analysis:
Assistant
(no content)
Assistant
(no content)
Assistant
Based on my comprehensive exploration of the hyperswitch codebase, I've identified and analyzed the key components related to refund handling, connector logic, and Cypress test files. Here's a summary of my findings:
Codebase Structure Analysis
1. Refund Handling System
The refund functionality is organized in the crates/router/src/core/refunds module:
Each connector has its own subdirectory with transformer files for converting data between hyperswitch and the payment processor formats
Connectors implement the refund functionality through their respective transformer implementations
Cypress Test Files
Cypress end-to-end tests for refunds are located in:
cypress-tests/cypress/e2e/spec/Payment/00009-RefundPayment.cy.js: Comprehensive refund test suite covering various scenarios (full refund, partial refund, 3DS vs No-3DS flows, manual vs automatic capture)
cypress-tests/cypress/fixtures/refund-flow-body.json: Test fixture data for refund operations
Test configurations are in cypress-tests/cypress/e2e/configs/Payment/ directory
Key Components
Refund Processing Flow
API Endpoints: Defined in crates/router/src/routes/refunds.rs
Core Logic: Implemented in crates/router/src/core/refunds.rs
Validation: Checks payment age, amount limits, and refund attempts
Connector Integration: Routes refunds through appropriate payment processors
Scheduling: Uses process tracker for asynchronous refund execution and synchronization
Connector Implementation Pattern
Each connector follows a consistent pattern with:
Transformers for converting between hyperswitch and connector-specific formats
Integration with the core refund processing system
Error handling and status updates
Test Coverage
The refund tests cover:
Various payment scenarios (3DS/No-3DS, manual/auto capture)
Full and partial refunds
Multiple connector types
Synchronization of refund status with payment processors
Error conditions and edge cases
This structure allows for modular development where new payment connectors can be easily added while maintaining consistent refund processing logic across all integrations.
crates/router/src/routes/refunds.rs
crates/router/src/core/refunds/transformers.rs: Data transformation logic
crates/router/src/core/refunds/validator.rs: Validation rules for refunds
2. Connector Logic Architecture
Connector implementations are located in crates/hyperswitch_connectors/src/connectors/:
Each payment processor has its own subdirectory (e.g., adyen, stripe, paypal)
Connectors implement refund functionality through standardized transformers
Consistent integration pattern across all payment processors
3. Cypress Test Coverage
End-to-end refund testing is implemented in cypress-tests/cypress/e2e/spec/Payment/:
Primary refund test file: 00009-RefundPayment.cy.js
Additional sync refund tests in 00010-SyncRefund.cy.js
Extensive test coverage for various scenarios including:
3DS vs No-3DS flows
Manual vs automatic capture
Full and partial refunds
Different connector types
Key Technical Details
The refund processing follows a workflow that:
Validates refund requests against payment constraints
Schedules refund execution through the process tracker system
Communicates with payment processors via connector-specific implementations
Handles both immediate and scheduled refund processing
Updates refund status and synchronizes with payment processors
This modular design enables hyperswitch to support multiple payment processors while maintaining consistent refund handling across all integrations. The system is well-tested with comprehensive Cypress end-to-end tests covering various refund scenarios and edge cases.