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_0 (already cloned)
- Base commit: bc767b9131e2637ce90997da9018085d2dadb80b
- Task ID: juspay__hyperswitch-8430
- Version: v1.114.0
TASK DESCRIPTION: Bug: [BUG] adyen connector creates connector's customer reference on the fly
Bug Description
Connector's customer ID is a unique identifier for a customer's entity in the underlying connector for HyperSwitch for mapping a customer. This identifier is stored under
connector_customerincustomerstable.However, for Adyen - this field is a combination of merchant ID and customer ID in HyperSwitch which is unique across different merchants and customers.
This is a blocker for migrated customers whose
shopperReference(customer ID in Adyen) can be in a different format.Expected Behavior
Adyen should rely on the
connector_customerfield for customer and fallback to any default connector specific behavior.Actual Behavior
Adyen uses a default behavior for generating
connector_customer_idSteps To Reproduce
--
Context For The Bug
--
Environment
--
Have you spent some time checking if this bug has been raised before?
- I checked and didn't find a similar issue
Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit a PR?
None
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
Assistant
I'll help you fix this Adyen connector bug where it's creating connector customer references on the fly instead of using the existing
connector_customerfield. Let me first understand the problem and locate the relevant files.Assistant
Let me search for Adyen connector related files to understand the current implementation:
Assistant
Let me examine the main Adyen connector implementation:
Assistant
Let me search for specific terms related to connector_customer and shopperReference in the Adyen connector:
Assistant
Let me search more broadly for Adyen-related code that might handle customer references:
Assistant
Let me look at the Adyen transformers file which seems to contain the shopperReference logic:
Assistant
Let me search for specific patterns in the Adyen connector files to understand how shopperReference is generated:
Assistant
Let me try a broader search for the customer-related implementation:
Assistant
Let me approach this differently by looking at the connector structure and understanding the codebase better:
Assistant
Let me search more specifically for where the connector_customer is used and how it relates to shopperReference:
Assistant
Now let me check the utils.rs file to understand how connector_customer is typically handled:
Assistant
(no content)
Assistant
Let me try to get a better understanding by examining the entire adyen.rs file structure:
Assistant
Now let me look at the transformers.rs file where shopperReference is likely to be defined:
Assistant
Let me look further into the Adyen transformer file to find how shopperReference is generated:
Assistant
Let me search for how the shopper_reference field is populated in the transformation process:
Assistant
Let me search for the try_from implementations in transformers.rs more broadly:
Assistant
Let me look at the end of the transformers.rs file where the implementations likely are:
Assistant
Let me continue looking at the transformers.rs file to find the implementations that create AdyenPaymentRequest:
Assistant
Perfect! Now I found the key function. Let me search for the
build_shopper_referencefunction which is likely responsible for creating the shopper reference:Assistant
Let me look for where the connector_customer is handled:
Assistant
Let me look at the end of the transformers.rs file to see how shopper_reference is built:
Assistant
I can see the issue! Let me examine how the
shopper_referenceis constructed in lines 2901-2904:let shopper_reference = build_shopper_reference( &item.router_data.customer_id, item.router_data.merchant_id.clone(), );This is the line that's causing the issue. Let me find the
build_shopper_referencefunction:Assistant
Let me find it in the whole file with a broader search:
Assistant
Let me look at the
build_shopper_referencefunction definition:Assistant
Now I need to understand the problem better. Based on my findings, the issue is that in the Adyen connector implementation, the
shopper_referencefield is generated usingbuild_shopper_referencefunction that combines merchant ID and customer ID to form a unique identifier. However, according to the bug report, the system should use an existingconnector_customerfield if it's available, rather than always generating one.Let me look at the function that handles recurring processing model which also sets shopper_reference:
Assistant
Let me check what the issue is exactly by examining how the connector_customer is supposed to be used. Let me also look for where it's referenced in the context of migrations:
Assistant
Looking at the current code and the bug description, I can now understand the issue. The problem is in the Adyen connector's
build_shopper_referencefunction. According to the bug description:- The connector's customer ID (stored under
connector_customerin the customers table) should be used for Adyen'sshopperReference - Currently, it generates a new
shopperReferenceusing merchant ID + customer ID combinations - For migrated customers, this approach causes issues because their
shopperReference(which was already set in Adyen) can be in a different format
The issue occurs in multiple places where
build_shopper_referenceis called, particularly in lines around 2901, 3509, and 5825. The fix should prioritize using an existingconnector_customerif available.Let me find how the connector_customer is accessed from the request data to implement the fix properly.
- The connector's customer ID (stored under
Assistant
Let me look for where connector_customer is accessed in the payments code:
Assistant
Let me examine the main payment_confirm.rs file to understand how connector_customer is accessed:
Assistant
Let me check if there's another way to access connector_customer - it might be in the Customer structure:
Assistant
Now I understand the issue better. Let me approach this differently - let me read how the connector_customer is typically used in other parts of the codebase. Let me look at the customer structure or check the data model:
Assistant
Let me take a different approach. Since the bug description mentions "Adyen should rely on the
connector_customerfield for customer and fallback to any default connector specific behavior", I need to look more closely at theget_recurring_processing_modelfunction since that's used in several places where shopper_reference is set.Assistant
Now I'm getting clearer on the issue. I see that in
get_recurring_processing_model, theshopper_referenceis being created in lines 1771-1775 and 1786-1790, but it's not considering theconnector_customerthat might already be present.The issue is that when customers are migrated, they may already have a shopperReference set in Adyen that doesn't follow the standard
merchant_id_customer_idpattern. The fix should check if a connector_customer already exists and use that instead of creating a new one.Let me understand what fields are available in the router data to access the connector_customer. Let me look for a method or field that accesses this in the router data itself:
- User
Here are the existing contents of your todo list:
[1. [in_progress] Identify the problem with current shopperReference implementation in Adyen connector 2. [pending] Analyze the connector_customer field usage in the system 3. [pending] Update the shopperReference logic to use connector_customer when available]
Assistant
Now I understand the problem clearly. The fix needs to be made in the Adyen connector to check for an existing
connector_customerbefore generating a new one. Let me now implement the fix by modifying the shopper reference logic:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.