curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/refund \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 10,
"operationId": "e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0",
"refundTransactionType": "Refund",
"metadata": {
"receiptId": "475-0002-000427"
}
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/refund"
payload = {
"amount": 10,
"operationId": "e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0",
"refundTransactionType": "Refund",
"metadata": { "receiptId": "475-0002-000427" }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 10,
operationId: 'e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0',
refundTransactionType: 'Refund',
metadata: {receiptId: '475-0002-000427'}
})
};
fetch('https://{host}/bonus/v2/transactions/{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://{host}/bonus/v2/transactions/{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' => 10,
'operationId' => 'e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0',
'refundTransactionType' => 'Refund',
'metadata' => [
'receiptId' => '475-0002-000427'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://{host}/bonus/v2/transactions/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://{host}/bonus/v2/transactions/{id}/refund")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}"
response = http.request(request)
puts response.read_body{
"transactionId": 9154412,
"remainingCapturedAmount": 10
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Refund a transaction
The POS or your backend calls this to reverse a captured transaction in full or in part, typically to pay a bonus payment back when goods are returned. It creates a new transaction that moves the bonus the other way: a refunded payment puts bonus back on the customer’s account, a refunded accrual takes it off.
Without amount everything that is captured and not refunded yet is reversed. With an amount only that part
is, and the response’s remainingCapturedAmount says what can still be refunded. The refund has the type in
refundTransactionType; left out, a payment is refunded as Refund and any other transaction as its own type.
It carries the original transaction’s metadata, with the pairs in metadata added and, for a key both have,
replacing the original’s.
Only a captured transaction can be refunded. One that is still waiting is refused, and so are a cancelled one, a refund itself and a transfer between two accounts. The customer’s account must be active.
Send an operationId with every refund, and a new one each time: a repeat with the same id returns the first
refund, and the same id with another amount or type is refused with InconsistentRetry. Two refunds of one
transaction without an id count as the same request.
curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/refund \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 10,
"operationId": "e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0",
"refundTransactionType": "Refund",
"metadata": {
"receiptId": "475-0002-000427"
}
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/refund"
payload = {
"amount": 10,
"operationId": "e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0",
"refundTransactionType": "Refund",
"metadata": { "receiptId": "475-0002-000427" }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 10,
operationId: 'e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0',
refundTransactionType: 'Refund',
metadata: {receiptId: '475-0002-000427'}
})
};
fetch('https://{host}/bonus/v2/transactions/{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://{host}/bonus/v2/transactions/{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' => 10,
'operationId' => 'e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0',
'refundTransactionType' => 'Refund',
'metadata' => [
'receiptId' => '475-0002-000427'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://{host}/bonus/v2/transactions/{id}/refund"
payload := strings.NewReader("{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://{host}/bonus/v2/transactions/{id}/refund")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 10,\n \"operationId\": \"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0\",\n \"refundTransactionType\": \"Refund\",\n \"metadata\": {\n \"receiptId\": \"475-0002-000427\"\n }\n}"
response = http.request(request)
puts response.read_body{
"transactionId": 9154412,
"remainingCapturedAmount": 10
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Authorizations
Path Parameters
Body
What to refund.
What to refund of a captured transaction.
Your unique id for this refund, at most 128 characters, never used for another transaction. Optional, but without it one partial refund cannot be told from the next. Send the same id only when you repeat the same request.
128"e5d4c3b2-a190-4f8e-b7c6-d5e4f3a2b1c0"
Response
The amount was refunded, or an earlier call with the same operationId had refunded it already. transactionId is the id of the refund transaction.