gn-api-sdk-java-examples
gn-api-sdk-java-examples copied to clipboard
Erro ao gerar Charge
Quando eu tento gerar um charge com minhas credenciais utilizando a API no meu servidor tomcat 7, utilizando JAVA 7, recebo a seguinte exception, alguma orientação de como resolver?
java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3071)
Meu código:
` try {
/* Setando credenciais */
JSONObject options = new JSONObject();
options.put("client_id", "meu_id");
options.put("client_secret", "meu_secret");
options.put("sandbox", true);
JSONArray items = new JSONArray();
JSONObject item = new JSONObject();
item.put("name", "Teste");
item.put("amount", 1);
item.put("value", 5000);
items.put(item);
/* Definindo body da transação */
JSONObject body = new JSONObject();
body.put("items", items);
/* Requisitando transação, retorno setado em charge */
Gerencianet gn = new Gerencianet(options);
JSONObject responseCharge = gn.call("createCharge", new HashMap<String,String>(), body);
System.out.println(responseCharge);
} catch(Exception e) {
e.printStackTrace();
}`
Conseguiu resolver?
Mesmo problema :/