Refund
curl --request POST \
--url https://api.sandbox.zafapay.com/v1/payments/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 5.5,
"currency": "sgd",
"reason": "Customer request"
}
'import requests
url = "https://api.sandbox.zafapay.com/v1/payments/{id}/refund"
payload = {
"amount": 5.5,
"currency": "sgd",
"reason": "Customer request"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 5.5, currency: 'sgd', reason: 'Customer request'})
};
fetch('https://api.sandbox.zafapay.com/v1/payments/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.zafapay.com/v1/payments/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 5.5,
'currency' => 'sgd',
'reason' => 'Customer request'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.zafapay.com/v1/payments/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.zafapay.com/v1/payments/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.zafapay.com/v1/payments/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}"
response = http.request(request)
puts response.read_body{
"id": "orf_xyz789",
"transaction_id": "tx_abc123",
"amount": "5.50",
"status": "succeeded",
"psp_refund_id": "re_xxxxx",
"refund_fee": "1.00"
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}Payments
Refund
Refund a completed payment
POST
/
v1
/
payments
/
{id}
/
refund
Refund
curl --request POST \
--url https://api.sandbox.zafapay.com/v1/payments/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 5.5,
"currency": "sgd",
"reason": "Customer request"
}
'import requests
url = "https://api.sandbox.zafapay.com/v1/payments/{id}/refund"
payload = {
"amount": 5.5,
"currency": "sgd",
"reason": "Customer request"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 5.5, currency: 'sgd', reason: 'Customer request'})
};
fetch('https://api.sandbox.zafapay.com/v1/payments/{id}/refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.zafapay.com/v1/payments/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 5.5,
'currency' => 'sgd',
'reason' => 'Customer request'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.zafapay.com/v1/payments/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.zafapay.com/v1/payments/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.zafapay.com/v1/payments/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 5.5,\n \"currency\": \"sgd\",\n \"reason\": \"Customer request\"\n}"
response = http.request(request)
puts response.read_body{
"id": "orf_xyz789",
"transaction_id": "tx_abc123",
"amount": "5.50",
"status": "succeeded",
"psp_refund_id": "re_xxxxx",
"refund_fee": "1.00"
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}Authorizations
Bearer authentication using access token
Path Parameters
Transaction ID
Example:
"tx_abc123"
Body
application/json
Refund amount (supports up to 2 decimal places). If omitted, full refund is processed.
Example:
5.5
Currency of the refund amount (3-letter ISO code). Use this when refunding in the original transaction currency (e.g., sgd) that differs from the settlement currency (e.g., usd). The amount will be automatically converted using the original exchange rate.
Example:
"sgd"
Refund reason
Example:
"Customer request"
Response
Refund successful
Refund ID
Example:
"orf_xyz789"
Transaction ID
Example:
"tx_abc123"
Refund amount (string format)
Example:
"5.50"
Refund status
Example:
"succeeded"
PSP refund ID
Example:
"re_xxxxx"
Refund fee (string format)
Example:
"1.00"
⌘I