> 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/java/refund-service.md).

# Refund Service Overview

## Overview

The Refund Service helps you track and synchronize refund statuses across payment processors using the Java SDK. While the Payment Service handles initiating refunds, this service provides dedicated operations for retrieving refund information.

**Business Use Cases:**

* **Refund status tracking** - Check the current status of pending refunds to inform customers
* **Financial reconciliation** - Synchronize refund states with your internal accounting systems
* **Webhook processing** - Handle asynchronous refund notifications from payment processors
* **Customer service** - Provide accurate refund status information to support teams

## Operations

| Operation                                               | Description                                                                                                                                 | Use When                                                              |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [`get`](/integrations/prism/java/refund-service/get.md) | Retrieve refund status from the payment processor. Tracks refund progress through processor settlement for accurate customer communication. | Checking refund status, reconciling refund states, customer inquiries |

## SDK Setup

```java
import com.hyperswitch.prism.PaymentClient;

PaymentClient paymentClient = PaymentClient.builder()
    .connector("stripe")
    .apiKey("YOUR_API_KEY")
    .environment("SANDBOX")
    .build();
```

## Common Patterns

### Refund Status Tracking Flow

```mermaid
sequenceDiagram
    participant App as Your App
    participant CS as Prism
    participant PP as Payment Provider

    Note over App: Customer requests refund
    App->>CS: 1. refund (via PaymentService)
    CS->>PP: Initiate refund
    PP-->>CS: Return refund initiated (PENDING)
    CS-->>App: Return connectorRefundId (PENDING)
    Note over App: Customer checks status
    App->>CS: 2. get (check refund status)
    CS->>PP: Retrieve refund status
    PP-->>CS: Return status: PENDING
    CS-->>App: Return status: PENDING
    Note over App: After some time
    App->>CS: 3. get (poll for update)
    CS->>PP: Retrieve refund status
    PP-->>CS: Return status: SUCCEEDED
    CS-->>App: Return status: SUCCEEDED
```

**Flow Explanation:**

1. **Initiate refund** - First, call the Payment Service's `refund` method to initiate the refund.
2. **Check status** - Call the Refund Service's `get` method with the `connectorRefundId`.
3. **Poll for updates** - For refunds that start as PENDING, periodically call `get` to check for status updates.

## Next Steps

* [Payment Service](/integrations/prism/java/payment-service.md) - Initiate refunds and process payments
* [Dispute Service](/integrations/prism/java/dispute-service.md) - Handle chargebacks that may result in refunds
* [Event Service](/integrations/prism/java/event-service.md) - Process asynchronous refund notifications


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
