Search in sources :

Example 1 with TokensClient

use of com.ingenico.connect.gateway.sdk.java.merchant.tokens.TokensClient in project connect-sdk-client-android by Ingenico-ePayments.

the class TokenUtil method createToken.

public String createToken(String merchantId, CreateTokenRequest body) throws CommunicationException {
    TokensClient tokensClient = client.merchant(merchantId).tokens();
    CreateTokenResponse response = tokensClient.create(body);
    if (response.getIsNewToken()) {
        return response.getToken();
    }
    String tokenId = response.getToken();
    tokensClient.delete(tokenId, new DeleteTokenParams());
    response = tokensClient.create(body);
    return response.getToken();
}
Also used : DeleteTokenParams(com.ingenico.connect.gateway.sdk.java.merchant.tokens.DeleteTokenParams) CreateTokenResponse(com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse) TokensClient(com.ingenico.connect.gateway.sdk.java.merchant.tokens.TokensClient)

Aggregations

CreateTokenResponse (com.ingenico.connect.gateway.sdk.java.domain.token.CreateTokenResponse)1 DeleteTokenParams (com.ingenico.connect.gateway.sdk.java.merchant.tokens.DeleteTokenParams)1 TokensClient (com.ingenico.connect.gateway.sdk.java.merchant.tokens.TokensClient)1