# Unreferenced Refund

An **unreferenced refund** is a card-present credit that is **not tied to any original sale**. Instead of pointing at a previous payment, you start a brand new transaction and the customer presents their card at the terminal to receive the money back.

Use this when you need to return funds but don't have, or don't want to use, the original payment's reference. If you do have the original payment, prefer a [Referenced Refund](./refund-payment.md), which links the credit back to the initial sale for cleaner reconciliation.

```admonition
icon: fas fa-exclamation-triangle
content: |
  Unreferenced refunds is currently not open to new applications. You may implement and test but not board any live customers.
```  

```admonition
icon: fas fa-exclamation-triangle
content: |
  Referenced refunds are strongly recommended wherever possible.
  An unreferenced refund sends a credit to a card without any link to a prior payment. Because there is no original transaction to validate against, these refunds are subject to additional fraud screening. As a result:
    - Some merchants may not be eligible to process unreferenced refunds at all.
    - An individual unreferenced refund may be declined even where the same refund would succeed as a referenced refund.
    - Eligibility cannot be reliably predicted, so building exclusively on unreferenced refunds risks unexplained refusals for merchants.
To use referenced refunds, the ePOS stores the `gateway_payment_id` returned when the original payment succeeds - the identifier of the original payment on a successful payment request. This single stored field unlocks automatic validation, lower decline rates, prevention of over-refunds and duplicate refunds, and cleaner reconciliation, since each refund maps directly to its original payment.
  Use unreferenced refunds only where the original `gateway_payment_id` is genuinely unavailable.
```  

## Make an unreferenced refund

Call the `makeUnreferencedRefund` JSON-RPC method. Unlike `refundPayment`, which refunds a specific previous payment by its `gatewayPaymentId` and returns a single result, an unreferenced refund reuses the payment state machine and **streams** state updates, just like `makePaymentAndSubscribe`.

```csharp
public async Task<JsonElement> MakeUnreferencedRefund(string id, int refundAmount)
{
    var refundParams = new
    {
        transactionId = id, // business id for this refund, or a random UUID. Must be unique within the linked store.
        amount = refundAmount, // amount to refund in minor units
        currency = "GBP", // The ISO 4217 currency code (e.g., "GBP", "EUR").
        useTeyaDefaultUi = true, // if true, the SDK app shows an interactive "in progress" UI window
    };
    return await SendRequestAsync("makeUnreferencedRefund", refundParams);
}
```

The SDK app streams state updates the same way as `makePaymentAndSubscribe`: intermediate states arrive as notifications, which have no `id` field in the json-rpc body and are matched by `transactionId`, and the final state is the response to your request. Each update looks like this:

```json
{
  "type": "makeUnreferencedRefund->onPaymentStateChanged",
  "transactionId": "tx-123",
  "amount": 500,
  "currency": "GBP",
  "gatewayRefundId": "tr_019851ef-29f2-70e8-800d-fdd875bfa0a4",
  "state": "SUCCESSFUL",
  "inProgressState": null,
  "isFinal": true,
  "reason": null,
  "transactionTimestamp": 1736175612000,
  "debugErrorMessage": null,
  "metadata": null
}
```

The structure mirrors `makePaymentAndSubscribe->onPaymentStateChanged`, described on the [Make Payment](./make-payment.md) page, with one difference: it carries a **`gatewayRefundId`**, the id of the created refund, instead of `gatewayPaymentId`. You can reuse the same handling for the shared fields `state`, `inProgressState`, `isFinal`, `reason` and `metadata`. If you reuse the `PaymentStateReason` enum from the Make Payment example, add the `FEATURE_NOT_ACTIVATED_UNREFERENCED_REFUNDS` value to it so the refund-specific reason deserializes. See the note below.

```admonition
icon: fas fa-info-circle
content: |
    Unreferenced refunds are **not available for tab, or Pay at Table, payments**.
```

## Re-attach to a refund in progress

If your ePOS loses track of a refund it started, you can re-attach to it with `subscribeToPayment` and the `transactionId` you started it with - see [Subscribe to an existing payment](./make-payment.md#subscribe-to-an-existing-payment).

```admonition
icon: fas fa-warning-triangle
title: Availability
content: |
    Contact us at partnersupport@teya.com to have unreferenced refunds enabled for your account. Until the feature is activated, the refund reaches a failed state whose `reason` field is `FEATURE_NOT_ACTIVATED_UNREFERENCED_REFUNDS` in the state-change payload.
```
