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
Body
Details required to earn points
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
Response
OK
Metadata for the Earn points response
Was this page helpful?
