Refund or Void Payment
curl --request POST \
--url https://api.example.com/payments \
--header 'Content-Type: application/json' \
--data '
{
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.parentPaymentId": "<string>",
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>"
},
"data.attributes.miscData": "<string>"
}
'import requests
url = "https://api.example.com/payments"
payload = {
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.parentPaymentId": "<string>",
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>"
},
"data.attributes.miscData": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
'data.type': '<string>',
'data.attributes': {},
'data.attributes.paymentType': '<string>',
'data.attributes.parentPaymentId': '<string>',
'data.attributes.transaction': {
'data.attributes.transaction.amount': '<string>',
'data.attributes.transaction.currency': '<string>'
},
'data.attributes.miscData': '<string>'
})
};
fetch('https://api.example.com/payments', 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.example.com/payments",
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([
'data.type' => '<string>',
'data.attributes' => [
],
'data.attributes.paymentType' => '<string>',
'data.attributes.parentPaymentId' => '<string>',
'data.attributes.transaction' => [
'data.attributes.transaction.amount' => '<string>',
'data.attributes.transaction.currency' => '<string>'
],
'data.attributes.miscData' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/payments"
payload := strings.NewReader("{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/payments")
.header("Content-Type", "application/json")
.body("{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Refund amount exceeds original transaction amount"
}
]
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Parent payment not found"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "Payment has already been fully refunded"
}
]
}
Payments
Refund or Void Payment
Refund a completed payment or void an eligible transaction
POST
/
payments
Refund or Void Payment
curl --request POST \
--url https://api.example.com/payments \
--header 'Content-Type: application/json' \
--data '
{
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.parentPaymentId": "<string>",
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>"
},
"data.attributes.miscData": "<string>"
}
'import requests
url = "https://api.example.com/payments"
payload = {
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.parentPaymentId": "<string>",
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>"
},
"data.attributes.miscData": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
'data.type': '<string>',
'data.attributes': {},
'data.attributes.paymentType': '<string>',
'data.attributes.parentPaymentId': '<string>',
'data.attributes.transaction': {
'data.attributes.transaction.amount': '<string>',
'data.attributes.transaction.currency': '<string>'
},
'data.attributes.miscData': '<string>'
})
};
fetch('https://api.example.com/payments', 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.example.com/payments",
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([
'data.type' => '<string>',
'data.attributes' => [
],
'data.attributes.paymentType' => '<string>',
'data.attributes.parentPaymentId' => '<string>',
'data.attributes.transaction' => [
'data.attributes.transaction.amount' => '<string>',
'data.attributes.transaction.currency' => '<string>'
],
'data.attributes.miscData' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/payments"
payload := strings.NewReader("{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/payments")
.header("Content-Type", "application/json")
.body("{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.parentPaymentId\": \"<string>\",\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\"\n },\n \"data.attributes.miscData\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Refund amount exceeds original transaction amount"
}
]
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Parent payment not found"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "Payment has already been fully refunded"
}
]
}
Endpoint
POST https://api.digitzs.com/payments
Overview
Use this endpoint to refund a payment or void an eligible transaction. The system automatically determines whether to perform a refund or void based on the transaction timing and type.Void vs Refund: If the transaction is eligible to be voided, the system will perform a void instead of a refund. Voids are processed faster and don’t incur additional processing fees.
Void Eligibility
Transactions can be voided under these conditions:- Card Transactions: Can be voided before 11:59 PM PST on the same day the transaction was processed
- ACH Transactions: Cannot be voided through the API. Contact support for ACH transaction issues.
Authentication
| Header | Value | Required |
|---|---|---|
x-api-key | Your API key from onboarding | Yes |
Authorization | Bearer {appToken} | Yes |
appId | Your application ID | Yes |
Content-Type | application/json | Yes |
Request Body
string
required
Must be
"payments"object
required
Container for payment attributes
string
required
Must be
"refund" for refund/void operationsstring
required
The payment ID of the original transaction to refund or void
object
required
string
Optional JSON string with refund reason or additional metadata
Example Request - Full Refund
{
"data": {
"type": "payments",
"attributes": {
"paymentType": "refund",
"parentPaymentId": "pay_abc123xyz",
"transaction": {
"amount": "2500",
"currency": "USD"
},
"miscData": "{\"reason\":\"customer_request\",\"notes\":\"Item damaged\"}"
}
}
}
Example Request - Partial Refund
{
"data": {
"type": "payments",
"attributes": {
"paymentType": "refund",
"parentPaymentId": "pay_abc123xyz",
"transaction": {
"amount": "1000",
"currency": "USD"
},
"miscData": "{\"reason\":\"partial_return\"}"
}
}
}
Response
Success Response (201 Created)
{
"links": {
"self": "https://api.digitzs.com/payments"
},
"data": {
"type": "payments",
"id": "pay_refund_xyz789",
"attributes": {
"paymentType": "refund",
"parentPaymentId": "pay_abc123xyz",
"transaction": {
"code": "0",
"message": "Success",
"amount": "2500",
"currency": "USD",
"refundType": "void"
}
}
}
}
string
Indicates whether transaction was voided (
"void") or refunded ("refund")Code Examples
curl -X POST https://api.digitzs.com/payments \
-H "x-api-key: your-api-key" \
-H "Authorization: Bearer your-app-token" \
-H "appId: your-app-id" \
-H "Content-Type: application/json" \
-d '{
"data": {
"type": "payments",
"attributes": {
"paymentType": "refund",
"parentPaymentId": "pay_abc123xyz",
"transaction": {
"amount": "2500",
"currency": "USD"
}
}
}
}'
const axios = require('axios');
async function refundPayment(paymentId, amount) {
const response = await axios.post(
'https://api.digitzs.com/payments',
{
data: {
type: 'payments',
attributes: {
paymentType: 'refund',
parentPaymentId: paymentId,
transaction: {
amount: amount,
currency: 'USD'
}
}
}
},
{
headers: {
'x-api-key': 'your-api-key',
'Authorization': 'Bearer your-app-token',
'appId': 'your-app-id',
'Content-Type': 'application/json'
}
}
);
const refundType = response.data.data.attributes.transaction.refundType;
console.log(`${refundType === 'void' ? 'Voided' : 'Refunded'} payment:`, response.data.data.id);
return response.data;
}
// Refund $25.00
refundPayment('pay_abc123xyz', '2500');
import requests
def refund_payment(payment_id, amount):
url = "https://api.digitzs.com/payments"
headers = {
"x-api-key": "your-api-key",
"Authorization": "Bearer your-app-token",
"appId": "your-app-id",
"Content-Type": "application/json"
}
payload = {
"data": {
"type": "payments",
"attributes": {
"paymentType": "refund",
"parentPaymentId": payment_id,
"transaction": {
"amount": amount,
"currency": "USD"
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
refund_type = response.json()["data"]["attributes"]["transaction"]["refundType"]
refund_id = response.json()["data"]["id"]
print(f"{'Voided' if refund_type == 'void' else 'Refunded'} payment: {refund_id}")
return response.json()
# Refund $25.00
refund_payment("pay_abc123xyz", "2500")
<?php
function refundPayment($paymentId, $amount) {
$url = "https://api.digitzs.com/payments";
$headers = [
"x-api-key: your-api-key",
"Authorization: Bearer your-app-token",
"appId: your-app-id",
"Content-Type: application/json"
];
$payload = json_encode([
"data" => [
"type" => "payments",
"attributes" => [
"paymentType" => "refund",
"parentPaymentId" => $paymentId,
"transaction" => [
"amount" => $amount,
"currency" => "USD"
]
]
]
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 201) {
$data = json_decode($response, true);
$refundType = $data["data"]["attributes"]["transaction"]["refundType"];
$action = $refundType === "void" ? "Voided" : "Refunded";
echo "$action payment: " . $data["data"]["id"] . "\n";
return $data;
} else {
throw new Exception("Error: " . $response);
}
}
// Refund $25.00
refundPayment("pay_abc123xyz", "2500");
?>
require 'net/http'
require 'json'
require 'uri'
def refund_payment(payment_id, amount)
uri = URI('https://api.digitzs.com/payments')
request = Net::HTTP::Post.new(uri)
request['x-api-key'] = 'your-api-key'
request['Authorization'] = 'Bearer your-app-token'
request['appId'] = 'your-app-id'
request['Content-Type'] = 'application/json'
request.body = {
data: {
type: 'payments',
attributes: {
paymentType: 'refund',
parentPaymentId: payment_id,
transaction: {
amount: amount,
currency: 'USD'
}
}
}
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.code == '201'
data = JSON.parse(response.body)
refund_type = data['data']['attributes']['transaction']['refundType']
action = refund_type == 'void' ? 'Voided' : 'Refunded'
puts "#{action} payment: #{data['data']['id']}"
data
else
raise "Error: #{response.body}"
end
end
# Refund $25.00
refund_payment('pay_abc123xyz', '2500')
Void vs Refund Comparison
| Feature | Void | Refund |
|---|---|---|
| Timing | Same day before 11:59 PM PST | Any time after settlement |
| Processing Speed | Immediate | 3-10 business days |
| Additional Fees | None | May incur refund processing fees |
| Fund Return | Instantly released on customer’s card | Processed as credit to customer’s card |
| Transaction Record | Transaction cancelled | New refund transaction created |
Error Responses
{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Refund amount exceeds original transaction amount"
}
]
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Parent payment not found"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "Payment has already been fully refunded"
}
]
}
Common Error Scenarios
Payment not found
Payment not found
Error: 404 Not FoundSolution: Verify the parentPaymentId is correct and the payment exists in your account.
Refund amount exceeds original
Refund amount exceeds original
Error: 400 Bad RequestSolution: Ensure the refund amount doesn’t exceed the original transaction amount or the remaining refundable balance.
Payment already refunded
Payment already refunded
Error: 422 Unprocessable EntitySolution: Check the payment status. If already fully refunded, no additional refunds are possible.
ACH refund attempted
ACH refund attempted
Error: 422 Unprocessable EntitySolution: Contact Digitzs support for ACH refund processing. ACH refunds require special handling.
Important Notes
ACH Transactions: Do not use this endpoint for ACH transactions. Contact Digitzs support for ACH refund assistance.
Partial Refunds: Multiple partial refunds are supported up to the original transaction amount.
Void Window: Process refunds on the same day before 11:59 PM PST to get instant voids instead of multi-day refunds.
Best Practices
- Check Timing: If same-day, consider the void window for faster processing
- Track Refunds: Monitor all refund transactions for reconciliation
- Document Reasons: Use miscData to record why refunds were issued
- Validate Amounts: Ensure refund amount doesn’t exceed original or remaining balance
- Customer Communication: Inform customers about refund processing time (instant void vs 3-10 day refund)
- Handle Splits: Use the split refund endpoint for split payments
Next Steps
Refund Split Payment
Learn how to refund split payments
Get Payment Status
Check refund status
⌘I

