curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/capture \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"operationId": "b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60",
"amount": 20,
"cancelRemainingAmount": true,
"metadata": {
"receiptId": "475-0002-000381"
}
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/capture"
payload = {
"operationId": "b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60",
"amount": 20,
"cancelRemainingAmount": True,
"metadata": { "receiptId": "475-0002-000381" }
}
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: 'b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60',
amount: 20,
cancelRemainingAmount: true,
metadata: {receiptId: '475-0002-000381'}
})
};
fetch('https://{host}/bonus/v2/transactions/{id}/capture', 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}/capture",
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' => 'b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60',
'amount' => 20,
'cancelRemainingAmount' => true,
'metadata' => [
'receiptId' => '475-0002-000381'
]
]),
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}/capture"
payload := strings.NewReader("{\n \"operationId\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\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}/capture")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operationId\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/capture")
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\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\n }\n}"
response = http.request(request)
puts response.read_body{
"state": "Successful",
"remainingReservedAmount": 0
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Capture a transaction
The POS or your backend calls this when the purchase behind a waiting transaction is final, to book what was
reserved. Without amount everything that is still reserved is captured. With an amount only that part is
captured, and the rest stays reserved for a later capture or cancel, unless cancelRemainingAmount is true,
which releases the rest in the same call. When nothing is left reserved the transaction becomes Successful.
metadata adds key-value pairs to the transaction, for example a receiptId that is known only now. A key the
transaction has already cannot be changed here.
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. Use a new id for each partial
capture.
curl --request POST \
--url https://{host}/bonus/v2/transactions/{id}/capture \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"operationId": "b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60",
"amount": 20,
"cancelRemainingAmount": true,
"metadata": {
"receiptId": "475-0002-000381"
}
}
'import requests
url = "https://{host}/bonus/v2/transactions/{id}/capture"
payload = {
"operationId": "b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60",
"amount": 20,
"cancelRemainingAmount": True,
"metadata": { "receiptId": "475-0002-000381" }
}
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: 'b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60',
amount: 20,
cancelRemainingAmount: true,
metadata: {receiptId: '475-0002-000381'}
})
};
fetch('https://{host}/bonus/v2/transactions/{id}/capture', 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}/capture",
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' => 'b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60',
'amount' => 20,
'cancelRemainingAmount' => true,
'metadata' => [
'receiptId' => '475-0002-000381'
]
]),
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}/capture"
payload := strings.NewReader("{\n \"operationId\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\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}/capture")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operationId\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v2/transactions/{id}/capture")
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\": \"b74e0c1d-9f3a-4a52-8c6b-1e2d3f4a5b60\",\n \"amount\": 20,\n \"cancelRemainingAmount\": true,\n \"metadata\": {\n \"receiptId\": \"475-0002-000381\"\n }\n}"
response = http.request(request)
puts response.read_body{
"state": "Successful",
"remainingReservedAmount": 0
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Authorizations
Body
What to capture.
What to capture of a waiting transaction.
Response
The amount was captured, or an earlier call with the same operationId had captured it already.
Where the transaction stands after the capture.
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 "Successful"