From 92b381b5aee6bc821d3fb297522fd0fd6eb8f597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:15:36 +0100 Subject: [PATCH] Add telemetry wip --- README.md | 19 ++++- .../checkout/AbstractCheckoutSdkBuilder.java | 8 +- .../checkout/ApacheHttpClientTransport.java | 52 ++++++++++++- src/main/java/com/checkout/ApiClientImpl.java | 2 +- .../com/checkout/CheckoutConfiguration.java | 2 + .../DefaultCheckoutConfiguration.java | 13 +++- .../java/com/checkout/RequestMetrics.java | 17 ++++ .../DefaultCheckoutConfigurationTest.java | 78 +++++++++++++++++-- .../PreviousStaticKeysSdkCredentialsTest.java | 4 +- .../StaticKeysSdkCredentialsTest.java | 4 +- 10 files changed, 179 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/checkout/RequestMetrics.java diff --git a/README.md b/README.md index b97262fb..e9234282 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ dependencies { ## How to use the SDK -This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features.
+This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features.
Please find in the table below the types of keys that can be used within this SDK. | Account System | Public Key (example) | Secret Key (example) | |----------------|-----------------------------------------|-----------------------------------------| -| Default | pk_pkhpdtvabcf7hdgpwnbhw7r2uic | sk_m73dzypy7cf3gf5d2xr4k7sxo4e | -| Previous | pk_g650ff27-7c42-4ce1-ae90-5691a188ee7b | sk_gk3517a8-3z01-45fq-b4bd-4282384b0a64 | +| Default | pk_abcdef123456ghijkl789mnopqr | sk_123456ghijklm7890abcdefxyz | +| Previous | pk_12345678-abcd-efgh-ijkl-mnopqrstuvwx | sk_abcdef12-3456-ghij-klmn-opqrstuvwxyz | Note: sandbox keys have a `sbox_` or `test_` identifier, for Default and Previous accounts respectively. @@ -207,6 +207,19 @@ The execution of integration tests require the following environment variables s * For default account systems (OAuth): `CHECKOUT_DEFAULT_OAUTH_CLIENT_ID` & `CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET` * For Previous account systems (ABC): `CHECKOUT_PREVIOUS_PUBLIC_KEY` & `CHECKOUT_PREVIOUS_SECRET_KEY` +## Telemetry +Request telemetry is enabled by default in the Java SDK. Request latency is included in the telemetry data. Recording the request latency allows Checkout.com to continuously monitor and improve the merchant experience. + +Request telemetry can be disabled by opting out during CheckoutSdk builder step: +```java +final CheckoutApi checkoutApi = CheckoutSdk.builder() + .staticKeys() + .secretKey("secret_key") + .environment(Environment.PRODUCTION) + .recordTelemetry(false) + .build(); +``` + ## Code of Conduct Please refer to [Code of Conduct](CODE_OF_CONDUCT.md) diff --git a/src/main/java/com/checkout/AbstractCheckoutSdkBuilder.java b/src/main/java/com/checkout/AbstractCheckoutSdkBuilder.java index 71399f40..2e11f781 100644 --- a/src/main/java/com/checkout/AbstractCheckoutSdkBuilder.java +++ b/src/main/java/com/checkout/AbstractCheckoutSdkBuilder.java @@ -11,6 +11,7 @@ public abstract class AbstractCheckoutSdkBuilder { private EnvironmentSubdomain environmentSubdomain; private Executor executor = ForkJoinPool.commonPool(); private TransportConfiguration transportConfiguration; + private Boolean recordTelemetry = true; public AbstractCheckoutSdkBuilder environment(final IEnvironment environment) { this.environment = environment; @@ -48,6 +49,11 @@ protected EnvironmentSubdomain getEnvironmentSubdomain() { return environmentSubdomain; } + public AbstractCheckoutSdkBuilder recordTelemetry(final Boolean recordTelemetry) { + this.recordTelemetry = recordTelemetry; + return this; + } + protected abstract SdkCredentials getSdkCredentials(); protected CheckoutConfiguration getCheckoutConfiguration() { @@ -62,7 +68,7 @@ protected CheckoutConfiguration getCheckoutConfiguration() { } private CheckoutConfiguration buildCheckoutConfiguration(final SdkCredentials sdkCredentials) { - return new DefaultCheckoutConfiguration(sdkCredentials, getEnvironment(), getEnvironmentSubdomain(), httpClientBuilder, executor, transportConfiguration); + return new DefaultCheckoutConfiguration(sdkCredentials, getEnvironment(), getEnvironmentSubdomain(), httpClientBuilder, executor, transportConfiguration, recordTelemetry); } public abstract T build(); diff --git a/src/main/java/com/checkout/ApacheHttpClientTransport.java b/src/main/java/com/checkout/ApacheHttpClientTransport.java index 0a8ead50..50c99de9 100644 --- a/src/main/java/com/checkout/ApacheHttpClientTransport.java +++ b/src/main/java/com/checkout/ApacheHttpClientTransport.java @@ -14,10 +14,13 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executor; import java.util.stream.Collectors; +import com.google.gson.Gson; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -57,12 +60,23 @@ class ApacheHttpClientTransport implements Transport { private static final String FILE = "file"; private static final String PURPOSE = "purpose"; private static final String PATH = "path"; + private final URI baseUri; private final CloseableHttpClient httpClient; private final Executor executor; private final TransportConfiguration transportConfiguration; + private final CheckoutConfiguration configuration; + + private final ConcurrentLinkedQueue requestMetricsQueue = new ConcurrentLinkedQueue<>(); + private final Gson gson = new Gson(); - ApacheHttpClientTransport(final URI baseUri, final HttpClientBuilder httpClientBuilder, final Executor executor, final TransportConfiguration transportConfiguration) { + ApacheHttpClientTransport( + final URI baseUri, + final HttpClientBuilder httpClientBuilder, + final Executor executor, + final TransportConfiguration transportConfiguration, + final CheckoutConfiguration configuration + ) { CheckoutUtils.validateParams("baseUri", baseUri, "httpClientBuilder", httpClientBuilder, "executor", executor); this.baseUri = baseUri; this.httpClient = httpClientBuilder @@ -70,6 +84,7 @@ class ApacheHttpClientTransport implements Transport { .build(); this.executor = executor; this.transportConfiguration = transportConfiguration; + this.configuration = configuration; } @Override @@ -154,15 +169,50 @@ private Response performCall(final SdkAuthorization authorization, request.setHeader(ACCEPT, getAcceptHeader(clientOperation)); request.setHeader(AUTHORIZATION, authorization.getAuthorizationHeader()); + String currentRequestId = null; + RequestMetrics lastRequestMetric = null; + + if (configuration.isTelemetryEnabled()) { + currentRequestId = UUID.randomUUID().toString(); + lastRequestMetric = requestMetricsQueue.poll(); + + if (lastRequestMetric != null) { + lastRequestMetric.setRequestId(currentRequestId); + try { + String serializedMetrics = gson.toJson(lastRequestMetric); + String sdkTelemetryHeader = "cko-sdk-telemetry"; + request.setHeader(sdkTelemetryHeader, serializedMetrics); + } catch (Exception e) { + log.error("Error serializing telemetry metrics", e); + } + } + } + + long startTime = System.currentTimeMillis(); + log.info("Request: " + Arrays.toString(sanitiseHeaders(request.getAllHeaders()))); if (requestBody != null && request instanceof HttpEntityEnclosingRequest) { ((HttpEntityEnclosingRequestBase) request).setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON)); } try (final CloseableHttpResponse response = httpClient.execute(request)) { + long elapsed = System.currentTimeMillis() - startTime; log.info("Response: " + response.getStatusLine().getStatusCode() + " " + Arrays.toString(response.getAllHeaders())); final int statusCode = response.getStatusLine().getStatusCode(); final Map headers = Arrays.stream(response.getAllHeaders()) .collect(Collectors.toMap(Header::getName, Header::getValue)); + + if (configuration.isTelemetryEnabled()) { + int maxCountInTelemetryQueue = 10; + if (requestMetricsQueue.size() < maxCountInTelemetryQueue) { + if (lastRequestMetric == null) { + lastRequestMetric = new RequestMetrics(); + } + lastRequestMetric.setPrevRequestDuration(elapsed); + lastRequestMetric.setPrevRequestId(currentRequestId); + requestMetricsQueue.offer(lastRequestMetric); + } + } + if (statusCode != HttpStatus.SC_NOT_FOUND && response.getEntity() != null && response.getEntity().getContent() != null) { return Response.builder() .statusCode(statusCode) diff --git a/src/main/java/com/checkout/ApiClientImpl.java b/src/main/java/com/checkout/ApiClientImpl.java index 10304dc7..36fb15ed 100644 --- a/src/main/java/com/checkout/ApiClientImpl.java +++ b/src/main/java/com/checkout/ApiClientImpl.java @@ -34,7 +34,7 @@ public class ApiClientImpl implements ApiClient { public ApiClientImpl(final CheckoutConfiguration configuration, final UriStrategy uriStrategy) { this.serializer = new GsonSerializer(); - this.transport = new ApacheHttpClientTransport(uriStrategy.getUri(), configuration.getHttpClientBuilder(), configuration.getExecutor(), configuration.getTransportConfiguration()); + this.transport = new ApacheHttpClientTransport(uriStrategy.getUri(), configuration.getHttpClientBuilder(), configuration.getExecutor(), configuration.getTransportConfiguration(), configuration); } @Override diff --git a/src/main/java/com/checkout/CheckoutConfiguration.java b/src/main/java/com/checkout/CheckoutConfiguration.java index 8df00873..eb02773b 100644 --- a/src/main/java/com/checkout/CheckoutConfiguration.java +++ b/src/main/java/com/checkout/CheckoutConfiguration.java @@ -18,4 +18,6 @@ public interface CheckoutConfiguration { TransportConfiguration getTransportConfiguration(); + Boolean isTelemetryEnabled(); + } diff --git a/src/main/java/com/checkout/DefaultCheckoutConfiguration.java b/src/main/java/com/checkout/DefaultCheckoutConfiguration.java index ffe2b2cf..14f6d675 100644 --- a/src/main/java/com/checkout/DefaultCheckoutConfiguration.java +++ b/src/main/java/com/checkout/DefaultCheckoutConfiguration.java @@ -14,12 +14,14 @@ class DefaultCheckoutConfiguration implements CheckoutConfiguration { private final IEnvironment environment; private final EnvironmentSubdomain environmentSubdomain; private final TransportConfiguration transportConfiguration; + private final boolean recordTelemetry; DefaultCheckoutConfiguration(final SdkCredentials sdkCredentials, final IEnvironment environment, final HttpClientBuilder httpClientBuilder, final Executor executor, - final TransportConfiguration transportConfiguration) { + final TransportConfiguration transportConfiguration, + final boolean recordTelemetry) { validateParams("sdkCredentials", sdkCredentials, "environment", environment, "httpClientBuilder", httpClientBuilder, "executor", executor, "transportConfiguration", transportConfiguration); this.sdkCredentials = sdkCredentials; this.httpClientBuilder = httpClientBuilder; @@ -27,6 +29,7 @@ class DefaultCheckoutConfiguration implements CheckoutConfiguration { this.environment = environment; this.environmentSubdomain = null; this.transportConfiguration = transportConfiguration; + this.recordTelemetry = recordTelemetry; } DefaultCheckoutConfiguration(final SdkCredentials sdkCredentials, @@ -34,7 +37,8 @@ class DefaultCheckoutConfiguration implements CheckoutConfiguration { final EnvironmentSubdomain environmentSubdomain, final HttpClientBuilder httpClientBuilder, final Executor executor, - final TransportConfiguration transportConfiguration) { + final TransportConfiguration transportConfiguration, + final Boolean recordTelemetry) { validateParams("sdkCredentials", sdkCredentials, "environment", environment, "httpClientBuilder", httpClientBuilder, "executor", executor, "transportConfiguration", transportConfiguration); this.sdkCredentials = sdkCredentials; this.httpClientBuilder = httpClientBuilder; @@ -42,6 +46,7 @@ class DefaultCheckoutConfiguration implements CheckoutConfiguration { this.environment = environment; this.environmentSubdomain = environmentSubdomain; this.transportConfiguration = transportConfiguration; + this.recordTelemetry = recordTelemetry; } @Override @@ -73,4 +78,8 @@ public EnvironmentSubdomain getEnvironmentSubdomain() { public TransportConfiguration getTransportConfiguration() { return transportConfiguration; } + + public Boolean isTelemetryEnabled() { + return this.recordTelemetry; + } } diff --git a/src/main/java/com/checkout/RequestMetrics.java b/src/main/java/com/checkout/RequestMetrics.java new file mode 100644 index 00000000..16a6cabe --- /dev/null +++ b/src/main/java/com/checkout/RequestMetrics.java @@ -0,0 +1,17 @@ +package com.checkout; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class RequestMetrics { + private String requestId; + private Long prevRequestDuration; + private String prevRequestId; + + public RequestMetrics(Long prevRequestDuration, String prevRequestId) { + this.prevRequestDuration = prevRequestDuration; + this.prevRequestId = prevRequestId; + } +} \ No newline at end of file diff --git a/src/test/java/com/checkout/DefaultCheckoutConfigurationTest.java b/src/test/java/com/checkout/DefaultCheckoutConfigurationTest.java index c0c0666a..daff450b 100644 --- a/src/test/java/com/checkout/DefaultCheckoutConfigurationTest.java +++ b/src/test/java/com/checkout/DefaultCheckoutConfigurationTest.java @@ -2,14 +2,19 @@ import static java.net.URI.create; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; import org.apache.http.HttpStatus; import org.apache.http.impl.client.HttpClientBuilder; @@ -28,7 +33,7 @@ class DefaultCheckoutConfigurationTest { void shouldFailCreatingConfiguration() { try { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); - new DefaultCheckoutConfiguration(credentials, null, null, null, null); + new DefaultCheckoutConfiguration(credentials, null, null, null, null, false); fail(); } catch (final Exception e) { assertTrue(e instanceof CheckoutArgumentException); @@ -41,7 +46,7 @@ void shouldCreateConfiguration() { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals(Environment.PRODUCTION, configuration.getEnvironment()); } @@ -53,7 +58,7 @@ void shouldCreateConfigurationWithSubdomain(String subdomain) { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); final EnvironmentSubdomain environmentSubdomain = new EnvironmentSubdomain(Environment.SANDBOX, subdomain); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, environmentSubdomain, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, environmentSubdomain, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals("https://" + subdomain + ".api.sandbox.checkout.com/", configuration.getEnvironmentSubdomain().getCheckoutApi().toString()); } @@ -64,7 +69,7 @@ void shouldCreateConfigurationWithBadSubdomain(String subdomain) { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); final EnvironmentSubdomain environmentSubdomain = new EnvironmentSubdomain(Environment.SANDBOX, subdomain); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, environmentSubdomain, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, environmentSubdomain, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals("https://api.sandbox.checkout.com/", configuration.getEnvironmentSubdomain().getCheckoutApi().toString()); } @@ -73,7 +78,7 @@ void shouldCreateConfiguration_defaultHttpClientBuilderAndExecutor() { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals(Environment.PRODUCTION, configuration.getEnvironment()); assertNotNull(configuration.getHttpClientBuilder()); @@ -91,7 +96,7 @@ void shouldCreateConfiguration_customHttpClientBuilderAndExecutor() { .defaultHttpStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR) .build(); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, httpClientBuilder, executorService, transportConfiguration); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, httpClientBuilder, executorService, transportConfiguration, false); assertEquals(Environment.PRODUCTION, configuration.getEnvironment()); assertEquals(httpClientBuilder, configuration.getHttpClientBuilder()); @@ -103,7 +108,7 @@ void shouldCreateConfigurationForProd() { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals(Environment.PRODUCTION, configuration.getEnvironment()); } @@ -120,7 +125,7 @@ void shouldCreateConfigurationWithCustomEnvironment() { final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); - final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, environment, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION); + final CheckoutConfiguration configuration = new DefaultCheckoutConfiguration(credentials, environment, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, false); assertEquals(environment, configuration.getEnvironment()); assertEquals(environment.getCheckoutApi(), configuration.getEnvironment().getCheckoutApi()); assertEquals(environment.getOAuthAuthorizationApi(), configuration.getEnvironment().getOAuthAuthorizationApi()); @@ -129,4 +134,61 @@ void shouldCreateConfigurationWithCustomEnvironment() { assertEquals(environment.getBalancesApi(), configuration.getEnvironment().getBalancesApi()); } + /** + * Test concurrent creation of configurations to ensure thread-safety or at least no exceptions. + * This is a simple concurrency test that tries to create multiple configurations in parallel. + */ + @Test + void shouldCreateConfigurationsConcurrently() throws InterruptedException, ExecutionException { + final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); + int numberOfThreads = 10; + ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads); + + List> futures = new ArrayList<>(); + for (int i = 0; i < numberOfThreads; i++) { + futures.add(executorService.submit(() -> new DefaultCheckoutConfiguration( + credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, true))); + } + + for (Future future : futures) { + CheckoutConfiguration config = future.get(); + assertNotNull(config); + assertEquals(Environment.PRODUCTION, config.getEnvironment()); + } + + executorService.shutdown(); + } + + /** + * Test to ensure telemetry flag works in concurrency as well. + * This test tries to create configurations with different telemetry flags and checks them. + */ + @Test + void shouldHandleTelemetryFlagConcurrently() throws InterruptedException, ExecutionException { + final StaticKeysSdkCredentials credentials = Mockito.mock(StaticKeysSdkCredentials.class); + int numberOfThreads = 10; + ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads); + + List> futures = new ArrayList<>(); + for (int i = 0; i < numberOfThreads; i++) { + final boolean flag = (i % 2 == 0); + futures.add(executorService.submit(() -> { + CheckoutConfiguration config = new DefaultCheckoutConfiguration( + credentials, Environment.PRODUCTION, DEFAULT_CLIENT_BUILDER, DEFAULT_EXECUTOR, DEFAULT_TRANSPORT_CONFIGURATION, flag); + return config.isTelemetryEnabled(); + })); + } + + for (int i = 0; i < numberOfThreads; i++) { + Boolean result = futures.get(i).get(); + if (i % 2 == 0) { + assertTrue(result, "Expected telemetry to be enabled for even i=" + i); + } else { + assertFalse(result, "Expected telemetry to be disabled for odd i=" + i); + } + } + + executorService.shutdown(); + } + } diff --git a/src/test/java/com/checkout/PreviousStaticKeysSdkCredentialsTest.java b/src/test/java/com/checkout/PreviousStaticKeysSdkCredentialsTest.java index e46d972e..d3f68ad9 100644 --- a/src/test/java/com/checkout/PreviousStaticKeysSdkCredentialsTest.java +++ b/src/test/java/com/checkout/PreviousStaticKeysSdkCredentialsTest.java @@ -64,7 +64,7 @@ void shouldFailToCreatePreviousStaticKeysSdkCredentialsForProd() { try { final PreviousStaticKeysSdkCredentials credentials = new PreviousStaticKeysSdkCredentials(VALID_PREVIOUS_SK, similarDefaultPk); - new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null); + new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null, false); fail(); } catch (final Exception e) { assertTrue(e instanceof CheckoutArgumentException); @@ -72,7 +72,7 @@ void shouldFailToCreatePreviousStaticKeysSdkCredentialsForProd() { } try { final PreviousStaticKeysSdkCredentials credentials = new PreviousStaticKeysSdkCredentials(similarDefaultSk, VALID_PREVIOUS_PK); - new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null); + new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null, false); fail(); } catch (final Exception e) { assertTrue(e instanceof CheckoutArgumentException); diff --git a/src/test/java/com/checkout/StaticKeysSdkCredentialsTest.java b/src/test/java/com/checkout/StaticKeysSdkCredentialsTest.java index 7e0da790..b2ead0bd 100644 --- a/src/test/java/com/checkout/StaticKeysSdkCredentialsTest.java +++ b/src/test/java/com/checkout/StaticKeysSdkCredentialsTest.java @@ -66,7 +66,7 @@ void shouldFailToCreateStaticKeysSdkCredentialsForProd() { try { final StaticKeysSdkCredentials credentials = new StaticKeysSdkCredentials(VALID_DEFAULT_SK, similarDefaultPk); - new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null); + new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null, false); fail(); } catch (final Exception e) { assertTrue(e instanceof CheckoutArgumentException); @@ -74,7 +74,7 @@ void shouldFailToCreateStaticKeysSdkCredentialsForProd() { } try { final StaticKeysSdkCredentials credentials = new StaticKeysSdkCredentials(similarDefaultSk, VALID_DEFAULT_PK); - new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null); + new DefaultCheckoutConfiguration(credentials, Environment.SANDBOX, null, null, null, false); fail(); } catch (final Exception e) { assertTrue(e instanceof CheckoutArgumentException);