Skip to content

Conversation

Aishwariyaa-Anand
Copy link
Contributor

@Aishwariyaa-Anand Aishwariyaa-Anand commented May 23, 2025

Type of Change

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

Description

Currently, we have two endpoints for retrieving payment information in v2:

  • GET /payments/:id
  • GET /payments/:id:/get-intent

The endpoint /payments/{payment_id} is called after confirmation, at which point a payment attempt always exists. Currently, payment_attempt in PaymentStatusData is stored as an optional field requiring implementation for get_payment_attempt().
This PR refactors the PaymentStatusData struct to make payment_attempt a required field

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. Payments Create
  2. Payments Confirm
  3. Payments Retrieve
curl --location 'http://localhost:8080/v2/payments/12345_pay_0196fd5c3d7a7502a39002fd8ce86a03?force_sync=true' \
--header 'x-profile-id: pro_zpak30UxH06EvzDWoXsW' \
--header 'Authorization: api-key=dev_Qi7ZsoVS4uccUf9Zy3pbS3eqvHjledzayfBn3i74bic6JHGMXNGpuY4wwN1xEMoQ' \
--data ''

Response

{
    "id": "12345_pay_0196fd5c3d7a7502a39002fd8ce86a03",
    "status": "succeeded",
    "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": 100
    },
    "customer_id": null,
    "connector": "stripe",
    "created": "2025-05-23T13:36:42.987Z",
    "payment_method_data": {
        "billing": null
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "connector_transaction_id": "pi_3RRvmED5R7gDAGff0qqjNSfu",
    "connector_reference_id": null,
    "merchant_connector_id": "mca_8S2I5IjIiW6MnlXUleeZ",
    "browser_info": null,
    "error": 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": "[email protected]"
    },
    "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": "[email protected]"
    },
    "attempts": null,
    "connector_token_details": {
        "token": "pm_1RRvmED5R7gDAGffXf71G5j2",
        "connector_token_request_reference_id": "waAfJPIqPwCZbPN4xC"
    },
    "payment_method_id": null,
    "next_action": null,
    "return_url": "https://google.com/success",
    "authentication_type": "no_three_ds",
    "authentication_type_applied": null,
    "is_iframe_redirection_enabled": null
}
  1. Payments Create
  2. Payments Retrieve
curl --location 'http://localhost:8080/v2/payments/12345_pay_01970c2d2a3c71e19ac6e9d20e9b5cb5?force_sync=true' \
--header 'x-profile-id: pro_3gDRiJh3bRKWv7ba0NYE' \
--header 'Authorization: api-key=dev_O5tsf4SGjEusjWDUE56oLxR8HIGNrQJoA4Rxp8LpNYFFNxoxo8j74KexSKWmeRbs' \
--data ''

Response

{
    "error": {
        "type": "invalid_request",
        "message": "This Payment could not be PaymentGet because it has a status of requires_payment_method. The expected state is requires_capture, requires_customer_action, requires_merchant_action, processing, succeeded, failed, partially_captured_and_capturable, partially_captured, cancelled",
        "code": "IR_14"
    }
}
  1. Payments Retrieve (get-intent)
curl --location 'http://localhost:8080/v2/payments/12345_pay_01970c2d2a3c71e19ac6e9d20e9b5cb5/get-intent' \
--header 'x-profile-id: pro_3gDRiJh3bRKWv7ba0NYE' \
--header 'Authorization: api-key=dev_O5tsf4SGjEusjWDUE56oLxR8HIGNrQJoA4Rxp8LpNYFFNxoxo8j74KexSKWmeRbs' \
--data ''

Response

{
    "id": "12345_pay_01970c2d2a3c71e19ac6e9d20e9b5cb5",
    "status": "requires_payment_method",
    "amount_details": {
        "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
    },
    "client_secret": null,
    "profile_id": "pro_3gDRiJh3bRKWv7ba0NYE",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "no_three_ds",
    "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": "[email protected]"
    },
    "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": "[email protected]"
    },
    "customer_id": null,
    "customer_present": "present",
    "description": null,
    "return_url": null,
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Skip",
    "statement_descriptor": null,
    "order_details": null,
    "allowed_payment_method_types": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2025-05-26T10:54:36.032Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

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

Copy link

semanticdiff-com bot commented May 23, 2025

Copy link
Contributor

@hrithikesh026 hrithikesh026 left a comment

Choose a reason for hiding this comment

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

LGTM

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 29, 2025
Merged via the queue into main with commit eb15fa1 May 29, 2025
14 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the payment-attempt-mandatory branch May 29, 2025 10:25
pixincreate added a commit that referenced this pull request May 30, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch: (30 commits)
  chore(version): 2025.05.30.0
  chore(ci): update postman ci credentials (#8172)
  chore(docs): remove old add_connector.md file (#8143)
  refactor: Payment Attempt as mandatory field in PaymentStatusData (#8126)
  fix(payment_link): sanitize embedded payment link data (#7736)
  chore(version): 2025.05.29.0
  feat(analytics): Add ckh columns for 3ds intelligence analytics (#8136)
  refactor(debit_routing): Handle missing merchant_business_country by defaulting to US (#8141)
  chore(version): 2025.05.28.0
  refactor(success_based): add support for exploration (#8158)
  feat(dynamic_routing): add get api for dynamic routing volume split (#8114)
  fix: incorrect payout_method_id in payouts table (#8107)
  feat(router): Enable client_secret auth for payments_get_intent [v2] (#8119)
  chore: address Rust 1.87.0 clippy lints (#8130)
  feat: list for dynamic routing (#8111)
  ci(cypress): fix mandates unsupported connectors (#8086)
  feat(connector): [Barclaycard] Implement Cards - Non 3DS flow (#8068)
  fix(authentication): add Organization context validation in `Merchant Create` and `Merchant List` APIs (#8103)
  feat(connector): [Worldpayxml] add card payment (#8076)
  feat(connector): Stripe revolut pay wallet integration (#8066)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REFACTOR] Payment Attempt as mandatory field in PaymentStatusData
4 participants