curl --request POST \
--url https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityReference": "Company LIBERTY CENTER",
"transactionTypeExternalReference": "Supplements",
"activityTimestamp": "2020-02-08 09:30:26",
"transactionExternalReference": "123321abc",
"transactionGrossAmount": 200,
"checkForDuplicateTransaction": 1,
"fetchUpdatedMemberPointTotals": 0,
"totalAmountPaid": 180,
"discountValue": 20,
"totalTax": 20,
"netAmount": 160,
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"redemptionCode": [
"67460e74-02e3-11e8-b443-00163e990bdb"
],
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"value": 20,
"type": "promotion",
"description": "Black Friday discount",
"id": 23
}
],
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": [
"H4B-1000"
]
}
],
"setToPending": false
}
'import requests
url = "https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn"
payload = {
"entityReference": "Company LIBERTY CENTER",
"transactionTypeExternalReference": "Supplements",
"activityTimestamp": "2020-02-08 09:30:26",
"transactionExternalReference": "123321abc",
"transactionGrossAmount": 200,
"checkForDuplicateTransaction": 1,
"fetchUpdatedMemberPointTotals": 0,
"totalAmountPaid": 180,
"discountValue": 20,
"totalTax": 20,
"netAmount": 160,
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"redemptionCode": ["67460e74-02e3-11e8-b443-00163e990bdb"],
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"value": 20,
"type": "promotion",
"description": "Black Friday discount",
"id": 23
}
],
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": ["H4B-1000"]
}
],
"setToPending": False
}
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({
entityReference: 'Company LIBERTY CENTER',
transactionTypeExternalReference: 'Supplements',
activityTimestamp: '2020-02-08 09:30:26',
transactionExternalReference: '123321abc',
transactionGrossAmount: 200,
checkForDuplicateTransaction: 1,
fetchUpdatedMemberPointTotals: 0,
totalAmountPaid: 180,
discountValue: 20,
totalTax: 20,
netAmount: 160,
profileId: '67460e74-02e3-11e8-b443-00163e990bdb',
issueAuditUser: 'Joe',
cancelAuditUser: 'John',
redemptionCode: ['67460e74-02e3-11e8-b443-00163e990bdb'],
reasonCode: '9393',
reasonDescription: 'earning item',
discounts: [{value: 20, type: 'promotion', description: 'Black Friday discount', id: 23}],
transactionItems: [
{
grossAmount: 200,
totalAmountPaid: 200,
taxAmount: 20,
netAmount: 180,
itemPrice: 90,
itemQuantity: 2,
SKU: '1123455',
lineNumber: 0,
itemName: 'demo item',
UOM: 'unit',
discounts: [{id: 2345, value: 0, type: 'promotion', description: 'Black Friday discount'}],
couponCodes: ['H4B-1000']
}
],
setToPending: false
})
};
fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn', 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/v2/earn",
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([
'entityReference' => 'Company LIBERTY CENTER',
'transactionTypeExternalReference' => 'Supplements',
'activityTimestamp' => '2020-02-08 09:30:26',
'transactionExternalReference' => '123321abc',
'transactionGrossAmount' => 200,
'checkForDuplicateTransaction' => 1,
'fetchUpdatedMemberPointTotals' => 0,
'totalAmountPaid' => 180,
'discountValue' => 20,
'totalTax' => 20,
'netAmount' => 160,
'profileId' => '67460e74-02e3-11e8-b443-00163e990bdb',
'issueAuditUser' => 'Joe',
'cancelAuditUser' => 'John',
'redemptionCode' => [
'67460e74-02e3-11e8-b443-00163e990bdb'
],
'reasonCode' => '9393',
'reasonDescription' => 'earning item',
'discounts' => [
[
'value' => 20,
'type' => 'promotion',
'description' => 'Black Friday discount',
'id' => 23
]
],
'transactionItems' => [
[
'grossAmount' => 200,
'totalAmountPaid' => 200,
'taxAmount' => 20,
'netAmount' => 180,
'itemPrice' => 90,
'itemQuantity' => 2,
'SKU' => '1123455',
'lineNumber' => 0,
'itemName' => 'demo item',
'UOM' => 'unit',
'discounts' => [
[
'id' => 2345,
'value' => 0,
'type' => 'promotion',
'description' => 'Black Friday discount'
]
],
'couponCodes' => [
'H4B-1000'
]
]
],
'setToPending' => false
]),
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/v2/earn"
payload := strings.NewReader("{\n \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\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/v2/earn")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn")
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 \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\n}"
response = http.request(request)
puts response.read_body{
"status": 201,
"message": "earned",
"errors": {},
"data": {
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"transactionNumber": "LOYALTY-54321",
"transactionType": "EARN",
"transactionCode": "78660e74-02e3-11e8-b443-00163e911bd2",
"transactionDateTime": "2020-03-20T14:28:23.382748",
"activityTimestamp": "2020-03-20T14:28:23.382748",
"totalAmountPaid": 180,
"totalTax": 20,
"transactionNetAmount": 160,
"points": 16,
"basePoints": 16,
"bonusPoints": 0,
"promotionalPoints": 0,
"currentPointsBalance": 26,
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"id": 2345,
"value": 20,
"type": "promotion",
"description": "Black Friday discount"
}
],
"discountValue": 20,
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": [
"H4B-1000"
]
}
],
"rewards": [
{
"reward_id": 111,
"core_rule_id": 2,
"reward_portion": 10
}
],
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"deviceId": "D10626",
"transactionActivityType": "BASE_POINTS_EARNED",
"transactionTypeExternalReference": "PURCHASE",
"transactionExternalReference": "SHOP-7654321",
"transactionEntityReference": "Liberty_center_store"
}
}{
"message": "Error message string",
"errors": {
"ExceptionString": [
"Invalid Field"
]
},
"data": null,
"status": 400
}{
"detail": "Authentication Failed"
}Earn Points
Earns and accumulates points based on core (earn and burn) rules, promotional rules, etc. set at the club level. It is possible, for instance, to set rules that a member will earn 10 points for every 100spentinapurchasetransaction,and10pointsareequivalentto2. Rules are customizable based on the requirement.
Points are categorized as:
1) Base points: Earned in any purchase transaction based on the core rule.
2) Bonus points: Earned as a bonus for example on a large purchase.
3) Promotional Points: Earned as part of promotional events.
4) Restricted Points: Points to be used only on specified stores.
Earn endpoint uses the following formula for validating Payload:
1) Amount Paid = Gross Amount - Discounts
2) Net Amount = Gross Amount - Taxes - Discounts
3) At the Transaction Item level: Item Price - (Discount/Quantity) = Net Amount / Quantity
4) Total of all Transaction Items' Gross Amount = Total Gross Amount
curl --request POST \
--url https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityReference": "Company LIBERTY CENTER",
"transactionTypeExternalReference": "Supplements",
"activityTimestamp": "2020-02-08 09:30:26",
"transactionExternalReference": "123321abc",
"transactionGrossAmount": 200,
"checkForDuplicateTransaction": 1,
"fetchUpdatedMemberPointTotals": 0,
"totalAmountPaid": 180,
"discountValue": 20,
"totalTax": 20,
"netAmount": 160,
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"redemptionCode": [
"67460e74-02e3-11e8-b443-00163e990bdb"
],
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"value": 20,
"type": "promotion",
"description": "Black Friday discount",
"id": 23
}
],
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": [
"H4B-1000"
]
}
],
"setToPending": false
}
'import requests
url = "https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn"
payload = {
"entityReference": "Company LIBERTY CENTER",
"transactionTypeExternalReference": "Supplements",
"activityTimestamp": "2020-02-08 09:30:26",
"transactionExternalReference": "123321abc",
"transactionGrossAmount": 200,
"checkForDuplicateTransaction": 1,
"fetchUpdatedMemberPointTotals": 0,
"totalAmountPaid": 180,
"discountValue": 20,
"totalTax": 20,
"netAmount": 160,
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"redemptionCode": ["67460e74-02e3-11e8-b443-00163e990bdb"],
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"value": 20,
"type": "promotion",
"description": "Black Friday discount",
"id": 23
}
],
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": ["H4B-1000"]
}
],
"setToPending": False
}
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({
entityReference: 'Company LIBERTY CENTER',
transactionTypeExternalReference: 'Supplements',
activityTimestamp: '2020-02-08 09:30:26',
transactionExternalReference: '123321abc',
transactionGrossAmount: 200,
checkForDuplicateTransaction: 1,
fetchUpdatedMemberPointTotals: 0,
totalAmountPaid: 180,
discountValue: 20,
totalTax: 20,
netAmount: 160,
profileId: '67460e74-02e3-11e8-b443-00163e990bdb',
issueAuditUser: 'Joe',
cancelAuditUser: 'John',
redemptionCode: ['67460e74-02e3-11e8-b443-00163e990bdb'],
reasonCode: '9393',
reasonDescription: 'earning item',
discounts: [{value: 20, type: 'promotion', description: 'Black Friday discount', id: 23}],
transactionItems: [
{
grossAmount: 200,
totalAmountPaid: 200,
taxAmount: 20,
netAmount: 180,
itemPrice: 90,
itemQuantity: 2,
SKU: '1123455',
lineNumber: 0,
itemName: 'demo item',
UOM: 'unit',
discounts: [{id: 2345, value: 0, type: 'promotion', description: 'Black Friday discount'}],
couponCodes: ['H4B-1000']
}
],
setToPending: false
})
};
fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn', 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/v2/earn",
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([
'entityReference' => 'Company LIBERTY CENTER',
'transactionTypeExternalReference' => 'Supplements',
'activityTimestamp' => '2020-02-08 09:30:26',
'transactionExternalReference' => '123321abc',
'transactionGrossAmount' => 200,
'checkForDuplicateTransaction' => 1,
'fetchUpdatedMemberPointTotals' => 0,
'totalAmountPaid' => 180,
'discountValue' => 20,
'totalTax' => 20,
'netAmount' => 160,
'profileId' => '67460e74-02e3-11e8-b443-00163e990bdb',
'issueAuditUser' => 'Joe',
'cancelAuditUser' => 'John',
'redemptionCode' => [
'67460e74-02e3-11e8-b443-00163e990bdb'
],
'reasonCode' => '9393',
'reasonDescription' => 'earning item',
'discounts' => [
[
'value' => 20,
'type' => 'promotion',
'description' => 'Black Friday discount',
'id' => 23
]
],
'transactionItems' => [
[
'grossAmount' => 200,
'totalAmountPaid' => 200,
'taxAmount' => 20,
'netAmount' => 180,
'itemPrice' => 90,
'itemQuantity' => 2,
'SKU' => '1123455',
'lineNumber' => 0,
'itemName' => 'demo item',
'UOM' => 'unit',
'discounts' => [
[
'id' => 2345,
'value' => 0,
'type' => 'promotion',
'description' => 'Black Friday discount'
]
],
'couponCodes' => [
'H4B-1000'
]
]
],
'setToPending' => false
]),
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/v2/earn"
payload := strings.NewReader("{\n \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\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/v2/earn")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn")
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 \"entityReference\": \"Company LIBERTY CENTER\",\n \"transactionTypeExternalReference\": \"Supplements\",\n \"activityTimestamp\": \"2020-02-08 09:30:26\",\n \"transactionExternalReference\": \"123321abc\",\n \"transactionGrossAmount\": 200,\n \"checkForDuplicateTransaction\": 1,\n \"fetchUpdatedMemberPointTotals\": 0,\n \"totalAmountPaid\": 180,\n \"discountValue\": 20,\n \"totalTax\": 20,\n \"netAmount\": 160,\n \"profileId\": \"67460e74-02e3-11e8-b443-00163e990bdb\",\n \"issueAuditUser\": \"Joe\",\n \"cancelAuditUser\": \"John\",\n \"redemptionCode\": [\n \"67460e74-02e3-11e8-b443-00163e990bdb\"\n ],\n \"reasonCode\": \"9393\",\n \"reasonDescription\": \"earning item\",\n \"discounts\": [\n {\n \"value\": 20,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\",\n \"id\": 23\n }\n ],\n \"transactionItems\": [\n {\n \"grossAmount\": 200,\n \"totalAmountPaid\": 200,\n \"taxAmount\": 20,\n \"netAmount\": 180,\n \"itemPrice\": 90,\n \"itemQuantity\": 2,\n \"SKU\": \"1123455\",\n \"lineNumber\": 0,\n \"itemName\": \"demo item\",\n \"UOM\": \"unit\",\n \"discounts\": [\n {\n \"id\": 2345,\n \"value\": 0,\n \"type\": \"promotion\",\n \"description\": \"Black Friday discount\"\n }\n ],\n \"couponCodes\": [\n \"H4B-1000\"\n ]\n }\n ],\n \"setToPending\": false\n}"
response = http.request(request)
puts response.read_body{
"status": 201,
"message": "earned",
"errors": {},
"data": {
"profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
"transactionNumber": "LOYALTY-54321",
"transactionType": "EARN",
"transactionCode": "78660e74-02e3-11e8-b443-00163e911bd2",
"transactionDateTime": "2020-03-20T14:28:23.382748",
"activityTimestamp": "2020-03-20T14:28:23.382748",
"totalAmountPaid": 180,
"totalTax": 20,
"transactionNetAmount": 160,
"points": 16,
"basePoints": 16,
"bonusPoints": 0,
"promotionalPoints": 0,
"currentPointsBalance": 26,
"reasonCode": "9393",
"reasonDescription": "earning item",
"discounts": [
{
"id": 2345,
"value": 20,
"type": "promotion",
"description": "Black Friday discount"
}
],
"discountValue": 20,
"transactionItems": [
{
"grossAmount": 200,
"totalAmountPaid": 200,
"taxAmount": 20,
"netAmount": 180,
"itemPrice": 90,
"itemQuantity": 2,
"SKU": "1123455",
"lineNumber": 0,
"itemName": "demo item",
"UOM": "unit",
"discounts": [
{
"id": 2345,
"value": 0,
"type": "promotion",
"description": "Black Friday discount"
}
],
"couponCodes": [
"H4B-1000"
]
}
],
"rewards": [
{
"reward_id": 111,
"core_rule_id": 2,
"reward_portion": 10
}
],
"issueAuditUser": "Joe",
"cancelAuditUser": "John",
"deviceId": "D10626",
"transactionActivityType": "BASE_POINTS_EARNED",
"transactionTypeExternalReference": "PURCHASE",
"transactionExternalReference": "SHOP-7654321",
"transactionEntityReference": "Liberty_center_store"
}
}{
"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
Details required to earn points
Name or ID for the store (or entity) where the transaction took place.
1 - 100"Company LIBERTY CENTER"
External reference for the transaction type such as purchase, return, or exchange (Configurable as per requirement).
1 - 100"Supplements"
Activity date (in UTC format). An activity could be enrolling a member, making a transaction, etc.
"2020-02-08 09:30:26"
Order ID or receipt ID for a transaction (received from the store). It is needed to cancel or return an order.
1 - 100"123321abc"
Gross transaction amount (in currency unit) of the total items earn. For example the gross amount of item1 is 50.00 and gross amount of item2 is 100.00. The transactionGrossAmount is 150.00.
x >= 0200
0 indicates the system allows duplicates and 1 indicates there is a validation in place to identity duplicate.
1
1 indicates the total points are calculated and shown to the member. 0 indicates the total points are not calculated and the member is only notified the earn is successful. Note: The response is faster when the value is 0 because the total points are not calculated on the fly.
0
Total amount paid for the items. For example, the amount paid for item1 is 100.00 and the amount of item2 is 200.00 so the total amount paid is 300.00.
180
Discount value on the transaction, if applicable
20
Total tax based on the number of items in the transaction. For example, the tax amount of item1 is 2.00 and tax amount of item2 is 1.00. The totalTax is 3.00.
20
Net transaction amount based on the total items in the transaction, after subtracting taxes and discounts.
x >= 0160
Profile ID of the member. In an ecosystem, it acts as a primary ID to keep the various systems (apps, websites, etc.) in sync.
"67460e74-02e3-11e8-b443-00163e990bdb"
Representative who issued the earn transaction
1 - 200"Joe"
Representative who cancelled the earn transaction
1 - 200"John"
Redemption code to identify and link the rewards used in a specific transaction. This is generated in the response of the Issue Variable Rewards endpoint - POST /api/v1/redeem/reward/issue.
["67460e74-02e3-11e8-b443-00163e990bdb"]
Reason code to categorize transactions. A parent company can configure custom codes for their stores as required.
1 - 30"9393"
When reason codes are not configured, store can make use of the reason description to add notes on the transaction.
1 - 300"earning item"
Represents the discounts on the item.
Show child attributes
Show child attributes
Details of the items in the transaction.
Show child attributes
Show child attributes
true: Points in Pending status
false: Points in Active status.
Note:The time period for Pending state is configurable.
Response
OK
Metadata for the Earn points response
Was this page helpful?
