Idempotent Requests

The Domec API supports idempotency for safely retrying requests without accidentally performing the same operation twice. For example, if a request to create a charge fails due to a network connection error, you can retry the request with the same idempotency key to guarantee that only a single charge is created.

To perform an idempotent request, provide an additional IdempotencyKey element to the request parameters.

How you create unique keys is completely up to you. We suggest using random strings or UUIDs. We’ll always send back the same response for requests made with the same key. However, you cannot use the same key with different request parameters.

An IdempotencyKey can be added to the UserData section of the Transaction Receipt by adding a __CLIENT_TX_ID__ parameter on it.

Have a look to the following example for further details.


{
    "IssuerData": {
        "Name":"Company Name",
        "Address":"Street Address",
        "Telephone":"123456789",
        "EMail":"email@company.com",
        "VATNumber":"987654321"
    },
    "IssueDate":"2016-01-11T22:40:06",
    "Products":[
        {"Code": "XYZ", "Name": "Dummy product", "Price": 25.50, "Quantity": 1.0}
    ],
    "Payments":[
        {"Method":0,"CardCode":"XXXXXXX", "Amount":25.50}
    ],
    "Total":25.50,
    "SenderData": {
        "Shop":"shop",
        "Terminal":"terminal",
        "Type": 1,
        "Number": 61,
        "CashDrawer": 61,
        "Operator":"123"
    },
    "UserData": "{ __CLIENT_TX_ID__ : \"IdempotencyKey" }"
}