Skip to navigation

AXCS Refund

Give a customer their money back for a card payment.
View as Markdown

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.
  • 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.

Refund a payment

From your backend, call the Refund transaction API with the transaction ID in the URL. There is no request body. Authenticate with your API key (see Authentication).

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

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:

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

When a refund fails

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

{
"error": "This transaction has already been refunded."
}
ErrorWhat it meansWhat to do
Invalid requestYour 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, then refund it with the call above.