> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zabcik.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Refunds

> How to create refunds and inspect refund history with the GoPay SDK.

# Refunds

<Info>
  Refunds apply to **captured** or settled payments. Partial refunds specify `amount` in the same **minor units** as the original payment currency.
</Info>

Use refunds when you need to return funds for an already processed payment.

## Full refund or partial refund

```ts theme={null}
const result = await client.refundPayment(paymentId, {
  amount: 10000, // amount in minor units
});

console.log(result.id, result.result);
```

> `amount` is required and is sent as URL-encoded form data according to the GoPay endpoint expectations.

## Refund history

```ts theme={null}
const refunds = await client.getPaymentRefunds(paymentId);

for (const refund of refunds) {
  console.log(refund.id, refund.state, refund.amount, refund.currency);
}
```

`RefundHistoryItem` includes:

* `id`
* `state`
* `amount`
* `currency`
* `date_requested`
* `date_last_change?`

## Refund best practices

* Persist refund metadata in your database (refund ID, amount, request timestamp).
* Keep refund amounts in minor units for consistency.
* Build idempotent refund workflows to avoid duplicate requests from retries.
