Handling the response | Response received Callback

The manual settlement is requested by the POS using the manualSettlement() function is returned using the responseReceivedCallback.

The result field contains the result of the request and will be one of two values, i.e., “success” or "failure."  The message field contains a text string that is to be displayed to the user, along with the currentTerminalBusinessDay, which returns the current reporting day after the settlement request and is only returned if the result is success, and the format is dd/mm/yyyy.

Example Response

Copy
Copied
{
"result":"success",
"message":"Settlement complete",
"currentTerminalBusinessDay":"19/01/2024"
}

Response received Callback

Function Description Usage Required
responseReceivedCallback Invoked when the request has been completed on the terminal. Called with a single object containing the following fields as shown in the below table. Required
Field Type Description Usage Required
result String The result of the report request, will be either ‘success’ or ‘failure’. Required
message String The message that is to be displayed to the merchant. Required
currentTerminalBusinessDay String Current reporting day after settlement request. Only returned if result is success. Format dd/MM/yyyy. Required

Steps to Follow

The steps to be followed in handling the response of the integrated manual settlement request are given as follows:

  1. You are required to program the function which handles the callback and the fields that are made available as part of the responseReceivedCallback .
  2. The POS must display a modal that displays the result of the request along with the message, and currentTerminalBusinessDay fields that are returned in case of a sucessful request.
  3. The POS must display a modal that displays the result of the request along with the message fields that are returned in case of an unsucessful request.

Callback Function

Given below is an example of a callback function created to handle the response of the manual settlement request.

Copy
Copied
var responseReceivedCallback = function(response) {
console.log(JSON.stringify(response));
$("#result").html(response.result);
$("#Message").html(response.message);
$("#TerminalBusinessDay").html(response.currentTerminalBusinessDay);

}

responseReceivedCallback Example Response

Given below is an example response returned for a successful manual settlement request.

Copy
Copied
{
  "result":"success",
  "message":"Settlement complete",
  "currentTerminalBusinessDay": "18/12/2021"
  
}
Copyright © Tyro Payments 2019-2022. All right reserved.