Sdk for Gerencianet Pagamentos' API. For more informations about parameters and values, please refer to Gerencianet documentation.
Em caso de dúvidas, você pode verificar a Documentação da API na Gerencianet e, necessitando de mais detalhes ou informações, entre em contato com nossa consultoria técnica, via nossos Canais de Comunicação.
- Java >= 7.0
java 7.0 and 8.0
Via gradle:
compile 'br.com.gerencianet.gnsdk:gn-api-sdk-java:2.0.0'
Via maven:
<dependency>
<groupId>br.com.gerencianet.gnsdk</groupId>
<artifactId>gn-api-sdk-java</artifactId>
<version>2.0.0</version>
</dependency>
Require the module and packages:
import br.com.gerencianet.gnsdk.Gerencianet;
import br.com.gerencianet.gnsdk.exceptions.GerencianetException;
Although the web services responses are in json format, the sdk will convert any server response to a JSONObject or a Map<String, Object>. The code must be within a try-catch and exceptions can be handled as follow:
```java
try {
/* code */
} catch(GerencianetException e) {
/* Gerencianet's api errors will come here */
} catch(Exception ex) {
/* Other errors will come here */
}
Instantiate the module passing using your client_id, client_secret and sandbox equals true:
JSONObject options = new JSONObject();
options.put("client_id", "client_id");
options.put("client_secret", "client_secret");
options.put("certificate", "./certs/developmentCertificate.p12");
options.put("sandbox", true);
Gerencianet gn = new Gerencianet($options);
Or
Map<String, Object> options = new HashMap<String, Object>();
options.put("client_id", "client_id");
options.put("client_secret", "client_secret");
options.put("certificate", "./certs/developmentCertificate.p12");
options.put("sandbox", true);
Gerencianet gn = new Gerencianet($options);
To change the environment to production, just set the third sandbox to false:
JSONObject options = new JSONObject();
options.put("client_id", "client_id");
options.put("client_secret", "client_secret");
options.put("certificate", "./certs/productionCertificate.p12");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet($options);
Or
Map<String, Object> options = new HashMap<String, Object>();
options.put("client_id", "client_id");
options.put("client_secret", "client_secret");
options.put("certificate", "./certs/productionCertificate.p12");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet($options);
To run the test suite with coverage:
mvn clean test jacoco:report
To run some existing examples follow the steps described at gn-api-sdk-java-examples.
The full documentation with all available endpoints is in https://dev.gerencianet.com.br/.