Documente Academic
Documente Profesional
Documente Cultură
1. Integrations details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Web Services integration - REST API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Web Services Integration - Create Document Full Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Integrations details
Following are the flows and integration points between as invoice issuer and a Virtual Operator (Electronic Invoicing System - EIC).
Synchronous
The synchronous API is available via the EIC Rest Webservices.
This document in section(Web Services integration) describes all the API calls required to fulfill the process ilustrated in (fig. Document issuing
with EIC)
Asynchronous
The Asynchrounous intgration is provided via a set of communication protocols and formats supported by "Trade"
This document in section (Asynchronous Integration) describes the message formats and communication protocols accepted in order to fulfill the
ex:https://api-einvoicing-co.saphety.com/swagger
Authentication
These web-services use a bearer token authentication.
The authentication token can be obtained providing a username and password.
{
"access_token": "eyJ0eX(...removed for security...)RnxY",
"expires": "2017-05-09T18:48:11.1671844Z",
"token_type": "bearer"
}
Url:
https://<APIBASEURL>/<VirtualOperatorAlias>/outbounddocuments/salesinvoice
Http Method: POST
ContentType: application/xml
Authorization: Bearer eyJ0eX(...removed for security...)RnxY
Body:
<SalesInvoice>
<IssueDate>2017-03-01T00:00:00</IssueDate>
(...removed legibility..)
</SalesInvoice>
],
"Documents": [],
"ResultData": [],
"ResultCode": 400
}
If the document creation is successful, as shown above, the document Id is returned ("Id": "2b57bd79-08b7-4363-8312-91eca3ab2f54").
Note that with the successful response on invoice creation you will also obtain the certified invoice according the DIAN UBL
specification:
We strongly recommend that this Id is stored in the HIS associated with the correspondent internal document. The purpose of this internal
association is to use the API calls to interact with the document on the eInvoice platform.
Now, we will describe the calls that allows to consult the document business status/communication status within the eInvoice platform assuming
that the HIS has the document Id and how to obtain the document details (e.g. certified Dian UBL file, PDF, metadata).
Request
Url:
https://<APIBASEURL>/<VirtualOperatorAlias>/documents/2b57bd79-08b7-4363-8
312-91eca3ab2f54
Http Method: GET
ContentType: application/json
Authorization: Bearer eyJ0eX(...removed for security...)RnxY
"BusinessStatus": "Certified",
"BusinessStatusReason": null,
"CommunicationStatus": "DeliverOk",
Business Status:
{
"Id": "a5aa2453-a00e-49af-a31b-143e5a7d5fb3",
"FileName": "FE983004349_26/05/2017.xml",
"DocumentFormat": "XML"
},
This identifies the certified Dian UBL document retrieved on document details.
Response
+ACbhbC4KZW5kc3RyZWFtCmVuZG9iago0IDAgb2JqCjw8L1N1YnR5cGUvVHlwZTAvVHlwZS9Gb
250L0Jhc2VG
b250L0tGUkpSSCtBcmlhbC9FbmNvZGluZy9JZGVudGl0eS1IL0Rlc2NlbmRhbnRGb250c1sxNC
AwIFJdL1RvVW
a. The operator administrator has already created your issuer company in the eInvoice platform;
b. The operator administrator has already created a user associated with your company;
c. For this steps you are always authenticated in the eInvoice platform:
For this example, the company user credentials are:
Email: issuer@company.com
Password: password.2017
First Step:
Create a valid series to be used on document creation. Note that the invoice number can be either generated by the eInvoice platform (Is
Autoincrement = true) or serialized through the HIS (Is Autoincrement = false).
In the following image, we have the result of a successful example Series creation.
Note that, when you create a new Series, by default is created inactivated, you'll have to activate it in the Serie details page.
Now you'll just have to submit the document from your HIS invoking the API endpoint as follows:
Note that this request is made using a xml document, but you can send a document in the json format, for that you just have to change
the contentType field to application/json
Request
Url: https://<APIBASEURL>/EIC/outbounddocuments/salesinvoice
Http Method: POST
ContentType: application/xml
Authorization: Bearer eyJ0eX(...removed for security...)RnxY
Body: <?xml version="1.0" encoding="utf-8"?>
<SalesInvoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CorrelationDocumentId>FRONTEND-14961589146771</CorrelationDocumentId>
<IssueDate>2017-05-30T00:00:00</IssueDate>
<BillingPeriod>
<From>2016-09-15T02:17:51.2487067</From>
<To>2016-09-15T19:00:15.1498338</To>
</BillingPeriod>
In this example, we have a successful document creation with the following response:
Response
{
"IsValid": true,
"Errors": [],
"Documents": [
{
"Id": "8459e3b7-c794-4b60-8217-9257bf66a18f",
"Content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmN...(removed for
simplification)...CiAgPC9mZTpJbnZvaWNlTGluZT4KPC9mZTpJbnZvaWNlPg==",
"ContentType": "text/xml"
}
],
"ResultData": [],
"ResultCode": 200
}
As we can see in the successful response example, we have three main fields:
Id - that represents the eInvoice unique identifier for the newly created document;
Content - certified DIAN UBL byte array encoded in UTF-8;
Content Type - certified DIAN UBL content type.
CorrelationDocumentId
{
"IsValid": false,
"Errors": [
{
"Field": "SalesInvoiceDTO.CorrelationDocumentId",
"Code": "Duplicated",
"Description": null
}
],
"Documents": [],
"ResultData": [],
"ResultCode": 400
}
In this example, we have a "CorrelationDocumentId" error. The correlation document Id is a unique field used to avoid the generation of the same
invoice twice.
If you get this error, you'll just have to update the CorrelationDocumentId field in your request body to an unused value.