Cash Payment (NOT FOR COMMERCIAL USE)

Payment Session

A payment session is created each time a payment session is started.

A payment session can have the following states:

  • Created = 0 : (temporary state) initial state after a payment session is started. This state is short-lived and is immediately followed by ‘WaitForPayment’

  • WaitForPayment = 10 : (temporary state) state after a payment request is sent. the coin acceptor is now ready to accept coins.

  • Cancelled = 40 : (end state) payment has been cancelled through an api call. See cancel a payment session.

  • Success = 50 : (end state) payment is successfull.

  • Failed = 60 : (end state) payment has failed, already inserted coins are lost in case no coin dispenser hardware is present.

  • Uncertain = 70 : (end state) payment has failed and outcome is uncertain (result should be verified manually in the webportal), already inserted coins are lost in case no coin dispenser hardware is present

Cashbag States

Coins are dropped in a cashbag when accepted by the coin validator.

The cashbag can have the following states:

  • Ok = 0

  • Almost full = 1

  • Full = 2

The cashbag state calculation is based on the number of coins being inserted, compared against the cashbag threshold values set through the ALIOT web portal.

Get the pending payment session state

Returns the pending session.

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

GET https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment

Example request:

GET /hal/devices/whb1/cashpayment HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "session": {
      "state": 10,
      "id": "2a31224d-2e91-43a1-9f9d-b098c1cdd726",
      "startedUtc": "2025-10-02T09:54:29.4639019Z"
   }
}
Status Codes:
Response Headers:
  • Content-Type – defines the serialization format for the response body (this depends on the Accept header of the request)

Response JSON Object:
  • session (object) –

    pending session

    • id (guid): session id

    • state (int): see payment session states.

    • startedUtc (datetime): session creation time (utc)

Get the detailed session state

Returns the details of a pending or ended session. The last 20 ended sessions can be retrieved. Older ended sessions can be consulted in the webportal.

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

  • sessionId: payment session id (guid).

GET https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/{sessionId}

Example request:

GET /hal/devices/whb1/cashpayment/sessions/6e3e10e2-5074-41d3-9e4c-623899f75785 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "state": 10,
   "id": "2a31224d-2e91-43a1-9f9d-b098c1cdd726",
   "startedUtc": "2025-10-02T09:54:29.4639019Z",
   "endedUtc": "0001-01-01T00:00:00",
   "toPay": 200,
   "payed": 100,
   "reference": 10000,
   "error":  {
      "id":0,
      "message":""
   },
   "coins": [
      50,
      50
   ],
   "coinErrors": [
      1
   ],
   "isTest":false
}
Status Codes:
Response Headers:
  • Content-Type – defines the serialization format for the response body (this depends on the Accept header of the request)

Response JSON Object:
  • id (guid) – session id

  • state (int) – see payment session states

  • startedUtc (datetime) – session creation time (utc)

  • endedUtc (datetime) – session ended time (utc)

  • toPay (uint) – to pay value in cents

  • payed (uint) – payed value in cents

  • reference (uint) – reference number passed when starting is payment session.

  • error (object) –

    null if no error.

    • id (int): error id

      • Timedout = 0,

    • message (string): error message

  • coins (List<uint>) – list of accepted coins in cents

  • coinErrors (List<int>) – list of coin errors caused by refused coins

  • isTest (bool) – indicates if the session was started in test mode

Start a new payment session

Initiates a new payment session. The result is ‘200 OK’ if a new payment session is started.

The payment session state can be followed by:

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

POST https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/start

Example request:

POST /hal/devices/whb1/cashpayment/sessions/start HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...
Content-Type: application/json

{
   "toPay": 200,
   "reference": 10,
   "timeout": 300
}
JSON Parameters:
  • toPay (uint) – (4bytes) payment amount in Cent (Euro, [1,5000]).

  • reference (uint) – (4bytes) reference for the payment.

  • timeout (int) – max allowed time (in seconds, [10,600]) that coins will accepted.

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "sessionId": "b964ccfd-2f06-4235-85fd-0d447dcde370"
}
Status Codes:
Response JSON Object:
  • id (guid) – session id

Cancel a payment session

Cancels a pending payment session. The result is ‘200 OK’ if a new payment session is cancelled.

Note

Cancellation is only possible if the session is not in an ended state.

The payment session state can be evaluated by:

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

  • sessionId: payment session id (guid).

POST https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/{sessionId}/cancel

Example request:

POST /hal/devices/whb1/cashpayment/sessions/6e3e10e2-5074-41d3-9e4c-623899f75785/cancel HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Status Codes:

Get the cashbag info

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

GET https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/cashbag

Example request:

GET /hal/devices/whb1/cashpayment/cashbag HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "state": 0,
   "lastEmptiedUtc": "2025-10-15T09:14:07.668Z",
   "insertedSinceLastEmptied": 50,
   "insertedCoinsSinceLastEmptied": 100
}
Status Codes:
Response Headers:
  • Content-Type – defines the serialization format for the response body (this depends on the Accept header of the request)

Response JSON Object:
  • state (int) – see cashbag states

  • lastEmptiedUtc (datetime) – timestamp (utc) of resetting the cashbag

  • insertedSinceLastEmptied (int) – current value in eurocents since last emptied

  • insertedCoinsSinceLastEmptied (int) – number of inserted coins since last emptied

Reset cashbag

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

POST https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/cashbag/reset

Example request:

POST /hal/devices/whb1/cashpayment/cashbag/reset HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Status Codes:

Start cash test

Starts a cash test session. In a test session all inserted coins are accepted and a payment session is created, but the inserted coins are not added to the cashbag total.

A test session must be stopped to stop coin being accepted. see stop cash test

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

POST https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/test/start

Example request:

POST /hal/devices/whb1/cashpayment/test/start HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Status Codes:

Stop cash test

Stops a cash test session.

URL parameters

  • hostIp: ip address of the API host.

  • deviceId: id of the device.

POST https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/test/stop

Example request:

POST /hal/devices/whb1/cashpayment/test/stop HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJS...
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Status Codes:

Events

The websocket server will send ‘payment session state change’ and ‘coin inserted’ websocket messages to a registered client.

Payment session state changed

The websocket - method name will be “receivePaymentSession”.

Example of an event after an payment session state change

{
   "data": {
      "methodName": "receivePaymentSession",
      "arguments": [
      {
         "sessions": [
         {
            "state": 10,
            "id": "b964ccfd-2f06-4235-85fd-0d447dcde370",
            "startedUtc": "2025-10-02T09:09:12.4877778Z"
         }],
         "deviceId": "whb1",
         "version": "1.0"
         }
     ]},
   "messageType": 1
}

Coin inserted

The websocket - method name will be “receiveCoinInserted”.

Example of an event after an coin being inserted

{
   "data": {
      "methodName": "receiveCoinInserted",
      "arguments": [
         {
            "value": 100,
            "deviceId": "whb1",
            "version": "1.0"
         }]
   },
   "messageType": 1
}