Skip to content

refactor(core): add support for expand attempt list in psync v2#7209

Merged
likhinbopanna merged 14 commits intomainfrom
expand_attempts
Feb 11, 2025
Merged

refactor(core): add support for expand attempt list in psync v2#7209
likhinbopanna merged 14 commits intomainfrom
expand_attempts

Conversation

@srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Feb 7, 2025

Type of Change

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

Description

We have expand attempts list in v1 payment sync response which is used by dashboard team. We need similar support in v2. By passing expand_attempts in psync query param, vector of payment attempts associated with the intent will be returned in the payments get response.

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?

Create payment intent and confirm the payment intent

Test case 1 : pass expand_attempts=true in payment get api

curl --location 'http://localhost:8080/v2/payments/12345_pay_0194eebea0707450881ed032755a27b7?expand_attempts=true' \
--header 'x-profile-id: pro_IpmUlwVXURuANo3ccFs0' \
--header 'api-key: dev_2my3hexC89mfCakPBewDWUw8Bzv4B1f00ytCBztsihHAfbVGhu3a7SGL5cSITK0K' \
--data ''

Response :

{
    "id": "12345_pay_0194eebea0707450881ed032755a27b7",
    "status": "failed",
    "amount": {
        "order_amount": 100,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null,
        "net_amount": 100,
        "amount_to_capture": null,
        "amount_capturable": 0,
        "amount_captured": null
    },
    "customer_id": null,
    "connector": "stripe",
    "client_secret": "12345_pay_0194eebea0707450881ed032755a27b7_secret_0194eebea0767932ab120325b3a4e16d",
    "created": "2025-02-10T07:24:17.910Z",
    "payment_method_data": {
        "billing": null
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "connector_transaction_id": null,
    "connector_reference_id": null,
    "merchant_connector_id": "mca_2iDdLhFi0qpgbqzARCBQ",
    "browser_info": null,
    "error": {
        "code": "invalid_expiry_month",
        "message": "Your card's expiration month is invalid.",
        "unified_code": null,
        "unified_message": null
    },
    "shipping": {
        "address": {
            "city": "Karwar",
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "581301",
            "state": "Karnataka",
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "example@example.com"
    },
    "billing": {
        "address": {
            "city": null,
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "example@example.com"
    },
    "attempts": [
        {
            "id": "12345_att_0194eebecdf97ec28ca55a5b24d25936",
            "status": "started",
            "amount": {
                "net_amount": 100,
                "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": "invalid_expiry_month",
                "message": "Your card's expiration month is invalid.",
                "unified_code": null,
                "unified_message": null
            },
            "authentication_type": "no_three_ds",
            "created_at": "2025-02-10T07:24:29.561Z",
            "modified_at": "2025-02-10T07:24:30.214Z",
            "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": null,
            "payment_method_id": null,
            "client_source": null,
            "client_version": null
        }
    ]
}

TestCase 2 : pass exapand_attemps = false or don't pass it in the query params, This should make attempts field in the response to 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

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 7, 2025
@srujanchikke srujanchikke self-assigned this Feb 10, 2025
@srujanchikke srujanchikke added A-core Area: Core flows api-v2 labels Feb 10, 2025
@srujanchikke srujanchikke marked this pull request as ready for review February 10, 2025 08:40
@srujanchikke srujanchikke requested review from a team as code owners February 10, 2025 08:40
@srujanchikke srujanchikke added the M-database-changes Metadata: This PR involves database schema changes label Feb 10, 2025
jarnura
jarnura previously approved these changes Feb 10, 2025
})
.async_and_then(|payment_attempts| async {
let mut domain_payment_attempts = Vec::with_capacity(payment_attempts.len());
for attempt in payment_attempts.into_iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@dracarys18 is the feature to decrypt multiple entities of the same merchant available in the key manager?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not yet, it's an open PR

@likhinbopanna likhinbopanna added this pull request to the merge queue Feb 11, 2025
Merged via the queue into main with commit d093317 Feb 11, 2025
17 of 20 checks passed
@likhinbopanna likhinbopanna deleted the expand_attempts branch February 11, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows api-v2 M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants