Search in sources :

Example 1 with SessionResponse

use of com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class BaseAsyncTaskTest method initializeValidMocksAndSession.

/**
 * Creates a mocked configuration that produces valid requests
 */
void initializeValidMocksAndSession() throws CommunicationException {
    SessionRequest request = new SessionRequest();
    if (token != null) {
        request.setTokens(Collections.singletonList(token));
    }
    try {
        SessionResponse response = sessionUtil.createSession(testMerchantId, request);
        initializeValidMocks(response);
    } catch (ApiException e) {
        throw new CommunicationException("ApiException while creating session", e);
    }
}
Also used : CommunicationException(com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException) SessionResponse(com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionResponse) SessionRequest(com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionRequest) ApiException(com.ingenico.connect.gateway.sdk.java.ApiException)

Example 2 with SessionResponse

use of com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionResponse in project connect-sdk-java by Ingenico-ePayments.

the class CreateSessionExample method example.

@SuppressWarnings("unused")
public void example() throws URISyntaxException, IOException {
    Client client = getClient();
    try {
        List<String> tokens = new ArrayList<String>();
        tokens.add("126166b16ed04b3ab85fb06da1d7a167");
        tokens.add("226166b16ed04b3ab85fb06da1d7a167");
        tokens.add("122c5b4d-dd40-49f0-b7c9-3594212167a9");
        tokens.add("326166b16ed04b3ab85fb06da1d7a167");
        tokens.add("426166b16ed04b3ab85fb06da1d7a167");
        SessionRequest body = new SessionRequest();
        body.setTokens(tokens);
        SessionResponse response = client.merchant("merchantId").sessions().create(body);
    } finally {
        client.close();
    }
}
Also used : ArrayList(java.util.ArrayList) Client(com.ingenico.connect.gateway.sdk.java.Client) SessionResponse(com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionResponse) SessionRequest(com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionRequest)

Aggregations

SessionRequest (com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionRequest)2 SessionResponse (com.ingenico.connect.gateway.sdk.java.domain.sessions.SessionResponse)2 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)1 ApiException (com.ingenico.connect.gateway.sdk.java.ApiException)1 Client (com.ingenico.connect.gateway.sdk.java.Client)1 ArrayList (java.util.ArrayList)1