diff --git a/README.md b/README.md
index 0cec069f0..ea7a7de04 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Add this dependency to your project's POM:
com.adyen
adyen-java-api-library
- 1.6.0
+ 1.7.0
```
diff --git a/docs/install-library.html b/docs/install-library.html
index 8907e6574..bfb60570b 100755
--- a/docs/install-library.html
+++ b/docs/install-library.html
@@ -49,7 +49,7 @@
Maven
class="hljs-tag"></groupId>
<artifactId>adyen-java-api-library</artifactId>
- <version>1.6.0</<version>1.7.0</version>
</dependency>
diff --git a/pom.xml b/pom.xml
index 68b96e2e8..14542fd54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.adyen
adyen-java-api-library
jar
- 1.6.0
+ 1.7.0
Adyen Java API Library
Adyen API Client Library for Java
https://github.com/adyen/adyen-java-api-library
diff --git a/src/main/java/com/adyen/Client.java b/src/main/java/com/adyen/Client.java
index e6ab081b8..a3fe72588 100644
--- a/src/main/java/com/adyen/Client.java
+++ b/src/main/java/com/adyen/Client.java
@@ -35,16 +35,16 @@ public class Client {
public static final String HPP_LIVE = "https://live.adyen.com/hpp";
public static final String MARKETPAY_ENDPOINT_TEST = "https://cal-test.adyen.com/cal/services";
public static final String MARKETPAY_ENDPOINT_LIVE = "https://cal-live.adyen.com/cal/services";
- public static final String API_VERSION = "v30";
+ public static final String API_VERSION = "v40";
public static final String RECURRING_API_VERSION = "v25";
public static final String MARKETPAY_ACCOUNT_API_VERSION = "v4";
public static final String MARKETPAY_FUND_API_VERSION = "v3";
public static final String MARKETPAY_NOTIFICATION_API_VERSION = "v1";
- public static final String USER_AGENT_SUFFIX = "adyen-java-api-library/";
- public static final String LIB_VERSION = "1.6.0";
+ public static final String LIB_NAME = "adyen-java-api-library";
+ public static final String LIB_VERSION = "1.7.0";
public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
- public static final String CHECKOUT_API_VERSION = "v32";
+ public static final String CHECKOUT_API_VERSION = "v40";
public static final String CHECKOUT_UTILITY_API_VERSION = "v1";
public static final String ENDPOINT_PROTOCOL = "https://";
@@ -57,28 +57,40 @@ public Client(Config config) {
}
public Client(String username, String password, Environment environment, String applicationName) {
+ this(username, password, environment, null, applicationName);
+ }
+
+ public Client(String username, String password, Environment environment, String liveEndpointUrlPrefix, String applicationName) {
this.config = new Config();
this.config.setUsername(username);
this.config.setPassword(password);
- this.setEnvironment(environment);
+ this.setEnvironment(environment, liveEndpointUrlPrefix);
this.config.setApplicationName(applicationName);
}
+ /**
+ * @deprecated As of library version 1.6.1, timeouts should be set by {@link #setTimeouts(int connectionTimeoutMillis, int readTimeoutMillis)} or directly by {@link com.adyen.Config#setConnectionTimeoutMillis(int connectionTimeoutMillis)}.
+ */
+ @Deprecated
public Client(String username, String password, Environment environment, int connectionTimeoutMillis) {
- this.config = new Config();
- this.config.setUsername(username);
- this.config.setPassword(password);
- this.setEnvironment(environment);
+ this(username, password, environment, null);
this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
}
- public Client(String apiKey, Environment environment) {
+ /**
+ * @deprecated As of library version 1.6.1, timeouts should be set by {@link #setTimeouts(int connectionTimeoutMillis, int readTimeoutMillis)} or directly by {@link com.adyen.Config#setConnectionTimeoutMillis(int connectionTimeoutMillis)}.
+ */
+ @Deprecated
+ public Client(String username, String password, Environment environment, int connectionTimeoutMillis, String liveEndpointUrlPrefix) {
- this.config = new Config();
- this.config.setApiKey(apiKey);
- this.setEnvironment(environment);
+ this(username, password, environment, liveEndpointUrlPrefix, null);
+ this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
+ }
+
+ public Client(String apiKey, Environment environment) {
+ this(apiKey, environment, null);
}
public Client(String apiKey, Environment environment, String liveEndpointUrlPrefix) {
@@ -87,28 +99,23 @@ public Client(String apiKey, Environment environment, String liveEndpointUrlPref
this.setEnvironment(environment, liveEndpointUrlPrefix);
}
+ /**
+ * @deprecated As of library version 1.6.1, timeouts should be set by {@link #setTimeouts(int connectionTimeoutMillis, int readTimeoutMillis)} or directly by {@link com.adyen.Config#setConnectionTimeoutMillis(int connectionTimeoutMillis)}.
+ */
+ @Deprecated
public Client(String apiKey, Environment environment, int connectionTimeoutMillis) {
- this.config = new Config();
- this.config.setApiKey(apiKey);
- this.setEnvironment(environment);
- this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
- }
-
- public Client(String username, String password, Environment environment, int connectionTimeoutMillis, String liveEndpointUrlPrefix) {
-
- this.config = new Config();
- this.config.setUsername(username);
- this.config.setPassword(password);
- this.setEnvironment(environment, liveEndpointUrlPrefix);
+ this(apiKey, environment);
this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
}
+ /**
+ * @deprecated As of library version 1.6.1, timeouts should be set by {@link #setTimeouts(int connectionTimeoutMillis, int readTimeoutMillis)} or directly by {@link com.adyen.Config#setConnectionTimeoutMillis(int connectionTimeoutMillis)}.
+ */
+ @Deprecated
public Client(String apiKey, Environment environment, int connectionTimeoutMillis, String liveEndpointUrlPrefix) {
- this.config = new Config();
- this.config.setApiKey(apiKey);
- this.setEnvironment(environment, liveEndpointUrlPrefix);
+ this(apiKey, environment, liveEndpointUrlPrefix);
this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
}
@@ -176,4 +183,9 @@ public void setApplicationName(String applicationName) {
this.config.setApplicationName(applicationName);
}
+ public void setTimeouts(int connectionTimeoutMillis, int readTimeoutMillis) {
+ this.config.setConnectionTimeoutMillis(connectionTimeoutMillis);
+ this.config.setReadTimeoutMillis(readTimeoutMillis);
+ }
+
}
diff --git a/src/main/java/com/adyen/Config.java b/src/main/java/com/adyen/Config.java
index e9aacf16c..f2322e2c0 100644
--- a/src/main/java/com/adyen/Config.java
+++ b/src/main/java/com/adyen/Config.java
@@ -32,6 +32,7 @@ public class Config {
protected String applicationName;
protected String apiKey;
protected int connectionTimeoutMillis;
+ protected int readTimeoutMillis;
//HPP specific
protected String hppEndpoint;
@@ -153,4 +154,12 @@ public void setConnectionTimeoutMillis(int connectionTimeoutMillis) {
this.connectionTimeoutMillis = connectionTimeoutMillis;
}
+ public int getReadTimeoutMillis() {
+ return readTimeoutMillis;
+ }
+
+ public void setReadTimeoutMillis(int readTimeoutMillis) {
+ this.readTimeoutMillis = readTimeoutMillis;
+ }
+
}
diff --git a/src/main/java/com/adyen/httpclient/HttpURLConnectionClient.java b/src/main/java/com/adyen/httpclient/HttpURLConnectionClient.java
index 7bb53fb3d..9dccbe6e6 100644
--- a/src/main/java/com/adyen/httpclient/HttpURLConnectionClient.java
+++ b/src/main/java/com/adyen/httpclient/HttpURLConnectionClient.java
@@ -67,8 +67,8 @@ public String request(String endpoint, String json, Config config, boolean isApi
@Override
public String request(String requestUrl, String requestBody, Config config, boolean isApiKeyRequired, RequestOptions requestOptions) throws IOException, HTTPClientException {
HttpURLConnection httpConnection = createRequest(requestUrl, config.getApplicationName(), requestOptions);
+
String apiKey = config.getApiKey();
- int connectionTimeoutMillis = config.getConnectionTimeoutMillis();
// Use Api key if required or if provided
if (isApiKeyRequired || (apiKey != null && ! apiKey.isEmpty())) {
setApiKey(httpConnection, apiKey);
@@ -76,7 +76,9 @@ public String request(String requestUrl, String requestBody, Config config, bool
setBasicAuthentication(httpConnection, config.getUsername(), config.getPassword());
}
- httpConnection.setConnectTimeout(connectionTimeoutMillis);
+ httpConnection.setConnectTimeout(config.getConnectionTimeoutMillis());
+ httpConnection.setReadTimeout(config.getReadTimeoutMillis());
+
setContentType(httpConnection, APPLICATION_JSON_TYPE);
return doPostRequest(httpConnection, requestBody);
@@ -150,7 +152,7 @@ private HttpURLConnection createRequest(String requestUrl, String applicationNam
httpConnection.setRequestMethod(METHOD_POST);
httpConnection.setRequestProperty(ACCEPT_CHARSET, CHARSET);
- httpConnection.setRequestProperty(USER_AGENT, String.format("%s %s%s", applicationName, Client.USER_AGENT_SUFFIX, Client.LIB_VERSION));
+ httpConnection.setRequestProperty(USER_AGENT, String.format("%s %s/%s", applicationName, Client.LIB_NAME, Client.LIB_VERSION));
if (requestOptions != null && requestOptions.getIdempotencyKey() != null) {
httpConnection.setRequestProperty(IDEMPOTENCY_KEY, requestOptions.getIdempotencyKey());
}
diff --git a/src/main/java/com/adyen/model/PaymentRequest.java b/src/main/java/com/adyen/model/PaymentRequest.java
index 792c2878e..6117913e2 100644
--- a/src/main/java/com/adyen/model/PaymentRequest.java
+++ b/src/main/java/com/adyen/model/PaymentRequest.java
@@ -27,7 +27,11 @@
import com.adyen.model.additionalData.InvoiceLine;
import com.adyen.model.additionalData.SplitPayment;
import com.adyen.model.additionalData.SplitPaymentItem;
+import com.adyen.model.applicationinfo.ApplicationInfo;
+import com.adyen.model.applicationinfo.CommonField;
import com.google.gson.annotations.SerializedName;
+import static com.adyen.Client.LIB_NAME;
+import static com.adyen.Client.LIB_VERSION;
/**
* PaymentRequest
@@ -47,6 +51,18 @@ public class PaymentRequest extends AbstractPaymentRequest {
@SerializedName("store")
private String store = null;
+ @SerializedName("applicationInfo")
+ private ApplicationInfo applicationInfo;
+
+ public PaymentRequest() {
+ CommonField adyenLibrary = new CommonField();
+ adyenLibrary.setName(LIB_NAME);
+ adyenLibrary.setVersion(LIB_VERSION);
+
+ this.applicationInfo = new ApplicationInfo();
+ this.applicationInfo.setAdyenLibrary(adyenLibrary);
+ }
+
/**
* how the shopper interacts with the system
*/
@@ -287,6 +303,19 @@ public void setStore(String store) {
this.store = store;
}
+ public ApplicationInfo getApplicationInfo() {
+ return applicationInfo;
+ }
+
+ public void setApplicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ }
+
+ public PaymentRequest applicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ return this;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -299,7 +328,9 @@ public boolean equals(Object o) {
return super.equals(paymentRequest)
&& Objects.equals(this.card, paymentRequest.card)
&& Objects.equals(this.mpiData, paymentRequest.mpiData)
- && Objects.equals(this.bankAccount, paymentRequest.bankAccount)
+ && Objects.equals(this.bankAccount,
+ paymentRequest.bankAccount)
+ && Objects.equals(this.applicationInfo, paymentRequest.applicationInfo)
&& Objects.equals(this.store, paymentRequest.store);
}
@@ -317,6 +348,7 @@ public String toString() {
sb.append(" mpiData: ").append(toIndentedString(mpiData)).append("\n");
sb.append(" bankAccount: ").append(toIndentedString(bankAccount)).append("\n");
sb.append(" recurringProcessingModel: ").append(toIndentedString(recurringProcessingModel)).append("\n");
+ sb.append(" applicationInfo: ").append(toIndentedString(applicationInfo)).append("\n");
sb.append("}");
return sb.toString();
}
diff --git a/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java b/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java
new file mode 100644
index 000000000..f49fc6b49
--- /dev/null
+++ b/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java
@@ -0,0 +1,109 @@
+/*
+ * ######
+ * ######
+ * ############ ####( ###### #####. ###### ############ ############
+ * ############# #####( ###### #####. ###### ############# #############
+ * ###### #####( ###### #####. ###### ##### ###### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ######
+ * ############# ############# ############# ############# ##### ######
+ * ############ ############ ############# ############ ##### ######
+ * ######
+ * #############
+ * ############
+ *
+ * Adyen Java API Library
+ *
+ * Copyright (c) 2017 Adyen B.V.
+ * This file is open source and available under the MIT license.
+ * See the LICENSE file for more info.
+ */
+package com.adyen.model.applicationinfo;
+
+import com.google.gson.annotations.SerializedName;
+
+public class ApplicationInfo {
+ @SerializedName("adyenLibrary")
+ private CommonField adyenLibrary;
+
+ @SerializedName("adyenPaymentSource")
+ private CommonField adyenPaymentSource;
+
+ @SerializedName("merchantApplication")
+ private CommonField merchantApplication;
+
+ @SerializedName("merchantDevice")
+ private MerchantDevice merchantDevice;
+
+ @SerializedName("externalPlatform")
+ private ExternalPlatform externalPlatform;
+
+ @SerializedName("shopperInteractionDevice")
+ private ShopperInteractionDevice shopperInteractionDevice;
+
+ public CommonField getAdyenLibrary() {
+ return adyenLibrary;
+ }
+
+ public void setAdyenLibrary(CommonField adyenLibrary) {
+ this.adyenLibrary = adyenLibrary;
+ }
+
+ public CommonField getAdyenPaymentSource() {
+ return adyenPaymentSource;
+ }
+
+ public void setAdyenPaymentSource(CommonField adyenPaymentSource) {
+ this.adyenPaymentSource = adyenPaymentSource;
+ }
+
+ public CommonField getMerchantApplication() {
+ return merchantApplication;
+ }
+
+ public void setMerchantApplication(CommonField merchantApplication) {
+ this.merchantApplication = merchantApplication;
+ }
+
+ public MerchantDevice getMerchantDevice() {
+ return merchantDevice;
+ }
+
+ public void setMerchantDevice(MerchantDevice merchantDevice) {
+ this.merchantDevice = merchantDevice;
+ }
+
+ public ExternalPlatform getExternalPlatform() {
+ return externalPlatform;
+ }
+
+ public void setExternalPlatform(ExternalPlatform externalPlatform) {
+ this.externalPlatform = externalPlatform;
+ }
+
+ public ShopperInteractionDevice getShopperInteractionDevice() {
+ return shopperInteractionDevice;
+ }
+
+ public void setShopperInteractionDevice(ShopperInteractionDevice shopperInteractionDevice) {
+ this.shopperInteractionDevice = shopperInteractionDevice;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationInfo{"
+ + "adyenLibrary="
+ + adyenLibrary
+ + ", adyenPaymentSource="
+ + adyenPaymentSource
+ + ", merchantApplication="
+ + merchantApplication
+ + ", merchantDevice="
+ + merchantDevice
+ + ", externalPlatform="
+ + externalPlatform
+ + ", shopperInteractionDevice="
+ + shopperInteractionDevice
+ + '}';
+ }
+}
diff --git a/src/main/java/com/adyen/model/applicationinfo/CommonField.java b/src/main/java/com/adyen/model/applicationinfo/CommonField.java
new file mode 100644
index 000000000..37eb2bd1c
--- /dev/null
+++ b/src/main/java/com/adyen/model/applicationinfo/CommonField.java
@@ -0,0 +1,52 @@
+/*
+ * ######
+ * ######
+ * ############ ####( ###### #####. ###### ############ ############
+ * ############# #####( ###### #####. ###### ############# #############
+ * ###### #####( ###### #####. ###### ##### ###### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ######
+ * ############# ############# ############# ############# ##### ######
+ * ############ ############ ############# ############ ##### ######
+ * ######
+ * #############
+ * ############
+ *
+ * Adyen Java API Library
+ *
+ * Copyright (c) 2017 Adyen B.V.
+ * This file is open source and available under the MIT license.
+ * See the LICENSE file for more info.
+ */
+package com.adyen.model.applicationinfo;
+
+import com.google.gson.annotations.SerializedName;
+
+public class CommonField {
+ @SerializedName("name")
+ private String name;
+
+ @SerializedName("version")
+ private String version;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ return "CommonField{" + "name='" + name + '\'' + ", version='" + version + '\'' + '}';
+ }
+}
diff --git a/src/main/java/com/adyen/model/applicationinfo/ExternalPlatform.java b/src/main/java/com/adyen/model/applicationinfo/ExternalPlatform.java
new file mode 100644
index 000000000..4729b89cc
--- /dev/null
+++ b/src/main/java/com/adyen/model/applicationinfo/ExternalPlatform.java
@@ -0,0 +1,41 @@
+/*
+ * ######
+ * ######
+ * ############ ####( ###### #####. ###### ############ ############
+ * ############# #####( ###### #####. ###### ############# #############
+ * ###### #####( ###### #####. ###### ##### ###### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ######
+ * ############# ############# ############# ############# ##### ######
+ * ############ ############ ############# ############ ##### ######
+ * ######
+ * #############
+ * ############
+ *
+ * Adyen Java API Library
+ *
+ * Copyright (c) 2017 Adyen B.V.
+ * This file is open source and available under the MIT license.
+ * See the LICENSE file for more info.
+ */
+package com.adyen.model.applicationinfo;
+
+import com.google.gson.annotations.SerializedName;
+
+public class ExternalPlatform extends CommonField {
+ @SerializedName("integrator")
+ private String integrator;
+
+ public String getIntegrator() {
+ return integrator;
+ }
+
+ public void setIntegrator(String integrator) {
+ this.integrator = integrator;
+ }
+
+ @Override
+ public String toString() {
+ return "ExternalPlatform{" + "integrator='" + integrator + '\'' + "} extends " + super.toString();
+ }
+}
diff --git a/src/main/java/com/adyen/model/applicationinfo/MerchantDevice.java b/src/main/java/com/adyen/model/applicationinfo/MerchantDevice.java
new file mode 100644
index 000000000..bf91542b7
--- /dev/null
+++ b/src/main/java/com/adyen/model/applicationinfo/MerchantDevice.java
@@ -0,0 +1,63 @@
+/*
+ * ######
+ * ######
+ * ############ ####( ###### #####. ###### ############ ############
+ * ############# #####( ###### #####. ###### ############# #############
+ * ###### #####( ###### #####. ###### ##### ###### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ######
+ * ############# ############# ############# ############# ##### ######
+ * ############ ############ ############# ############ ##### ######
+ * ######
+ * #############
+ * ############
+ *
+ * Adyen Java API Library
+ *
+ * Copyright (c) 2017 Adyen B.V.
+ * This file is open source and available under the MIT license.
+ * See the LICENSE file for more info.
+ */
+package com.adyen.model.applicationinfo;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MerchantDevice {
+ @SerializedName("os")
+ private String os;
+
+ @SerializedName("osVersion")
+ private String osVersion;
+
+ @SerializedName("reference")
+ private String reference;
+
+ public String getOs() {
+ return os;
+ }
+
+ public void setOs(String os) {
+ this.os = os;
+ }
+
+ public String getOsVersion() {
+ return osVersion;
+ }
+
+ public void setOsVersion(String osVersion) {
+ this.osVersion = osVersion;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ @Override
+ public String toString() {
+ return "MerchantDevice{" + "os='" + os + '\'' + ", osVersion='" + osVersion + '\'' + ", reference='" + reference + '\'' + '}';
+ }
+}
diff --git a/src/main/java/com/adyen/model/applicationinfo/ShopperInteractionDevice.java b/src/main/java/com/adyen/model/applicationinfo/ShopperInteractionDevice.java
new file mode 100644
index 000000000..383394cc5
--- /dev/null
+++ b/src/main/java/com/adyen/model/applicationinfo/ShopperInteractionDevice.java
@@ -0,0 +1,63 @@
+/*
+ * ######
+ * ######
+ * ############ ####( ###### #####. ###### ############ ############
+ * ############# #####( ###### #####. ###### ############# #############
+ * ###### #####( ###### #####. ###### ##### ###### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
+ * ###### ###### #####( ###### #####. ###### ##### ##### ######
+ * ############# ############# ############# ############# ##### ######
+ * ############ ############ ############# ############ ##### ######
+ * ######
+ * #############
+ * ############
+ *
+ * Adyen Java API Library
+ *
+ * Copyright (c) 2017 Adyen B.V.
+ * This file is open source and available under the MIT license.
+ * See the LICENSE file for more info.
+ */
+package com.adyen.model.applicationinfo;
+
+import com.google.gson.annotations.SerializedName;
+
+public class ShopperInteractionDevice {
+ @SerializedName("os")
+ private String os;
+
+ @SerializedName("osVersion")
+ private String osVersion;
+
+ @SerializedName("locale")
+ private String locale;
+
+ public String getOs() {
+ return os;
+ }
+
+ public void setOs(String os) {
+ this.os = os;
+ }
+
+ public String getOsVersion() {
+ return osVersion;
+ }
+
+ public void setOsVersion(String osVersion) {
+ this.osVersion = osVersion;
+ }
+
+ public String getLocale() {
+ return locale;
+ }
+
+ public void setLocale(String locale) {
+ this.locale = locale;
+ }
+
+ @Override
+ public String toString() {
+ return "ShopperInteractionDevice{" + "os='" + os + '\'' + ", osVersion='" + osVersion + '\'' + ", locale='" + locale + '\'' + '}';
+ }
+}
diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java
index b1ffa80f6..2f1d3fc21 100755
--- a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java
+++ b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java
@@ -21,6 +21,9 @@
package com.adyen.model.checkout;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
import com.adyen.model.Amount;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
@@ -28,9 +31,6 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
-import java.io.IOException;
-import java.util.Objects;
-
/**
* PaymentMethodsRequest
*/
@@ -48,6 +48,10 @@ public class PaymentMethodsRequest {
private String shopperLocale = null;
@SerializedName("shopperReference")
private String shopperReference = null;
+ @SerializedName("allowedPaymentMethods")
+ private List allowedPaymentMethods;
+ @SerializedName("blockedPaymentMethods")
+ private List blockedPaymentMethods;
public PaymentMethodsRequest amount(Amount amount) {
this.amount = amount;
@@ -73,7 +77,8 @@ public PaymentMethodsRequest channel(ChannelEnum channel) {
}
/**
- * The platform where a payment transaction takes place. This field can be used for filtering out payment methods that are only available on specific platforms. Possible values: * iOS * Android * Web
+ * The platform where a payment transaction takes place. This field can be used for filtering out payment methods that are only available on specific platforms. Possible values: * iOS * Android *
+ * Web
*
* @return channel
**/
@@ -157,6 +162,22 @@ public void setShopperReference(String shopperReference) {
this.shopperReference = shopperReference;
}
+ public List getAllowedPaymentMethods() {
+ return allowedPaymentMethods;
+ }
+
+ public void setAllowedPaymentMethods(List allowedPaymentMethods) {
+ this.allowedPaymentMethods = allowedPaymentMethods;
+ }
+
+ public List getBlockedPaymentMethods() {
+ return blockedPaymentMethods;
+ }
+
+ public void setBlockedPaymentMethods(List blockedPaymentMethods) {
+ this.blockedPaymentMethods = blockedPaymentMethods;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -166,17 +187,20 @@ public boolean equals(Object o) {
return false;
}
PaymentMethodsRequest paymentMethodsRequest = (PaymentMethodsRequest) o;
- return Objects.equals(this.amount, paymentMethodsRequest.amount) &&
- Objects.equals(this.channel, paymentMethodsRequest.channel) &&
- Objects.equals(this.countryCode, paymentMethodsRequest.countryCode) &&
- Objects.equals(this.merchantAccount, paymentMethodsRequest.merchantAccount) &&
- Objects.equals(this.shopperLocale, paymentMethodsRequest.shopperLocale) &&
- Objects.equals(this.shopperReference, paymentMethodsRequest.shopperReference);
+ return Objects.equals(this.amount, paymentMethodsRequest.amount)
+ && Objects.equals(this.channel, paymentMethodsRequest.channel)
+ && Objects.equals(this.countryCode,
+ paymentMethodsRequest.countryCode)
+ && Objects.equals(this.merchantAccount, paymentMethodsRequest.merchantAccount)
+ && Objects.equals(this.shopperLocale, paymentMethodsRequest.shopperLocale)
+ && Objects.equals(this.allowedPaymentMethods, paymentMethodsRequest.allowedPaymentMethods)
+ && Objects.equals(this.blockedPaymentMethods, paymentMethodsRequest.blockedPaymentMethods)
+ && Objects.equals(this.shopperReference, paymentMethodsRequest.shopperReference);
}
@Override
public int hashCode() {
- return Objects.hash(amount, channel, countryCode, merchantAccount, shopperLocale, shopperReference);
+ return Objects.hash(amount, channel, countryCode, merchantAccount, shopperLocale, shopperReference, allowedPaymentMethods, blockedPaymentMethods);
}
@Override
@@ -190,6 +214,8 @@ public String toString() {
sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n");
sb.append(" shopperLocale: ").append(toIndentedString(shopperLocale)).append("\n");
sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n");
+ sb.append(" allowedPaymentMethods: ").append(toIndentedString(allowedPaymentMethods)).append("\n");
+ sb.append(" blockedPaymentMethods: ").append(toIndentedString(blockedPaymentMethods)).append("\n");
sb.append("}");
return sb.toString();
}
@@ -206,7 +232,8 @@ private String toIndentedString(Object o) {
}
/**
- * The platform where a payment transaction takes place. This field can be used for filtering out payment methods that are only available on specific platforms. Possible values: * iOS * Android * Web
+ * The platform where a payment transaction takes place. This field can be used for filtering out payment methods that are only available on specific platforms. Possible values: * iOS * Android *
+ * Web
*/
@JsonAdapter(ChannelEnum.Adapter.class)
public enum ChannelEnum {
diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java
index 00e8afca5..e4bdadb56 100755
--- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java
+++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java
@@ -18,8 +18,6 @@
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
-
-
package com.adyen.model.checkout;
import java.io.IOException;
@@ -35,6 +33,8 @@
import com.adyen.model.ForexQuote;
import com.adyen.model.Installments;
import com.adyen.model.Name;
+import com.adyen.model.applicationinfo.ApplicationInfo;
+import com.adyen.model.applicationinfo.CommonField;
import com.adyen.serializer.DateSerializer;
import com.adyen.serializer.DateTimeGMTSerializer;
import com.google.gson.TypeAdapter;
@@ -42,22 +42,20 @@
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
+import static com.adyen.Client.LIB_NAME;
+import static com.adyen.Client.LIB_VERSION;
import static com.adyen.constants.ApiConstants.PaymentMethodType.TYPE_SCHEME;
/**
* PaymentsRequest
*/
public class PaymentsRequest {
-
@SerializedName("additionalData")
private Map additionalData = null;
-
@SerializedName("amount")
private Amount amount = null;
-
@SerializedName("billingAddress")
private Address billingAddress = null;
-
@SerializedName("captureDelayHours")
private Integer captureDelayHours = null;
@SerializedName("channel")
@@ -130,6 +128,17 @@ public class PaymentsRequest {
private BrowserInfo browserInfo = null;
@SerializedName("deviceFingerprint")
private String deviceFingerprint = null;
+ @SerializedName("applicationInfo")
+ private ApplicationInfo applicationInfo;
+
+ public PaymentsRequest() {
+ CommonField adyenLibrary = new CommonField();
+ adyenLibrary.setName(LIB_NAME);
+ adyenLibrary.setVersion(LIB_VERSION);
+
+ this.applicationInfo = new ApplicationInfo();
+ this.applicationInfo.setAdyenLibrary(adyenLibrary);
+ }
public PaymentsRequest additionalData(Map additionalData) {
this.additionalData = additionalData;
@@ -901,6 +910,19 @@ public PaymentsRequest deviceFingerprint(String deviceFingerprint) {
return this;
}
+ public ApplicationInfo getApplicationInfo() {
+ return applicationInfo;
+ }
+
+ public void setApplicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ }
+
+ public PaymentsRequest applicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ return this;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -947,6 +969,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.shopperStatement, paymentsRequest.shopperStatement)
&& Objects.equals(this.socialSecurityNumber, paymentsRequest.socialSecurityNumber)
&& Objects.equals(this.deviceFingerprint, paymentsRequest.deviceFingerprint)
+ && Objects.equals(this.applicationInfo, paymentsRequest.applicationInfo)
&& Objects.equals(this.telephoneNumber, paymentsRequest.telephoneNumber);
}
@@ -988,6 +1011,7 @@ public int hashCode() {
shopperStatement,
socialSecurityNumber,
deviceFingerprint,
+ applicationInfo,
telephoneNumber);
}
@@ -1032,6 +1056,7 @@ public String toString() {
sb.append(" shopperStatement: ").append(toIndentedString(shopperStatement)).append("\n");
sb.append(" socialSecurityNumber: ").append(toIndentedString(socialSecurityNumber)).append("\n");
sb.append(" deviceFingerprint: ").append(toIndentedString(deviceFingerprint)).append("\n");
+ sb.append(" applicationInfo: ").append(toIndentedString(applicationInfo)).append("\n");
sb.append(" telephoneNumber: ").append(toIndentedString(telephoneNumber)).append("\n");
sb.append("}");
return sb.toString();
diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java
index 03592c372..d25ec8908 100644
--- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java
+++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java
@@ -1,4 +1,4 @@
-/**
+/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
@@ -27,7 +27,11 @@
import com.adyen.model.additionalData.InvoiceLine;
import com.adyen.model.additionalData.SplitPayment;
import com.adyen.model.additionalData.SplitPaymentItem;
+import com.adyen.model.applicationinfo.ApplicationInfo;
+import com.adyen.model.applicationinfo.CommonField;
import com.google.gson.annotations.SerializedName;
+import static com.adyen.Client.LIB_NAME;
+import static com.adyen.Client.LIB_VERSION;
/**
* Abstract class for modification requests
@@ -48,6 +52,18 @@ public class AbstractModificationRequest additionalData = null;
+ @SerializedName("applicationInfo")
+ private ApplicationInfo applicationInfo;
+
+ public AbstractModificationRequest() {
+ CommonField adyenLibrary = new CommonField();
+ adyenLibrary.setName(LIB_NAME);
+ adyenLibrary.setVersion(LIB_VERSION);
+
+ this.applicationInfo = new ApplicationInfo();
+ this.applicationInfo.setAdyenLibrary(adyenLibrary);
+ }
+
public T reference(String reference) {
this.reference = reference;
return (T) this;
@@ -120,6 +136,19 @@ public void setMerchantAccount(String merchantAccount) {
this.merchantAccount = merchantAccount;
}
+ public ApplicationInfo getApplicationInfo() {
+ return applicationInfo;
+ }
+
+ public void setApplicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ }
+
+ public T applicationInfo(ApplicationInfo applicationInfo) {
+ this.applicationInfo = applicationInfo;
+ return (T) this;
+ }
+
public Map getAdditionalData() {
return additionalData;
}
@@ -221,12 +250,13 @@ public boolean equals(Object o) {
&& Objects.equals(this.originalReference,
modificationRequest.originalReference)
&& Objects.equals(this.merchantAccount, modificationRequest.merchantAccount)
+ && Objects.equals(this.applicationInfo, modificationRequest.applicationInfo)
&& Objects.equals(this.additionalData, modificationRequest.additionalData);
}
@Override
public int hashCode() {
- return Objects.hash(reference, authorisationCode, originalReference, merchantAccount, additionalData);
+ return Objects.hash(reference, authorisationCode, originalReference, merchantAccount, additionalData, applicationInfo);
}
@Override
@@ -237,6 +267,7 @@ public String toString() {
sb.append(" authorisationCode: ").append(toIndentedString(authorisationCode)).append("\n");
sb.append(" originalReference: ").append(toIndentedString(originalReference)).append("\n");
sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n");
+ sb.append(" applicationInfo: ").append(toIndentedString(additionalData)).append("\n");
sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n");
return sb.toString();
diff --git a/src/test/java/com/adyen/BaseTest.java b/src/test/java/com/adyen/BaseTest.java
index 6bd1563d7..63877fdfb 100644
--- a/src/test/java/com/adyen/BaseTest.java
+++ b/src/test/java/com/adyen/BaseTest.java
@@ -20,28 +20,43 @@
*/
package com.adyen;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import com.adyen.Util.DateUtil;
import com.adyen.Util.Util;
import com.adyen.enums.VatCategory;
import com.adyen.httpclient.HTTPClientException;
import com.adyen.httpclient.HttpURLConnectionClient;
-import com.adyen.model.*;
+import com.adyen.model.AbstractPaymentRequest;
+import com.adyen.model.Address;
+import com.adyen.model.Amount;
+import com.adyen.model.Name;
+import com.adyen.model.PaymentRequest;
+import com.adyen.model.PaymentRequest3d;
+import com.adyen.model.RequestOptions;
import com.adyen.model.additionalData.InvoiceLine;
import com.adyen.model.modification.AbstractModificationRequest;
import com.adyen.model.modification.CaptureRequest;
import com.adyen.model.modification.RefundRequest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.isNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class BaseTest {
+ protected static final Gson PRETTY_PRINT_GSON = new GsonBuilder().setPrettyPrinting().create();
+
/**
* Returns a Client object that has a mocked response
*/
@@ -60,7 +75,7 @@ protected Client createMockClientFromResponse(String response) {
Config config = new Config();
config.setHmacKey("DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00");
- config.setCheckoutEndpoint(client.CHECKOUT_ENDPOINT_TEST);
+ config.setCheckoutEndpoint(Client.CHECKOUT_ENDPOINT_TEST);
client.setConfig(config);
return client;
@@ -87,7 +102,7 @@ public String getFileContents(String fileName) {
int length;
InputStream fileStream = classLoader.getResourceAsStream(fileName);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- while ((length = fileStream.read(buffer)) != -1) {
+ while ((length = fileStream.read(buffer)) != - 1) {
outputStream.write(buffer, 0, length);
}
result = outputStream.toString(StandardCharsets.UTF_8.name());
@@ -103,8 +118,8 @@ public String getFileContents(String fileName) {
*/
protected T createBasePaymentRequest(T abstractPaymentRequest) {
abstractPaymentRequest.merchantAccount("AMerchant")
- .setBrowserInfoData("User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36", "*/*")
- .setShopperIP("1.2.3.4");
+ .setBrowserInfoData("User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36", "*/*")
+ .setShopperIP("1.2.3.4");
return abstractPaymentRequest;
}
@@ -114,8 +129,8 @@ protected T createBasePaymentRequest(T abstra
*/
protected PaymentRequest createFullCardPaymentRequest() {
PaymentRequest paymentRequest = createBasePaymentRequest(new PaymentRequest()).reference("123456")
- .setAmountData("1000", "EUR")
- .setCardData("5136333333333335", "John Doe", "08", "2018", "737");
+ .setAmountData("1000", "EUR")
+ .setCardData("5136333333333335", "John Doe", "08", "2018", "737");
return paymentRequest;
}
diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java
index d8f3399a1..6a2f94d72 100644
--- a/src/test/java/com/adyen/CheckoutTest.java
+++ b/src/test/java/com/adyen/CheckoutTest.java
@@ -39,7 +39,6 @@
import com.adyen.model.checkout.PaymentsResponse;
import com.adyen.service.Checkout;
import com.google.gson.annotations.SerializedName;
-import static com.adyen.Service.GSON;
import static com.adyen.enums.Environment.LIVE;
import static junit.framework.TestCase.assertNull;
import static org.junit.Assert.assertEquals;
@@ -200,7 +199,7 @@ public void TestPaymentsResultErrorMocked() throws Exception {
@Test
public void TestPaymentMethodsFailureMissingIdentifierOnLive() throws Exception {
Client client = createMockClientFromFile("mocks/checkout/paymentsresult-error-invalid-data-payload-422.json");
- client.setEnvironment(LIVE);
+ client.setEnvironment(LIVE, "dumyPrefix");
try {
new Checkout(client);
} catch (IllegalArgumentException e) {
@@ -212,25 +211,52 @@ public void TestPaymentMethodsFailureMissingIdentifierOnLive() throws Exception
@Test
public void TestPaymentMethodDetails() {
PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest();
- String jsonRequest = GSON.toJson(paymentsRequest);
- assertEquals(
- "{\"amount\":{\"value\":1000,\"currency\":\"USD\"},\"merchantAccount\":\"MagentoMerchantTest\",\"paymentMethod\":{\"type\":\"scheme\",\"number\":\"4111111111111111\",\"expiryMonth\":\"10\",\"expiryYear\":\"2018\",\"holderName\":\"John Smith\",\"cvc\":\"737\"},\"reference\":\"Your order number\",\"returnUrl\":\"https://your-company.com/...\"}",
- jsonRequest);
+ paymentsRequest.setApplicationInfo(null);
+ String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
+
+ assertEquals("{\n"
+ + " \"amount\": {\n"
+ + " \"value\": 1000,\n"
+ + " \"currency\": \"USD\"\n"
+ + " },\n"
+ + " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ + " \"paymentMethod\": {\n"
+ + " \"type\": \"scheme\",\n"
+ + " \"number\": \"4111111111111111\",\n"
+ + " \"expiryMonth\": \"10\",\n"
+ + " \"expiryYear\": \"2018\",\n"
+ + " \"holderName\": \"John Smith\",\n"
+ + " \"cvc\": \"737\"\n"
+ + " },\n"
+ + " \"reference\": \"Your order number\",\n"
+ + " \"returnUrl\": \"https://your-company.com/...\"\n"
+ + "}", jsonRequest);
TestPaymentMethodDetails testPaymentMethodDetails = new TestPaymentMethodDetails();
testPaymentMethodDetails.setType("testType");
testPaymentMethodDetails.setTestValue("testValue");
paymentsRequest.setPaymentMethod(testPaymentMethodDetails);
- jsonRequest = GSON.toJson(paymentsRequest);
- assertEquals(
- "{\"amount\":{\"value\":1000,\"currency\":\"USD\"},\"merchantAccount\":\"MagentoMerchantTest\",\"paymentMethod\":{\"testKey\":\"testValue\",\"type\":\"testType\"},\"reference\":\"Your order number\",\"returnUrl\":\"https://your-company.com/...\"}",
- jsonRequest);
+ jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
+ assertEquals("{\n"
+ + " \"amount\": {\n"
+ + " \"value\": 1000,\n"
+ + " \"currency\": \"USD\"\n"
+ + " },\n"
+ + " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ + " \"paymentMethod\": {\n"
+ + " \"testKey\": \"testValue\",\n"
+ + " \"type\": \"testType\"\n"
+ + " },\n"
+ + " \"reference\": \"Your order number\",\n"
+ + " \"returnUrl\": \"https://your-company.com/...\"\n"
+ + "}", jsonRequest);
}
@Test
public void TestDateSerializers() throws ParseException {
PaymentsRequest paymentsRequest = new PaymentsRequest();
+ paymentsRequest.setApplicationInfo(null);
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -238,8 +264,8 @@ public void TestDateSerializers() throws ParseException {
Date d = fmt.parse("2018-10-31");
paymentsRequest.setDateOfBirth(d);
paymentsRequest.setDeliveryDate(d);
- String jsonRequest = GSON.toJson(paymentsRequest);
- assertEquals("{\"dateOfBirth\":\"2018-10-31\",\"deliveryDate\":\"2018-10-31T00:00:00.000Z\"}", jsonRequest);
+ String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
+ assertEquals("{\n" + " \"dateOfBirth\": \"2018-10-31\",\n" + " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\"\n" + "}", jsonRequest);
}
/**
diff --git a/src/test/java/com/adyen/PaymentRequestBuilderTest.java b/src/test/java/com/adyen/PaymentRequestBuilderTest.java
index 069cb7f45..63b4130d4 100644
--- a/src/test/java/com/adyen/PaymentRequestBuilderTest.java
+++ b/src/test/java/com/adyen/PaymentRequestBuilderTest.java
@@ -25,17 +25,15 @@
import com.adyen.constants.ApiConstants;
import com.adyen.model.PaymentRequest;
import com.adyen.model.PaymentRequest3d;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import static org.junit.Assert.assertEquals;
public class PaymentRequestBuilderTest extends BaseTest {
- private static final Gson PRETTY_PRINT_GSON = new GsonBuilder().setPrettyPrinting().create();
@Test
public void TestCCPaymentRequest() {
PaymentRequest paymentRequest = createFullCardPaymentRequest();
+ paymentRequest.setApplicationInfo(null);
// Test metadata
paymentRequest.setMetadata(new HashMap());
@@ -77,6 +75,7 @@ public void TestCCPaymentRequest() {
@Test
public void TestCSEPaymentRequest() {
PaymentRequest paymentRequest = createCSEPaymentRequest();
+ paymentRequest.setApplicationInfo(null);
String paymentRequestJson = PRETTY_PRINT_GSON.toJson(paymentRequest);