Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Release 6.42.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
IngenicoEPayments committed Aug 11, 2023
1 parent 93730fb commit d49d742
Show file tree
Hide file tree
Showing 25 changed files with 359 additions and 72 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.ingenico.connect.gateway</groupId>
<artifactId>connect-sdk-java</artifactId>
<version>6.41.0</version>
<version>6.42.0</version>
<packaging>jar</packaging>

<name>connect-sdk-java</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.ingenico.connect.gateway.sdk.java.CommunicatorConfiguration;
import com.ingenico.connect.gateway.sdk.java.Factory;
import com.ingenico.connect.gateway.sdk.java.merchant.services.ConvertAmountParams;
import com.ingenico.connect.gateway.sdk.java.merchant.services.ServicesClient;

public class ConnectionPoolingTest extends ItTest {

Expand Down Expand Up @@ -73,12 +74,16 @@ private void testConnectionPooling(ExecutorService executorService, Communicator
private final class ConvertAmountAction implements Callable<ConvertAmountResult> {

private final CountDownLatch barrier;
private final Communicator communicator;
private final ServicesClient servicesClient;
private final ConvertAmountParams request;

@SuppressWarnings("resource")
private ConvertAmountAction(CountDownLatch barrier, int index, Communicator communicator) {
this.barrier = barrier;
this.communicator = communicator;
this.servicesClient = Factory.createClient(communicator)
.withClientMetaInfo("")
.merchant(getMerchantId())
.services();

request = new ConvertAmountParams();
request.setSource("USD");
Expand All @@ -88,11 +93,10 @@ private ConvertAmountAction(CountDownLatch barrier, int index, Communicator comm

@Override
public ConvertAmountResult call() throws Exception {

barrier.await();

long startTime = System.currentTimeMillis();
Factory.createClient(communicator).withClientMetaInfo("").merchant(getMerchantId()).services().convertAmount(request).getConvertedAmount();
servicesClient.convertAmount(request).getConvertedAmount();
long endTime = System.currentTimeMillis();

return new ConvertAmountResult(startTime, endTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,30 @@ public void test() throws URISyntaxException, IOException {
client.close();
}
}

/**
* Smoke test for convert amount service with connection reuse turned off.
*/
@Test
public void testWithoutConnectionReuse() throws URISyntaxException, IOException {

ConvertAmountParams request = new ConvertAmountParams();
request.setAmount(123L);
request.setSource("USD");
request.setTarget("EUR");

Client client = getClientWithoutConnectionReuse();
try {
ConvertAmount response = client.merchant(getMerchantId()).services().convertAmount(request);

Assert.assertNotNull(response.getConvertedAmount());

response = client.merchant(getMerchantId()).services().convertAmount(request);

Assert.assertNotNull(response.getConvertedAmount());

} finally {
client.close();
}
}
}
12 changes: 12 additions & 0 deletions src/it/java/com/ingenico/connect/gateway/sdk/it/ItTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected CommunicatorConfiguration getCommunicatorConfigurationWithProxy() thro
.withProxyConfiguration(new ProxyConfiguration(new URI(proxyURI), proxyUsername, proxyPassword));
}

@SuppressWarnings("resource")
protected Client getClient() throws URISyntaxException {
URL propertiesUrl = getClass().getResource(PROPERTIES_URL);
CommunicatorConfiguration configuration = getCommunicatorConfiguration(propertiesUrl);
Expand All @@ -72,13 +73,24 @@ protected Client getClient() throws URISyntaxException {
.withClientMetaInfo("{\"test\":\"test\"}");
}

@SuppressWarnings("resource")
protected Client getClientWithProxy() throws URISyntaxException {
CommunicatorConfiguration configuration = getCommunicatorConfigurationWithProxy();
return Factory
.createClient(configuration)
.withClientMetaInfo("{\"test\":\"test\"}");
}

@SuppressWarnings("resource")
protected Client getClientWithoutConnectionReuse() throws URISyntaxException {
URL propertiesUrl = getClass().getResource(PROPERTIES_URL);
CommunicatorConfiguration configuration = getCommunicatorConfiguration(propertiesUrl);
configuration.setConnectionReuse(false);
return Factory
.createClient(configuration)
.withClientMetaInfo("{\"test\":\"test\"}");
}

protected String getMerchantId() {
return MERCHANT_ID;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/assembly/src.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<include>pom.xml</include>
<include>README.md</include>
<include>LICENSE.txt</include>
<include>checkstyle.xml</include>
</includes>
</fileSet>
<fileSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ public void setMerchantOrderId(Long value) {
}

/**
* <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the GlobalCollect platform is 30.</div> Your unique reference of the transaction that is also returned in our report files. This is almost always used for your reconciliation of our report files.
* <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the GlobalCollect platform is 30.</div> <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the WL Online Payment Acceptance Platform platform is 50.</div> Your unique reference of the transaction that is also returned in our report files. This is almost always used for your reconciliation of our report files.
*/
public String getMerchantReference() {
return merchantReference;
}

/**
* <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the GlobalCollect platform is 30.</div> Your unique reference of the transaction that is also returned in our report files. This is almost always used for your reconciliation of our report files.
* <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the GlobalCollect platform is 30.</div> <div class="alert alert-info">Note that the maximum length of this field for transactions processed on the WL Online Payment Acceptance Platform platform is 50.</div> Your unique reference of the transaction that is also returned in our report files. This is almost always used for your reconciliation of our report files.
*/
public void setMerchantReference(String value) {
this.merchantReference = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

package com.ingenico.connect.gateway.sdk.java.domain.payment.definitions;

import com.ingenico.connect.gateway.sdk.java.domain.definitions.CardEssentials;

public class RefundCardMethodSpecificOutput extends RefundMethodSpecificOutput {

private String authorisationCode = null;

private CardEssentials card = null;

/**
* Card Authorization code as returned by the acquirer
*/
Expand All @@ -22,4 +26,18 @@ public String getAuthorisationCode() {
public void setAuthorisationCode(String value) {
this.authorisationCode = value;
}

/**
* Object containing card details
*/
public CardEssentials getCard() {
return card;
}

/**
* Object containing card details
*/
public void setCard(CardEssentials value) {
this.card = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public void setHostedCheckoutId(String value) {
}

/**
* Your unique transaction reference to filter on.
* Your unique transaction reference to filter on. The maximum length is 52 characters for payments that are processed by WL Online Payment Acceptance platform.
*/
public String getMerchantReference() {
return merchantReference;
}

/**
* Your unique transaction reference to filter on.
* Your unique transaction reference to filter on. The maximum length is 52 characters for payments that are processed by WL Online Payment Acceptance platform.
*/
public void setMerchantReference(String value) {
this.merchantReference = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private String instantiateUri(String uri) {
return uri;
}

private String replaceAll(String uri, Map<String, String> pathContext) {
private static String replaceAll(String uri, Map<String, String> pathContext) {
if (pathContext != null) {
for (Map.Entry<String, String> entry : pathContext.entrySet()) {
uri = uri.replace(String.format("{%s}", entry.getKey()), entry.getValue());
Expand Down Expand Up @@ -138,7 +138,7 @@ protected RuntimeException createException(int statusCode, String responseBody,
}
}

private boolean isIdempotenceError(List<APIError> errors, CallContext context) {
private static boolean isIdempotenceError(List<APIError> errors, CallContext context) {
return context != null
&& context.getIdempotenceKey() != null
&& errors.size() == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ protected void throwExceptionIfNecessary(int statusCode, InputStream bodyStream,
}
}

private String toString(InputStream bodyStream) {
private static String toString(InputStream bodyStream) {
try {
Reader reader = new InputStreamReader(bodyStream, CHARSET);
StringBuilder body = new StringBuilder();
Expand All @@ -680,7 +680,7 @@ private String toString(InputStream bodyStream) {
}
}

private boolean isJson(List<ResponseHeader> headers) {
private static boolean isJson(List<ResponseHeader> headers) {
String contentType = ResponseHeader.getHeaderValue(headers, "Content-Type");
return contentType == null || "application/json".equalsIgnoreCase(contentType) || contentType.toLowerCase().startsWith("application/json");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class CommunicatorConfiguration {

private int maxConnections = DEFAULT_MAX_CONNECTIONS;

private boolean connectionReuse = true;

private AuthorizationType authorizationType;

private String apiKeyId;
Expand Down Expand Up @@ -72,33 +74,35 @@ public CommunicatorConfiguration(Properties properties) {
httpsProtocols.addAll(Arrays.asList(COMMA_SEPARATOR_PATTERN.split(httpsProtocolString.trim())));
}

connectionReuse = Boolean.parseBoolean(properties.getProperty("connect.api.connectionReuse", "true"));

integrator = properties.getProperty("connect.api.integrator");
shoppingCartExtension = getShoppingCartExtension(properties);
}
}

private int getProperty(Properties properties, String key, int defaultValue) {
private static int getProperty(Properties properties, String key, int defaultValue) {
String propertyValue = properties.getProperty(key, null);
return propertyValue != null ? Integer.parseInt(propertyValue) : defaultValue;
}

private URI getApiEndpoint(Properties properties) {
private static URI getApiEndpoint(Properties properties) {
String host = properties.getProperty("connect.api.endpoint.host");
String scheme = properties.getProperty("connect.api.endpoint.scheme");
String port = properties.getProperty("connect.api.endpoint.port");

return createURI(scheme != null ? scheme : "https", host, port != null ? Integer.parseInt(port) : -1);
}

private URI createURI(String scheme, String host, int port) {
private static URI createURI(String scheme, String host, int port) {
try {
return new URI(scheme, null, host, port, null, null, null);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Unable to construct API endpoint URI", e);
}
}

private ShoppingCartExtension getShoppingCartExtension(Properties properties) {
private static ShoppingCartExtension getShoppingCartExtension(Properties properties) {
String creator = properties.getProperty("connect.api.shoppingCartExtension.creator");
String name = properties.getProperty("connect.api.shoppingCartExtension.name");
String version = properties.getProperty("connect.api.shoppingCartExtension.version");
Expand Down Expand Up @@ -229,6 +233,19 @@ public CommunicatorConfiguration withMaxConnections(int maxConnections) {
return this;
}

public boolean isConnectionReuse() {
return connectionReuse;
}

public void setConnectionReuse(boolean connectionReuse) {
this.connectionReuse = connectionReuse;
}

public CommunicatorConfiguration withConnectionReuse(boolean connectionReuse) {
this.connectionReuse = connectionReuse;
return this;
}

public ProxyConfiguration getProxyConfiguration() {
return proxyConfiguration;
}
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/com/ingenico/connect/gateway/sdk/java/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Properties;

import com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultAuthenticator;
import com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnection;
import com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultConnectionBuilder;
import com.ingenico.connect.gateway.sdk.java.defaultimpl.DefaultMarshaller;

/**
Expand Down Expand Up @@ -60,13 +60,13 @@ public static SessionBuilder createSessionBuilder(CommunicatorConfiguration conf

return new SessionBuilder()
.withAPIEndpoint(configuration.getApiEndpoint())
.withConnection(new DefaultConnection(
configuration.getConnectTimeout(),
configuration.getSocketTimeout(),
configuration.getMaxConnections(),
configuration.getProxyConfiguration(),
configuration.getHttpsProtocols()
))
.withConnection(new DefaultConnectionBuilder(configuration.getConnectTimeout(), configuration.getSocketTimeout())
.withMaxConnections(configuration.getMaxConnections())
.withConnectionReuse(configuration.isConnectionReuse())
.withProxyConfiguration(configuration.getProxyConfiguration())
.withHttpsProtocols(configuration.getHttpsProtocols())
.build()
)
.withMetaDataProvider(metaDataProvider)
.withAuthenticator(new DefaultAuthenticator(
configuration.getAuthorizationType(),
Expand Down Expand Up @@ -103,20 +103,23 @@ public static Communicator createCommunicator(Session session) {
* Creates a {@link Client} based on the configuration values in
* {@code configurationFileUri}, {@code apiKeyId} and {@code secretApiKey}.
*/
@SuppressWarnings("resource")
public static Client createClient(URI configurationFileUri, String apiKeyId, String secretApiKey) {
return createClient(createCommunicator(configurationFileUri, apiKeyId, secretApiKey));
}

/**
* Creates a {@link Client} based on the passed configuration.
*/
@SuppressWarnings("resource")
public static Client createClient(CommunicatorConfiguration configuration) {
return createClient(createCommunicator(configuration));
}

/**
* Creates a {@link Client} based on the passed {@link Session}.
*/
@SuppressWarnings("resource")
public static Client createClient(Session session) {
return createClient(createCommunicator(session));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class MetaDataProvider {

private static final String SDK_VERSION = "6.41.0";
private static final String SDK_VERSION = "6.42.0";

private static final String SERVER_META_INFO_HEADER = "X-GCS-ServerMetaInfo";
static final Set<String> PROHIBITED_HEADERS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public RequestHeader(String name, String value) {
this.value = normalizeValue(value);
}

private String normalizeValue(String value) {
private static String normalizeValue(String value) {
if (value == null || value.isEmpty()) {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ String toDataToSign(String httpMethod, URI resourceUri, List<RequestHeader> http
* Returns the encoded URI path without the HTTP method and including all
* decoded query parameters.
*/
private String toCanonicalizedResource(URI resourceUri) {
private static String toCanonicalizedResource(URI resourceUri) {
String rawPath = resourceUri.getRawPath();
if (resourceUri.getQuery() == null) {
return rawPath;
Expand All @@ -145,11 +145,11 @@ private String toCanonicalizedResource(URI resourceUri) {
return rawPath + '?' + resourceUri.getQuery();
}

private String toCanonicalizeHeaderName(String originalName) {
private static String toCanonicalizeHeaderName(String originalName) {
return originalName.toLowerCase(Locale.ENGLISH);
}

String toCanonicalizeHeaderValue(String originalValue) {
static String toCanonicalizeHeaderValue(String originalValue) {

if (originalValue == null) {
return "";
Expand Down
Loading

0 comments on commit d49d742

Please sign in to comment.