Guided Tour: Transaction Services
This is a step-by-step guide to using Transaction Services for sending and receiving electronic business documents from a backend, such as an ERP system, in JSON format.
Transaction Services are used for creating or parsing electronic business documents with JSON metadata, which abstracts the underlying XML (or EDI) technical specifications.
- Documents are validated before delivery. Errors are returned if submitted data is inconsistent, but Unimaze will otherwise guarantee that documents are in compliance with syntax and business rules.
- For working with raw XML, please refer to MAPI Guided Tour – Message Services .
Sending electronic documents
-
Create a random unique identifier (GUID) and store internally. This will become the message identifier (
:mid). -
Prepare the JSON message and submit the business documents using, e.g.:\
POST /transactions/submit-invoicePOST /transactions/correct-with-creditPOST /transactions/submit-order
When including additional attachments in the message, ensure the parametermoreis set totrue. Otherwise set it tofalseto trigger processing and delivery of the message.
-
Optionally, stream a binary payload as attachment (e.g. timesheet, product description) using:\
POST /messages/:mid/documents
The content type must be a valid MIME type, supported are images, PDF, XLSX, CSV and plain text files. Setmoretotrueorfalsedepending on if processing can be triggered or not. If desired, setembedDocumenttotrue.
-
Check the state of the message any time using:\
GET messages/:mid/status
This will both give delivery information as well as message handling traces. The states: a)Delivered(delivered to endpoint), b)Failed(there was an error) and c)Parked(manually parked as handled) may be considered final states.
-
Store the
referenceIdparameter for each document for later displaying the document(s) see Receiving electronic documents below.
Alerting users of pending incoming documents
To avoid pending incoming documents from piling up in the inbox, either:
-
Set up a service that will routinely (every 10-30 minutes) fetch the inbound documents into the ERP system (according to the instructions below).
-
Add an alert, notification or badge on a dashboard or in context views related to handling invoices and credit notes indicating the number of pending entries and an action to fetch them:\
GET /parties/{isoIdentifier}/pending-summaries?action=SubmitInvoice,CorrectWithCredit(whereisoIdentiferis the prefixed identifier e.g.0196:6511230889andactionlimits the query to invoices and credit notes) for partner admin users OR\GET /messages/pending-summaries?action=SubmitInvoice,CorrectWithCredit(in the ERP user context)
Receiving electronic documents
-
Fetch a list of pending incoming messages using:\
GET /messages?status=pendingdelivery&transfer=inbound
For each message, make a note of the unique identifier (GUID), theactionparameter and thereferenceIdof the document(s).
-
If
validationStatusof a message is not approved, it has one or more validation errors. Either mark the message as delivered or parked so that it will be removed from the list of pending incoming messages. If you like to fetch validation errors or warnings use:\GET /messages/:mid/validations
-
Based on the
actionparameter, get business document data in JSON format using:\GET /transactions/submit-invoice?messageId=:mid\GET /transactions/correct-with-credit?messageId=:mid\GET /transactions/submit-order?messageId=:mid, etc.
Optionally, get any attached documents and store them if needed:\GET /messages/:mid/documents/{nameOrIndex}**
-
Change the state of the message to delivered using:\
POST /messages/:mid/mark-as-delivered
Generally, marking the message delivered should be done as soon as possible (within minutes or hours).
-
To allow a user to view the document or any of the attached documents, use:\
GET /messages/display/:referenceId(optionally add the?lang=<language>parameter)
Updated about 2 months ago
