Connection¶
Establishing Connection¶
Warning
bind is necessary to establish communication between the integration app and the pix app. All other functions must be executed only after bind have been carried out..
val pixClient = PixClient(context)
val bindCallback = object : PixClient.BindCallback {
override fun onServiceConnected() {
println("Conectado")
}
override fun onServiceDisconnected() {
println("Desconectado")
}
}
pixClient.bind(bindCallback)
If you need to check whether the connection is still active, you can using the isBound function:
val pixClient = PixClient(context)
val bound = pixClient.isBound()
println(bound)
At the end of the application execution, the connection must be closed, To do this, use the unbind method
val pixClient = PixClient(context)
pixClient.unbind()
Success and error responses¶
The app that is integrating will always receive a string in json format both in
onSuccess as in onError. The response structures are:
// success response
{
"tx_id": "b849b36b-7846-48f8-81ce-a8dbf2530f42",
"cob_value": "20.00",
"status": "CONCLUIDA",
}
// error response
{
"error_message": "Error generating billing"
}
Check if the pix app is installed¶
isAppPixInstalled()¶
To use the integration, in addition to the SDK, the terminal must have the PIX payments application, so the SDK has a function that returns a boolean checking whether the pix application is installed or not
val pixClient = PixClient(context)
val pixInstalled = pixClient.isAppPixInstalled()
println(pixInstalled) // true ou false