Earn Points - Fabric

Earn Points

cURL

curl --request POST \
  --url https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '\n{\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}\n'  

Python

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)

JavaScript

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;
}

Response

Success

{
  "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"
  }
}

Error Response

{
  "message": "Error message string",
  "errors": {
    "ExceptionString": ["Invalid Field"]
  },
  "data": null,
  "status": 400
}

Authorizations

Authorization: Bearer <token> – required.