This article describes how you can process data (Payload) originating of your source system for the purpose of utilizing it in outgoing PDF Confirmations.
Overview
To enhance the PDF generation capabilities in Confirmation Hub, a field called "Payload" is available. This field allows the passing of custom payloads to the PDF tool, facilitating the inclusion of more complex data structures.
Payload Field Usage
The "Payload" field can accept data in the following formats:
-
String Text
-
Example:
"Payload": "My test value"
-
-
Escaped JSON String
-
Example:
"Payload": "[\n {\n \"id\": 105,\n \"order_number\": \"ORDER1234\",\n \"date\": \"16.09.2019\",\n \"line_items\": [\n {\n \"name\": \"Item number 1\",\n \"price\": \"4,080.00\",\n \"total\": \"8,160.00\",\n \"quantity\": 2\n },\n {\n \"name\": \"Item number 2\",\n \"price\": \"2,060.00\",\n \"total\": \"2,060.00\",\n \"quantity\": 1\n }\n ]\n },\n {\n \"id\": 106,\n \"order_number\": \"ORDER12345\",\n \"date\": \"17.09.2019\",\n \"line_items\": [\n {\n \"name\": \"Item number 1\",\n \"price\": \"5,080.00\",\n \"total\": \"15,240.00\",\n \"quantity\": 3\n },\n {\n \"name\": \"Item number 2\",\n \"price\": \"1,060.00\",\n \"total\": \"1,060.00\",\n \"quantity\": 1\n },\n {\n \"name\": \"Item number 3\",\n \"price\": \"3,060.00\",\n \"total\": \"3,060.00\",\n \"quantity\": 1\n }\n ]\n }\n ]"
-
-
Valid JSON Object or Array
-
Example:
"Payload": [ { "id": 105, "order_number": "ORDER1234", "date": "16.09.2019", "line_items": [ { "name": "Item number 1", "price": "4,080.00", "total": "8,160.00", "quantity": 2 }, { "name": "Item number 2", "price": "2,060.00", "total": "2,060.00", "quantity": 1 } ] }, { "id": 106, "order_number": "ORDER12345", "date": "17.09.2019", "line_items": [ { "name": "Item number 1", "price": "5,080.00", "total": "15,240.00", "quantity": 3 }, { "name": "Item number 2", "price": "1,060.00", "total": "1,060.00", "quantity": 1 }, { "name": "Item number 3", "price": "3,060.00", "total": "3,060.00", "quantity": 1 } ] } ]
-
The Payload handling allows for flexibility in the data structures that can be included in the Confirmation PDFs. By supporting plain strings, escaped JSON strings, and valid JSON objects/arrays, Confirmation Hub can handle a wide range of data formats, enhancing the overall functionality of the PDF generation tool.
API Considerations
The Payload field is available via an additional endpoint to retrieve the payload for a specific Confirmation:
-
Method: GET
-
Endpoint:
/confirmation/{confirmationId}/payload
Usage in Document uploads
The Payload field can be used when uploading documents in both XML and JSON formats. This flexibility ensures that the custom payload can be incorporated regardless of the document format being used.
Usage in PDF template builder
Test Documents
-
json - payload_as_string.json
-
json - jsonpayload_as_json.json
Payload data example in PDF tool
The example below shows a json payload containing an array within an array iteration. The first array renders the container component. Within the container component, there is another array that renders line items.
Payload data usage example in pdf
The example below demonstrates an array within an array iteration. The first array renders the container component. Within the container component, there is another array that renders line items. This example showcases two components, each containing multiple line items.