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

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant