Android
Learn how to install and configure our Android SDK to use Efí APIs
Requests made to Efí APIs using the Android SDK require the certificate generated in your Efí account in .pem format.
Check here the step-by-step process to convert your P12 certificate to PEM format.
Prerequisites
Android 7.0+
Installation via gradle
implementation 'br.com.gerencianet.mobile:gn-api-sdk-android:1.0.0'
Our SDK is also available on our repository on Github.
Tested with
Android 7.0
and 11.0
Basic Usage
Require the module and packages:
import br.com.gerencianet.mobile.Gerencianet;
- Android
try {
/* code */
} catch(GerencianetException e) {
/* Gerencianet's api errors will come here */
} catch(Exception ex) {
/* Other errors will come here */
}
For sandbox environment
Instantiate the module passing your Client_Id, Client_Secret, and setting sandbox to true
:
- Sandbox
HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("sandbox", true);
Gerencianet gn = new Gerencianet(options);
For production environment
To change the environment to production, simply set the third sandbox to false
, and its Client_Id and Client_Secret to production:
- Production
HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet(options);
Pix API
To use the PIX API, it is necessary to enter the certificate path, in .12 format within the assets folder and pass the assets of the context as a parameter.
- Pix API
HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("pix_cert", "./cert.p12");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet(options, context.getAssets());