Skip to content

feat(router): Add v2 payment cancellation flow#9083

Merged
likhinbopanna merged 14 commits intomainfrom
feat/paymentcancel_v2
Sep 22, 2025
Merged

feat(router): Add v2 payment cancellation flow#9083
likhinbopanna merged 14 commits intomainfrom
feat/paymentcancel_v2

Conversation

@ayush22667
Copy link
Contributor

@ayush22667 ayush22667 commented Aug 29, 2025

Type of Change

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

Description

Add V2 payments_cancel flow by endpoint {{baseUrl}}/v2/payments/:payment_id/cancel.A payment can be cancelled when the status is RequiresCapture, PartiallyAuthorizedAndRequiresCapture, or PartiallyCapturedAndCapturable.

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_0199568c7d307cb093a2f9d517fec5cc/cancel' \
--header 'X-Profile-Id: pro_ICrZFKL8QL6GlxNOuGiT' \
--header 'Authorization: api-key=dev_lLeDL7DZk8Vf8vF7PTd53ces09iGYEerHYDBQzle5s1N1QPpzj3pKViOnv7VsQd5' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_lLeDL7DZk8Vf8vF7PTd53ces09iGYEerHYDBQzle5s1N1QPpzj3pKViOnv7VsQd5' \
--data '{
    "cancellation_reason": "Requested by Merchant"
}'

Response:

{
    "id": "12345_pay_019956bfbb0472f28d713b8190b897b7",
    "status": "cancelled",
    "cancellation_reason": "Requested by Merchant",
    "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": 100,
        "amount_captured": 0
    },
    "customer_id": "12345_cus_0199568c731e77d2960fde597ad801ac",
    "connector": "authorizedotnet",
    "created": "2025-09-17T08:17:09.937Z",
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "attempts": null,
    "return_url": null
}
image image image

closes #9082

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 August 29, 2025 06:04
@ayush22667 ayush22667 self-assigned this Aug 29, 2025
@ayush22667 ayush22667 added api-v2 C-feature Category: Feature request or enhancement labels Aug 29, 2025
@ayush22667 ayush22667 changed the title fea(router)t: Add v2 payment cancellation flow fea(router): Add v2 payment cancellation flow Aug 29, 2025
@ayush22667 ayush22667 changed the title fea(router): Add v2 payment cancellation flow feat(router): Add v2 payment cancellation flow Aug 31, 2025
@prasunna09
Copy link
Contributor

prasunna09 commented Sep 4, 2025

Also can we add a screenshot of connector cancel request and response in the test cases

@ayush22667 ayush22667 force-pushed the feat/paymentcancel_v2 branch 3 times, most recently from 88f81b4 to f2f7577 Compare September 4, 2025 11:10
@ayush22667 ayush22667 requested review from prasunna09 and removed request for prasunna09 September 8, 2025 05:48
@ayush22667 ayush22667 removed the request for review from su-shivanshmathur September 11, 2025 05:51
@ayush22667 ayush22667 requested review from prasunna09 and su-shivanshmathur and removed request for prasunna09 and su-shivanshmathur September 11, 2025 05:52
Copy link
Contributor

@prasunna09 prasunna09 left a comment

Choose a reason for hiding this comment

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

no request response types are introduced in pr.
Are reusing the v1 structs?
then that is wrong, we need to add new structs for v2 since v1 has different type for payment id compared to v2

@ayush22667 ayush22667 requested a review from a team as a code owner September 17, 2025 07:44
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Sep 17, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Sep 22, 2025
Merged via the queue into main with commit 617b3fa Sep 22, 2025
21 of 25 checks passed
@likhinbopanna likhinbopanna deleted the feat/paymentcancel_v2 branch September 22, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Payment void endpoint for v2

4 participants