Receipt Generator Service

   Journey Manager (JM) The transaction engine for the platform.  |    System Manager / DevOps  |  24.10 This feature was introduced in 24.10

Manager provides a Receipt Generator service for creating PDF receipts based only on a form design and a form XML data files. The service doesn't require any form submission data, as opposed to the Dynamic PDF Receipt service and the Chromium Puppeteer Receipt service, so you can conveniently create a receipt on demand. This is usually to render Maestro forms. Manager doesn't store generated receipts so they are discarded after use.

The Receipt Generator service supports only the PuppeteerPuppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium. and the PhantomJSPhantomJS is a scripted, headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment. PhantomJS is based on WebKit making it a similar browsing environment to Safari and Google Chrome (before Chrome's fork of WebKit evolved into Blink). It is open-source software released under the BSD License. headless internet browsers.

To run the service against a form, the form must belong to an organization and a user must have that organization or form assigned to them to call the service.

You can generate a receipt using one of following options:

Generate Using Fluent API

You can use any rendering service or create a new one using Fluent API.

The example below illustrates how to generate a receipt as an array of bytes:

import com.avoka.tm.svc.ReceiptGenerator

byte[] receiptBytes = new ReceiptGenerator()
	.setFormCode("formCode")
	.setFormTemplateVersion("1.0.0")
	.setSvcName("serviceName")
	.setSvcVersion("1.0.0")
	.setXml("xmlData")
	.generateReceipt() 

Generate Using API

The Journey Manager REST API provides the endpoint URL to generate a receipt. The endpoint uses the Basic Auth.

To call this REST API, you need:

HTTP Request
Both HTTP and HTTPS protocols are supported:
http(s)://{JM_SERVER}/manager/secure/rest/fluentapi/receiptgenerator/generateReceipt
Parameters
setXml: a form content as XML that is used to generate a PDF receipt of the form.
setFormCode: a form code.
setFormTemplateVersion - a form template version.
setSvcName: a service name.
setSvcVersion: a version of a service
Response
If successful, this operation returns a response with a receipt encoded as Base64 and a HTTP 200 OK status code.
If an error occurs, the Can't resolve the form, Invalid XML (a form XML data must include AvokaSmartForm) or Unauthorized message is logged into the Error Log.
Example
curl --location --request POST ‘http(s)://{JM_SERVER}/manager/secure/rest/fluentapi/receiptgenerator/generateReceipt’ \
	"setXml": "<?xml version=.....", \
	"setFormCode": "RECEIPT-GENERATOR", \
	"setFormTemplateVersion": "0.1.0", \
	"setSvcName": "Dynamic PDF Receipt", /	
	"setSvcVersion": "1.0.0"					

Next, learn how to regenerate a receipt.