curl --request POST \
--url https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"entityReference": "Company_Club",
"transactionTimestamp": "2020-02-08 09:30:26",
"taxAmount": 1,
"grossAmount": 6,
"netAmount": 5,
"transactionItems": [
{
"grossAmount": 6,
"netAmount": 5,
"categories": [
"Proteins",
"Adults"
],
"itemPrice": 5,
"itemQuantity": 1,
"SKU": "123456",
"taxAmount": 1,
"itemName": "Whey"
}
]
}
'import requests
url = "https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"
payload = {
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"entityReference": "Company_Club",
"transactionTimestamp": "2020-02-08 09:30:26",
"taxAmount": 1,
"grossAmount": 6,
"netAmount": 5,
"transactionItems": [
{
"grossAmount": 6,
"netAmount": 5,
"categories": ["Proteins", "Adults"],
"itemPrice": 5,
"itemQuantity": 1,
"SKU": "123456",
"taxAmount": 1,
"itemName": "Whey"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
profileId: '67460e74-02e3-11e8-b443-00163e990bdb',
entityReference: 'Company_Club',
transactionTimestamp: '2020-02-08 09:30:26',
taxAmount: 1,
grossAmount: 6,
netAmount: 5,
transactionItems: [
{
grossAmount: 6,
netAmount: 5,
categories: ['Proteins', 'Adults'],
itemPrice: 5,
itemQuantity: 1,
SKU: '123456',
taxAmount: 1,
itemName: 'Whey'
}
]
})
};
fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts', 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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts",
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([
'profileId' => '67460e74-02e3-11e8-b443-00163e990bdb',
'entityReference' => 'Company_Club',
'transactionTimestamp' => '2020-02-08 09:30:26',
'taxAmount' => 1,
'grossAmount' => 6,
'netAmount' => 5,
'transactionItems' => [
[
'grossAmount' => 6,
'netAmount' => 5,
'categories' => [
'Proteins',
'Adults'
],
'itemPrice' => 5,
'itemQuantity' => 1,
'SKU' => '123456',
'taxAmount' => 1,
'itemName' => 'Whey'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"
payload := strings.NewReader("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Created",
"errors": {},
"data": [
{
"grossAmount": 6,
"taxAmount": 1,
"netAmount": 4,
"discounts": [
{
"value": 1,
"type": "tier",
"description": "20.0% discount from tier rule.",
"id": 23,
"ruleName": "tier-discount-rule",
"discountPercentage": 20,
"discountAmount": 1
}
],
"transactionItems": [
{
"SKU": "123456",
"discounts": []
}
],
"miscellaneous": []
}
]
}{
"message": "Error message string",
"errors": {
"ExceptionString": [
"Invalid Field"
]
},
"data": null,
"status": 400
}{
"detail": "Authentication Failed"
}Get Discounts
Gets applicable discounts for a transaction. The discounts are categorized as
1) Transaction-level discounts: Applied on the whole transaction. For example, if the transaction is for $100, the discount is applied by percentage or amount to the whole transaction amount. This category includes tier-specific discounts.
2) Item-level discounts: Applied on specific SKU so that discount percentage or amount is applied to specific product (regardless of the quantity).
3) Miscellaneous discounts - This category captures all other types of discounts.
curl --request POST \
--url https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"entityReference": "Company_Club",
"transactionTimestamp": "2020-02-08 09:30:26",
"taxAmount": 1,
"grossAmount": 6,
"netAmount": 5,
"transactionItems": [
{
"grossAmount": 6,
"netAmount": 5,
"categories": [
"Proteins",
"Adults"
],
"itemPrice": 5,
"itemQuantity": 1,
"SKU": "123456",
"taxAmount": 1,
"itemName": "Whey"
}
]
}
'import requests
url = "https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"
payload = {
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"entityReference": "Company_Club",
"transactionTimestamp": "2020-02-08 09:30:26",
"taxAmount": 1,
"grossAmount": 6,
"netAmount": 5,
"transactionItems": [
{
"grossAmount": 6,
"netAmount": 5,
"categories": ["Proteins", "Adults"],
"itemPrice": 5,
"itemQuantity": 1,
"SKU": "123456",
"taxAmount": 1,
"itemName": "Whey"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
profileId: '67460e74-02e3-11e8-b443-00163e990bdb',
entityReference: 'Company_Club',
transactionTimestamp: '2020-02-08 09:30:26',
taxAmount: 1,
grossAmount: 6,
netAmount: 5,
transactionItems: [
{
grossAmount: 6,
netAmount: 5,
categories: ['Proteins', 'Adults'],
itemPrice: 5,
itemQuantity: 1,
SKU: '123456',
taxAmount: 1,
itemName: 'Whey'
}
]
})
};
fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts', 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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts",
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([
'profileId' => '67460e74-02e3-11e8-b443-00163e990bdb',
'entityReference' => 'Company_Club',
'transactionTimestamp' => '2020-02-08 09:30:26',
'taxAmount' => 1,
'grossAmount' => 6,
'netAmount' => 5,
'transactionItems' => [
[
'grossAmount' => 6,
'netAmount' => 5,
'categories' => [
'Proteins',
'Adults'
],
'itemPrice' => 5,
'itemQuantity' => 1,
'SKU' => '123456',
'taxAmount' => 1,
'itemName' => 'Whey'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts"
payload := strings.NewReader("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v1/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"entityReference\": \"Company_Club\",\n \"transactionTimestamp\": \"2020-02-08 09:30:26\",\n \"taxAmount\": 1,\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"transactionItems\": [\n {\n \"grossAmount\": 6,\n \"netAmount\": 5,\n \"categories\": [\n \"Proteins\",\n \"Adults\"\n ],\n \"itemPrice\": 5,\n \"itemQuantity\": 1,\n \"SKU\": \"123456\",\n \"taxAmount\": 1,\n \"itemName\": \"Whey\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Created",
"errors": {},
"data": [
{
"grossAmount": 6,
"taxAmount": 1,
"netAmount": 4,
"discounts": [
{
"value": 1,
"type": "tier",
"description": "20.0% discount from tier rule.",
"id": 23,
"ruleName": "tier-discount-rule",
"discountPercentage": 20,
"discountAmount": 1
}
],
"transactionItems": [
{
"SKU": "123456",
"discounts": []
}
],
"miscellaneous": []
}
]
}{
"message": "Error message string",
"errors": {
"ExceptionString": [
"Invalid Field"
]
},
"data": null,
"status": 400
}{
"detail": "Authentication Failed"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Profile ID of member
"67460e74-02e3-11e8-b443-00163e990bdb"
External reference of the store where the transaction occurred
1"Company_Club"
Transaction timestamp (UTC format)
"2020-02-08 09:30:26"
Tax amount
1
Gross amount of the transaction (before discount)
6
Net amount of the transaction (after discount).
5
Show child attributes
Show child attributes
Was this page helpful?
