Receipt API

Introduction

The receipt API provides endpoints to create receipts for carts, query them and generate printing instructions.

For more details about this API usage check our API documentation

Preparation

  • Have an authenticated token from the authentication service, this token should be used as an authorization bearer token header for every request done in this API (more information about the authorization service here).
  • Have the cart ID you wish to create a receipt for (more information about carts here).
  • That the cart ID you are using has been entirely paid using the payment API (more information about payments here).

Create a receipt

In order to create a receipt we need to provide the cart ID by making a POST request to the /receipts endpoint. Here is an example request.

Example request body:

{
"cartId":"db05019c-bb72-4e2d-85a9-ab7d7526032d"
}

Example response:

{
"receipt": {
"id" : "5c3f59e4368d0e448c15557e",
"receiptNumber" : 1,
"cartId" : "cartId01",
"cartCreateDateTime" : "2019-11-26T16:41:34+00:00",
"transactionType" : "SALE",
"stationId" : "1",
"store" : {
"storeId" : "1337",
"branchName" : "Reno Store Osnabrück",
"distChannel" : "DE01RE",
"address" : {
"country" : "DE",
"city" : "Osnabrück",
"postalcode" : "49074",
"street" : "Möserstraße",
"houseNumber" : "2-3"
},
"phone" : "0541/5009780",
"defaultCurrency" : "EUR",
"taxId" : "123456789"
},
"cashier" : {
"id" : "11111",
"name" : "Erika",
"lastname" : "Mustermann",
"salutation" : "Frau",
"store" : "1337"
},
"items" : [ {
"positionId" : 0,
"sku" : "10005",
"description" : "FU Pflegemit Spray",
"quantity" : 3,
"basePrice" : {
"value" : 6600,
"currency" : "EUR"
},
"totalBasePrice" : 6600,
"discounts" : [ ],
"totalDiscountAmount" : 0,
"priceAfterDiscounts" : 6600,
"vatCode" : "A5",
"vatRate" : 19,
"priceBeforeVat" : 5346,
"vatAmount" : 1254,
"status" : "OPEN"
} ],
"paymentDetails" : {
"paymentTransactions" : [ {
"transactionStatus" : "PARTIAL",
"time" : "2017-12-24T18:25Z",
"method" : "PINPAD",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
}, {
"transactionStatus" : "CLOSED",
"time" : "2017-12-24T18:25Z",
"method" : "CASH",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
} ],
"customerPaid" : 10000,
"changeValue" : 1,
"transactionEnd" : "2017-12-24T18:25Z",
"grossSum" : -9999,
"deRundetAuf" : 0,
"netSum" : -8403,
"currency" : "EUR",
"vatTotals" : [ {
"vatCode" : "A5",
"vatRate" : 19,
"vatAmountSum" : -1596
} ]
},
"createDateTime" : "2019-11-16T17:20:52.092",
"barcode" : "1911160133701000001"
},
"apiResponseStatus" : {
"responseCode" : "I08001",
"httpStatus" : "CREATED",
"message" : "Receipt created successfully."
}
}

Create a receipt with postal code

Receipts can also capture the postal code of customers whenever the business requires doing so. A POST request to the /receipts endpoint must be done adding the cart Id and postal code in the request body. An example is shown bellow.

Example request body:

{
"cartId":"db05019c-bb72-4e2d-85a9-ab7d7526032d",
"postalCode": "12345"
}

Example response:

{
"receipt" : {
"id" : "5c3f59e4368d0e448c15557e",
"receiptNumber" : 1,
"cartId" : "cartId01",
"cartCreateDateTime" : "2018-11-26T16:41:34+00:00",
"transactionType" : "SALE",
"stationId" : "1",
"store" : {
"storeId" : "1337",
"branchName" : "Reno Store Osnabrück",
"distChannel" : "DE01RE",
"address" : {
"country" : "DE",
"city" : "Osnabrück",
"postalcode" : "49074",
"street" : "Möserstraße",
"houseNumber" : "2-3"
},
"phone" : "0541/5009780",
"defaultCurrency" : "EUR",
"taxId" : "123456789"
},
"cashier" : {
"id" : "11111",
"name" : "Erika",
"lastname" : "Mustermann",
"salutation" : "Frau",
"store" : "1337"
},
"items" : [ {
"positionId" : 0,
"sku" : "10005",
"description" : "FU Pflegemit Spray",
"quantity" : 3,
"basePrice" : {
"value" : 6600,
"currency" : "EUR"
},
"totalBasePrice" : 6600,
"discounts" : [ ],
"totalDiscountAmount" : 0,
"priceAfterDiscounts" : 6600,
"vatCode" : "A5",
"vatRate" : 19,
"priceBeforeVat" : 5346,
"vatAmount" : 1254,
"status" : "OPEN"
} ],
"paymentDetails" : {
"paymentTransactions" : [ {
"transactionStatus" : "PARTIAL",
"time" : "2017-12-24T18:25Z",
"method" : "Kartenzahlung",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
}, {
"transactionStatus" : "CLOSED",
"time" : "2017-12-24T18:25Z",
"method" : "Barzahlung",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
} ],
"customerPaid" : 10000,
"changeValue" : 1,
"transactionEnd" : "2017-12-24T18:25Z",
"grossSum" : -9999,
"deRundetAuf" : 0,
"netSum" : -8403,
"currency" : "EUR",
"vatTotals" : [ {
"vatCode" : "A5",
"vatRate" : 19,
"vatAmountSum" : -1596
} ]
},
"createDateTime" : "2019-01-16T17:20:52.092",
"barcode" : "1712240133701000001",
"postalCode": "12345"
},
"apiResponseStatus" : {
"responseCode" : "I08001",
"httpStatus" : "CREATED",
"message" : "Receipt created successfully."
}
}

