public CobGerada pixCreateImmediateCharge(ClienteDto cliente) throws JSONException, EfiPayException {
try {
Credentials credentials = new Credentials();
JSONObject options = new JSONObject();
options.put("client_id", credentials.getClientId());
options.put("client_secret", credentials.getClientSecret());
options.put("certificate", credentials.getCertificate());
options.put("sandbox", credentials.isSandbox());
JSONObject body = new JSONObject();
System.out.println(cliente.toString());
String cpf = cliente.cpf().replaceAll("\\.", "");
cpf = cpf.replaceAll("-", "");
String rg = cliente.rg().replaceAll("\\.", "");
rg = rg.replaceAll("-", "");
body.put("calendario", new JSONObject().put("expiracao", 3600));
body.put("devedor", new JSONObject().put("cpf", cpf ).put("nome" , cliente.nome_completo()));
body.put("valor", new JSONObject().put("original", "0.01"));
body.put("chave", "3c4961f4-0921-4eda-97bc-71704defb09f");
EfiPay efi = new EfiPay(options);
JSONObject response = efi.call("pixCreateImmediateCharge", new HashMap(), body);
CobGerada res = new Gson().fromJson(response.toString() , CobGerada.class);
return res;
}catch (EfiPayException e){
System.out.println(e.getError());
System.out.println(e.getErrorDescription());
throw new RuntimeException(e.getMessage());
}
catch (Exception e) {
System.out.println(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
esse codigo funcionaria como um envio de pagamento pix via api?