> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.alphax.asia/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.alphax.asia/_mcp/server.

# AXCS Refund

A refund sends the money from a card payment back to the customer's card. You start it with one API call from your backend.

## Before you start

You can refund a payment when:

* It is a card payment taken through the [Card Payment SDK](/payments/card-payment-sdk).
* Its status is `AUTHORIZED`.
* It has not been refunded already. Each payment can be refunded only once.

You need the payment's transaction ID. It is the `ulid` returned when you [confirmed the payment](/api-reference/alpha-x-api/card-payments/confirm-card-payment).

## Refund a payment

From your backend, call the [Refund transaction API](/api-reference/alpha-x-api/transactions/refund-transaction) with the transaction ID in the URL. There is no request body. Authenticate with your API key (see [Authentication](/authentication)).

> **Warning**
>
> Never call this API from the browser. Your API key must stay on your server.

```bash
curl -X POST https://public-api.alphax.asia/v1/transactions/01kqc6aaq3jshqyz6a0k8nkxfe/refund \
  -H "X-API-Key: YOUR_API_KEY"
```

If the refund works, you get back the transaction ID and its new status:

```json
{
  "id": "01kqc6aaq3jshqyz6a0k8nkxfe",
  "status": "REFUNDED"
}
```

## When a refund fails

If the payment can't be refunded, you get a `400` response with an `error` message:

```json
{
  "error": "This transaction has already been refunded."
}
```

| Error                                                   | What it means                                                  | What to do                                    |
| ------------------------------------------------------- | -------------------------------------------------------------- | --------------------------------------------- |
| `Invalid request`                                       | Your company doesn't take payments through AlphaX.             | Contact AlphaX support.                       |
| `Invalid transaction.`                                  | The transaction is not a card payment.                         | Check that you used the right transaction ID. |
| `This transaction has already been refunded.`           | The money was already sent back.                               | Nothing. The customer has their refund.       |
| `Only authorized transactions can be refunded.`         | The payment did not go through, so there is nothing to refund. | Check the payment status first.               |
| `Failed to refund the payment. Please try again later.` | Something went wrong on our side or at the card network.       | Wait a moment and try again.                  |

If the transaction ID doesn't exist, or belongs to another company, you get a `404` response instead.

## Try it on demo

On the demo environment (`https://public-api.demo.alphax.asia`), take a payment with one of the [AXCS test cards](/payments/axcs-test-cards), then refund it with the call above.