SettleFlow API
API Reference

POST /v1/refund/direct

Full refund of a previously captured payment (E-PRO compatible)

Refunds the full amount of a captured payment. Partial refunds are not available in V1. See the Refund guide for the narrative version.

Request

POST /v1/refund/direct HTTP/1.1
Host: api.settleflow.io
Content-Type: application/json
epro-api-key: sk_test_...

Body

Provide one of the following identifiers. When both are sent, Reference wins.

FieldTypeDescription
ReferencestringSettleFlow payment request ID returned from /v1/payment/direct.
TidstringYour own transaction reference from the original payment.

Success response

{
  "Code": 0,
  "Result": {
    "OperationType": "refund",
    "Status": "captured",
    "Tid": "order-2026-001",
    "Reference": "ref_xyz789",
    "Amount": 49.99,
    "UserId": "customer-42",
    "Message": "Payment refunded",
    "Date": "2026-04-23 09:12:03"
  }
}

Result fields

FieldTypeDescription
OperationTypestringAlways "refund".
Statusstringcaptured on success, failed otherwise.
TidstringYour original transaction reference.
ReferencestringSettleFlow refund ID (distinct from the payment Reference).
AmountnumberRefunded amount in major currency units.
UserIdstringUid supplied on the original payment.
MessagestringHuman-readable outcome.
DatestringYYYY-MM-DD HH:mm:ss (UTC).

Error response

{ "Code": 102, "Error": "Transaction not found" }
CodeMeaning
1Neither Tid nor Reference supplied
3Invalid API key
4API key missing
102Transaction not found
103Invalid transaction (e.g. already refunded, not captured)

Full list on Error codes.

Examples

cURL

curl -X POST https://api.settleflow.io/v1/refund/direct \
  -H "epro-api-key: sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{ "Reference": "pr_abc123" }'

Node.js

const res = await fetch("https://api.settleflow.io/v1/refund/direct", {
  method: "POST",
  headers: {
    "epro-api-key": process.env.SETTLEFLOW_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ Reference: "pr_abc123" }),
});
const { Code, Result, Error: errMsg } = await res.json();
if (Code !== 0) throw new Error(`[${Code}] ${errMsg}`);

PHP

<?php
$ch = curl_init('https://api.settleflow.io/v1/refund/direct');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'epro-api-key: ' . getenv('SETTLEFLOW_API_KEY'),
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode(['Reference' => 'pr_abc123']),
]);
$body = json_decode(curl_exec($ch), true);
if ($body['Code'] !== 0) {
    throw new \RuntimeException("[{$body['Code']}] {$body['Error']}");
}

Notes

  • Refunds are idempotent against the source payment — a second call returns 103.
  • A REFUND_SUCCEEDED webhook is delivered to the CallbackUrl registered on the original payment. See Webhooks.

On this page