.. _SystemIntegration_HandlingCashPayment: ##################################### Cash Payment (NOT FOR COMMERCIAL USE) ##################################### .. _SystemIntegration_CashPayment_PaymentSessionStates: Payment Session *************** A payment session is created each time :ref:`a payment session is started `. A payment session can have the following states: * Created = 0 : (temporary state) initial state after :ref:`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 :ref:`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 .. _SystemIntegration_CashPayment_CashbagStates: 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. .. _SystemIntegration_CashPayment_GetState: Get the pending payment session state ************************************** Returns the pending session. **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:get:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment **Example request**: .. sourcecode:: http GET /hal/devices/whb1/cashpayment HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... **Example response**: .. sourcecode:: http 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" } } :statuscode 200: OK :statuscode 400: Bad Request. A descriptive error comes along with this error. :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error :resheader Content-Type: defines the serialization format for the response body (this depends on the :mailheader:`Accept` header of the request) :>json object session: pending session * id (guid): session id * state (int): see :ref:`payment session states `. * startedUtc (datetime): session creation time (utc) .. _SystemIntegration_CashPayment_GetDetailedSessionState: 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). .. http:get:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/{sessionId} **Example request**: .. sourcecode:: http GET /hal/devices/whb1/cashpayment/sessions/6e3e10e2-5074-41d3-9e4c-623899f75785 HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... **Example response**: .. sourcecode:: http 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 } :statuscode 200: OK :statuscode 400: Bad Request. A descriptive error comes along with this error. :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error :resheader Content-Type: defines the serialization format for the response body (this depends on the :mailheader:`Accept` header of the request) :>json guid id: session id :>json int state: see :ref:`payment session states ` :>json datetime startedUtc: session creation time (utc) :>json datetime endedUtc: session ended time (utc) :>json uint toPay: to pay value in cents :>json uint payed: payed value in cents :>json uint reference: reference number passed when :ref:`starting is payment session `. :>json object error: null if no error. * id (int): error id - Timedout = 0, * message (string): error message :>json List coins: list of accepted coins in cents :>json List coinErrors: list of coin errors caused by refused coins :>json bool isTest: indicates if the session was started in test mode .. _SystemIntegration_CashPayment_StartPaymentSession: 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: * Processing the :ref:`payment session state websocket messages ` * Processing the :ref:`coin inserted websocket messages ` * Requesting the :ref:`payment session states ` **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:post:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/start **Example request**: .. sourcecode:: http 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 } :jsonparam uint toPay: (4bytes) payment amount in Cent (Euro, [1,5000]). :jsonparam uint reference: (4bytes) reference for the payment. :jsonparam int timeout: max allowed time (in seconds, [10,600]) that coins will accepted. **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "sessionId": "b964ccfd-2f06-4235-85fd-0d447dcde370" } :statuscode 200: OK :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error :>json guid id: session id .. _SystemIntegration_CashPayment_CancelPaymentSession: 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: * Processing the :ref:`payment session state websocket messages ` * Requesting the :ref:`payment session states ` **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. * **sessionId**: payment session id (guid). .. http:post:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/sessions/{sessionId}/cancel **Example request**: .. sourcecode:: http 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**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 :statuscode 200: OK :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error .. _SystemIntegration_CashPayment_GetDetailedSessionState: Get the cashbag info ******************** **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:get:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/cashbag **Example request**: .. sourcecode:: http GET /hal/devices/whb1/cashpayment/cashbag HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... **Example response**: .. sourcecode:: http 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 } :statuscode 200: OK :statuscode 400: Bad Request. A descriptive error comes along with this error. :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error :resheader Content-Type: defines the serialization format for the response body (this depends on the :mailheader:`Accept` header of the request) :>json int state: see :ref:`cashbag states ` :>json datetime lastEmptiedUtc: timestamp (utc) of :ref:`resetting the cashbag ` :>json int insertedSinceLastEmptied: current value in eurocents since last emptied :>json int insertedCoinsSinceLastEmptied: number of inserted coins since last emptied .. _SystemIntegration_CashPayment_ResetCashbag: Reset cashbag ************* **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:post:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/cashbag/reset **Example request**: .. sourcecode:: http POST /hal/devices/whb1/cashpayment/cashbag/reset HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... Content-Type: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 :statuscode 200: OK :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error .. _SystemIntegration_CashPayment_StartCashTest: 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 :ref:`stop cash test ` **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:post:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/test/start **Example request**: .. sourcecode:: http POST /hal/devices/whb1/cashpayment/test/start HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... Content-Type: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 :statuscode 200: OK :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error .. _SystemIntegration_CashPayment_StopCashTest: Stop cash test *************** Stops a cash test session. **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:post:: https://{hostIp}:7081/hal/devices/{deviceId}/cashpayment/test/stop **Example request**: .. sourcecode:: http POST /hal/devices/whb1/cashpayment/test/stop HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... Content-Type: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 :statuscode 200: OK :statuscode 401: Unauthorized. Something is wrong with the :mailheader:`Authorization` header of the request :statuscode 403: Forbidden. Something is wrong with the claims of the user. :statuscode 500: Internal Server Error Events ****** The websocket server will send 'payment session state change' and 'coin inserted' websocket messages to a registered client. .. _SystemIntegration_CashPayment_PaymentSessionStateChanged: 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 } .. _SystemIntegration_CashPayment_CoinInserted: 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 }