diff --git a/README.md b/README.md index 9679ebe..14222a5 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Add this dependency to your project's POM: com.postfinancecheckout postfinancecheckout-java-sdk - 2.2.4 + 2.2.5 compile ``` @@ -33,7 +33,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -compile "com.postfinancecheckout:postfinancecheckout-java-sdk:2.2.4" +compile "com.postfinancecheckout:postfinancecheckout-java-sdk:2.2.5" ``` ### Others @@ -46,7 +46,7 @@ mvn clean package Then manually install the following JARs: -* `target/postfinancecheckout-java-sdk-2.2.4.jar` +* `target/postfinancecheckout-java-sdk-2.2.5.jar` * `target/lib/*.jar` ## Usage diff --git a/build.gradle b/build.gradle index 2fe799a..2797e6c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'idea' apply plugin: 'eclipse' group = 'com.postfinancecheckout' -version = '2.2.4' +version = '2.2.5' buildscript { repositories { diff --git a/build.sbt b/build.sbt index 8005b4c..c4710d8 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.postfinancecheckout", name := "postfinancecheckout-java-sdk", - version := "2.2.4", + version := "2.2.5", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index 9ee578c..ce12c3b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ postfinancecheckout-java-sdk jar postfinancecheckout-java-sdk - 2.2.4 + 2.2.5 https://www.postfinance.ch/checkout The SDK for simplifying the integration with PostFinance Checkout API. diff --git a/src/main/java/com/postfinancecheckout/sdk/ApiClient.java b/src/main/java/com/postfinancecheckout/sdk/ApiClient.java index 37360de..7057af0 100644 --- a/src/main/java/com/postfinancecheckout/sdk/ApiClient.java +++ b/src/main/java/com/postfinancecheckout/sdk/ApiClient.java @@ -17,11 +17,11 @@ public class ApiClient { - private final String basePath = "https://checkout.postfinance.ch:443/api"; + private final String basePath; private final HttpRequestFactory httpRequestFactory; private final ObjectMapper objectMapper; - private long userId; - private String applicationKey; + private final long userId; + private final String applicationKey; // A reasonable default object mapper. Client can pass in a chosen ObjectMapper anyway, this is just for reasonable defaults. private static ObjectMapper createDefaultObjectMapper() { @@ -40,13 +40,27 @@ private static ObjectMapper createDefaultObjectMapper() { * @param applicationKey */ public ApiClient(long userId, String applicationKey) { + this(userId, applicationKey, "https://checkout.postfinance.ch:443/api"); + } + + /** + * Constructor for ApiClient + * + * @param userId + * @param applicationKey + */ + public ApiClient(long userId, String applicationKey, String basePath) { if (applicationKey == null || applicationKey.trim().isEmpty()) { throw new IllegalArgumentException("The application key cannot be empty or null."); } if (userId < 1) { throw new IllegalArgumentException("The user id is invalid."); } - + if (basePath == null || basePath.trim().isEmpty()) { + throw new IllegalArgumentException("The base path cannot be empty."); + } + + this.basePath = basePath; this.userId = userId; this.applicationKey = applicationKey; this.httpRequestFactory = this.createRequestFactory();