Skip to content

refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template#8681

Merged
SanchithHegde merged 17 commits intomainfrom
fetch_payment_method_information_in_attempt_list
Jul 21, 2025
Merged

refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template#8681
SanchithHegde merged 17 commits intomainfrom
fetch_payment_method_information_in_attempt_list

Conversation

@NISHANTH1221
Copy link
Contributor

Type of Change

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

Description

This pr adds fetches payment method data in payment attempt list v2 api.

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?

Request:

curl --location 'http://localhost:8080/v2/payments/12345_pay_0198179b2de5751292df2b555eaa3cf2/list_attempts' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_2Kk2ddRcJttgm6ONh0zm' \
--header 'api-key: dev_g5HfT4ijuVQs3QLUPf3xAT6M26ebVgHHTivreiSljKPdRvEsqBNSKxHJrhLboLsT' \
--header 'Authorization: api-key=dev_g5HfT4ijuVQs3QLUPf3xAT6M26ebVgHHTivreiSljKPdRvEsqBNSKxHJrhLboLsT'

Response

{
    "payment_attempt_list": [
        {
            "id": "12345_att_0198179b2e167703a070a6ec12d40213",
            "status": "voided",
            "amount": {
                "net_amount": 10000,
                "amount_to_capture": null,
                "surcharge_amount": null,
                "tax_on_surcharge": null,
                "amount_capturable": 0,
                "shipping_cost": null,
                "order_tax_amount": null
            },
            "connector": "stripe",
            "error": {
                "code": "card_declined",
                "message": "Your card was declined.",
                "unified_code": null,
                "unified_message": null,
                "network_advice_code": null,
                "network_decline_code": null,
                "network_error_message": null
            },
            "authentication_type": "no_three_ds",
            "created_at": "2025-07-16T12:18:21.000Z",
            "modified_at": "2025-07-17T08:58:23.034Z",
            "cancellation_reason": null,
            "payment_token": null,
            "connector_metadata": null,
            "payment_experience": null,
            "payment_method_type": "card",
            "connector_reference_id": null,
            "payment_method_subtype": "credit",
            "connector_payment_id": {
                "TxnId": "pi_3RlUHlCZJlEh6syL1TxJJCst"
            },
            "payment_method_id": null,
            "client_source": null,
            "client_version": null,
            "feature_metadata": {
                "revenue_recovery": {
                    "attempt_triggered_by": "external",
                    "charge_id": "ch_3RlUHlCZJlEh6syL1gLXCiDC"
                }
            },
            "payment_method_data": {
                "card": {
                    "last4": "0008",
                    "card_type": null,
                    "card_network": null,
                    "card_issuer": "Chase",
                    "card_issuing_country": null,
                    "card_isin": null,
                    "card_extended_bin": null,
                    "card_exp_month": "06",
                    "card_exp_year": "50",
                    "card_holder_name": null,
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            }
        }
    ]
}

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

@NISHANTH1221 NISHANTH1221 requested review from a team as code owners July 17, 2025 14:01
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jul 17, 2025

@NISHANTH1221 NISHANTH1221 self-assigned this Jul 17, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jul 17, 2025
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,

/// payment method data
pub payment_method_data: Option<PaymentMethodDataResponseWithBilling>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the entire struct can we just populate the additional_payment_method_Data here

Copy link
Contributor Author

@NISHANTH1221 NISHANTH1221 Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed a better choice since it is being used in struct PaymentsResponse v2 too

/// Additional data that might be required by hyperswitch, to enable some specific features.
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,

/// payment method data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more descriptive comment. You can refer to the other places where PaymentMethodDataResponseWithBilling` is being used.

> = attempt
.payment_method_data
.clone()
.and_then(|data| serde_json::from_value(data.expose().clone()).ok());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to log the error message ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we dont want to log we will just ignore the error here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we ignoring the error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought of ForeignFrom expects a self not result. Instead of propagating the error could have logged the error. Will pick it up in next pr.

@NISHANTH1221 NISHANTH1221 requested a review from a team as a code owner July 18, 2025 17:13
@NISHANTH1221 NISHANTH1221 changed the title refactor(payments): fetch payment method information in attempts list api v2 refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template Jul 18, 2025
swangi-kumari
swangi-kumari previously approved these changes Jul 19, 2025
Copy link
Contributor

@swangi-kumari swangi-kumari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connector changes looks good

ShankarSinghC
ShankarSinghC previously approved these changes Jul 20, 2025
swangi-kumari
swangi-kumari previously approved these changes Jul 20, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 20, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 21, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 21, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jul 21, 2025
@NISHANTH1221 NISHANTH1221 dismissed stale reviews from ShankarSinghC and swangi-kumari via 3cf95df July 21, 2025 11:11
ShankarSinghC
ShankarSinghC previously approved these changes Jul 21, 2025
@NISHANTH1221 NISHANTH1221 requested review from a team and removed request for a team July 21, 2025 13:47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this file to custombilling.rs and move it to crates/router/tests/connectors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

default_imp_for_authorize_session_token!(
connectors::Custombilling,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow alphabetical order in this file

}

default_imp_for_new_connector_integration_payment!(
connectors::Custombilling,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow alphabetical order in this file

> = attempt
.payment_method_data
.clone()
.and_then(|data| serde_json::from_value(data.expose().clone()).ok());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the .expose().clone()? Isn't .expose() sufficient?

> = attempt
.payment_method_data
.clone()
.and_then(|data| serde_json::from_value(data.expose().clone()).ok());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we ignoring the error here?

@SanchithHegde SanchithHegde merged commit 110beaf into main Jul 21, 2025
16 of 20 checks passed
@SanchithHegde SanchithHegde deleted the fetch_payment_method_information_in_attempt_list branch July 21, 2025 19:08
pixincreate added a commit that referenced this pull request Jul 22, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch:
  refactor(connector): [Adyen] map ssn and session validity for Pix (#8702)
  feat(core): Implement UCS kill switch for emergency fallback (#8651)
  fix(openapi): Added Error Response Schema for Status Code 400 (#8684)
  feat(connector): Add template code for breadpay (#8655)
  chore(version): 2025.07.21.1
  refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681)
  fix(router): Make v2 endpoints follow standard naming conventions (#8630)
  fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards  (#8663)
  feat(routing): Add API key auth for decision engine endpoints (#8640)
  feat(authentication): Added eligibility flow for modular authentication (#8431)
  feat(connector): [BLACKHAWKNETWORK] Add Template Code  (#8632)
  fix: remove straight through routing from routing approach (#8695)
  fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689)
  chore(version): 2025.07.21.0
pixincreate added a commit that referenced this pull request Jul 22, 2025
…ayload-recurring

* 'main' of github.com:juspay/hyperswitch: (48 commits)
  fix(connector): Add Trustpay in Authentication Providers Config (#8622)
  refactor(connector): [Adyen] map ssn and session validity for Pix (#8702)
  feat(core): Implement UCS kill switch for emergency fallback (#8651)
  fix(openapi): Added Error Response Schema for Status Code 400 (#8684)
  feat(connector): Add template code for breadpay (#8655)
  chore(version): 2025.07.21.1
  refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681)
  fix(router): Make v2 endpoints follow standard naming conventions (#8630)
  fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards  (#8663)
  feat(routing): Add API key auth for decision engine endpoints (#8640)
  feat(authentication): Added eligibility flow for modular authentication (#8431)
  feat(connector): [BLACKHAWKNETWORK] Add Template Code  (#8632)
  fix: remove straight through routing from routing approach (#8695)
  fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689)
  chore(version): 2025.07.21.0
  feat(debit_routing): add debit routing support for apple pay (#8673)
  refactor(router): decrypt the wallet token before the debit routing call (#8598)
  chore: update org retrieve api response to include org type (#8660)
  feat(routing): Add routing evaluation rule endpoint and related flow (#8656)
  fix(connector): [AUTHORIZEDOTNET] Added Invoice Number Fix (#8685)
  ...
pixincreate added a commit that referenced this pull request Jul 22, 2025
…acilitapay-mca-metadata

* 'main' of github.com:juspay/hyperswitch:
  fix(connector): Add Trustpay in Authentication Providers Config (#8622)
  refactor(connector): [Adyen] map ssn and session validity for Pix (#8702)
  feat(core): Implement UCS kill switch for emergency fallback (#8651)
  fix(openapi): Added Error Response Schema for Status Code 400 (#8684)
  feat(connector): Add template code for breadpay (#8655)
  chore(version): 2025.07.21.1
  refactor(payments): fetch payment method information in attempts list api v2 and add custom billing connector template (#8681)
  fix(router): Make v2 endpoints follow standard naming conventions (#8630)
  fix(connector): [Cybersource] Add type_selection_indicator as 1 for all cards  (#8663)
  feat(routing): Add API key auth for decision engine endpoints (#8640)
  feat(authentication): Added eligibility flow for modular authentication (#8431)
  feat(connector): [BLACKHAWKNETWORK] Add Template Code  (#8632)
  fix: remove straight through routing from routing approach (#8695)
  fix(connector): [Access Worldpay] correct enum deserialization for payment responses for (#8689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(payments): Fetch payment method details n PaymentListAttempt api

6 participants