Getnet DocsGetnet Docs

Check Terminal Connectivity (Polling)

This guide shows you how to verify if the Getnet Payment App is connected and ready to receive commands. The Polling operation checks connectivity and ensures the terminal is in a ready state to process new requests.

Before you begin

Before starting, ensure you have:

  • Getnet Payment App installed on the Android terminal
  • Your application configured to handle Android Intents
  • Basic understanding of the App2App integration model

Recommendation: Perform a Polling request as the initial step before any operation to ensure the terminal is ready and not processing another transaction.

Step 1: Send the polling request

To check terminal connectivity, create an Intent with the Polling URI and send it to the Getnet Payment App.

private val POLLING_REQUEST_CODE = 1001

fun checkTerminalStatus() {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/polling"))
    startActivityForResult(intent, POLLING_REQUEST_CODE)
}

The Polling deeplink does not require any parameters. The terminal will immediately respond with its current status.

Step 2: Handle the response

Capture and process the response returned by the Getnet Payment App in the onActivityResult method.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    
    if (requestCode == POLLING_REQUEST_CODE && resultCode == RESULT_OK) {
        val result = data?.extras?.getString("result")
        val resultDetails = data?.extras?.getString("resultDetails")
        
        when (result) {
            "0" -> {
                // Terminal is ready
                Log.d("Polling", "Terminal ready: $resultDetails")
                // Proceed with your operation
            }
            else -> {
                // Terminal is not ready or error occurred
                Log.e("Polling", "Terminal not ready: $resultDetails")
                // Handle error appropriately
            }
        }
    }
}

Response Parameters

ParameterTypeDescription
resultStringStatus code: "0" indicates terminal is ready
resultDetailsStringDetailed message about the terminal status

Example response when terminal is ready:

{
  "result": "0",
  "resultDetails": "success"
}

Next steps

Once you have verified the terminal is ready via Polling, you can proceed to: