Skip to content

feat(refunds_v2): Add refund update core flow in v2 apis#7724

Merged
Gnanasundari24 merged 14 commits intomainfrom
refunds-v2-update-flow
May 13, 2025
Merged

feat(refunds_v2): Add refund update core flow in v2 apis#7724
Gnanasundari24 merged 14 commits intomainfrom
refunds-v2-update-flow

Conversation

@AmeyWale
Copy link
Contributor

@AmeyWale AmeyWale commented Apr 4, 2025

Type of Change

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

Description

This PR contains refunds update flow for v2 apis. It is a part of v2 implementation of refunds.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Merging this pr will add refunds update flow to the hyperswitch v2 apis, merchants can update refunds with v2 apis.

How did you test it?

  • Create Refund API Call
curl --location 'http://localhost:8080/v2/refunds' \
--header 'X-Profile-Id: pro_AL59Mhfn1eDbm5FtUXao' \
--header 'Content-Type: application/json' \
--header 'Authorization: api-key=dev_t3GJeRLga4fvpMYfeA26gnjD5jwPWUFA9gbGdUfRwujMbWd54GDi5YjhcbmL5WiQ' \
--data '{
    "payment_id":"12345_pay_01966ca5ba0f781394e31ca377c045c1",
    "merchant_reference_id":"1745579609",
    "reason":"Paid by mistake",
    "metadata":{
        "foo":"bar"
    }
}'
  • Response from the above call
{
    "id": "12345_ref_01966ca5cdd87781af1426c620531fb5",
    "payment_id": "12345_pay_01966ca5ba0f781394e31ca377c045c1",
    "merchant_reference_id": "1745579528",
    "amount": 100,
    "currency": "USD",
    "status": "succeeded",
    "reason": "Paid by mistake",
    "metadata": {
        "foo": "bar"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-04-25T11:12:07.651Z",
    "updated_at": "2025-04-25T11:12:08.717Z",
    "connector": "stripe",
    "profile_id": "pro_AL59Mhfn1eDbm5FtUXao",
    "merchant_connector_id": "mca_rAbIwlE7su9DkFILFzSO",
    "connector_refund_reference_id": null
}
  • Update Refund API Call
curl --location --request PUT 'http://localhost:8080/v2/refunds/12345_ref_01966ca5cdd87781af1426c620531fb5/update_metadata' \
--header 'x-profile-id: pro_AL59Mhfn1eDbm5FtUXao' \
--header 'Content-Type: application/json' \
--header 'Authorization: api-key=dev_t3GJeRLga4fvpMYfeA26gnjD5jwPWUFA9gbGdUfRwujMbWd54GDi5YjhcbmL5WiQ' \
--data '{
    "reason":"Customer asked for refund",
    "metadata": {
        "customer": "Mr bean from IIT Dholakpur"
    }
}'
  • Response from the above call
{
    "id": "12345_ref_01966ca5cdd87781af1426c620531fb5",
    "payment_id": "12345_pay_01966ca5ba0f781394e31ca377c045c1",
    "merchant_reference_id": "1745579528",
    "amount": 100,
    "currency": "USD",
    "status": "succeeded",
    "reason": "Customer asked for refund",
    "metadata": {
        "customer": "Mr bean from IIT Dholakpur"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-04-25T11:12:07.651Z",
    "updated_at": "2025-04-25T11:12:10.581Z",
    "connector": "stripe",
    "profile_id": "pro_AL59Mhfn1eDbm5FtUXao",
    "merchant_connector_id": "mca_rAbIwlE7su9DkFILFzSO",
    "connector_refund_reference_id": 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

@AmeyWale AmeyWale requested review from a team as code owners April 4, 2025 13:18
@semanticdiff-com
Copy link

semanticdiff-com bot commented Apr 4, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/routes/app.rs  50% smaller
  api-reference-v2/openapi_spec.json  36% smaller
  crates/openapi/src/openapi_v2.rs  10% smaller
  crates/api_models/src/refunds.rs  0% smaller
  crates/openapi/src/routes/refunds.rs  0% smaller
  crates/router/src/core/refunds_v2.rs Unsupported file format
  crates/router/src/routes/refunds.rs  0% smaller
  crates/router/src/types/api/refunds.rs  0% smaller

@AmeyWale AmeyWale self-assigned this Apr 4, 2025
@AmeyWale AmeyWale linked an issue Apr 4, 2025 that may be closed by this pull request
@AmeyWale AmeyWale added the api-v2 label Apr 4, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Apr 4, 2025
hrithikesh026
hrithikesh026 previously approved these changes Apr 7, 2025
jarnura
jarnura previously approved these changes Apr 7, 2025
Base automatically changed from refunds-create-core-flow to main April 21, 2025 09:19
@likhinbopanna likhinbopanna dismissed stale reviews from jarnura and hrithikesh026 April 21, 2025 09:19

The base branch was changed.

@AmeyWale AmeyWale requested a review from a team as a code owner April 21, 2025 09:19
@AmeyWale AmeyWale force-pushed the refunds-v2-update-flow branch from 3ee76c6 to d3a45a5 Compare April 21, 2025 10:54
hrithikesh026
hrithikesh026 previously approved these changes Apr 24, 2025
jarnura
jarnura previously approved these changes Apr 25, 2025
tsdk02
tsdk02 previously approved these changes Apr 29, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Apr 30, 2025
@AmeyWale AmeyWale dismissed stale reviews from tsdk02 and jarnura via 10c2d28 May 2, 2025 07:07
jarnura
jarnura previously approved these changes May 2, 2025
hrithikesh026
hrithikesh026 previously approved these changes May 8, 2025
jarnura
jarnura previously approved these changes May 8, 2025
@AmeyWale AmeyWale dismissed stale reviews from jarnura and hrithikesh026 via bf6fa47 May 13, 2025 05:41
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 13, 2025
Merged via the queue into main with commit 04dc14a May 13, 2025
14 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the refunds-v2-update-flow branch May 13, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[FEATURE] Add refunds update flow in v2 apis

5 participants