External Events Integration
Transaction Repository provides two event sources to retrieve data on your webhooks at the same time as the service processes it. To learn more about event sources and how to use them, please see the External Events documentation, this page only covers the Event Source configuration for the Transaction repository.
Transactions
This Event Source provides a way to receive ZIP (DEFLATE algorithm) archives with transactions using a webhook.
id | txr.transactions.v1 |
type | application/zip |
description | PosLogv6 transaction xml file, zipped |
Exposed Attributes
meta.businessDay
field of the Cloud Event will contain the current business day.This value is calculated using transaction timestamp and
timeOffset
field of a business unit linked throughBusiness-Unit-Id
attribute, provided by Business Unit Management service.Transaction timestamp is extracted from the
EndDateTime
field in PosLog with a fallback toTransaction-Timestamp
attribute. It will useTimezone-Offset-Minutes
attribute in case no timezone is specified in the date.
Example:
POST /your-receiver HTTP/1.1
Host: receiving-host.example
User-Agent: Hii-Event-Gun/1.0
Content-Length: 397
Authorization: Bearer jwt-token-by-goodle
Content-Type: application/json
Correlation-Id: ec580d96-4d6c-4a68-9724-c01ffa95bda1
X-Hii-Signature: HS256=65fd717df8dd1ae9c432cf0000cfda46e1143122fcfc8af944482f9771c2a9d7
{
"id": "4050752561927993",
"time": "2022-02-05T15:34:47.857Z",
"type": "exe.events.v1",
"datacontenttype": "application/json",
"data": "eyJtZXNzYWdlIjoiVGhpcyBpcyBzYW1wbGUgZXZlbnQgZGF0YSwgcmVhbCBkYXRhIGZyb20gZXZlbnQgc291cmNlIHdpbGwgZGlmZmVyIiwiY29mZmVlIjoi4piVIiwiY3VycmVudFRpbWUiOiIxOTcwLTAxLTAxIDAwOjAwOjAwIn0=",
"meta": {
"businessDay": "2020-01-01"
},
"source": "exe-dispatch.retailsvc.com",
"specversion": "1.0",
"dataencoding": "base64"
}
For more detailed docs for consming the webhooks can be found here
Example webhook
import { inflateSync } from "zlib";
function webhookController(request, response) {
const body = request.body;
const type = body.type;
if (type === "txr.transactions.v1") {
const data = body.data;
const transaction = inflateSync(Buffer.from(data, "base64"));
// Do something with the transaction
}
response.status(200).send();
}
Sequence gaps
This Event Source provides a way to receive notifications about transaction sequence gaps happening within the system.
id | txr.sequence-gaps.v1 |
type | application/json |
description | Transactions for which sequence gaps were detected |
Example webhook
function webhookController(request, response) {
const body = request.body;
const type = body.type;
if (type === "txr.sequence-gaps.v1") {
const data = body.data;
const sequenceGap = JSON.parse(Buffer.from(data, "base64"));
console.log(sequenceGap);
// {
// tenantId: 'CIR7nQwtS0rA6t0S6ejd',
// transactionId: '001;01;23;2021-11-1417:13:10;4',
// businessUnitId: '01',
// }
// Do something with the sequence gap
}
response.status(200).send();
}