Skip to main content

Refunds V2 (Sandbox)

The Refunds API V2 lets you create total or partial refunds of an approved transaction, with support for up to 5 custom references and the ability to simulate deterministic scenarios in the Sandbox environment.

V2 Endpoint

The new refunds version is exposed at the POST /v1/refunds endpoint.

Sandbox applicability

The Sandbox simulator for refunds applies only to the new version (V2) exposed at POST /v1/refunds. The legacy version (V1) at POST /v1/transactions/:id/refunds does not process the extended reference attributes nor interact with the Sandbox V2 logic.

Authentication

The Refunds API V2 strictly requires a Private Key (prv_*) sent as a Bearer token.

  • Required header: Authorization: Bearer <PRIVATE_KEY>
  • Sandbox: prv_test_...
  • Production: prv_prod_...
Security restriction

Unauthenticated requests or requests using a Public Key (pub_*) are not allowed and will return 401 Unauthorized / 403 Forbidden.

Request contract (Request Body V2)

FieldTypeRequiredDescription
transaction_idstringYesID of the approved transaction to be refunded.
amount_in_centsintegerYesTotal or partial amount, in cents, to refund. Example: for $100.00 use 10000.
reasonstringNoRefund reason.
referencestringNoCustom reference 1.
reference_2stringNoCustom reference 2.
reference_3stringNoCustom reference 3.
reference_4stringNoCustom reference 4.
reference_5stringNoCustom reference 5.
{
"transaction_id": "trx_test_123456789",
"amount_in_cents": 15000,
"reason": "Customer request",
"reference": "REF_001",
"reference_2": "REF_002",
"reference_3": "REF_003",
"reference_4": "REF_004",
"reference_5": "REF_005"
}

Request example (cURL)

curl -i -X POST https://api-sandbox.wompi.pa/v1/refunds \
-H "Authorization: Bearer prv_test_XXXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "1688-1788842576-38603",
"amount_in_cents": 15000,
"reason": "Customer request",
"reference": "REF_001",
"reference_2": "REF_002",
"reference_3": "REF_003",
"reference_4": "REF_004",
"reference_5": "REF_005"
}'

Successful response example

{
"data": {
"id": 1523,
"status": "APPROVED",
"status_message": "",
"v2_refund_id": "v2_refund_abc123",
"amount_in_cents": 15000,
"transaction_id": "1688-1788842576-38603",
"reference": "REF_001",
"reference_2": "REF_002",
"reference_3": "REF_003",
"reference_4": "REF_004",
"reference_5": "REF_005",
"created_at": "2024-01-15 14:30:45 UTC"
}
}

Sandbox test scenarios

In Sandbox you can deterministically simulate the five final states of a refund. Each state is reached via the test_scenario field in the request, and all requests must pass pre-validation checks.

ScenarioSandbox test conditionExpected responseHTTP code
1. Approved (Successful)test_scenario: "approved" + transaction_id of approved transaction + amount_in_cents valid according to check_amount_restrictionAPPROVED status, assignment of v2_refund_id, and the references reflected in the response201 Created
2. Declined (Time limit)test_scenario: "declined"DECLINED status, status_message: "Tiempo límite sin encontrar fondos excedido", cancelled_at: null201 Created
3. Error (Technical)test_scenario: "error"ERROR status, status_message: "Error en la comunicación con el autorizador", cancelled_at: null201 Created
4. Cancelled (By merchant)test_scenario: "cancelled"CANCELLED status, status_message: null, cancelled_at: [timestamp]201 Created
5. Validation (More than 5 references)Include more than 5 reference fields in the requestUNPROCESSABLE ENTITY status with error code INPUT_VALIDATION_ERROR422 Unprocessable Entity

Regional availability

The Refunds API V2 is available for:

API reference

See the full endpoint detail in the API reference.