curl --request POST \
--url https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
[
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
'import requests
url = "https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem"
payload = ["6679b89b-f37c-46d0-a3cd-0a25302e75a9", "168f3e64-da3f-4f48-acbb-552d66110e77"]
headers = {
"Idempotency-Key": "<idempotency-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', 'Content-Type': 'application/json'},
body: JSON.stringify(['6679b89b-f37c-46d0-a3cd-0a25302e75a9', '168f3e64-da3f-4f48-acbb-552d66110e77'])
};
fetch('https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem', 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-redeem",
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([
'6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'168f3e64-da3f-4f48-acbb-552d66110e77'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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-redeem"
payload := strings.NewReader("[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-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}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem")
.header("Idempotency-Key", "<idempotency-key>")
.header("Content-Type", "application/json")
.body("[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\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 redemptions
The POS calls this when a customer returns goods, to give the coupons back so the customer can use them again. Send the Idempotency-Key the coupons were redeemed with, that is the sale’s receipt id, and in the body the ids of the coupons to give back. A request cancels redemptions made under that one key; for coupons redeemed on several sales, send one request per sale.
Lobyco cancels the redemption of every coupon it finds under the key, so the coupon counts as unused again and is listed again if it has not expired. Repeating the call changes nothing. An unknown coupon id, or a coupon with no redemption under the key, is reported in the 400 response, and the other coupons are still given back.
Where Lobyco’s refund handling is enabled for your environment, recording the return with the Purchase API gives the coupons back without this call.
curl --request POST \
--url https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
[
"6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"168f3e64-da3f-4f48-acbb-552d66110e77"
]
'import requests
url = "https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem"
payload = ["6679b89b-f37c-46d0-a3cd-0a25302e75a9", "168f3e64-da3f-4f48-acbb-552d66110e77"]
headers = {
"Idempotency-Key": "<idempotency-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', 'Content-Type': 'application/json'},
body: JSON.stringify(['6679b89b-f37c-46d0-a3cd-0a25302e75a9', '168f3e64-da3f-4f48-acbb-552d66110e77'])
};
fetch('https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem', 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-redeem",
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([
'6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'168f3e64-da3f-4f48-acbb-552d66110e77'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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-redeem"
payload := strings.NewReader("[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-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}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem")
.header("Idempotency-Key", "<idempotency-key>")
.header("Content-Type", "application/json")
.body("[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/api/v1/customers/{customerId}/coupons/cancel-redeem")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"168f3e64-da3f-4f48-acbb-552d66110e77\"\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 ids of the coupons to give back, exactly as the coupon list returned them. At least one.