Create a void receipt

Void receipts can also be created, these are not related to retail transactions so no cart Id is needed in the request body. A POST request to the /receipts endpoint must be done adding the void receipt flag in the request body. An example is shown bellow.

Example request body:

{
"voidReceipt": true
}

Example response:

{
"receipt" : {
"id" : "5d405a3e826a6f2061ecc76d",
"receiptNumber" : 1,
"transactionType" : "SALE",
"stationId" : "1",
"store" : {
"storeId" : "1337",
"branchName" : "Reno Store Osnabrück",
"distChain" : "DE01RE",
"address" : {
"country" : "DE",
"city" : "Osnabrück",
"postalcode" : "49074",
"street" : "Möserstraße",
"houseNumber" : "2-3"
},
"contact" : {
"phone" : "0541/5009780"
},
"defaultCurrency" : "EUR",
"taxId" : "123456789",
"properties" : {
"logoFilename" : "Store_logo_image.png",
"footerImageFilename" : "Footer_image.png"
}
},
"cashier" : {
"id" : "11111",
"name" : "Erika",
"lastName" : "Mustermann",
"salutation" : "Frau",
"store" : "1337"
},
"paymentDetails" : {
"paymentTransactions" : [ {
"transactionStatus" : "CLOSED",
"time" : "2019-07-30T16:54:54.922",
"method" : "CASH",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 0
} ],
"changeValue" : 0,
"grossSum" : 0
},
"createDateTime" : "2019-07-30T16:54:54.921",
"barcode" : "1907300133701000001"
},
"apiResponseStatus" : {
"responseCode" : "I08001",
"httpStatus" : "CREATED",
"message" : "Receipt created successfully."
}
}

Generate receipt printing instructions

Part of the process of creating a receipt is to print a receipt containing information about the transaction. This API provides an endpoint to generate printing instructions in XML format that contains general information of it. To generate such printing instructions a GET request needs to be done with the format to /receipts/{receiptId}/xml, no request body is required.

Example response:

{
"receiptXML" : "<receipt><image src=\"/usr/local/share/bon/bilder/BonLogo_mayer_de.png\"></image></receipt>",
"apiResponseStatus" : {
"responseCode" : "I08002",
"httpStatus" : "OK",
"message" : "Receipt retrieved successfully."
}
}

Here are some important observations in the response:

  • receiptXML contains a string with a specialized printing instructions of the receipt in XML format.

Query receipts

This API enables the possibility of making flexible queries. They can be done by providing different attributes of a receipt as request parameters. They can be queried by the store number, or a date when they were created. More specific queries can be built by using other attributes such as the type of transaction, or the cashier that created receipts in a given date, there any many possibilities and combinations that could serve different purposes. To make these queries, a GET request must be done providing different receipt attributes as request parameters, in this example, we are querying receipts created in a specific store and a specific date as shown here /receipts?store.storeId=1337&createDateTime=startsWith(2019-01-16), no request body is required.

Example response:

{
"receipts": [{
"receipt": {
"id" : "5c3f59e4368d0e448c15557e",
"receiptNumber" : 1,
"cartId" : "cartId01",
"cartCreateDateTime" : "2018-11-26T16:41:34+00:00",
"transactionType" : "SALE",
"stationId" : "1",
"store" : {
"storeId" : "1337",
"branchName" : "Reno Store Osnabrück",
"distChannel" : "DE01RE",
"address" : {
"country" : "DE",
"city" : "Osnabrück",
"postalcode" : "49074",
"street" : "Möserstraße",
"houseNumber" : "2-3"
},
"phone" : "0541/5009780",
"defaultCurrency" : "EUR",
"taxId" : "123456789"
},
"cashier" : {
"id" : "11111",
"name" : "Erika",
"lastname" : "Mustermann",
"salutation" : "Frau",
"store" : "1337"
},
"items" : [ {
"positionId" : 0,
"sku" : "10005",
"description" : "FU Pflegemit Spray",
"quantity" : 3,
"basePrice" : {
"value" : 6600,
"currency" : "EUR"
},
"totalBasePrice" : 6600,
"discounts" : [ ],
"totalDiscountAmount" : 0,
"priceAfterDiscounts" : 6600,
"vatCode" : "A5",
"vatRate" : 19,
"priceBeforeVat" : 5346,
"vatAmount" : 1254,
"status" : "OPEN"
} ],
"paymentDetails" : {
"paymentTransactions" : [ {
"transactionStatus" : "PARTIAL",
"time" : "2017-12-24T18:25Z",
"method" : "Kartenzahlung",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
}, {
"transactionStatus" : "CLOSED",
"time" : "2017-12-24T18:25Z",
"method" : "Barzahlung",
"currency" : "EUR",
"monetaryFlowType" : "PAYMENT",
"transactionType" : "SALE",
"amount" : 5000
} ],
"customerPaid" : 10000,
"changeValue" : 1,
"transactionEnd" : "2017-12-24T18:25Z",
"grossSum" : -9999,
"deRundetAuf" : 0,
"netSum" : -8403,
"currency" : "EUR",
"vatTotals" : [ {
"vatCode" : "A5",
"vatRate" : 19,
"vatAmountSum" : -1596
} ]
},
"createDateTime" : "2019-01-16T17:20:52.092",
"barcode" : "1712240133701000001"
}
}],
"apiResponseStatus" : {
"responseCode" : "I08003",
"httpStatus" : "OK",
"message" : "Receipts retrieved successfully."
}
}

Here are some important observations in the response:

  • receipts is the result of the query made, the receipts in the list match the criteria provided in the request parameters.