.. _SystemIntegration_HandlingElectronicPayment: ################## Electronic Payment ################## .. _SystemIntegration_ElectronicPayment_PaymentSessionStates: Payment Session *************** A payment session is created each time :ref:`a payment session is started `. .. attention:: * It is possible for a terminal to handle mutiple open payment sessions, however this is not yet supported by the RestApi. A payment session can have the following states: * Created = 0 : (temporary state) initial state after :ref:`a payment session is started `. * WaitForCard = 10 : (temporary state) state after a payment request is sent to the payterminal. the terminal waits for a card to be presented. * WaitForAuthorization = 20 : (temporary state) a card is presented and the terminal requests authorization at the acquirer. * Authorized = 21 : (temporary state) payment is authorized by acquirer. * WaitForCommit = 30 : (temporary state) waiting to commit authorized payment. * Cancelled = 40 : (end state) payment has been cancelled by the user or through an api call. See :ref:`cancel a payment session `. * Success = 50 : (end state) payment is successfull. * Failed = 60 : (end state) payment has failed, no money is withdrawn from the customer account. * Uncertain = 70 : (end state) payment has failed and outcome is uncertain (result should be verified manually in the webportal) .. _SystemIntegration_ElectronicPayment_TerminalStates: Terminal states *************** * Initializing : 0, * Ready = 1 .. note:: A new payment session can only be started if the terminal state = 'Ready'. .. _SystemIntegration_ElectronicPayment_GetState: Get the terminal and pending payment sessions state **************************************************** Returns the terminal state and pending sessions. Currently only one pending session is allowed. **URL parameters** * **hostIp**: ip address of the API host. * **deviceId**: id of the device. .. http:get:: https://{hostIp}:7081/hal/devices/{deviceId}/electronicpayment **Example request**: .. sourcecode:: http GET /hal/devices/payter1/electronicpayment 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": 1 "sessions":[ { "id": "85354418-0446-45fa-9c64-0efbfb2e37b4", "state":10, "startedUtc": "2025-02-26T12:33:20.4325251Z" }, ... { "id": "6e3e10e2-5074-41d3-9e4c-623899f75785", "state": 20 "startedUtc": "2025-02-25T12:33:20.4325251Z" }] } :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:`terminal states ` :>json array sessions: array of pending session. currently only one session is allowed. * id (guid): session id * state (int): see :ref:`payment session states `. * startedUtc (datetime): session creation time (utc) .. _SystemIntegration_ElectronicPayment_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}/electronicpayment/sessions/{sessionId} **Example request**: .. sourcecode:: http GET /hal/devices/payter1/electronicpayment/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 { "id": "6e3e10e2-5074-41d3-9e4c-623899f75785", "state": 50, "startedUtc": "2025-02-26T11:15:46.0543259Z" "endedUtc": "2025-02-26T11:16:30.9289079Z" "toPay": 100, "payed": 100, "reference":30000, "error": { "id":0, "message":"" }, "receipt":"Receipt\r\nAID A0000000043060\r\nBrand Maestro\r\nCard 581322xxxxxxx7135\r\nPAN Seq No 50\r\nInterface Contactless\r\nTransaction Type Pre-Auth\r\nAuthorized Amount 0.02 EUR\r\nFinal Amount 0.02 EUR\r\nPre-auth Amount 0.02 EUR\r\nOutcome Approved\r\nState Final\r\nAuth Code 51065192\r\nReference 1841185189347032301\r\nUser Reference 30000\r\nTerminal ID \r\nTime 04/03/2025 11:46:27 (CET)\r\n\u0000", "cardInfo":{ "cardUid": "hex string", "cardHash": "hex string", "maskedPan": "string" } } :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 Error error: (optional) null if no error. * id (int): error id - NotStarted = 1, - NotAuthorized = 2, - NotFullyAuthorized = 3, - NotCommitted = 4 * message (string) :>json string receipt: ticket receipt (pre-formatted by the terminal). Only available in case of a successfull payment :>json CardInfo cardInfo: only available after presenting a card * cardUID (string) * cardHash (string) * maskedPan (string) .. _SystemIntegration_ElectronicPayment_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 ` * Requesting the :ref:`terminal and 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}/electronicpayment/sessions/start **Example request**: .. sourcecode:: http POST /hal/devices/payter1/electronicpayment/sessions/start HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... Content-Type: application/json { "toPay": 5, "reference": 10, "autoCommit": true, "language": "en" } :jsonparam uint toPay: (4bytes) payment amount in Cent (Euro). :jsonparam uint reference: (4bytes) reference for the payment. :jsonparam bool autoCommit: (optional) allows payment reservation sessions (toPay is not displayed on payterminal screen when autoCommit=false) :jsonparam bool language: language during payment. Possible values: "en", "de", "fr", "nl" (language support depends on the payment terminal type) **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "sessionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6" } :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_ElectronicPayment_CancelPaymentSession: Cancel a payment session ************************ Cancels a pending payment session. The result is '200 OK' if a new payment session is cancelled. .. note:: Note that cancellation is only possible in the session state **WaitForCard** The payment session state can be evaluated by: * Processing the :ref:`payment session state websocket messages ` * Requesting the :ref:`terminal and 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}/electronicpayment/sessions/{sessionId}/cancel **Example request**: .. sourcecode:: http POST /hal/devices/payter1/electronicpayment/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 Commit a reserved payment session ********************************* .. attention:: This feature is not supported in the current version. Commits a pending payment reservation session. * The result is '200 OK' if the payment reservation session is committed. The payment session state can be evaluated by: - Processing the :ref:`payment session state websocket messages ` - Requesting the :ref:`terminal and 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}/electronicpayment/sessions/{sessionId}/commit **Example request**: .. sourcecode:: http POST /hal/devices/payter1/electronicpayment/sessions/6e3e10e2-5074-41d3-9e4c-623899f75785/commit HTTP/1.1 Accept: application/json Authorization: Bearer eyJhbGciOiJS... Content-Type: application/json { "toPay": 100, } :jsonparam string toPay: final payment amount in Cent (Euro). Must be equal or lower than the reserved amount. **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 ****** .. _SystemIntegration_ElectronicPayment_PaymentSessionStateChanged: Payment session state changed ============================= The websocket server will send 'payment session state change' websocket messages to a registered client. The websocket - method name will be "**receivePaymentSession**". **Example of an event after an payment session state change** :: "messageType": 1, "data": { "methodName": "receivePaymentSession", "arguments": [ { "sessions": [ { "id": "6e3e10e2-5074-41d3-9e4c-623899f75785", "state": 50, "startedUtc": "2025-02-26T11:15:46.0543259Z" }], "deviceId": "payter1", "version": "1.0" } ]}