Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include client_version and client_source in retried payments #4826

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

vsrivatsa-edinburgh
Copy link
Member

@vsrivatsa-edinburgh vsrivatsa-edinburgh commented May 30, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

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

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

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_id": "pay_Ycjp9242NLsL9UT2pQKS_1",
            "status": "failure",
            "amount": 6540,
            "currency": "USD",
            "connector": "cybersource",
            "error_message": "Authentication failed",
            "payment_method": "card",
            "connector_transaction_id": null,
            "capture_method": "automatic",
            "authentication_type": "no_three_ds",
            "cancellation_reason": null,
            "mandate_id": null,
            "error_code": "No error code",
            "payment_token": "token_FnzQEt8rNha2E4EzV7Va",
            "connector_metadata": null,
            "payment_experience": null,
            "payment_method_type": "credit",
            "reference_id": null,
            "unified_code": null,
            "unified_message": null,
            "client_source": "ExpressCheckout",
            "client_version": "1.1.1"
        }

Attempt 2

        {
            "attempt_id": "pay_Ycjp9242NLsL9UT2pQKS_2",
            "status": "charged",
            "amount": 6540,
            "currency": "USD",
            "connector": "stripe",
            "error_message": "null,
            "payment_method": "card",
            "connector_transaction_id": null,
            "capture_method": "automatic",
            "authentication_type": "no_three_ds",
            "cancellation_reason": null,
            "mandate_id": null,
            "error_code": "No error code",
            "payment_token": "token_FnzQEt8rNha2E4EzV7Va",
            "connector_metadata": null,
            "payment_experience": null,
            "payment_method_type": "credit",
            "reference_id": null,
            "unified_code": null,
            "unified_message": null,
            "client_source": "ExpressCheckout",
            "client_version": "1.1.1"
        }

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

@vsrivatsa-edinburgh vsrivatsa-edinburgh self-assigned this May 30, 2024
@vsrivatsa-edinburgh vsrivatsa-edinburgh requested a review from a team as a code owner May 30, 2024 13:01
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jun 3, 2024
@jagan-jaya jagan-jaya removed this pull request from the merge queue due to a manual request Jun 3, 2024
@jarnura jarnura added this pull request to the merge queue Jun 3, 2024
Merged via the queue into main with commit fa5f5a4 Jun 3, 2024
25 checks passed
@jarnura jarnura deleted the fix/client_cols_retry branch June 3, 2024 18:09
pixincreate added a commit that referenced this pull request Jun 4, 2024
…atus_pt

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.06.04.0
  fix: include client_version and client_source in retried payments (#4826)
  refactor(users): Changes for Home and Signout APIs for TOTP Redis flows (#4851)
  feat(users): Create config for TOTP Issuer (#4776)
  feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)
  feat(connector): [AUTHORIZEDOTNET] Support payment_method_id in recurring mandate payment (#4841)
  refactor(connector): airwallex convert init payment to preprocessing (#4842)
  feat(router): send `three_ds_requestor_url` in authentication_response for external 3ds flow (#4828)
  feat(consolidated-kafka-events): add consolidated kafka payment events (#4798)
  refactor(connector): [Klarna] Add shipping Address in Klarna Session and Payment Request (#4836)
  fix(connector): make few fields optional in struct NetceteraErrorDetails (#4827)
  chore(cypress): remove logs that expose `globalState` (#4844)
pixincreate added a commit that referenced this pull request Jun 4, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(cypress): Add service level testing for Payouts (#4744)
  feat(auth): Create and use `SinglePurposeOrLoginTokenAuth` (#4830)
  refactor(connector): [Adyen] handle redirection error response (#4862)
  refactor(api_models): rename Card struct for payouts to avoid overrides in auto generated open API spec (#4861)
  chore(version): 2024.06.04.1
  fix(connector): [Adyen]add required fields for afterpay clearpay (#4858)
  chore(version): 2024.06.04.0
  fix: include client_version and client_source in retried payments (#4826)
  refactor(users): Changes for Home and Signout APIs for TOTP Redis flows (#4851)
  feat(users): Create config for TOTP Issuer (#4776)
  feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)
  feat(connector): [AUTHORIZEDOTNET] Support payment_method_id in recurring mandate payment (#4841)
  refactor(connector): airwallex convert init payment to preprocessing (#4842)
  feat(router): send `three_ds_requestor_url` in authentication_response for external 3ds flow (#4828)
  feat(consolidated-kafka-events): add consolidated kafka payment events (#4798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Include client source and client version to identify where a payment attempt originated from
4 participants