Skip to content

fix(payments): update error handling for payment void v2#9595

Merged
likhinbopanna merged 17 commits intomainfrom
feat/paymentcancel_v2
Oct 7, 2025
Merged

fix(payments): update error handling for payment void v2#9595
likhinbopanna merged 17 commits intomainfrom
feat/paymentcancel_v2

Conversation

@ayush22667
Copy link
Contributor

@ayush22667 ayush22667 commented Sep 29, 2025

Type of Change

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

Description

Add error details when payment void is failed at connector level and update the status accordingly.

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_01999518b93e7d92bf68807c23919ddd/cancel' \
--header 'X-Profile-Id: pro_qBLZYRTYcOoyu0qPg4Nn' \
--header 'X-Merchant-Id: cloth_seller_nG8IQZGXCrxMkMyNF6oL' \
--header 'Authorization: api-key=dev_JqT4NtSwFvhxcBGkuWyDTIHvC7tkwp63QoyATDSxZ5X6PzudKWtOkzbJJvwZuRl3' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JqT4NtSwFvhxcBGkuWyDTIHvC7tkwp63QoyATDSxZ5X6PzudKWtOkzbJJvwZuRl3' \
--data '{
    "cancellation_reason": "duplicat"
}'

Response:

{
    "id": "12345_pay_01999518b93e7d92bf68807c23919ddd",
    "status": "failed",
    "cancellation_reason": "duplicat",
    "amount": {
        "order_amount": 10000,
        "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": 10000,
        "amount_to_capture": null,
        "amount_capturable": 0,
        "amount_captured": 0
    },
    "customer_id": "12345_cus_019995055fdd795190c715dccfbcdef4",
    "connector": "stripe",
    "created": "2025-09-29T10:50:49.594Z",
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "attempts": null,
    "return_url": null,
    "error": {
        "code": "No error code",
        "message": "No error message",
        "reason": "Invalid cancellation_reason: must be one of duplicate, fraudulent, requested_by_customer, or abandoned",
        "unified_code": null,
        "unified_message": null,
        "network_advice_code": null,
        "network_decline_code": null,
        "network_error_message": null
    }
}

Request:

curl --location 'http://localhost:8080/v2/payments/12345_pay_0199951c2f4274b3b5a2825b0849a279/cancel' \
--header 'X-Profile-Id: pro_qBLZYRTYcOoyu0qPg4Nn' \
--header 'X-Merchant-Id: cloth_seller_nG8IQZGXCrxMkMyNF6oL' \
--header 'Authorization: api-key=dev_JqT4NtSwFvhxcBGkuWyDTIHvC7tkwp63QoyATDSxZ5X6PzudKWtOkzbJJvwZuRl3' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JqT4NtSwFvhxcBGkuWyDTIHvC7tkwp63QoyATDSxZ5X6PzudKWtOkzbJJvwZuRl3' \
--data '{
    "cancellation_reason": "duplicate"
}'

Response:

{
    "id": "12345_pay_0199951c2f4274b3b5a2825b0849a279",
    "status": "cancelled",
    "cancellation_reason": "duplicate",
    "amount": {
        "order_amount": 10000,
        "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": 10000,
        "amount_to_capture": null,
        "amount_capturable": 10000,
        "amount_captured": 0
    },
    "customer_id": "12345_cus_019995055fdd795190c715dccfbcdef4",
    "connector": "stripe",
    "created": "2025-09-29T10:54:36.366Z",
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "attempts": null,
    "return_url": null,
    "error": null
}

closes #9616

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

@ayush22667 ayush22667 requested review from a team as code owners September 29, 2025 08:52
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 29, 2025

@ayush22667 ayush22667 self-assigned this Sep 29, 2025
@ayush22667 ayush22667 added the C-bug Category: Bug label Sep 29, 2025
@ayush22667 ayush22667 changed the title Feat/paymentcancel v2 Add missing description field in PaymentAttemptUpdate (tokenization flow) and update error handling for payment cancel v2 Sep 29, 2025
@ayush22667 ayush22667 marked this pull request as draft September 29, 2025 08:59
@ayush22667 ayush22667 force-pushed the feat/paymentcancel_v2 branch from 698e5e7 to fdb504d Compare September 29, 2025 10:19
@ayush22667 ayush22667 changed the title Add missing description field in PaymentAttemptUpdate (tokenization flow) and update error handling for payment cancel v2 update error handling for payment cancel v2 Sep 29, 2025
@ayush22667 ayush22667 marked this pull request as ready for review September 29, 2025 10:23
@ayush22667 ayush22667 force-pushed the feat/paymentcancel_v2 branch from fdb504d to a6a210d Compare September 29, 2025 10:57
@ayush22667 ayush22667 changed the title update error handling for payment cancel v2 fix(payments):update error handling for payment cancel v2 Sep 29, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Sep 29, 2025
@ayush22667 ayush22667 changed the title fix(payments):update error handling for payment cancel v2 fix(payments): update error handling for payment cancel v2 Sep 30, 2025
@ayush22667 ayush22667 changed the title fix(payments): update error handling for payment cancel v2 fix(payments): update error handling for payment void v2 Sep 30, 2025
@ayush22667 ayush22667 added M-api-contract-changes Metadata: This PR involves API contract changes and removed M-api-contract-changes Metadata: This PR involves API contract changes labels Sep 30, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 6, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 7, 2025
Merged via the queue into main with commit e2ed289 Oct 7, 2025
34 of 41 checks passed
@likhinbopanna likhinbopanna deleted the feat/paymentcancel_v2 branch October 7, 2025 08:22
pixincreate added a commit that referenced this pull request Oct 7, 2025
…esouro-googlepay

* 'main' of github.com:juspay/hyperswitch:
  feat(connector): [tesouro] apple pay (#9648)
  fix(payments): update error handling for payment void v2 (#9595)
  fix(connectors): [Nexixpay] MIT & order_id fix (#9644)
  chore(version): 2025.10.07.0
  fix(database): percent-encode spaces in Postgres connection URI (#9685)
  chore(version): 2025.10.06.0
  feat(subscriptions): Invoice record back workflow (#9529)
  feat: Implement subscriptions workflow and incoming webhook support (#9400)
  Feat(Customer): Added search Feature to the Customer Page (#9619)
  chore(version): 2025.10.02.0
  feat(subscription): Add support to call payments microservice from subscription service via payments API client (#9590)
UdayPandey01 pushed a commit to UdayPandey01/hyperswitch that referenced this pull request Oct 8, 2025
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Category: Bug M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] fix(payments): add connector error details in response when payment void fails

4 participants