Skip to main content

Signature for payment via REST API

How to sign a payable invoice using the REST API

Written by Petr Pech

ABRA Flexi may require an invoice to be signed before a payment order is issued (see settings). A signed document can then be entered into a payment order; without a signature, it cannot.

The REST API allows you to sign an invoice using the action sign-for-payment. To cancel a signature, use the action unsign-for-payment. To perform the action, you need to know the specific ID (code) of the invoice, or you can use filtering to sign multiple invoices at once.


Usage Examples

We send the request using the POST method to the URL https://demo.flexibee.eu/c/demo/faktura-prijata.xml (or alternatively .json):

<winstrom version="1.0">
<faktura-prijata id="123" action="sign-for-payment"/>
</winstrom>

Or alternatively, with the identifier written as a separate element:

<winstrom version="1.0">
<faktura-prijata action="sign-for-payment">
<id>123</id>
</faktura-prijata>
</winstrom>

Similarly, the request can be sent in JSON format using the document's internal number. Adding a payment signature:

{
"winstrom": {
"faktura-prijata": {
"id": "code:PF0015/2022",
"@action": "sign-for-payment"
}
}
}

Canceling the payment signature:

{
"winstrom": {
"faktura-prijata": {
"id": "code:PF0015/2022",
"@action": "unsign-for-payment"
}
}
}

ABRA Flexi's response then updates the selected record:

{
"winstrom": {
"@version": "1.0",
"success": "true",
"stats": {
"created": "0",
"updated": "1",
"deleted": "0",
"skipped": "0",
"failed": "0"
},
"results": [
{
"id": "910",
"request-id": "code:PF0015/2022",
"ref": "/c/demo/faktura-prijata/910.json"
}
]
}
}


Filtering Invoices for Signing

The action can also be triggered in bulk over a group of documents using a filter. Again, we send the request using the POST method to https://demo.flexibee.eu/c/demo/faktura-prijata.xml:

<winstrom version="1.0">
<faktura-prijata filter="datSplat gt now()"
action="sign-for-payment"/>
</winstrom>

Similarly in JSON format:

{
"winstrom": {
"faktura-prijata": {
"@filter": "sumCelkem lt 100",
"@action": "unsign-for-payment"
}
}
}


Unsuccessful Requests

The Specified or Filtered Object Does Not Exist

If the object cannot be found, the API response is:

"message": "Objekt bude teprve vytvořen, žádnou akci nelze provést."

The Action Is Written Incorrectly

If you call an incorrect action (a typo or an error in the name):

<error>Atribut 'action' obsahuje špatnou hodnotu. Pro daný objekt smí obsahovat jen:
[delete, lock, lock-for-ucetni, storno, uhrad-zapoctem] [PF0013/2223]</error>

⚠️ The list of actions in this error message is not complete — sign-for-payment and unsign-for-payment on a received invoice work even though the message does not list them. Do not treat the list in the message as a complete overview of the available actions.

Incorrectly Written Filter

The filter does not comply with the defined filtering rules; the response gives the approximate position of the error in the filter:

<error>Špatný formát WQL dotazu, problém na pozici 11 poblíž textu 'now()'
org.antlr.v4.runtime.misc.ParseCancellationException
org.antlr.v4.runtime.NoViableAltException</error>

The Invoice Is Locked

If you try to sign a document that is locked, the response is a failure. The document must first be unlocked using the action action="unlock":

"message": "Záznam je zamčený. [PF0031/2021]"


Related Articles

Did this answer your question?