Histórico de mensagens sobre Erro

EXIBINDO CONVERSAS RECENTES:

Texto: Erro
Data: 20/10/2024
# pix
Avatar discord do usuario rafaaoki

rafaaoki

Ver Respostas


Credentials credentials = new Credentials();

HashMap options = new HashMap();
options.put("client_id", credentials.getClientId());
options.put("client_secret", credentials.getClientSecret());
options.put("certificate", credentials.getCertificate());
options.put("sandbox", credentials.isSandbox());

HashMap params = new HashMap();
params.put("idEnvio", "12453567890123456789");

Map body = new HashMap();
body.put("valor", "99.99");

Map pagador = new HashMap();
pagador.put("chave", "Insira_aqui_sua_chave");
body.put("pagador", pagador);

Map favorecido = new HashMap();
favorecido.put("chave", "joã[email protected]");
body.put("favorecido", favorecido);

try {
EfiPay efi= new EfiPay(options);

Map response = efi.call("pixSend", params, body);
System.out.println(response);
}catch (EfiPayException e){
System.out.println(e.getError());
System.out.println(e.getErrorDescription());
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
este seria de envio entao?

# pix
Avatar discord do usuario rafaaoki

rafaaoki

Ver Respostas

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?