> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/prism/node/payment-service/refund.md).

# Refund

## Overview

The `refund` method returns funds to a customer's payment method after a successful payment. Use this for returns, cancellations after fulfillment, or goodwill adjustments.

**Business Use Case:** A customer returns an item they purchased. The original payment was already captured. You process a refund to return their money.

## Purpose

**Why use refund?**

| Scenario                                                        | Benefit |
| --------------------------------------------------------------- | ------- |
| **Product returns** - Refund customers for returned merchandise |         |
| **Service cancellation** - Refund for unrendered services       |         |
| **Goodwill gestures** - Partial refunds for service issues      |         |
| **Duplicate charges** - Correct accidental charges              |         |

## Request Fields

| Field                    | Type   | Required | Description                                     |
| ------------------------ | ------ | -------- | ----------------------------------------------- |
| `merchantRefundId`       | string | Yes      | Your unique refund reference                    |
| `connectorTransactionId` | string | Yes      | The connector's transaction ID from the payment |
| `refundAmount`           | Money  | Yes      | Amount to refund (can be partial)               |
| `reason`                 | string | No       | Reason for refund                               |
| `metadata`               | object | No       | Additional data (max 20 keys)                   |

## Response Fields

| Field               | Type         | Description                                |
| ------------------- | ------------ | ------------------------------------------ |
| `merchantRefundId`  | string       | Your refund reference (echoed back)        |
| `connectorRefundId` | string       | Connector's refund ID (e.g., re\_xxx)      |
| `status`            | RefundStatus | Current status: PENDING, SUCCEEDED, FAILED |
| `refundAmount`      | Money        | Refund amount                              |
| `error`             | ErrorInfo    | Error details if status is FAILED          |
| `statusCode`        | number       | HTTP-style status code (200, 422, etc.)    |

## Example

### SDK Setup

```javascript
const { PaymentClient } = require('hyperswitch-prism');

const paymentClient = new PaymentClient({
    connector: 'stripe',
    apiKey: 'YOUR_API_KEY',
    environment: 'SANDBOX'
});
```

### Request

```javascript
const request = {
    merchantRefundId: "refund_001",
    connectorTransactionId: "pi_3Oxxx...",
    refundAmount: {
        minorAmount: 1000,
        currency: "USD"
    },
    reason: "Customer returned item"
};

const response = await paymentClient.refund(request);
```

### Response

```javascript
{
    merchantRefundId: "refund_001",
    connectorRefundId: "re_3Oxxx...",
    status: "PENDING",
    refundAmount: {
        minorAmount: 1000,
        currency: "USD"
    },
    statusCode: 200
}
```

## Refund vs Void vs Reverse

| Action      | When to Use                               | Timeline           |
| ----------- | ----------------------------------------- | ------------------ |
| **Void**    | Before capture, during authorization hold | Same day           |
| **Reverse** | After capture, before settlement          | Same day           |
| **Refund**  | After settlement                          | 5-10 business days |

## Next Steps

* [getRefund](/integrations/prism/node/refund-service/get.md) - Check refund status
* [capture](/integrations/prism/node/payment-service/capture.md) - Ensure payment is captured before refunding
* [void](/integrations/prism/node/payment-service/void.md) - Cancel if still in authorized state


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hyperswitch.io/integrations/prism/node/payment-service/refund.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
