curl --request POST \
--url https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation \
--header 'Content-Type: application/json' \
--data '
{
"reservedBy": "pos-475-2",
"couponIds": [
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
}
'import requests
url = "https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation"
payload = {
"reservedBy": "pos-475-2",
"couponIds": ["6679b89b-f37c-46d0-a3cd-0a25302e75a9", "168f3e64-da3f-4f48-acbb-552d66110e77"]
}
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({
reservedBy: 'pos-475-2',
couponIds: ['6679b89b-f37c-46d0-a3cd-0a25302e75a9', '168f3e64-da3f-4f48-acbb-552d66110e77']
})
};
fetch('https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation', 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}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation",
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([
'reservedBy' => 'pos-475-2',
'couponIds' => [
'6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'168f3e64-da3f-4f48-acbb-552d66110e77'
]
]),
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://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation"
payload := strings.NewReader("{\n \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\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://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation")
.header("Content-Type", "application/json")
.body("{\n \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation")
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 \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"couponIds": [
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Cancel coupon reservation
The POS calls this when a sale is abandoned after coupons were reserved, so the customer can use them elsewhere straight away. Send the coupon ids and the reservedBy the reservation was made with. An unreleased reservation ends by itself at its reservedUntil time.
Every coupon must be found and, if it is reserved, reserved under the reservedBy sent; otherwise the call is refused and nothing is released. A coupon that is not reserved, or whose reservation has expired, is accepted and returned as released.
For a basket priced by Lobyco’s discount calculation, send the basket’s id or the purchase’s receiptId as reservedBy: that is what the calculation reserved the coupons under.
curl --request POST \
--url https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation \
--header 'Content-Type: application/json' \
--data '
{
"reservedBy": "pos-475-2",
"couponIds": [
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
}
'import requests
url = "https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation"
payload = {
"reservedBy": "pos-475-2",
"couponIds": ["6679b89b-f37c-46d0-a3cd-0a25302e75a9", "168f3e64-da3f-4f48-acbb-552d66110e77"]
}
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({
reservedBy: 'pos-475-2',
couponIds: ['6679b89b-f37c-46d0-a3cd-0a25302e75a9', '168f3e64-da3f-4f48-acbb-552d66110e77']
})
};
fetch('https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation', 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}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation",
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([
'reservedBy' => 'pos-475-2',
'couponIds' => [
'6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'168f3e64-da3f-4f48-acbb-552d66110e77'
]
]),
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://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation"
payload := strings.NewReader("{\n \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\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://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation")
.header("Content-Type", "application/json")
.body("{\n \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-reservation")
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 \"reservedBy\": \"pos-475-2\",\n \"couponIds\": [\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"couponIds": [
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Headers
Body
The coupons to release and who reserved them.
The coupons to release and who reserved them.