curl --request POST \
--url https://{host}/coupon/v2/customers/{customerId}/coupons/redeem \
--header 'Content-Type: application/json' \
--data '
{
"storeId": "475",
"receiptId": "R-475-2-000123",
"coupons": [
{
"couponId": "6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"value": 2
},
{
"couponId": "168f3e64-da3f-4f48-acbb-552d66110e77",
"value": 10
}
],
"basketValue": 86.5
}
'import requests
url = "https://{host}/coupon/v2/customers/{customerId}/coupons/redeem"
payload = {
"storeId": "475",
"receiptId": "R-475-2-000123",
"coupons": [
{
"couponId": "6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"value": 2
},
{
"couponId": "168f3e64-da3f-4f48-acbb-552d66110e77",
"value": 10
}
],
"basketValue": 86.5
}
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({
storeId: '475',
receiptId: 'R-475-2-000123',
coupons: [
{couponId: '6679b89b-f37c-46d0-a3cd-0a25302e75a9', value: 2},
{couponId: '168f3e64-da3f-4f48-acbb-552d66110e77', value: 10}
],
basketValue: 86.5
})
};
fetch('https://{host}/coupon/v2/customers/{customerId}/coupons/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/v2/customers/{customerId}/coupons/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([
'storeId' => '475',
'receiptId' => 'R-475-2-000123',
'coupons' => [
[
'couponId' => '6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'value' => 2
],
[
'couponId' => '168f3e64-da3f-4f48-acbb-552d66110e77',
'value' => 10
]
],
'basketValue' => 86.5
]),
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/v2/customers/{customerId}/coupons/redeem"
payload := strings.NewReader("{\n \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\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/v2/customers/{customerId}/coupons/redeem")
.header("Content-Type", "application/json")
.body("{\n \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/v2/customers/{customerId}/coupons/redeem")
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 \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\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
}Redeem coupons
The POS calls this once the sale has completed, to tell Lobyco which coupons it used so they cannot be used again. Send the Idempotency-Key header set to the sale’s receipt id, and in the body the store, the same receipt id, each coupon with the discount it granted, and the sale’s total. Alternatively, put the coupon ids on the purchase the POS records with the Purchase API, under the same receipt id; Lobyco then redeems them when it loads the purchase, and a coupon redeemed both ways counts once.
Lobyco adds a redemption to every coupon it finds, counts it against the offer’s limits and releases the coupon’s reservation. A repeated call with the same Idempotency-Key redeems nothing twice and returns the same ids; a multi-use coupon counts one redemption per key. An unknown coupon id is reported in the 400 response, and the other coupons are still redeemed.
The Idempotency-Key is optional for compatibility only. Without it a retry can redeem a multi-use coupon again, and the redemption cannot be cancelled when the goods come back.
curl --request POST \
--url https://{host}/coupon/v2/customers/{customerId}/coupons/redeem \
--header 'Content-Type: application/json' \
--data '
{
"storeId": "475",
"receiptId": "R-475-2-000123",
"coupons": [
{
"couponId": "6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"value": 2
},
{
"couponId": "168f3e64-da3f-4f48-acbb-552d66110e77",
"value": 10
}
],
"basketValue": 86.5
}
'import requests
url = "https://{host}/coupon/v2/customers/{customerId}/coupons/redeem"
payload = {
"storeId": "475",
"receiptId": "R-475-2-000123",
"coupons": [
{
"couponId": "6679b89b-f37c-46d0-a3cd-0a25302e75a9",
"value": 2
},
{
"couponId": "168f3e64-da3f-4f48-acbb-552d66110e77",
"value": 10
}
],
"basketValue": 86.5
}
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({
storeId: '475',
receiptId: 'R-475-2-000123',
coupons: [
{couponId: '6679b89b-f37c-46d0-a3cd-0a25302e75a9', value: 2},
{couponId: '168f3e64-da3f-4f48-acbb-552d66110e77', value: 10}
],
basketValue: 86.5
})
};
fetch('https://{host}/coupon/v2/customers/{customerId}/coupons/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/v2/customers/{customerId}/coupons/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([
'storeId' => '475',
'receiptId' => 'R-475-2-000123',
'coupons' => [
[
'couponId' => '6679b89b-f37c-46d0-a3cd-0a25302e75a9',
'value' => 2
],
[
'couponId' => '168f3e64-da3f-4f48-acbb-552d66110e77',
'value' => 10
]
],
'basketValue' => 86.5
]),
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/v2/customers/{customerId}/coupons/redeem"
payload := strings.NewReader("{\n \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\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/v2/customers/{customerId}/coupons/redeem")
.header("Content-Type", "application/json")
.body("{\n \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/coupon/v2/customers/{customerId}/coupons/redeem")
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 \"storeId\": \"475\",\n \"receiptId\": \"R-475-2-000123\",\n \"coupons\": [\n {\n \"couponId\": \"6679b89b-f37c-46d0-a3cd-0a25302e75a9\",\n \"value\": 2\n },\n {\n \"couponId\": \"168f3e64-da3f-4f48-acbb-552d66110e77\",\n \"value\": 10\n }\n ],\n \"basketValue\": 86.5\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 the sale used, and the sale they were used on.
The coupons a finished sale used, and the sale they were used on.