You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_4 (already cloned)
- Base commit: 20b37bdb7a25ec053e7671332d4837a0ad743983
- Task ID: juspay__hyperswitch-8325
- Version: v1.115.0
TASK DESCRIPTION: Bug: feat(recovery-events): add revenue recovery topic and vector config to push these events to s3
Add new event for revenue recovery and write vector config to send data to aws s3.
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This new Kafka Event consume the revenue recovery related events which will be constructed from both
RecoveryPaymentIntentandRecoveryPaymentAttemptin revenue recovery flow. The events form Kafka will be picked up by vector and this be eventually batched and pushed to s3 based on the set config. They file path will look like thismerchant_id/Year/month/timestamp.csv.The events will be recorded at two places.
Webhook Flow(External Payments done by billing processor) andInternal Proxy Flow(Internal Done by Hyperswitch as a part of retrying). The event structure is mentioned in the kafka message in code.The estimated size of each event is around 1000bytes. We want to keep the config at 1000 batches and one day(86400s) timeout in vector. So that vector collects all the events till the end of the time out or till it hits 1000 events and push them to s3 file in the designated file path in a csv format in the order mentioned in the config. Based on the above config vector needs 10mb size buffer to support this. S3 auth will be done using the IAM Instance profile which will be taken care off at the time of the deployment.
Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
As for the Revenue Recovery System we needed a pipeline which can move transaction based data to s3 where we store the entire transactional data which can be further used to train models. The transactional data consists of various parameters from both payment intent and payment attempt. So we created a new topic to facilitate this requirement.
How did you test it?
At the time of this pr getting merged, Kafka is not enabled for V2 . So we cannot test it. It can be tested by the following steps once kafka is enabled for v2. Follow the steps in this pr #7461 and check the s3 attached to that kafka topic to find a file after waiting for one day. Sample Kafka Event :
Here is the S3 File Path:
Here is the AWS File sample
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
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_4/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll help you implement the revenue recovery topic and vector config for pushing events to S3. Let me start by creating a plan and exploring the repository structure to understand where changes need to be made.
Assistant
Let me first explore the repository structure to understand where Kafka topics and vector configurations are defined.
Assistant
Now let me examine the existing Kafka configuration and event handling code to understand the structure better.
Assistant
Let me check the event types to understand how to add the new recovery event type:
Assistant
Let me check the EventType enum to understand how to add the new recovery event type:
Assistant
(no content)
Assistant
Now let me check the revenue recovery module to understand how it works and where events should be generated:
Assistant
Now let me check the vector configuration file to understand how to add S3 output:
Assistant
Let me now look at how the configuration is structured to understand where to add the new topic:
Assistant
Now I need to understand how recovery events should be structured. Let me look for existing recovery-related message types to see how to create the new one:
Assistant
Let me now create the recovery event message type and update the necessary files. First, I'll create a new Kafka message type for revenue recovery events.
Assistant
First, let me add the new
Recoveryevent type to theEventTypeenum:Assistant
Let me first read the file to make sure I understand the current state correctly:
Assistant
Now I'll add the Recovery event type to the enum. Let me use the appropriate tool:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →