Building the API client library requires Maven to be installed.
To install the API client library to your local Maven repository, simply execute:
mvn installTo deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn deployRefer to the official documentation for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>Add this dependency to your project's build file:
compile "io.swagger:swagger-java-client:1.0.0"At first generate the JAR by executing:
mvn package
Then manually install the following JARs:
- target/swagger-java-client-1.0.0.jar
- target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
Example of an utility method to encrypt AES key with de public key
public static void encryptAESKey(String keyId, String key, String publicKey) throws Exception {
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] sigBytes = decoder.decodeBuffer(publicKey);
java.security.spec.X509EncodedKeySpec x509KeySpec = new java.security.spec.X509EncodedKeySpec(sigBytes);
java.security.KeyFactory keyFact = java.security.KeyFactory.getInstance(Algorithms.RSA);
java.security.PublicKey pubKey = keyFact.generatePublic(x509KeySpec);
Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
byte[] encrypted = cipher.doFinal(aesKey.getEncoded());
key = org.apache.commons.codec.binary.Base64.encodeBase64String(encrypted);
/*
(POST - https://api-visa.sensedia.com/security/v1/keys)
{
"id": keyId,
"key": key
}
*/
}
Example of an utility code to encrypt the requests
try {
byte[] cipherText = null;
final javax.crypto.Cipher cipher = Cipher.getInstance(Algorithms.AES);
java.security.Key aesKey = new javax.crypto.spec.SecretKeySpec(key.getBytes(), Algorithms.AES);
cipher.init(Cipher.ENCRYPT_MODE, aesKey);
String clientId = org.apache.commons.codec.binary.Base64.encodeBase64String(cipher.doFinal("CLIENT_ID".getBytes()));
// ACCESS_TOKEN format = accessToken_yyyy-MM-dd HH:mm:ss.SSS
String accessToken = org.apache.commons.codec.binary.Base64.encodeBase64String(cipher.doFinal("ACCESS_TOKEN".getBytes()));
String body = org.apache.commons.codec.binary.Base64.encodeBase64String(cipher.doFinal("BODY".getBytes()));
} catch (java.lang.Exception e) {
new java.lang.RuntimeException(e);
}
Code exemple to request
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.CartoesApi;
import java.io.File;
import java.util.*;
public class CartoesApiExample {
public static void main(String[] args) {
try {
byte[] cipherText = null;
final javax.crypto.Cipher cipher = Cipher.getInstance(Algorithms.AES);
java.security.Key aesKey = new javax.crypto.spec.SecretKeySpec("AES_KEY", Algorithms.AES);
cipher.init(Cipher.ENCRYPT_MODE, aesKey);
String clientId = org.apache.commons.codec.binary.Base64.encodeBase64String(cipher.doFinal("CLIENT_ID".getBytes()));
String accessToken = org.apache.commons.codec.binary.Base64.encodeBase64String(cipher.doFinal("ACCESS_TOKEN".getBytes()));
} catch (java.lang.Exception e) {
new java.lang.RuntimeException(e);
}
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: access_token
ApiKeyAuth access_token = (ApiKeyAuth) defaultClient.getAuthentication("access_token");
access_token.setApiKey(accessToken);
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//access_token.setApiKeyPrefix("Token");
// Configure API key authorization: key_id
ApiKeyAuth key_id = (ApiKeyAuth) defaultClient.getAuthentication("key_id");
key_id.setApiKey("KEY_ID");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//key_id.setApiKeyPrefix("Token");
// Configure API key authorization: client_id
ApiKeyAuth client_id = (ApiKeyAuth) defaultClient.getAuthentication("client_id");
client_id.setApiKey(clientId);
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//client_id.setApiKeyPrefix("Token");
CartoesApi apiInstance = new CartoesApi();
String tipoCartao = "fisico"; // String | Identifica qual o tipo do cartão, físico ou virtual.
try {
CartaoDisponivel result = apiInstance.cartoesGet(tipoCartao);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CartoesApi#cartoesGet");
e.printStackTrace();
}
}
}| Class | Method | HTTP request | Description |
|---|---|---|---|
| CartoesApi | cartoesGet | GET /cartoes | Obtém o número de identificação (Proxy) de um cartão |
| CartoesApi | cartoesIdCartaoExtratoGet | GET /cartoes/{idCartao}/extrato | Extrato do cartão |
| CartoesApi | cartoesIdCartaoPortadorGet | GET /cartoes/{idCartao}/portador | Informações do portador do cartão |
| CartoesApi | cartoesIdCartaoSaldoGet | GET /cartoes/{idCartao}/saldo | Saldo do cartão |
| CartoesApi | cartoesIdCartaoSaldoPut | PUT /cartoes/{idCartao}/saldo | Credita ou debita valor da conta de um cartão. |
| CartoesApi | cartoesIdCartaoStatusGet | GET /cartoes/{idCartao}/status | Status do cartão |
| CartoesApi | cartoesIdCartaoStatusPut | PUT /cartoes/{idCartao}/status | Altera status do cartão |
| CartoesApi | cartoesPost | POST /cartoes | Requisita um cartão de debito |
| PagamentosApi | pagamentosPost | POST /pagamentos | Pagamento de boletos. |
| TransferenciasApi | transferenciasCadastrosPost | POST /transferencias/cadastros | Cadastro de beneficiário |
| TransferenciasApi | transferenciasPost | POST /transferencias | Transferência de valor |
- CadastroBenificiario
- CartaoDisponivel
- DetalhamentoExtrato
- EnderecoPortador
- ExtratoResponse
- MsgErro
- NovoCartao
- NovoCartaoPortador
- NovoCartaoPortadorContato
- NovoCartaoPortadorEndereco
- Pagamento
- Portador
- PortadorResponse
- Saldo
- SetCardStatus
- SetNovoCartao
- SetPagamento
- SetSaldo
- SetSaldoValor
- SetTransferencia
- StatusCartaoResponse
- Transferencia
- TransferenciaCadastroBenificiario
- Valor
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: access_token
- Location: HTTP header
- Type: API key
- API key parameter name: client_id
- Location: HTTP header
- Type: API key
- API key parameter name: api_key
- Location: HTTP header
It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.