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_7 (already cloned)
- Base commit: d91cf70ae346cbf613ce5c1cfad2ae8a28c71d1c
- Task ID: juspay__hyperswitch-8176
- Version: v1.114.0
TASK DESCRIPTION: Bug: Properly Handle encoded_data in PSync flow [v2]
PSync is failing for adyen with error:
validate_psync_reference_id failed. We need to pass theencoded_datain payment_attemptDETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
Add
encoded_datafromPaymentsRetrieveRequestinpayment_attemptinsideget_trackersfor PSyncAdditional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
Closes #8176
How did you test it?
No visible changes in API response. Verified that payment status changes to
succeeded.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
Assistant
I'll tackle this bug fix for the PSync flow with Adyen. Let me first understand the issue and locate the relevant files.
The bug is that
validate_psync_reference_id failedwhen using PSync with Adyen, and we need to properly handleencoded_datain thepayment_attemptwithin theget_trackersfunction.Let me start by exploring the codebase to understand the structure and locate the relevant files.
Assistant
Let me start by exploring the codebase to understand the structure and locate the relevant files related to PSync flow and payment attempts.
Assistant
(no content)
Assistant
Now let me search for the specific error mentioned in the issue: "validate_psync_reference_id failed".
Assistant
Let me examine the Adyen connector implementation where the error occurs:
Assistant
(no content)
Assistant
Let me look at the psync_flow.rs file to understand the flow:
Assistant
Now let me examine the transformer functions that handle constructing router data for PSync:
Assistant
(no content)
Assistant
Let me search for the specific function construct_router_data_for_psync:
Assistant
Let me continue searching for this function:
Assistant
Let me check what the specific function looks like in the transformers file by looking further down:
Assistant
Let me search more specifically for the PSync related transformers:
Assistant
Let me check the PaymentsRetrieveRequest definition more closely:
Assistant
Now let me check the v2 version of the PaymentsRetrieveRequest to understand its structure better:
Assistant
Let me also examine the payment_attempt structure to understand how it relates to PSync:
Assistant
Let me look specifically at how the PSync flow handles the request data to understand how to pass encoded_data:
Assistant
Let me now look at the payment_attempt model to see if it has encoded_data:
Assistant
Let me look for how encoded_data is used in PSync context in Adyen connector:
Assistant
Let me examine how payment attempt is being constructed during PSync flow to understand where encoded_data should be passed. Let me look more closely at the psync_flow.rs file again to find the issue:
Assistant
Looking at the issue description, the key point is that "we need to pass the
encoded_datain payment_attempt". The issue is that when validating PSync reference ID in Adyen connector, thevalidate_psync_reference_idfunction is failing. This suggests that theencoded_datafield in thePaymentsRetrieveRequestis not being correctly passed through to thepayment_attempt.Let me check what
encoded_datashould contain. Looking at the context, this seems to be related to payment connector reference ID validation in PSync flow. In the PSync flow, we have thePaymentsRetrieveRequestwith aparamfield that likely contains encoded data, but it's not being passed into the payment attempt in the right way.Let me look at how PSync gets the payment attempt from the get_trackers and understand where the connection should be made:
Assistant
Let me search for more specific information about how PSync data flows through the system to understand where encoded_data needs to be added:
Assistant
Looking more carefully at the code, I need to identify where in the PSync flow
encoded_datashould be passed. Based on the errorvalidate_psync_reference_id failedin the Adyen connector, and knowing that this is about proper handling of encoded data, I suspect the issue is that when constructing the router data for PSync, theencoded_data(which comes fromPaymentsRetrieveRequest.param) is not being properly passed to the payment attempt.Let me examine how this data flows through the system. Based on my analysis, I believe the fix is to make sure that when constructing the router data for PSync, the encoded_data (from
paramfield inPaymentsRetrieveRequest) gets passed to the payment attempt in thepayment_attemptfield.Let me find the specific areas in the PSync code where the payment attempt data is used and ensure
encoded_datais properly propagated:Assistant
Based on the task and my analysis, I need to understand where the encoded_data from
PaymentsRetrieveRequest(specifically theparamfield) should be mapped in the payment attempt for PSync flow.Let me also look at how the
paramfield fromPaymentsRetrieveRequestgets used elsewhere:Assistant
Based on the problem description, let me now examine the specific validation that is failing and look for how encoded_data should be passed from PSync request to payment_attempt.
Looking at the issue, it seems that in PSync flow, the
encoded_data(from theparamfield inPaymentsRetrieveRequest) needs to be properly passed to the payment attempt when validating reference ID for certain connectors like Adyen.Looking closer at the PSync code in
psync_flow.rsand theconstruct_router_data_for_psyncfunction, I need to check what the issue is. Let me find how the PSync data flows through and where we should be populatingencoded_datain payment attempt:Assistant
Let me understand the problem better by looking for where encoded_data should be mapped. Let me search for a broader context of how payment attempt stores encoded data in the codebase:
Assistant
(no content)
Assistant
Great! Now I can see that
PaymentAttempthas anencoded_datafield (line 70) which is of typeOption<masking::Secret<String>>. Now I need to understand where this field should be populated from. Looking back at the issue and the PSync flow, the problem is likely in theconstruct_payment_router_data_for_psyncfunction where the PSync request parameters are processed.Looking at the
PaymentsRetrieveRequeststructure, I can see it has aparamfield (line 5574 in the api_models) that contains encoded data, but it's not being properly propagated to the payment attempt.Let me now create the fix:
Assistant
I see that I need to understand the issue more deeply. Let me check if there's a difference between how payment data is accessed in the
PaymentStatusDatain the PSync flow versus what I was looking at. The problem is that the issue specifically mentions passing encoded_data from the PSync request into payment_attempt. Let me understand what exactly theparamfield contains and how it should be mapped toencoded_data.Let me check what the
paramfield actually contains and how it should map toencoded_data:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.