fix: include client_version and client_source in retried payments #4826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
This pull request addresses a bug where the client_source and client_version fields were not populated for payment attempts created via retry cases. This issue resulted in these fields being correctly displayed for the first payment attempt but missing in subsequent retry attempts.
Issue:
Problem: For the first payment attempt, the client_source and client_version fields were populated correctly. However, for subsequent payments made through retry mechanisms, these fields were not populated, leading to incomplete data in the PaymentAttemptResponse struct.
Impact: This caused inconsistencies in tracking the source and version of clients across different payment attempts, impacting analytics, debugging, and support.
Backward Compatibility:
This fix is backward compatible as it does not change the existing API or data structures but ensures that existing fields are correctly populated.
fixes #4656
Additional Changes
Motivation and Context
How did you test it?
1. Setup Two Connectors on Hyperswitch Control Center:
Access the Hyperswitch Control Center.
Navigate to the "Connectors" section.
Configure two different payment connectors (Connector 1 and Connector 2).
Ensure both connectors are properly set up and enabled.
2. Create a Payment Intent and Try Confirming It:
Use the Hyperswitch API or dashboard to create a new payment intent.
Ensure to include the client_source and client_version fields in the request headers in the confirm request
3. Produce a Retriable Error from Connector 1 so It Gets Retried with Connector 2:
Simulate a retriable error on Connector 1 (e.g., by configuring Connector 1 to return a specific error code that triggers a retry).
Ensure that Hyperswitch handles the error and automatically retries the payment using Connector 2.
4. Check the Values for client_source and client_version for Both Payment Attempts:
Retrieve the payment intent by passing
?expand_attempts=true
Verify that both the initial and retry payment attempts contain the client_source and client_version fields
Attempt 1
Attempt 2
Checklist
cargo +nightly fmt --all
cargo clippy