curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/cancel \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"operationId": "c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21",
"amount": 5.5
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/cancel"
payload = {
"operationId": "c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21",
"amount": 5.5
}
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({operationId: 'c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21', amount: 5.5})
};
fetch('https://{host}/bonus/v2/transactions/{id}/cancel', 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}/cancel",
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([
'operationId' => 'c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21',
'amount' => 5.5
]),
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}/cancel"
payload := strings.NewReader("{\n \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\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}/cancel")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/cancel")
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 \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\n}"
response = http.request(request)
puts response.read_body{
"state": "Waiting",
"remainingReservedAmount": 20
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Cancel a transaction
The POS or your backend calls this to release what a waiting transaction has reserved, for example when a
purchase is abandoned or comes out cheaper than what was reserved. A reserved payment goes back to the
customer’s available balance. Without amount everything that is still reserved is released; with an amount
only that part.
When nothing is left reserved the transaction becomes Cancelled, or Successful when a part of it was
captured before. A final transaction cannot be cancelled; pay a captured payment back with
POST /v2/transactions/{id}/refund.
The call is idempotent on operationId within the transaction: repeating it with the same id returns the first
answer, and the same id with another amount is refused with InconsistentRetry.
curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/cancel \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"operationId": "c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21",
"amount": 5.5
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/cancel"
payload = {
"operationId": "c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21",
"amount": 5.5
}
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({operationId: 'c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21', amount: 5.5})
};
fetch('https://{host}/bonus/v2/transactions/{id}/cancel', 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}/cancel",
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([
'operationId' => 'c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21',
'amount' => 5.5
]),
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}/cancel"
payload := strings.NewReader("{\n \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\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}/cancel")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/cancel")
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 \"operationId\": \"c1a9e7d3-2b48-4f60-9d15-7a6b5c4d3e21\",\n \"amount\": 5.5\n}"
response = http.request(request)
puts response.read_body{
"state": "Waiting",
"remainingReservedAmount": 20
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Authorizations
Body
What to release.
What to release of a waiting transaction.
Response
The amount was released, or an earlier call with the same operationId had released it already.
Where the transaction stands after the cancel.
Where a transaction stands.
Waiting: an amount is reserved and waits to be captured or cancelled.Successful: the transaction is final. Its amount was captured, in full or in part with the rest cancelled.Cancelled: the whole reservation was cancelled and nothing was captured.
This list is not final. Lobyco may add a value at any time, and a consumer must not fail on a value it does not know.
Waiting, Successful, Cancelled "Waiting"