Documentation

1Terminal Introduction

Generally there are are two ways to process payments on a terminal:

  • Use the terminal in the standalone mode where the cashier is entering the amount to charge on the terminal or

  • connect the till to the terminal and allow the till to coordinate the payment on the terminal.

In the standalone mode there is no integration required and as such it can be simply used. The transactions done on the terminal will appear in the transaction list once they are executed.

To connect the till with the terminal consists on the following steps:

  1. Ensure the terminal is connected to the Internet. This might be different depending on the terminal hardware.

  2. Create a transaction with the Transaction Service. Use the create operation to create a new transaction.

  3. Use the till-connection-credentials method of the Transaction Terminal Service to get connection credentials for your transaction and the terminal it should be processed on.

  4. Connect your till to initialize the processing of the payment by using WebSockets. You need to implement some interactive process through the WebSocket.

The creation of the transaction is done in the same way as for any other integration. The details of the WebSocket integration are described in the following sections.

2Till Integration with WebSockets

As there are interactions between the cashier and the terminal during the payment process a technique has to be used which supports this. Specifically the interaction requires a two way communication. WebSockets allow this kind of communication.

Within the WebSocket the STOMP protocol is used to exchange messages. See https://stomp.github.io/stomp-specification-1.2.html

2.1Connect

The connect will open the connection and as a result the transaction processing on the terminal will start. All the details about the transaction like amount etc. is taken from the transaction object as created earlier with the Transaction Service over the regular REST API.

When the WebSocket is breaking because of a network issue (e.g. in a mobile network this can happen often) the payment processing will not stop. The WebSocket can be again opened and the Connect can be sent again. The transaction is tried to be resumed. If the timeout has been reached the transaction will fail and accordingly the error message will be sent from the server. In this case a new transaction must be started.

2.2WebSocket Messages

The messages to display on the till are passed as plain JavaScript objects and can contain the following elements.

2.2.1Notification

The notification contains information to display to the attendant on the till.

{
	information: {
		elements: [ ... ],
		recipient: "CUSTOMER" or "MERCHANT"
	}
}

2.2.2Question

The question contains information to display to the attendant on the till and options he needs to chose from.

{
	information: {
		elements: [ ... ],
		recipient: "CUSTOMER" or "MERCHANT"
	},
	options: [
		{
			identifier: "option-1",
			text: "First option",
			primary: true
		},
		{
			identifier: "option-2",
			text: "Second option",
			primary: false
		}
	]
}

2.2.3Error

Errors to WebSocket requests contain the following information.

{
	id: "ab-1234567 (2000-01-01T00:00:00.000Z)",
	date: "2000-01-01T00:00:00.000",
	message: "Translated error message",
	defaultMessage: "English error message",
	type: "END_USER_ERROR" or "CONFIGURATION_ERROR" or "DEVELOPER_ERROR" or "SERVER_ERROR"
}

2.3Elements

Paragraph

The paragraph represents a block of text.

Example

Ridiculus metus pulvinar morbi natoque sem etiam dictum, hac ipsum placerat risus orci est ante, fames tellus felis erat elit gravida. Euismod facilisis gravida sollicitudin nisi pellentesque tincidunt enim fusce dictum sit, odio magna feugiat interdum varius himenaeos diam venenatis sociis.

{
	text: "Ridiculus metus pulvinar morbi natoque sem etiam dictum, hac ipsum placerat risus orci est ante, fames tellus felis erat elit gravida. Euismod facilisis gravida sollicitudin nisi pellentesque tincidunt enim fusce dictum sit, odio magna feugiat interdum varius himenaeos diam venenatis sociis.",
	type: "PARAGRAPH"
}

Ordered List

The ordered list represents a numbered list of items:

Example
  1. First

  2. Second

  3. Third

{
	items: [
		{ text: "First" },
		{ text: "Second" },
		{ text: "Third" }
	],
	type: "ORDERED_LIST"
}

Unordered List

The unordered list represents a list of items with bullet points.

Example
  • First

  • Second

  • Third

{
	items: [
		{ text: "First" },
		{ text: "Second" },
		{ text: "Third" }
	],
	type: "UNORDERED_LIST"
}

Description List

The ordered list represents a list of items with description.

Example
First

The first element

Second

The second element

Third

The third element

{
	items: [
		{
			description: "First",
			text: "The first element"
		},
		{
			description: "Second",
			text: "The second element"
		},
		{
			description: "Third",
			text: "The third element"
		}
	],
	type: "DESCRIPTION_LIST"
}

Table

Table 1. Example
Text Number Amount

First

1

USD1.00

Second

2

CHF2.00

Third

3

EUR3.00

{
	columns: [
		{
			identifier: "text",
			text: "Text",
			type: "TEXT"
		},
		{
			identifier: "number",
			text: "Number",
			type: "NUMBER"
		},
		{
			identifier: "amount",
			text: "Amount",
			type: "AMOUNT"
		}
	],
	rows: [
		{ cells: [
			{ column: "text", text: "First" },
			{ column: "number", text: "1" },
			{ column: "amount", text: "USD1.00" }
		] },
		{ cells: [
			{ column: "text", text: "Second" },
			{ column: "number", text: "2" },
			{ column: "amount", text: "CHF2.00" }
		] },
		{ cells: [
			{ column: "text", text: "Third" },
			{ column: "number", text: "3" },
			{ column: "amount", text: "EUR3.00" }
		] },
	],
	type: "TABLE"
}

3JavaScript SDK

To connect your till via a WebSocket using JavaScript, we recommend using our TerminalTillConnection JavaScript utility.

  1. Include the JavaScript file of the utility.

    <script src="https://app-wallee.com/assets/payment/terminal-till-connection.js" type="text/javascript"></script>
  2. Create a new instance of TerminalTillConnection passing the WebSocket URL, the connection credentials as options.

    var tillConnection = new TerminalTillConnection({
    	url: "wss://app-wallee.com/terminal-websocket",
    	token: "[connection-credentials]"
    });
  3. Subscribe to events to handle messages from the terminal.

    tillConnection.subscribe("notification", function(payload){
    	// Display the information on the till.
    });
    
    tillConnection.subscribe("question", function(payload, callback){
    	// Display the question on the till and allow the attendant to chose one of the options.
    	// Call the callback method with the chosen option's identifier as argument.
    	callback(optionIdentifier);
    });
    
    tillConnection.subscribe("charged", function(){
    	// The transaction has been successfully charged.
    });
    
    tillConnection.subscribe("canceled", function(){
    	// The payment was canceled.
    });
    
    tillConnection.subscribe("error", function(error){
    	// An error occurred during the process of a WebSocket request.
    });
    
    tillConnection.subscribe("connected", function(){
    	// The connection has been established.
    });
    
    tillConnection.subscribe("disconnected", function(){
    	// The connection has been disconnected or lost.
    });
  4. Establish the connection.

    tillConnection.connect();
  5. Use the cancel method to cancel the payment.

    tillConnection.cancel();