diff --git a/README.md b/README.md
index 7593ce99..b0b866a4 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ V3-JAVA-SDK
===========
**Help:** [Support](https://developer.intuit.com/help), [Samples](https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0200_java/0004_sample_code_and_sample_apps)
-**Documentation:** [User Guide](https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_accounting/0200_java/0001_quick_start), [JavaDocs](https://developer-static.intuit.com/SDKDocs/QBV3Doc/ipp-v3-java-devkit-javadoc/index.html)
+**Documentation:** [User Guide](https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/java), [JavaDocs](https://developer-static.intuit.com/SDKDocs/QBV3Doc/ipp-v3-java-devkit-javadoc/index.html)
**Continuous Integration:** [](https://travis-ci.org/intuit/QuickBooks-V3-Java-SDK)
@@ -34,6 +34,7 @@ The QuickBooks Online Java SDK provides a set of Java class libraries that make
* ipp-v3-java-devkit - core component, contains REST API support.
* ipp-java-qbapihelper - contains QuickBooks Online API Helper methods for OAuth, Disconnect and Reconnect API.
* oauth2-platform-api - contains QuickBooks Online API Helper methods for obtaining OAuth2 tokens, Disconnect and Reconnect API for OAuth2 apps.
+* payments-api - Payments SDK for V2 API, contains methods for charge, echeck, token, card and bank account APIs.
## System Requirements
The SDK works on JDK 1.6 and above.
diff --git a/ipp-java-qbapihelper/pom.xml b/ipp-java-qbapihelper/pom.xml
index 5b605fe8..7759321d 100644
--- a/ipp-java-qbapihelper/pom.xml
+++ b/ipp-java-qbapihelper/pom.xml
@@ -21,19 +21,34 @@
ipp-v3-java-devkit-pom
com.intuit.quickbooks-online
- 4.1.1
+ 5.0.0
ipp-java-qbapihelper
- 4.1.1
+ 5.0.0
jar
- QuickBooks API Helper for Oauth
- QuickBooks API Helper Project for OAuth, Disconnect and Reconnect
+ Quickbooks API Helper for Oauth
+ Quickbooks API Helper Project for OAuth, Disconnect and Reconnect
org.openid4java
openid4java
0.9.8
-
+
+
+ net.sf.kxml
+ kxml2
+ 2.2.2
+
+
+ oauth.signpost
+ signpost-core
+ 1.2.1.1
+
+
+ oauth.signpost
+ signpost-commonshttp4
+ 1.2
+
diff --git a/ipp-v3-java-data/pom.xml b/ipp-v3-java-data/pom.xml
index b711e065..8f17f521 100755
--- a/ipp-v3-java-data/pom.xml
+++ b/ipp-v3-java-data/pom.xml
@@ -4,13 +4,13 @@
com.intuit.quickbooks-online
ipp-v3-java-devkit-pom
- 4.1.1
+ 5.0.0
ipp-v3-java-data
- QuickBooks V3 Java - Data Project
- QuickBooks Java V3 DevKit Data - Entities generation
- 4.1.1
+ IPP V3 Java - Data Project
+ IPP Java V3 DevKit Data project - FMS Entities generation
+ 5.0.0
UTF-8
@@ -18,6 +18,11 @@
+
+ org.jvnet.jaxb2_commons
+ jaxb2-basics-runtime
+ 1.11.1
+
joda-time
joda-time
@@ -28,6 +33,11 @@
jaxb2-commons-lang
2.4
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.9.6
+
@@ -164,4 +174,4 @@
-
+
\ No newline at end of file
diff --git a/ipp-v3-java-devkit/pom.xml b/ipp-v3-java-devkit/pom.xml
index d67b8932..bb03fd8c 100755
--- a/ipp-v3-java-devkit/pom.xml
+++ b/ipp-v3-java-devkit/pom.xml
@@ -6,14 +6,14 @@
ipp-v3-java-devkit-pom
com.intuit.quickbooks-online
- 4.1.1
+ 5.0.0
ipp-v3-java-devkit
- 4.1.1
+ 5.0.0
jar
- QuickBooks V3 Java Devkit - Development Project
- QuickBooks Java V3 DevKit Project - Core
+ IPP V3 Java Devkit - Development Project
+ IPP Java V3 DevKit Project - Core
java
@@ -25,8 +25,81 @@
com.intuit.quickbooks-online
ipp-v3-java-data
- 4.1.1
+ 5.0.0
+
+ cglib
+ cglib
+ 2.2.2
+
+
+ asm
+ asm-commons
+ 3.3.1
+
+
+ com.sun.mail
+ javax.mail
+ 1.6.1
+
+
+ com.google.code.gson
+ gson
+ 2.8.1
+
+
+ javax.servlet
+ servlet-api
+ 2.4
+ provided
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.2.11
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.2.11
+
+
+ oauth.signpost
+ signpost-core
+ 1.2.1.1
+
+
+ oauth.signpost
+ signpost-commonshttp4
+ 1.2
+
+
+ commons-configuration
+ commons-configuration
+ 1.6
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+ com.fasterxml.jackson.jaxrs
+ jackson-jaxrs-json-provider
+ 2.9.6
+
+
+ org.jmockit
+ jmockit
+ 1.16
+ test
+
+
+ junit
+ junit
+ 4.12
+ test
+
@@ -191,4 +264,4 @@
-
+
\ No newline at end of file
diff --git a/ipp-v3-java-devkit/src/main/resources/ippdevkit.properties b/ipp-v3-java-devkit/src/main/resources/ippdevkit.properties
index 023a4e9b..63805585 100755
--- a/ipp-v3-java-devkit/src/main/resources/ippdevkit.properties
+++ b/ipp-v3-java-devkit/src/main/resources/ippdevkit.properties
@@ -2,7 +2,7 @@
## Devkit Version
# This version has to be updated according to the pom version
-version = 4.1.1
+version = 5.0.0
# This is to have the request source to be sent to IDS request header
request.source = V3JavaSDK
diff --git a/ipp-v3-java-devkit/src/test/resources/ippdevkit.properties b/ipp-v3-java-devkit/src/test/resources/ippdevkit.properties
index b3ae541a..ab17fab6 100755
--- a/ipp-v3-java-devkit/src/test/resources/ippdevkit.properties
+++ b/ipp-v3-java-devkit/src/test/resources/ippdevkit.properties
@@ -1,7 +1,7 @@
### IPP Dev Kit helper properties
## Devkit version
-version = 4.1.1
+version = 5.0.0
# This is to have the request source to be sent to IDS request header
request.source = V3JavaSDK
@@ -26,4 +26,3 @@ testsuit.qbo.realm.id =
-
diff --git a/oauth2-platform-api/pom.xml b/oauth2-platform-api/pom.xml
index 72705efb..393671d1 100644
--- a/oauth2-platform-api/pom.xml
+++ b/oauth2-platform-api/pom.xml
@@ -18,12 +18,12 @@
ipp-v3-java-devkit-pom
com.intuit.quickbooks-online
- 4.1.1
+ 5.0.0
oauth2-platform-api
- 4.1.1
- QuickBooks API Helper for OAuth2
- QuickBooks API Helper Project for OAuth2
+ 5.0.0
+ Quickbooks API Helper for OAuth2
+ Quickbooks API Helper Project for OAuth2
commons-lang
@@ -35,6 +35,27 @@
json
20160810
+
+ oauth.signpost
+ signpost-core
+ 1.2.1.1
+
+
+ oauth.signpost
+ signpost-commonshttp4
+ 1.2
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.6
+
+
+ commons-codec
+ commons-codec
+ 1.11
+
+
@@ -136,4 +157,4 @@
-
+
\ No newline at end of file
diff --git a/oauth2-platform-api/src/main/resources/oauthclient.properties b/oauth2-platform-api/src/main/resources/oauthclient.properties
index 545eb56c..6abf9f81 100644
--- a/oauth2-platform-api/src/main/resources/oauthclient.properties
+++ b/oauth2-platform-api/src/main/resources/oauthclient.properties
@@ -33,7 +33,7 @@ ADDRESS=address
EMAIL=email
#Version
-version=4.1.1
+version=5.0.0
#MIGRATION SERVICE URL
OAUTH_MIGRATION_URL_PRODUCTION=https://developer.api.intuit.com/v2/oauth2/tokens/migrate
diff --git a/oauth2-platform-api/src/test/resources/oauthclient.properties b/oauth2-platform-api/src/test/resources/oauthclient.properties
index 545eb56c..6abf9f81 100644
--- a/oauth2-platform-api/src/test/resources/oauthclient.properties
+++ b/oauth2-platform-api/src/test/resources/oauthclient.properties
@@ -33,7 +33,7 @@ ADDRESS=address
EMAIL=email
#Version
-version=4.1.1
+version=5.0.0
#MIGRATION SERVICE URL
OAUTH_MIGRATION_URL_PRODUCTION=https://developer.api.intuit.com/v2/oauth2/tokens/migrate
diff --git a/payments-api/README.md b/payments-api/README.md
new file mode 100644
index 00000000..f2d7eaf0
--- /dev/null
+++ b/payments-api/README.md
@@ -0,0 +1,108 @@
+JAVA-PAYMENTS-SDK
+==================
+
+**Help:** [Support](https://developer.intuit.com/help), [Samples](https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0200_java/0004_sample_code_and_sample_apps)
+**Documentation:** [User Guide](https://developer.intuit.com/app/developer/qbpayments/docs/develop/using-an-sdk-to-integrate-with-the-payments-api#java)
+**Continuous Integration:** [](https://travis-ci.org/intuit/QuickBooks-V3-Java-SDK)
+**Maven:** [](https://maven-badges.herokuapp.com/maven-central/com.intuit.quickbooks-online/payments-api)
+**License:** [](http://www.apache.org/licenses/LICENSE-2.0)
+
+
+## Overview
+This Payments SDK provides a Java library that make it easier to call QuickBooks Online Payments API. This library supports the following APIs:
+
+* Token creation for card and bankAccount.
+* BankAccount functions like create, delete, retrieve.
+* Card functions like create, delete, retrieve.
+* Charge functions like create, capture, retrieve, refund.
+* ECheck functions like create retrieve, refund.
+
+In addition to the above, the library also supports, logging, error handling, serialization/deserialization and capturing intuit_tid for easier debugging.
+Note: This library works only for OAuth2 apps.
+
+## System Requirements
+The SDK works on JDK 1.6 and above.
+
+## Install
+The SDK can be installed using one of the ways below-
+1. Download the latest version of the jar from [maven](https://search.maven.org/search?q=quickbooks) and add it to your projects classpath
+ ```sh
+ payment-api.jar
+ ```
+
+2. Add the following dependency to the build.gradle file. Make sure to use the latest version of the SDK found [here](https://search.maven.org/search?q=quickbooks)
+ ```sh
+ compile("com.intuit.quickbooks-online:payments-api:5.0.0")
+ ```
+
+3. Add the following dependency to the pom.xml file. Make sure to use the latest version of the SDK found [here](https://search.maven.org/search?q=quickbooks)
+ ```sh
+
+ com.intuit.quickbooks-online
+ payments-api
+ 5.0.0
+
+ ```
+
+## Usage
+1. Create the RequestContext object as shown below. Pass in the accessToken and Environment.
+```java
+RequestContext requestContext = new RequestContext.Builder(accessToken, Environment.SANDBOX).build();
+```
+The above code automatically sets a unique requestid as well. To provide your custom requestid use the below code-
+```java
+RequestContext requestContext = new RequestContext.Builder(accessToken, Environment.SANDBOX)
+ .requestId(requestId).build();
+```
+You can also set Proxy parameters in the same way.
+
+2. Create the Service object. The sample below shows how to create a TokenService, you can create other service objects - Echeck, Charge, Card, BankAccount in the same way.
+```java
+TokenService tokenService = new TokenService(requestContext);
+```
+
+3. Prepare Token request create token for a credit card
+```java
+Address address = new Address.Builder().region("CA").postalCode("94086")
+ .streetAddress("1130 Kifer Rd").city("Sunnyvale")
+ .country("US").build();
+```
+
+```java
+Card card = new Card.Builder().expYear("2020").expMonth("02").address(address)
+ .name("emulate=0").cvc("123")
+ .number("4111111111111111").build();
+```
+
+```java
+Token tokenRequest = new Token.Builder().card(card).build();
+```
+
+4. Call the TokenService to create token
+```java
+Token token = tokenService.createToken(tokenRequest);
+```
+
+5. Retrieve token value
+```java
+token.getValue();
+```
+
+## Logging important attributes
+Makes sure to log intuit_tid and requestId for each of your request for easier debugging
+
+For logging intuit_tid, use the following method
+```java
+token.getIntuit_tid();
+```
+
+For logging requestId, use the following method
+```java
+token.getRequestId();
+```
+
+## Sample
+For more samples on how to create other entities and operation, take a look at the sample application below :
+[sample](https://github.com/IntuitDeveloper/SampleApp-Payments-Java/tree/master/src/main/java/com/intuit/sample/paymentsdk)
+
+
diff --git a/payments-api/pom.xml b/payments-api/pom.xml
new file mode 100644
index 00000000..6aa3509e
--- /dev/null
+++ b/payments-api/pom.xml
@@ -0,0 +1,137 @@
+
+
+ 4.0.0
+
+ ipp-v3-java-devkit-pom
+ com.intuit.quickbooks-online
+ 5.0.0
+
+ payments-api
+ Payments API SDK
+ Payments API SDK
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ com.fasterxml.jackson.module
+ jackson-module-jaxb-annotations
+ 2.9.6
+
+
+
+
+
+ ${basedir}/src/test/resources
+
+
+
+
+ ${basedir}/src/main/resources
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+
+
+
+ maven-jar-plugin
+
+
+
+ fully.qualified.MainClass
+
+
+
+
+
+
+ maven-assembly-plugin
+
+ ${project.artifactId}-${project.version}
+
+ jar-with-dependencies
+
+
+
+
+ payments-api
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
+ testng.xml
+
+
+
+ sign
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+
+
+
diff --git a/payments-api/src/main/java/com/intuit/payment/config/ProxyConfig.java b/payments-api/src/main/java/com/intuit/payment/config/ProxyConfig.java
new file mode 100644
index 00000000..2975f654
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/config/ProxyConfig.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.config;
+
+/**
+ * Config class to hold the proxy properties
+ *
+ * @author dderose
+ *
+ */
+public class ProxyConfig {
+
+ private String host;
+ private String port;
+ private String username;
+ private String password;
+
+ private ProxyConfig(ProxyConfigBuilder builder) {
+ this.host = builder.host;
+ this.port = builder.port;
+ this.username = builder.username;
+ this.password = builder.password;
+
+ }
+
+ /**
+ * @return
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @return
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * @return
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @return
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Builder class for ProxyConfig
+ *
+ * @author dderose
+ *
+ */
+ public static class ProxyConfigBuilder {
+
+ private String host;
+ private String port;
+ private String username;
+ private String password;
+
+ public ProxyConfigBuilder(String host, String port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ public ProxyConfigBuilder username(String username) {
+ this.username = username;
+ return this;
+ }
+
+ public ProxyConfigBuilder password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ public ProxyConfig buildConfig() {
+ return new ProxyConfig(this);
+ }
+
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/config/RequestContext.java b/payments-api/src/main/java/com/intuit/payment/config/RequestContext.java
new file mode 100644
index 00000000..b8941fd1
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/config/RequestContext.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.config;
+
+import java.util.UUID;
+
+import com.intuit.payment.util.PropertiesConfig;
+
+/**
+ * RequestContext holds the key attributes for making an API call
+ * accessToken and environment are mandatory parameters
+ * requestId is auto generated if not set explicitly
+ * baseUrl is derieved automatically based on the environment value
+ *
+ * * @author dderose
+ *
+ */
+public class RequestContext {
+
+ private String requestId;
+ private String accessToken;
+ private ProxyConfig proxyConfig;
+ private String baseUrl;
+
+ public enum Environment {
+ PRODUCTION, SANDBOX
+ };
+
+ public RequestContext() {
+ }
+
+ private RequestContext(Builder builder) {
+ this.requestId = builder.requestId;
+ this.accessToken = builder.accessToken;
+ this.baseUrl = builder.baseUrl;
+ this.proxyConfig = builder.proxyConfig;
+ }
+
+ /**
+ * @return
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * @return
+ */
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ /**
+ * @return
+ */
+ public ProxyConfig getProxyConfig() {
+ return proxyConfig;
+ }
+
+ /**
+ * @return
+ */
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
+ /**
+ * @param requestId
+ */
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ /**
+ * @param accessToken
+ */
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ /**
+ * @param proxyConfig
+ */
+ public void setProxyConfig(ProxyConfig proxyConfig) {
+ this.proxyConfig = proxyConfig;
+ }
+
+ /**
+ * @param baseUrl
+ */
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl;
+ }
+
+
+
+ /**
+ * Builder class for RequestContext
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String requestId;
+ private String accessToken;
+ private ProxyConfig proxyConfig;
+ private String baseUrl;
+
+ public Builder(String accessToken, Environment environment) {
+ this.accessToken = accessToken;
+ this.baseUrl = getBaseUrlFromProperties(environment);
+ this.requestId = UUID.randomUUID().toString().replace("-", "");
+ }
+
+ public Builder requestId(String requestId) {
+ this.requestId = requestId;
+ return this;
+ }
+
+ public Builder proxyConfig(ProxyConfig proxyConfig) {
+ this.proxyConfig = proxyConfig;
+ return this;
+ }
+
+ public RequestContext build() {
+ return new RequestContext(this);
+ }
+
+ }
+
+ /**
+ * Retrieves base url from payment.properties
+ *
+ * @param environment
+ * @return
+ */
+ private static String getBaseUrlFromProperties(Environment environment) {
+ return PropertiesConfig.getInstance().getProperty("PAYMENTS_BASE_URL_" + environment.toString());
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Address.java b/payments-api/src/main/java/com/intuit/payment/data/Address.java
new file mode 100644
index 00000000..574f1cfd
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Address.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Address extends Entity {
+
+ private static final long serialVersionUID = 1L;
+ private String streetAddress = null;
+ private String city = null;
+ private String region = null;
+ private String country = null;
+ private String postalCode = null;
+
+ public Address() {
+ }
+
+ private Address(Builder builder) {
+ this.streetAddress = builder.streetAddress;
+ this.city = builder.city;
+ this.region = builder.region;
+ this.country = builder.country;
+ this.postalCode = builder.postalCode;
+ }
+
+ /**
+ * Full street adddress, which may include house number and street name (CR
+ * acceptable)
+ *
+ * @return Full street adddress, which may include house number and street
+ * name (CR acceptable)
+ */
+ public String getStreetAddress() {
+ return streetAddress;
+ }
+
+ /**
+ * Full street adddress, which may include house number and street name (CR
+ * acceptable)
+ *
+ * @param streetAddress
+ * Full street adddress, which may include house number and
+ * street name (CR acceptable)
+ */
+ public void setStreetAddress(String streetAddress) {
+ this.streetAddress = streetAddress;
+ }
+
+ /**
+ * City
+ *
+ * @return City
+ */
+ public String getCity() {
+ return city;
+ }
+
+ /**
+ * City
+ *
+ * @param city
+ * City
+ */
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ /**
+ * Region within a country. State, province, prefecture or region component.
+ *
+ * @return Region within a country. State, province, prefecture or region
+ * component.
+ */
+ public String getRegion() {
+ return region;
+ }
+
+ /**
+ * Region within a country. State, province, prefecture or region component.
+ *
+ * @param region
+ * Region within a country. State, province, prefecture or region
+ * component.
+ */
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
+ /**
+ * Country code or name
+ *
+ * @return Country code or name
+ */
+ public String getCountry() {
+ return country;
+ }
+
+ /**
+ * Country code or name
+ *
+ * @param country
+ * Country code or name
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ /**
+ * Postal Code
+ *
+ * @return Postal Code
+ */
+ public String getPostalCode() {
+ return postalCode;
+ }
+
+ /**
+ * Postal Code
+ *
+ * @param postalCode
+ * Postal Code
+ */
+ public void setPostalCode(String postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Address
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String streetAddress = null;
+ private String city = null;
+ private String region = null;
+ private String country = null;
+ private String postalCode = null;
+
+ public Builder() {
+ }
+
+ public Builder streetAddress(String streetAddress) {
+ this.streetAddress = streetAddress;
+ return this;
+ }
+
+ public Builder city(String city) {
+ this.city = city;
+ return this;
+ }
+
+ public Builder region(String region) {
+ this.region = region;
+ return this;
+ }
+
+ public Builder country(String country) {
+ this.country = country;
+ return this;
+ }
+
+ public Builder postalCode(String postalCode) {
+ this.postalCode = postalCode;
+ return this;
+ }
+
+ public Address build() {
+ return new Address(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/BankAccount.java b/payments-api/src/main/java/com/intuit/payment/data/BankAccount.java
new file mode 100644
index 00000000..23be58af
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/BankAccount.java
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author dderose
+ *
+ */
+public class BankAccount extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private String name = null;
+ private Date created = null;
+ private Date updated = null;
+ private BankAccountInputTypeEnum inputType = null;
+
+ public enum BankAccountInputTypeEnum {
+ KEYED
+ };
+
+ private String routingNumber = null;
+ private String accountNumber = null;
+ private AccountType accountType = null;
+
+ public enum AccountType {
+ PERSONAL_CHECKING, PERSONAL_SAVINGS
+ };
+
+ private String phone = null;
+
+ @JsonProperty("default")
+ private Boolean defaultValue = null;
+
+ private String country = null;
+ private String bankCode = null;
+
+ public BankAccount() {
+ }
+
+ private BankAccount(Builder builder) {
+ this.id = builder.id;
+ this.name = builder.name;
+ this.created = builder.created;
+ this.updated = builder.updated;
+ this.inputType = builder.inputType;
+ this.routingNumber = builder.routingNumber;
+ this.accountNumber = builder.accountNumber;
+ this.accountType = builder.accountType;
+ this.phone = builder.phone;
+ this.defaultValue = builder.defaultValue;
+ this.country = builder.country;
+ this.bankCode = builder.bankCode;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @return System generated alpha-numeric id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @param id
+ * System generated alpha-numeric id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @return Object create time, in ISO 8601 date-time format
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @param created
+ * Object create time, in ISO 8601 date-time format
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * @return
+ */
+ public Date getUpdated() {
+ return updated;
+ }
+
+ /**
+ * @param updated
+ */
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ /**
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return
+ */
+ public String getRoutingNumber() {
+ return routingNumber;
+ }
+
+ /**
+ * @param routingNumber
+ */
+ public void setRoutingNumber(String routingNumber) {
+ this.routingNumber = routingNumber;
+ }
+
+ /**
+ * @return
+ */
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ /**
+ * @param accountNumber
+ */
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ /**
+ * @return
+ */
+ public AccountType getAccountType() {
+ return accountType;
+ }
+
+ /**
+ * @param accountType
+ */
+ public void setAccountType(AccountType accountType) {
+ this.accountType = accountType;
+ }
+
+ /**
+ * @return
+ */
+ public String getPhone() {
+ return phone;
+ }
+
+ /**
+ * @param phone
+ */
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ /**
+ * @return
+ */
+ public String getCountry() {
+ return country;
+ }
+
+ /**
+ * @param country
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ /**
+ * @return
+ */
+ public BankAccountInputTypeEnum getInputType() {
+ return inputType;
+ }
+
+ /**
+ * @param inputType
+ */
+ public void setInputType(BankAccountInputTypeEnum inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return
+ */
+ public String getBankCode() {
+ return bankCode;
+ }
+
+ /**
+ * @param bankCode
+ */
+ public void setBankCode(String bankCode) {
+ this.bankCode = bankCode;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @param defaultValue
+ */
+ public void setDefaultValue(Boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for BankAccount
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private String name = null;
+ private Date created = null;
+ private Date updated = null;
+ private BankAccountInputTypeEnum inputType = null;
+ private String routingNumber = null;
+ private String accountNumber = null;
+ private AccountType accountType = null;
+ private String phone = null;
+ private Boolean defaultValue = null;
+ private String country = null;
+ private String bankCode = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder updated(Date updated) {
+ this.updated = updated;
+ return this;
+ }
+
+ public Builder inputType(BankAccountInputTypeEnum inputType) {
+ this.inputType = inputType;
+ return this;
+ }
+
+ public Builder routingNumber(String routingNumber) {
+ this.routingNumber = routingNumber;
+ return this;
+ }
+
+ public Builder accountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ return this;
+ }
+
+ public Builder accountType(AccountType accountType) {
+ this.accountType = accountType;
+ return this;
+ }
+
+ public Builder phone(String phone) {
+ this.phone = phone;
+ return this;
+ }
+
+ public Builder defaultValue(Boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ return this;
+ }
+
+ public Builder country(String country) {
+ this.country = country;
+ return this;
+ }
+
+ public Builder bankCode(String bankCode) {
+ this.bankCode = bankCode;
+ return this;
+ }
+
+ public BankAccount build() {
+ return new BankAccount(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Capture.java b/payments-api/src/main/java/com/intuit/payment/data/Capture.java
new file mode 100644
index 00000000..87665b2d
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Capture.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Capture extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private Date created = null;
+ private BigDecimal amount = null;
+ private PaymentContext context = null;
+ private String description = null;
+
+ public Capture() {
+ }
+
+ private Capture(Builder builder) {
+ this.created = builder.created;
+ this.amount = builder.amount;
+ this.context = builder.context;
+ this.description = builder.description;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @return Object create time, in ISO 8601 date-time format
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @param created
+ * Object create time, in ISO 8601 date-time format
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @return Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @param amount
+ * Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Optional additional data that will be stored with this charge
+ *
+ * @return Optional additional data that will be stored with this charge
+ */
+ public PaymentContext getContext() {
+ return context;
+ }
+
+ /**
+ * Optional additional data that will be stored with this charge
+ *
+ * @param context
+ * Optional additional data that will be stored with this charge
+ */
+ public void setContext(PaymentContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @return Optional description that will be stored with this charge
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @param description
+ * Optional description that will be stored with this charge
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Capture
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private Date created = null;
+ private BigDecimal amount = null;
+ private PaymentContext context = null;
+ private String description = null;
+
+ public Builder() {
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder amount(BigDecimal amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ public Builder context(PaymentContext context) {
+ this.context = context;
+ return this;
+ }
+
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public Capture build() {
+ return new Capture(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Card.java b/payments-api/src/main/java/com/intuit/payment/data/Card.java
new file mode 100644
index 00000000..37e6bb43
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Card.java
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author dderose
+ *
+ */
+public class Card extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private String number = null;
+ private String name = null;
+ private Address address = null;
+ private Date created = null;
+ private Date updated = null;
+ private String commercialCardCode = null;
+ private CvcVerification cvcVerification = null;
+ private String cardType = null;
+ private String expMonth = null;
+ private String expYear = null;
+ private Boolean isBusiness = null;
+ private Boolean isLevel3Eligible = null;
+
+ @JsonProperty("default")
+ private Boolean defaultValue = null;
+
+ private String cvc = null;
+
+
+ public Card() {
+ }
+
+ private Card(Builder builder) {
+ this.id = builder.id;
+ this.number = builder.number;
+ this.name = builder.name;
+ this.address = builder.address;
+ this.created = builder.created;
+ this.updated = builder.updated;
+ this.commercialCardCode = builder.commercialCardCode;
+ this.cvcVerification = builder.cvcVerification;
+ this.cardType = builder.cardType;
+ this.expMonth = builder.expMonth;
+ this.expYear = builder.expYear;
+ this.isBusiness = builder.isBusiness;
+ this.isLevel3Eligible = builder.isLevel3Eligible;
+ this.defaultValue = builder.defaultValue;
+ this.cvc = builder.cvc;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @return System generated alpha-numeric id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @param id
+ * System generated alpha-numeric id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Credit/debit card number
+ *
+ * @return Credit/debit card number
+ */
+ public String getNumber() {
+ return number;
+ }
+
+ /**
+ * Credit/debit card number
+ *
+ * @param number
+ * Credit/debit card number
+ */
+ public void setNumber(String number) {
+ this.number = number;
+ }
+
+ /**
+ * Two digits indicating card's expiration month
+ *
+ * @return Two digits indicating card's expiration month
+ */
+ public String getExpMonth() {
+ return expMonth;
+ }
+
+ /**
+ * Two digits indicating card's expiration month
+ *
+ * @param expMonth
+ * Two digits indicating card's expiration month
+ */
+ public void setExpMonth(String expMonth) {
+ this.expMonth = expMonth;
+ }
+
+ /**
+ * Four digits indicating card's expiration year
+ *
+ * @return Four digits indicating card's expiration year
+ */
+ public String getExpYear() {
+ return expYear;
+ }
+
+ /**
+ * Four digits indicating card's expiration year
+ *
+ * @param expYear
+ * Four digits indicating card's expiration year
+ */
+ public void setExpYear(String expYear) {
+ this.expYear = expYear;
+ }
+
+ /**
+ * CVC code - Strongly recommended for screening fraudulent transactions
+ *
+ * @return CVC code - Strongly recommended for screening fraudulent
+ * transactions
+ */
+ public String getCvc() {
+ return cvc;
+ }
+
+ /**
+ * CVC code - Strongly recommended for screening fraudulent transactions
+ *
+ * @param cvc
+ * CVC code - Strongly recommended for screening fraudulent
+ * transactions
+ */
+ public void setCvc(String cvc) {
+ this.cvc = cvc;
+ }
+
+ /**
+ * Cardholder's name as it appears on the card
+ *
+ * @return Cardholder's name as it appears on the card
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Cardholder's name as it appears on the card
+ *
+ * @param name
+ * Cardholder's name as it appears on the card
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Address
+ *
+ * @return Address
+ */
+ public Address getAddress() {
+ return address;
+ }
+
+ /**
+ * Address
+ *
+ * @param address
+ * Address
+ */
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+
+ /**
+ * Specific code that is applicable when the card used is a commercial card
+ * (corporate cards)
+ *
+ * @return Specific code that is applicable when the card used is a
+ * commercial card (corporate cards)
+ */
+ public String getCommercialCardCode() {
+ return commercialCardCode;
+ }
+
+ /**
+ * Specific code that is applicable when the card used is a commercial card
+ * (corporate cards)
+ *
+ * @param commercialCardCode
+ * Specific code that is applicable when the card used is a
+ * commercial card (corporate cards)
+ */
+ public void setCommercialCardCode(String commercialCardCode) {
+ this.commercialCardCode = commercialCardCode;
+ }
+
+ /**
+ * @return
+ */
+ public String getCardType() {
+ return cardType;
+ }
+
+ /**
+ * @param cardType
+ */
+ public void setCardType(String cardType) {
+ this.cardType = cardType;
+ }
+
+ /**
+ * @return
+ */
+ public CvcVerification getCvcVerification() {
+ return cvcVerification;
+ }
+
+ /**
+ * @param cvcVerification
+ */
+ public void setCvcVerification(CvcVerification cvcVerification) {
+ this.cvcVerification = cvcVerification;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getIsBusiness() {
+ return isBusiness;
+ }
+
+ /**
+ * @param isBusiness
+ */
+ public void setIsBusiness(Boolean isBusiness) {
+ this.isBusiness = isBusiness;
+ }
+
+ /**
+ * @return
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * @param created
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * @return
+ */
+ public Date getUpdated() {
+ return updated;
+ }
+
+ /**
+ * @param updated
+ */
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getIsLevel3Eligible() {
+ return isLevel3Eligible;
+ }
+
+ /**
+ * @param isLevel3Eligible
+ */
+ public void setIsLevel3Eligible(Boolean isLevel3Eligible) {
+ this.isLevel3Eligible = isLevel3Eligible;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @param defaultValue
+ */
+ public void setDefaultValue(Boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Card
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private String number = null;
+ private String name = null;
+ private Address address = null;
+ private Date created = null;
+ private Date updated = null;
+ private String commercialCardCode = null;
+ private CvcVerification cvcVerification = null;
+ private String cardType = null;
+ private String expMonth = null;
+ private String expYear = null;
+ private Boolean isBusiness = null;
+ private Boolean isLevel3Eligible = null;
+ private Boolean defaultValue = null;
+ private String cvc = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder number(String number) {
+ this.number = number;
+ return this;
+ }
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder address(Address address) {
+ this.address = address;
+ return this;
+ }
+
+ public Builder createdDate(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder updatedDate(Date updated) {
+ this.updated = updated;
+ return this;
+ }
+
+ public Builder commercialCardCode(String commercialCardCode) {
+ this.commercialCardCode = commercialCardCode;
+ return this;
+ }
+
+ public Builder cvcVerification(CvcVerification cvcVerification) {
+ this.cvcVerification = cvcVerification;
+ return this;
+ }
+
+ public Builder cardType(String cardType) {
+ this.cardType = cardType;
+ return this;
+ }
+
+ public Builder expMonth(String expMonth) {
+ this.expMonth = expMonth;
+ return this;
+ }
+
+ public Builder expYear(String expYear) {
+ this.expYear = expYear;
+ return this;
+ }
+
+ public Builder isBusiness(Boolean isBusiness) {
+ this.isBusiness = isBusiness;
+ return this;
+ }
+
+ public Builder isLevel3Eligible(Boolean isLevel3Eligible) {
+ this.isLevel3Eligible = isLevel3Eligible;
+ return this;
+ }
+
+ public Builder defaultValue(Boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ return this;
+ }
+
+ public Builder cvc(String cvc) {
+ this.cvc = cvc;
+ return this;
+ }
+
+ public Card build() {
+ return new Card(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Charge.java b/payments-api/src/main/java/com/intuit/payment/data/Charge.java
new file mode 100644
index 00000000..3ab3efff
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Charge.java
@@ -0,0 +1,543 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Charge extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private Date created = null;
+ private ChargeStatus status = null;
+
+ public enum ChargeStatus {
+ AUTHORIZED, DECLINED, CAPTURED, CANCELLED, REFUNDED, SETTLED,PENDING,
+ DISPUTED, RETURNED, WITHHELD
+ };
+
+ private BigDecimal amount = null;
+ private String currency = null;
+ private String token = null;
+ private Card card = null;
+ private PaymentContext context = null;
+ private Boolean capture = null;
+ private String authCode = null;
+ private Capture captureDetail = null;
+ private Refund[] refundDetail = null;
+ private String description = null;
+ private String avsStreet = null;
+ private String avsZip = null;
+ private String cardSecurityCodeMatch = null;
+ private String appType = null;
+ private String cardOnFile = null;
+
+ public Charge() {
+ }
+
+ private Charge(Builder builder) {
+ this.id = builder.id;
+ this.created = builder.created;
+ this.status = builder.status;
+ this.amount = builder.amount;
+ this.currency = builder.currency;
+ this.token = builder.token;
+ this.card = builder.card;
+ this.context = builder.context;
+ this.capture = builder.capture;
+ this.authCode = builder.authCode;
+ this.captureDetail = builder.captureDetail;
+ this.refundDetail = builder.refundDetail;
+ this.description = builder.description;
+ this.avsStreet = builder.avsStreet;
+ this.avsZip = builder.avsZip;
+ this.cardSecurityCodeMatch = builder.cardSecurityCodeMatch;
+ this.appType = builder.appType;
+ this.cardOnFile = builder.cardOnFile;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @return System generated alpha-numeric id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @param id
+ * System generated alpha-numeric id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @return Object create time, in ISO 8601 date-time format
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @param created
+ * Object create time, in ISO 8601 date-time format
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Status of the transaction
+ *
+ * @return Status of the transaction
+ */
+ public ChargeStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * Status of the transaction
+ *
+ * @param status
+ * Status of the transaction
+ */
+ public void setStatus(ChargeStatus status) {
+ this.status = status;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @return Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @param amount
+ * Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Three-letter ISO 4217 currency code representing the currency in which
+ * the charge was made
+ *
+ * @return Three-letter ISO 4217 currency code representing the currency in
+ * which the charge was made
+ */
+ public String getCurrency() {
+ return currency;
+ }
+
+ /**
+ * Three-letter ISO 4217 currency code representing the currency in which
+ * the charge was made
+ *
+ * @param currency
+ * Three-letter ISO 4217 currency code representing the currency
+ * in which the charge was made
+ */
+ public void setCurrency(String currency) {
+ this.currency = currency;
+ }
+
+ /**
+ * Opaque representation of the credit card associated with this charge, as
+ * returned by the token endpoint
+ *
+ * @return Opaque representation of the credit card associated with this
+ * charge, as returned by the token endpoint
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * Opaque representation of the credit card associated with this charge, as
+ * returned by the token endpoint
+ *
+ * @param token
+ * Opaque representation of the credit card associated with this
+ * charge, as returned by the token endpoint
+ */
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ /**
+ * Credit card details associated with this charge
+ *
+ * @return Credit card details associated with this charge
+ */
+ public Card getCard() {
+ return card;
+ }
+
+ /**
+ * Credit card details associated with this charge
+ *
+ * @param card
+ * Credit card details associated with this charge
+ */
+ public void setCard(Card card) {
+ this.card = card;
+ }
+
+ /**
+ * Optional additional data that will be stored with this charge
+ *
+ * @return Optional additional data that will be stored with this charge
+ */
+ public PaymentContext getContext() {
+ return context;
+ }
+
+ /**
+ * Optional additional data that will be stored with this charge
+ *
+ * @param context
+ * Optional additional data that will be stored with this charge
+ */
+ public void setContext(PaymentContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Capture flag
+ *
+ * @return Capture flag
+ */
+ public Boolean getCapture() {
+ return capture;
+ }
+
+ /**
+ * Capture flag
+ *
+ * @param capture
+ * Capture flag
+ */
+ public void setCapture(Boolean capture) {
+ this.capture = capture;
+ }
+
+ /**
+ * Authorization code. Available for uncaptured charges, only
+ *
+ * @return Authorization code. Available for uncaptured charges, only
+ */
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ /**
+ * Authorization code. Available for uncaptured charges, only
+ *
+ * @param authCode
+ * Authorization code. Available for uncaptured charges, only
+ */
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ /**
+ * Charge capture detail. Available for charges previously authorized
+ *
+ * @return Charge capture detail. Available for charges previously
+ * authorized
+ */
+ public Capture getCaptureDetail() {
+ return captureDetail;
+ }
+
+ /**
+ * Charge capture detail. Available for charges previously authorized
+ *
+ * @param captureDetail
+ * Charge capture detail. Available for charges previously
+ * authorized
+ */
+ public void setCaptureDetail(Capture captureDetail) {
+ this.captureDetail = captureDetail;
+ }
+
+ /**
+ * Details for one or more refunds against this charge
+ *
+ * @return Details for one or more refunds against this charge
+ */
+ public Refund[] getRefundDetail() {
+ return refundDetail;
+ }
+
+ /**
+ * Details for one or more refunds against this charge
+ *
+ * @param refundDetail
+ * Details for one or more refunds against this charge
+ */
+ public void setRefundDetail(Refund[] refundDetail) {
+ this.refundDetail = refundDetail;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @return Optional description that will be stored with this charge
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @param description
+ * Optional description that will be stored with this charge
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return
+ */
+ public String getAvsStreet() {
+ return avsStreet;
+ }
+
+ /**
+ * @param avsStreet
+ */
+ public void setAvsStreet(String avsStreet) {
+ this.avsStreet = avsStreet;
+ }
+
+ /**
+ * @return
+ */
+ public String getAvsZip() {
+ return avsZip;
+ }
+
+ /**
+ * @param avsZip
+ */
+ public void setAvsZip(String avsZip) {
+ this.avsZip = avsZip;
+ }
+
+ /**
+ * @return
+ */
+ public String getCardSecurityCodeMatch() {
+ return cardSecurityCodeMatch;
+ }
+
+ /**
+ * @param cardSecurityCodeMatch
+ */
+ public void setCardSecurityCodeMatch(String cardSecurityCodeMatch) {
+ this.cardSecurityCodeMatch = cardSecurityCodeMatch;
+ }
+
+ /**
+ * @return
+ */
+ public String getAppType() {
+ return appType;
+ }
+
+ /**
+ * @param appType
+ */
+ public void setAppType(String appType) {
+ this.appType = appType;
+ }
+
+ /**
+ * @return
+ */
+ public String getCardOnFile() {
+ return cardOnFile;
+ }
+
+ /**
+ * @param cardOnFile
+ */
+ public void setCardOnFile(String cardOnFile) {
+ this.cardOnFile = cardOnFile;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Charge
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private Date created = null;
+ private ChargeStatus status = null;
+ private BigDecimal amount = null;
+ private String currency = null;
+ private String token = null;
+ private Card card = null;
+ private PaymentContext context = null;
+ private Boolean capture = null;
+ private String authCode = null;
+ private Capture captureDetail = null;
+ private Refund[] refundDetail = null;
+ private String description = null;
+ private String avsStreet = null;
+ private String avsZip = null;
+ private String cardSecurityCodeMatch = null;
+ private String appType = null;
+ private String cardOnFile = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder status(ChargeStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ public Builder amount(BigDecimal amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ public Builder currency(String currency) {
+ this.currency = currency;
+ return this;
+ }
+
+ public Builder token(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public Builder card(Card card) {
+ this.card = card;
+ return this;
+ }
+
+ public Builder context(PaymentContext context) {
+ this.context = context;
+ return this;
+ }
+
+ public Builder capture(Boolean capture) {
+ this.capture = capture;
+ return this;
+ }
+
+ public Builder authCode(String authCode) {
+ this.authCode = authCode;
+ return this;
+ }
+
+ public Builder captureDetail(Capture captureDetail) {
+ this.captureDetail = captureDetail;
+ return this;
+ }
+
+ public Builder refundDetail(Refund[] refundDetail) {
+ this.refundDetail = refundDetail;
+ return this;
+ }
+
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public Builder avsStreet(String avsStreet) {
+ this.avsStreet = avsStreet;
+ return this;
+ }
+
+ public Builder avsZip(String avsZip) {
+ this.avsZip = avsZip;
+ return this;
+ }
+
+ public Builder cardSecurityCodeMatch(String cardSecurityCodeMatch) {
+ this.cardSecurityCodeMatch = cardSecurityCodeMatch;
+ return this;
+ }
+
+ public Builder appType(String appType) {
+ this.appType = appType;
+ return this;
+ }
+
+ public Builder cardOnFile(String cardOnFile) {
+ this.cardOnFile = cardOnFile;
+ return this;
+ }
+
+ public Charge build() {
+ return new Charge(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/CheckContext.java b/payments-api/src/main/java/com/intuit/payment/data/CheckContext.java
new file mode 100644
index 00000000..84d2153c
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/CheckContext.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class CheckContext extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private DeviceInfo deviceInfo = null;
+
+ public CheckContext() {
+ }
+
+ private CheckContext(Builder builder) {
+ this.deviceInfo = builder.deviceInfo;
+ }
+
+ /**
+ * @return
+ */
+ public DeviceInfo getDeviceInfo() {
+ return deviceInfo;
+ }
+
+ /**
+ * @param deviceInfo
+ */
+ public void setDeviceInfo(DeviceInfo deviceInfo) {
+ this.deviceInfo = deviceInfo;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for CheckContext
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private DeviceInfo deviceInfo = null;
+
+ public Builder(DeviceInfo deviceInfo) {
+ this.deviceInfo = deviceInfo;
+ }
+
+ public CheckContext build() {
+ return new CheckContext(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/CvcVerification.java b/payments-api/src/main/java/com/intuit/payment/data/CvcVerification.java
new file mode 100644
index 00000000..ff1e9e3a
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/CvcVerification.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class CvcVerification extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String result = null;
+ private Date date = null;
+
+ public CvcVerification() {
+ }
+
+ private CvcVerification(Builder builder) {
+ this.result = builder.result;
+ this.date = builder.date;
+ }
+
+ /**
+ * @return
+ */
+ public String getResult() {
+ return result;
+ }
+
+ /**
+ * @param result
+ */
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ /**
+ * @return
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * @param date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for CvcVerification
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String result = null;
+ private Date date = null;
+
+ public Builder() {
+ }
+
+ public Builder result(String result) {
+ this.result = result;
+ return this;
+ }
+
+ public Builder date(Date date) {
+ this.date = date;
+ return this;
+ }
+
+ public CvcVerification build() {
+ return new CvcVerification(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/DeviceInfo.java b/payments-api/src/main/java/com/intuit/payment/data/DeviceInfo.java
new file mode 100644
index 00000000..e836962f
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/DeviceInfo.java
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class DeviceInfo extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private String type = null;
+ private String longitude = null;
+ private String latitude = null;
+ private Boolean encrypted = null;
+ private String phoneNumber = null;
+ private String macAddress = null;
+ private String ipAddress = null;
+
+ public DeviceInfo() {
+ }
+
+ private DeviceInfo(Builder builder) {
+ this.id = builder.id;
+ this.type = builder.type;
+ this.longitude = builder.longitude;
+ this.latitude = builder.latitude;
+ this.encrypted = builder.encrypted;
+ this.phoneNumber = builder.phoneNumber;
+ this.macAddress = builder.macAddress;
+ this.ipAddress = builder.ipAddress;
+ }
+
+ /**
+ * @return
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return
+ */
+ public String getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * @param longitude
+ */
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+ /**
+ * @return
+ */
+ public String getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * @param latitude
+ */
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ /**
+ * @return
+ */
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ /**
+ * @param phoneNumber
+ */
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ /**
+ * @return
+ */
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ /**
+ * @param macAddress
+ */
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ /**
+ * @return
+ */
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ /**
+ * @param ipAddress
+ */
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getEncrypted() {
+ return encrypted;
+ }
+
+ /**
+ * @param encrypted
+ */
+ public void setEncrypted(Boolean encrypted) {
+ this.encrypted = encrypted;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for DeviceInfo
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private String type = null;
+ private String longitude = null;
+ private String latitude = null;
+ private Boolean encrypted = null;
+ private String phoneNumber = null;
+ private String macAddress = null;
+ private String ipAddress = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder longitude(String longitude) {
+ this.longitude = longitude;
+ return this;
+ }
+
+ public Builder latitude(String latitude) {
+ this.latitude = latitude;
+ return this;
+ }
+
+ public Builder encrypted(Boolean encrypted) {
+ this.encrypted = encrypted;
+ return this;
+ }
+
+ public Builder phoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ return this;
+ }
+
+ public Builder macAddress(String macAddress) {
+ this.macAddress = macAddress;
+ return this;
+ }
+
+ public Builder ipAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return this;
+ }
+
+ public DeviceInfo build() {
+ return new DeviceInfo(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/ECheck.java b/payments-api/src/main/java/com/intuit/payment/data/ECheck.java
new file mode 100644
index 00000000..90a6e6b2
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/ECheck.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class ECheck extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private Date created = null;
+ private String authCode = null;
+ private ECheckStatus status = null;
+
+ public enum ECheckStatus {
+ PENDING, SUCCEEDED, DECLINED, VOIDED, REFUNDED
+ };
+
+ private BigDecimal amount = null;
+ private BankAccount bankAccount = null;
+ private String token = null;
+ private String bankAccountOnFile = null;
+ private CheckContext context = null;
+ private PaymentModeType paymentMode = null;
+
+ public enum PaymentModeType {
+ WEB
+ };
+
+ private String description = null;
+ private String checkNumber = null;
+
+ public ECheck() {
+ }
+
+ private ECheck(Builder builder) {
+ this.id = builder.id;
+ this.created = builder.created;
+ this.authCode = builder.authCode;
+ this.status = builder.status;
+ this.amount = builder.amount;
+ this.bankAccount = builder.bankAccount;
+ this.token = builder.token;
+ this.bankAccountOnFile = builder.bankAccountOnFile;
+ this.context = builder.context;
+ this.paymentMode = builder.paymentMode;
+ this.description = builder.description;
+ this.checkNumber = builder.checkNumber;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @return System generated alpha-numeric id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @param id
+ * System generated alpha-numeric id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @return Object create time, in ISO 8601 date-time format
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @param created
+ * Object create time, in ISO 8601 date-time format
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @return Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @param amount
+ * Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Opaque representation of the credit card associated with this charge, as
+ * returned by the token endpoint
+ *
+ * @return Opaque representation of the credit card associated with this
+ * charge, as returned by the token endpoint
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * Opaque representation of the credit card associated with this charge, as
+ * returned by the token endpoint
+ *
+ * @param token
+ * Opaque representation of the credit card associated with this
+ * charge, as returned by the token endpoint
+ */
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ /**
+ * Authorization code. Available for uncaptured charges, only
+ *
+ * @return Authorization code. Available for uncaptured charges, only
+ */
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ /**
+ * Authorization code. Available for uncaptured charges, only
+ *
+ * @param authCode
+ * Authorization code. Available for uncaptured charges, only
+ */
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @return Optional description that will be stored with this charge
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Optional description that will be stored with this charge
+ *
+ * @param description
+ * Optional description that will be stored with this charge
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return
+ */
+ public ECheckStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status
+ */
+ public void setStatus(ECheckStatus status) {
+ this.status = status;
+ }
+
+ /**
+ * @return
+ */
+ public BankAccount getBankAccount() {
+ return bankAccount;
+ }
+
+ /**
+ * @param bankAccount
+ */
+ public void setBankAccount(BankAccount bankAccount) {
+ this.bankAccount = bankAccount;
+ }
+
+ /**
+ * @return
+ */
+ public String getBankAccountOnFile() {
+ return bankAccountOnFile;
+ }
+
+ /**
+ * @param bankAccountOnFile
+ */
+ public void setBankAccountOnFile(String bankAccountOnFile) {
+ this.bankAccountOnFile = bankAccountOnFile;
+ }
+
+ /**
+ * @return
+ */
+ public CheckContext getContext() {
+ return context;
+ }
+
+ /**
+ * @param context
+ */
+ public void setContext(CheckContext context) {
+ this.context = context;
+ }
+
+ /**
+ * @return
+ */
+ public PaymentModeType getPaymentMode() {
+ return paymentMode;
+ }
+
+ /**
+ * @param paymentMode
+ */
+ public void setPaymentMode(PaymentModeType paymentMode) {
+ this.paymentMode = paymentMode;
+ }
+
+ /**
+ * @return
+ */
+ public String getCheckNumber() {
+ return checkNumber;
+ }
+
+ /**
+ * @param checkNumber
+ */
+ public void setCheckNumber(String checkNumber) {
+ this.checkNumber = checkNumber;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for ECheck
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private Date created = null;
+ private String authCode = null;
+ private ECheckStatus status = null;
+ private BigDecimal amount = null;
+ private BankAccount bankAccount = null;
+ private String token = null;
+ private String bankAccountOnFile = null;
+ private CheckContext context = null;
+ private PaymentModeType paymentMode = null;
+ private String description = null;
+ private String checkNumber = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder authCode(String authCode) {
+ this.authCode = authCode;
+ return this;
+ }
+
+ public Builder status(ECheckStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ public Builder amount(BigDecimal amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ public Builder bankAccount(BankAccount bankAccount) {
+ this.bankAccount = bankAccount;
+ return this;
+ }
+
+ public Builder token(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public Builder bankAccountOnFile(String bankAccountOnFile) {
+ this.bankAccountOnFile = bankAccountOnFile;
+ return this;
+ }
+
+ public Builder context(CheckContext context) {
+ this.context = context;
+ return this;
+ }
+
+ public Builder paymentMode(PaymentModeType paymentMode) {
+ this.paymentMode = paymentMode;
+ return this;
+ }
+
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public Builder checkNumber(String checkNumber) {
+ this.checkNumber = checkNumber;
+ return this;
+ }
+
+ public ECheck build() {
+ return new ECheck(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Entity.java b/payments-api/src/main/java/com/intuit/payment/data/Entity.java
new file mode 100644
index 00000000..45563dfb
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Entity.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * @author dderose
+ *
+ */
+@JsonIgnoreProperties({"intuit_tid", "requestId"})
+public abstract class Entity implements Serializable, IEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String intuit_tid = null;
+ private String requestId = null;
+
+ /**
+ * @return
+ */
+ public String getIntuit_tid() {
+ return intuit_tid;
+ }
+
+ /**
+ * @param intuit_tid
+ */
+ public void setIntuit_tid(String intuit_tid) {
+ this.intuit_tid = intuit_tid;
+ }
+
+ /**
+ * @return
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * @param requestId
+ */
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Error.java b/payments-api/src/main/java/com/intuit/payment/data/Error.java
new file mode 100644
index 00000000..3f5bb683
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Error.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Error extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String code = null;
+ private String type = null;
+ private String message = null;
+ private String detail = null;
+ private String moreInfo = null;
+ private String infoLink = null;
+
+ public Error() {
+ }
+
+ private Error(Builder builder) {
+ this.code = builder.code;
+ this.type = builder.type;
+ this.message = builder.message;
+ this.detail = builder.detail;
+ this.moreInfo = builder.moreInfo;
+ this.infoLink = builder.infoLink;
+ }
+
+ /**
+ * Error Code
+ *
+ * @return Error Code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * Error Code
+ *
+ * @param code
+ * Error Code
+ */
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ * Type for the error
+ *
+ * @return Type for the error
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Type for the error
+ *
+ * @param type
+ * Type for the error
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Reason for the error
+ *
+ * @return Reason for the error
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Reason for the error
+ *
+ * @param message
+ * Reason for the error
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Additonal detail of the error
+ *
+ * @return Additonal detail of the error
+ */
+ public String getDetail() {
+ return detail;
+ }
+
+ /**
+ * Additonal detail of the error
+ *
+ * @param detail
+ * Additonal detail of the error
+ */
+ public void setDetail(String detail) {
+ this.detail = detail;
+ }
+
+ /**
+ * More info
+ *
+ * @return More info
+ */
+ public String getMoreInfo() {
+ return moreInfo;
+ }
+
+ /**
+ * More info
+ *
+ * @param moreInfo
+ * More info
+ */
+ public void setMoreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ }
+
+ /**
+ * Info link
+ *
+ * @return Info link
+ */
+ public String getInfoLink() {
+ return infoLink;
+ }
+
+ /**
+ * Info link
+ *
+ * @param infoLink
+ * Info link
+ */
+ public void setInfoLink(String infoLink) {
+ this.infoLink = infoLink;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Error
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String code = null;
+ private String type = null;
+ private String message = null;
+ private String detail = null;
+ private String moreInfo = null;
+ private String infoLink = null;
+
+ public Builder() {
+ }
+
+ public Builder code(String code) {
+ this.code = code;
+ return this;
+ }
+
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public Builder detail(String detail) {
+ this.detail = detail;
+ return this;
+ }
+
+ public Builder moreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ return this;
+ }
+
+ public Builder infoLink(String infoLink) {
+ this.infoLink = infoLink;
+ return this;
+ }
+
+ public Error build() {
+ return new Error(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Errors.java b/payments-api/src/main/java/com/intuit/payment/data/Errors.java
new file mode 100644
index 00000000..f78b6b5b
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Errors.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author dderose
+ *
+ */
+public class Errors extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("errors")
+ private List errorList = new ArrayList();
+
+ public Errors() {
+ }
+
+ private Errors(Builder builder) {
+ this.errorList = builder.errorList;
+ }
+
+ /**
+ * @return
+ */
+ public List getErrorList() {
+ return errorList;
+ }
+
+ /**
+ * @param errorList
+ */
+ public void setErrorList(List errorList) {
+ this.errorList = errorList;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Errors
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private List errorList = new ArrayList();
+
+ public Builder(List errorList) {
+ this.errorList = errorList;
+ }
+
+ public Errors build() {
+ return new Errors(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/IEntity.java b/payments-api/src/main/java/com/intuit/payment/data/IEntity.java
new file mode 100644
index 00000000..f3aa4601
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/IEntity.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+/**
+ * @author dderose
+ *
+ */
+public interface IEntity {
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/data/PaymentContext.java b/payments-api/src/main/java/com/intuit/payment/data/PaymentContext.java
new file mode 100644
index 00000000..75297a4c
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/PaymentContext.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.math.BigDecimal;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class PaymentContext extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private BigDecimal tax = null;
+ private DeviceInfo deviceInfo = null;
+ private Boolean recurring = null;
+ private String mobile = null;
+ private String isEcommerce = null;
+
+ public PaymentContext() {
+ }
+
+ private PaymentContext(Builder builder) {
+ this.tax = builder.tax;
+ this.deviceInfo = builder.deviceInfo;
+ this.recurring = builder.recurring;
+ this.mobile = builder.mobile;
+ this.isEcommerce = builder.isEcommerce;
+ }
+
+ /**
+ * Sales Tax - required for commercial card processing
+ *
+ * @return Sales Tax - required for commercial card processing
+ */
+ public BigDecimal getTax() {
+ return tax;
+ }
+
+ /**
+ * Sales Tax - required for commercial card processing
+ *
+ * @param tax
+ * Sales Tax - required for commercial card processing
+ */
+ public void setTax(BigDecimal tax) {
+ this.tax = tax;
+ }
+
+ /**
+ * @return
+ */
+ public DeviceInfo getDeviceInfo() {
+ return deviceInfo;
+ }
+
+ /**
+ * @param deviceInfo
+ */
+ public void setDeviceInfo(DeviceInfo deviceInfo) {
+ this.deviceInfo = deviceInfo;
+ }
+
+ /**
+ * This boolean value should be set to true if the charge is recurring. This
+ * value is not applicable for capture or refund request and it won't be
+ * used.
+ *
+ * @return This boolean value should be set to true if the charge is
+ * recurring. This value is not applicable for capture or refund
+ * request and it won't be used.
+ */
+ public Boolean getRecurring() {
+ return recurring;
+ }
+
+ /**
+ * This boolean value should be set to true if the charge is recurring. This
+ * value is not applicable for capture or refund request and it won't be
+ * used.
+ *
+ * @param recurring
+ * This boolean value should be set to true if the charge is
+ * recurring. This value is not applicable for capture or refund
+ * request and it won't be used.
+ */
+ public void setRecurring(Boolean recurring) {
+ this.recurring = recurring;
+ }
+
+ /**
+ * @return
+ */
+ public String getMobile() {
+ return mobile;
+ }
+
+ /**
+ * @param mobile
+ */
+ public void setMobile(String mobile) {
+ this.mobile = mobile;
+ }
+
+ /**
+ * @return
+ */
+ public String getIsEcommerce() {
+ return isEcommerce;
+ }
+
+ /**
+ * @param isEcommerce
+ */
+ public void setIsEcommerce(String isEcommerce) {
+ this.isEcommerce = isEcommerce;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for PaymentContext
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private BigDecimal tax = null;
+ private DeviceInfo deviceInfo = null;
+ private Boolean recurring = null;
+ private String mobile = null;
+ private String isEcommerce = null;
+
+ public Builder() {
+ }
+
+ public Builder tax(BigDecimal tax) {
+ this.tax = tax;
+ return this;
+ }
+
+ public Builder deviceInfo(DeviceInfo deviceInfo) {
+ this.deviceInfo = deviceInfo;
+ return this;
+ }
+
+ public Builder recurring(Boolean recurring) {
+ this.recurring = recurring;
+ return this;
+ }
+
+ public Builder mobile(String mobile) {
+ this.mobile = mobile;
+ return this;
+ }
+
+ public Builder isEcommerce(String isEcommerce) {
+ this.isEcommerce = isEcommerce;
+ return this;
+ }
+
+ public PaymentContext build() {
+ return new PaymentContext(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/QueryResponse.java b/payments-api/src/main/java/com/intuit/payment/data/QueryResponse.java
new file mode 100644
index 00000000..0673528b
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/QueryResponse.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class QueryResponse extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private List bankAccounts = new ArrayList();
+ private List cards = new ArrayList();
+
+ public QueryResponse() {
+ }
+
+ private QueryResponse(Builder builder) {
+ this.bankAccounts = builder.bankAccounts;
+ this.cards = builder.cards;
+ }
+
+ /**
+ * @return
+ */
+ public List getBankAccounts() {
+ return bankAccounts;
+ }
+
+ /**
+ * @param bankAccounts
+ */
+ public void setBankAccounts(List bankAccounts) {
+ this.bankAccounts = bankAccounts;
+ }
+
+ /**
+ * @return
+ */
+ public List getCards() {
+ return cards;
+ }
+
+ /**
+ * @param cards
+ */
+ public void setCards(List cards) {
+ this.cards = cards;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for QueryResponse
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private List bankAccounts = new ArrayList();
+ private List cards = new ArrayList();
+
+ public Builder() {
+ }
+
+ public Builder bankAccounts(List bankAccounts) {
+ this.bankAccounts = bankAccounts;
+ return this;
+ }
+
+ public Builder cards(List cards) {
+ this.cards = cards;
+ return this;
+ }
+
+ public QueryResponse build() {
+ return new QueryResponse(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Refund.java b/payments-api/src/main/java/com/intuit/payment/data/Refund.java
new file mode 100644
index 00000000..e8799964
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Refund.java
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Refund extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id = null;
+ private Date created = null;
+ private RefundStatus status = null;
+
+ public enum RefundStatus {
+ ISSUED, DECLINED, SETTLED, VOIDED, SUCCEEDED
+ };
+
+ private BigDecimal amount = null;
+ private PaymentContext context = null;
+ private String description = null;
+ private String type = null;
+
+ public Refund() {
+ }
+
+ private Refund(Builder builder) {
+ this.id = builder.id;
+ this.created = builder.created;
+ this.status = builder.status;
+ this.amount = builder.amount;
+ this.context = builder.context;
+ this.description = builder.description;
+ this.type = builder.type;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @return System generated alpha-numeric id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * System generated alpha-numeric id
+ *
+ * @param id
+ * System generated alpha-numeric id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @return Object create time, in ISO 8601 date-time format
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Object create time, in ISO 8601 date-time format
+ *
+ * @param created
+ * Object create time, in ISO 8601 date-time format
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Status of this refund
+ *
+ * @return Status of this refund
+ */
+ public RefundStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * Status of this refund
+ *
+ * @param status
+ * Status of this refund
+ */
+ public void setStatus(RefundStatus status) {
+ this.status = status;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @return Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ /**
+ * Amount of the transaction. Valid values for amount are in the range 0.00
+ * through 99999.99
+ *
+ * @param amount
+ * Amount of the transaction. Valid values for amount are in the
+ * range 0.00 through 99999.99
+ */
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Optional additional data that will be stored with this refund
+ *
+ * @return Optional additional data that will be stored with this refund
+ */
+ public PaymentContext getContext() {
+ return context;
+ }
+
+ /**
+ * Optional additional data that will be stored with this refund
+ *
+ * @param context
+ * Optional additional data that will be stored with this refund
+ */
+ public void setContext(PaymentContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Optional description that will be stored with this refund
+ *
+ * @return Optional description that will be stored with this refund
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Optional description that will be stored with this refund
+ *
+ * @param description
+ * Optional description that will be stored with this refund
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Refund
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private String id = null;
+ private Date created = null;
+ private RefundStatus status = null;
+ private BigDecimal amount = null;
+ private PaymentContext context = null;
+ private String description = null;
+ private String type = null;
+
+ public Builder() {
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+ public Builder status(RefundStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ public Builder amount(BigDecimal amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ public Builder context(PaymentContext context) {
+ this.context = context;
+ return this;
+ }
+
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public Builder type(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Refund build() {
+ return new Refund(this);
+ }
+
+ }
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/data/Token.java b/payments-api/src/main/java/com/intuit/payment/data/Token.java
new file mode 100644
index 00000000..fa0a171f
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/data/Token.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.data;
+
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+
+/**
+ * @author dderose
+ *
+ */
+public class Token extends Entity {
+
+ private static final long serialVersionUID = 1L;
+
+ private Card card = null;
+ private BankAccount bankAccount = null;
+ private String value = null;
+
+ public Token() {
+ }
+
+ private Token(Builder builder) {
+ this.card = builder.card;
+ this.bankAccount = builder.bankAccount;
+ this.value = builder.value;
+ }
+
+ /**
+ * @return
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return
+ */
+ public Card getCard() {
+ return card;
+ }
+
+ /**
+ * @param card
+ */
+ public void setCard(Card card) {
+ this.card = card;
+ }
+
+ /**
+ * @return
+ */
+ public BankAccount getBankAccount() {
+ return bankAccount;
+ }
+
+ /**
+ * @param bankAccount
+ */
+ public void setBankAccount(BankAccount bankAccount) {
+ this.bankAccount = bankAccount;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ /**
+ * Builder class for Token
+ *
+ * @author dderose
+ *
+ */
+ public static class Builder {
+
+ private Card card = null;
+ private BankAccount bankAccount = null;
+ private String value = null;
+
+ public Builder() {
+ }
+
+ public Builder card(Card card) {
+ this.card = card;
+ return this;
+ }
+
+ public Builder bankAccount(BankAccount bankAccount) {
+ this.bankAccount = bankAccount;
+ return this;
+ }
+
+ public Builder value(String value) {
+ this.value = value;
+ return this;
+ }
+
+ public Token build() {
+ return new Token(this);
+ }
+
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/exception/AuthorizationException.java b/payments-api/src/main/java/com/intuit/payment/exception/AuthorizationException.java
new file mode 100644
index 00000000..64aa40b4
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/exception/AuthorizationException.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+/**
+ * Exception class to handle authorization specific exceptions
+ *
+ * @author dderose
+ *
+ */
+public class AuthorizationException extends BaseException {
+
+ /**
+ * The Constant serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ public AuthorizationException(com.intuit.payment.data.Errors errors) {
+ super(errors);
+ }
+
+ /**
+ * Constructor AuthorizationException
+ *
+ * @param errorMessage the error message
+ */
+ public AuthorizationException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructor AuthorizationException
+ *
+ * @param throwable the throwable
+ */
+ public AuthorizationException(Throwable throwable) {
+ super(throwable);
+ }
+
+ /**
+ * Constructor AuthorizationException
+ *
+ * @param errorMessage the error message
+ * @param throwable the throwable
+ */
+ public AuthorizationException(String errorMessage, Throwable throwable) {
+ super(errorMessage, throwable);
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/exception/BadRequestException.java b/payments-api/src/main/java/com/intuit/payment/exception/BadRequestException.java
new file mode 100644
index 00000000..33846898
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/exception/BadRequestException.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+/**
+ * Exception class to handle bad request in HTTP Status code
+ *
+ * @author dderose
+ *
+ */
+public class BadRequestException extends BaseException {
+
+ /**
+ * The Constant serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ public BadRequestException(com.intuit.payment.data.Errors errors) {
+ super(errors);
+ }
+ /**
+ * Constructor BasRequestException
+ *
+ * @param errorMessage the error message
+ */
+ public BadRequestException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructor BasRequestException
+ *
+ * @param throwable the throwable
+ */
+ public BadRequestException(Throwable throwable) {
+ super(throwable);
+ }
+
+ /**
+ * Constructor BasRequestException
+ *
+ * @param errorMessage the error message
+ * @param throwable the throwable
+ */
+ public BadRequestException(String errorMessage, Throwable throwable) {
+ super(errorMessage, throwable);
+ }
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/exception/BaseException.java b/payments-api/src/main/java/com/intuit/payment/exception/BaseException.java
new file mode 100755
index 00000000..d8e42a45
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/exception/BaseException.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+import java.util.Iterator;
+import java.util.List;
+
+import com.intuit.payment.data.Errors;
+
+/**
+ * Base Exception class to handle Exceptions thrown from SDK
+ *
+ * @author dderose
+ *
+ */
+public class BaseException extends Exception {
+
+ /**
+ * The Constant serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ private Errors errors = null;
+
+ /**
+ * variable throwable
+ */
+ private Throwable throwable;
+
+ public BaseException(Errors errors) {
+ super(getString(errors.getErrorList()));
+ this.errors = errors;
+ }
+
+ /**
+ * Constructor FMSException
+ *
+ * @param errorMessage the error message
+ */
+ public BaseException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructor FMSException
+ *
+ * @param throwable the throwable
+ */
+ public BaseException(Throwable throwable) {
+ super(throwable);
+ this.throwable = throwable;
+ }
+
+ /**
+ * Constructor FMSException
+ *
+ * @param errorMessage the error message
+ * @param throwable the throwable
+ */
+ public BaseException(String errorMessage, Throwable throwable) {
+ super(errorMessage, throwable);
+ this.throwable = throwable;
+ }
+
+ /**
+ * Method to get the Throwable object
+ *
+ * @return Throwable
+ */
+ public Throwable getThrowable() {
+ return this.throwable;
+ }
+
+ /**
+ * @return
+ */
+ public Errors getErrors() {
+ return errors;
+ }
+
+ /**
+ * Method to get the error codes received from server as String message
+ *
+ * @param errorList
+ * @return
+ */
+ protected static String getString(List errorList) {
+ String exceptionDetails = "";
+ if (errorList != null) {
+ Iterator iter = errorList.iterator();
+ while (iter.hasNext()) {
+ com.intuit.payment.data.Error error = iter.next();
+ StringBuilder sb = new StringBuilder();
+ sb.append("ERROR CODE:").append(error.getCode())
+ .append(", ERROR MESSAGE:").append(error.getMessage())
+ .append(", ERROR DETAIL:").append(error.getDetail())
+ .append(", ERROR INFO LINK:").append(error.getInfoLink())
+ .append(", ERROR MORE INFO:").append(error.getMoreInfo())
+ .append(", ERROR TYPE:").append(error.getType());
+
+ sb.append("\r\n");
+ exceptionDetails = exceptionDetails + sb.toString();
+ }
+ }
+ return exceptionDetails;
+ }
+
+
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/exception/SerializationException.java b/payments-api/src/main/java/com/intuit/payment/exception/SerializationException.java
new file mode 100644
index 00000000..c2bbf6d9
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/exception/SerializationException.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+/**
+ * Exception class to handle data serialization specific exceptions
+ *
+ * @author dderose
+ *
+ */
+public class SerializationException extends BaseException {
+
+ /**
+ * The Constant serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor SerializationException
+ *
+ * @param errorMessage the error message
+ */
+ public SerializationException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructor SerializationException
+ *
+ * @param throwable the throwable
+ */
+ public SerializationException(Throwable throwable) {
+ super(throwable);
+ }
+
+ /**
+ * Constructor SerializationException
+ *
+ * @param errorMessage the error message
+ * @param throwable the throwable
+ */
+ public SerializationException(String errorMessage, Throwable throwable) {
+ super(errorMessage, throwable);
+ }
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/exception/ServiceException.java b/payments-api/src/main/java/com/intuit/payment/exception/ServiceException.java
new file mode 100644
index 00000000..71a6c8b3
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/exception/ServiceException.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+/**
+ * Exception class to handle service specific exceptions
+ *
+ * @author dderose
+ *
+ */
+public class ServiceException extends BaseException {
+
+ /**
+ * The Constant serialVersionUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ public ServiceException(com.intuit.payment.data.Errors errors) {
+ super(errors);
+ }
+
+ /**
+ * Constructor ServiceException
+ *
+ * @param errorMessage the error message
+ */
+ public ServiceException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructor ServiceException
+ *
+ * @param throwable the throwable
+ */
+ public ServiceException(Throwable throwable) {
+ super(throwable);
+ }
+
+ /**
+ * Constructor ServiceException
+ *
+ * @param errorMessage the error message
+ * @param throwable the throwable
+ */
+ public ServiceException(String errorMessage, Throwable throwable) {
+ super(errorMessage, throwable);
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/http/HttpRequestClient.java b/payments-api/src/main/java/com/intuit/payment/http/HttpRequestClient.java
new file mode 100644
index 00000000..bde268a3
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/http/HttpRequestClient.java
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.client.utils.HttpClientUtils;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicHeader;
+import org.slf4j.Logger;
+
+import com.intuit.payment.config.ProxyConfig;
+import com.intuit.payment.exception.BadRequestException;
+import com.intuit.payment.util.LoggerImpl;
+import com.intuit.payment.util.PropertiesConfig;
+
+/**
+ * Client class to make http request calls
+ *
+ * @author dderose
+ *
+ */
+public class HttpRequestClient {
+
+ private final CloseableHttpClient client;
+
+ private static final int CONNECTION_TIMEOUT = 10000;
+ private static final int SOCKET_TIMEOUT = 30000;
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ /**
+ * Build the HttpClient
+ *
+ */
+ public HttpRequestClient(ProxyConfig proxyConfig) {
+ RequestConfig config = RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT)
+ .setSocketTimeout(SOCKET_TIMEOUT).build();
+
+ // add default headers
+ List headers = new ArrayList();
+ headers.add(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "utf-8"));
+ headers.add(new BasicHeader(HttpHeaders.ACCEPT, "application/json"));
+ headers.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"));
+ headers.add(new BasicHeader(HttpHeaders.USER_AGENT,
+ "V3JavaSDK-payments-" + PropertiesConfig.getInstance().getProperty("version")));
+
+ // build the client
+ Registry socketFactoryRegistry = RegistryBuilder. create()
+ .register("https", prepareClientSSL()).build();
+ PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
+ HttpClientBuilder hcBuilder = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(config)
+ .setDefaultHeaders(headers).setMaxConnPerRoute(10)
+ .setDefaultCredentialsProvider(setProxyAuthentication(proxyConfig));
+
+ // getting proxy from Config file.
+ HttpHost proxy = getProxy(proxyConfig);
+
+ if (proxy != null) {
+ hcBuilder.setProxy(proxy);
+ }
+ client = hcBuilder.build();
+ }
+
+ /**
+ * Method to make the HTTP request call using the request attributes
+ * supplied
+ *
+ * @param request
+ * @return
+ * @throws BadRequestException
+ */
+ public Response makeRequest(Request serviceRequest) throws BadRequestException {
+
+ logger.debug("Enter HttpRequestClient::makeRequest");
+
+ // prepare request
+ RequestBuilder builder = RequestBuilder.create(serviceRequest.getMethod().toString())
+ .setUri(serviceRequest.getUrl()).setVersion(HttpVersion.HTTP_1_1).setCharset(StandardCharsets.UTF_8);
+
+ builder.addHeader("Request-Id", serviceRequest.getContext().getRequestId());
+
+ // add auth header
+ if (!serviceRequest.isIgnoreAuthHeader()) {
+ builder.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + serviceRequest.getContext().getAccessToken());
+ }
+
+ MethodType method = serviceRequest.getMethod();
+ if (method == MethodType.POST) {
+ // add post json
+ HttpEntity entity = new StringEntity(serviceRequest.getPostJson(), "UTF-8");
+ builder.setEntity(entity);
+ }
+
+ logger.debug("Request URI : " + builder.getUri());
+ logger.debug("Http Method : " + builder.getMethod());
+
+ HttpResponse httpResponse = null;
+ try {
+ // make the call
+ httpResponse = client.execute(builder.build());
+
+ // prepare response
+ return new Response(httpResponse.getStatusLine().getStatusCode(), getResult(httpResponse), getIntuitTid(httpResponse));
+
+ } catch (IOException e) {
+ logger.error("Exception while making httpRequest", e);
+ throw new BadRequestException(e.getMessage());
+ } finally {
+ //close
+ HttpClientUtils.closeQuietly(httpResponse);
+ }
+ }
+
+ /**
+ * Method to set proxy authentication
+ *
+ * @return
+ */
+ public CredentialsProvider setProxyAuthentication(ProxyConfig proxyConfig) {
+
+ if (proxyConfig == null) {
+ return null;
+ }
+ String username = proxyConfig.getUsername();
+ String password = proxyConfig.getPassword();
+
+ if (!username.isEmpty() && !password.isEmpty()) {
+ String host = proxyConfig.getHost();
+ String port = proxyConfig.getPort();
+ if (!host.isEmpty() && !port.isEmpty()) {
+ CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+ credentialsProvider.setCredentials(new AuthScope(host, Integer.parseInt(port)),
+ new UsernamePasswordCredentials(username, password));
+ return credentialsProvider;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ public SSLConnectionSocketFactory prepareClientSSL() {
+ try {
+ KeyStore trustStore = null;
+ SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
+ .build();
+
+ String tlsVersion = PropertiesConfig.getInstance().getProperty("TLS_VERSION");
+ logger.info("tlsVersion used: " + tlsVersion);
+ SSLConnectionSocketFactory sslConnectionFactory = new SSLConnectionSocketFactory(sslContext,
+ new String[] { tlsVersion }, null, new NoopHostnameVerifier());
+ return sslConnectionFactory;
+ } catch (Exception ex) {
+ logger.error("couldn't create SSLConnectionSocketFactory!! {}", ex.getMessage(), ex);
+ return null;
+ }
+ }
+
+ /**
+ * Method to get proxy
+ *
+ * @return returns HttpHost
+ */
+ public HttpHost getProxy(ProxyConfig proxyConfig) {
+ if (proxyConfig == null) {
+ return null;
+ }
+ String host = proxyConfig.getHost();
+ String port = proxyConfig.getPort();
+ HttpHost proxy = null;
+ if (!host.isEmpty() && !port.isEmpty()) {
+ proxy = new HttpHost(host, Integer.parseInt(port));
+ }
+ return proxy;
+ }
+
+ /**
+ * Parse the response and return the string from httpresponse body
+ *
+ * @param response
+ * @return String
+ * @throws IOException
+ */
+ public static String getResult(HttpResponse response) throws IOException {
+ StringBuffer result = new StringBuffer();
+ if (response.getEntity() != null && response.getEntity().getContent() != null) {
+ BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+ String line = "";
+ while ((line = rd.readLine()) != null) {
+ result.append(line);
+ }
+ }
+ logger.info(result.toString());
+ return result.toString();
+ }
+
+ /**
+ * Parses the response headers and returns value for intuit_tid parameter
+ *
+ * @param response
+ * @return String
+ * @throws IOException
+ */
+ public static String getIntuitTid(HttpResponse response) throws IOException {
+ return response.getFirstHeader("intuit_tid").getValue();
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/http/MethodType.java b/payments-api/src/main/java/com/intuit/payment/http/MethodType.java
new file mode 100644
index 00000000..3b52b108
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/http/MethodType.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.http;
+
+/**
+ * Enum for the supported method type for Payments API
+ *
+ *@author dderose
+ */
+public enum MethodType {
+
+ /**
+ * the GET method type
+ */
+ GET,
+
+ /**
+ * the POST method type
+ */
+ POST,
+
+ /**
+ * the DELETE method type
+ */
+ DELETE
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/http/Request.java b/payments-api/src/main/java/com/intuit/payment/http/Request.java
new file mode 100644
index 00000000..0bcefe1c
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/http/Request.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.http;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+
+/**
+ * Class to hold the request attributes for making the http call
+ * method - defines the httpmethod type
+ * url - defines the api url
+ * ignoreAuthHeader - flag to determine if authorization header should be applied
+ * postJson - serialized object string used for post data
+ * requestObject - object sent by the client, this is serialized and sent as post data via postJson
+ * typeReference - indicates the Class type that should be used during deserialization
+ * context - holds the requestContext attributes
+ *
+ * @author dderose
+ *
+ */
+public class Request {
+
+ private final MethodType method;
+ private final String url;
+ private final boolean ignoreAuthHeader;
+ private String postJson;
+ private final Object requestObject;
+ private final TypeReference> typeReference;
+ private final RequestContext context;
+
+ private Request(RequestBuilder builder) {
+ this.method = builder.method;
+ this.url = builder.url;
+ this.ignoreAuthHeader = builder.ignoreAuthHeader;
+ this.requestObject = builder.requestObject;
+ this.typeReference = builder.typeReference;
+ this.context = builder.context;
+ }
+
+ public MethodType getMethod() {
+ return method;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public boolean isIgnoreAuthHeader() {
+ return ignoreAuthHeader;
+ }
+
+ public String getPostJson() {
+ return postJson;
+ }
+
+ public Object getRequestObject() {
+ return requestObject;
+ }
+
+ public TypeReference> getTypeReference() {
+ return typeReference;
+ }
+
+ public RequestContext getContext() {
+ return context;
+ }
+
+ public void setPostJson(String postJson) {
+ this.postJson = postJson;
+ }
+
+ /**
+ * Builder class for Request
+ *
+ * @author dderose
+ *
+ */
+ public static class RequestBuilder {
+
+ private final MethodType method;
+ private final String url;
+ private boolean ignoreAuthHeader;
+ private Object requestObject;
+ private TypeReference> typeReference;
+ private RequestContext context;
+
+ public RequestBuilder(MethodType method, String url) {
+ this.method = method;
+ this.url = url;
+ }
+
+ public RequestBuilder ignoreAuthHeader(boolean ignoreAuthHeader) {
+ this.ignoreAuthHeader = ignoreAuthHeader;
+ return this;
+ }
+
+ public RequestBuilder requestObject(Object requestObject) {
+ this.requestObject = requestObject;
+ return this;
+ }
+
+ public RequestBuilder typeReference(TypeReference> typeReference) {
+ this.typeReference = typeReference;
+ return this;
+ }
+
+ public RequestBuilder context(RequestContext context) {
+ this.context = context;
+ return this;
+ }
+
+ public Request build() {
+ return new Request(this);
+ }
+
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/http/Response.java b/payments-api/src/main/java/com/intuit/payment/http/Response.java
new file mode 100644
index 00000000..42673ac9
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/http/Response.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.http;
+
+import com.intuit.payment.data.Errors;
+
+/**
+ * Class to hold the http response attributes
+ * statusCode - httpstatus code
+ * intuit_tid - constains value for intuit_tid paramter from response header
+ * content - content returned back in the response
+ * responseObject - deserialized object
+ * errors - deserialized error object
+ *
+ * @author dderose
+ *
+ */
+public class Response {
+
+ private Object responseObject;
+ private final int statusCode;
+ private final String content;
+ private final String intuit_tid;
+ private Errors errors = null;
+
+ public Response(final int statusCode, final String content, final String intuit_tid) {
+ this.content = content;
+ this.statusCode = statusCode;
+ this.intuit_tid = intuit_tid;
+ }
+
+ public Object getResponseObject() {
+ return responseObject;
+ }
+
+ public void setResponseObject(Object responseObject) {
+ this.responseObject = responseObject;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public String getIntuit_tid() {
+ return intuit_tid;
+ }
+
+ public Errors getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Errors errors) {
+ this.errors = errors;
+ }
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/BankAccountService.java b/payments-api/src/main/java/com/intuit/payment/services/BankAccountService.java
new file mode 100644
index 00000000..ca0f5a1d
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/BankAccountService.java
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services;
+
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+import com.intuit.payment.data.BankAccount;
+import com.intuit.payment.data.QueryResponse;
+import com.intuit.payment.data.Token;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.services.base.ServiceBase;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Provides operations for BankAccount API
+ *
+ * @author dderose
+ *
+ */
+public class BankAccountService extends ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ private RequestContext requestContext;
+
+ public BankAccountService(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Hiding the default constructor
+ */
+ protected BankAccountService() {
+ }
+
+ public RequestContext getRequestContext() {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Method to create BankAccount for a given customer
+ *
+ * @param bankAccount
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ public BankAccount create(BankAccount bankAccount, String customerId) throws BaseException {
+
+ logger.debug("Enter BankAccountService::create");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(bankAccount)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // retrieve response
+ BankAccount bankAccountResponse = (BankAccount) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, bankAccountResponse);
+ return bankAccountResponse;
+ }
+
+ /**
+ * Method to create a BankAccount for a given customer using Token value
+ *
+ * @param token
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ public BankAccount createFromToken(Token token, String customerId) throws BaseException {
+
+ logger.debug("Enter BankAccountService::createFromToken");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers")
+ + "{id}/bank-accounts/createFromToken".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(token)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // retrieve response
+ BankAccount bankAccountResponse = (BankAccount) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, bankAccountResponse);
+ return bankAccountResponse;
+ }
+
+ /**
+ * Method to delete a bankAccount
+ *
+ * @param customerId
+ * @param bankaccountId
+ * @return
+ * @throws BaseException
+ */
+ public BankAccount delete(String customerId, String bankaccountId) throws BaseException {
+
+ logger.debug("Enter BankAccountService::delete");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(bankaccountId)) {
+ logger.error("IllegalArgumentException {}", bankaccountId);
+ throw new IllegalArgumentException("bankaccountId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers")
+ + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", customerId.toString())
+ .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // For delete, there's not body returned back, hence initializing a
+ // dummy object to return other attributes
+ BankAccount bankAccountResponse = new BankAccount();
+
+ // set additional attributes
+ prepareResponse(request, response, bankAccountResponse);
+ return bankAccountResponse;
+ }
+
+ /**
+ * Method to retrieve a bankAccount based on a bankaccountId for a given
+ * customer
+ *
+ * @param customerId
+ * @param bankaccountId
+ * @return
+ * @throws BaseException
+ */
+ public BankAccount getBankAccount(String customerId, String bankaccountId) throws BaseException {
+
+ logger.debug("Enter BankAccountService::getBankAccount");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(bankaccountId)) {
+ logger.error("IllegalArgumentException {}", bankaccountId);
+ throw new IllegalArgumentException("bankaccountId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers")
+ + "{id}/bank-accounts/{bankaccount_id}".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", customerId.toString())
+ .replaceAll("\\{" + "bankaccount_id" + "\\}", bankaccountId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // retrieve response
+ BankAccount bankAccountResponse = (BankAccount) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, bankAccountResponse);
+ return bankAccountResponse;
+ }
+
+ /**
+ * Method to Get All BankAccounts for a given customer
+ *
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ @SuppressWarnings("unchecked")
+ public QueryResponse getAllBankAccounts(String customerId) throws BaseException {
+
+ logger.debug("Enter BankAccountService::getAllBankAccounts");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference> typeReference = new TypeReference>() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ List bankAccounts = (List) response.getResponseObject();
+ QueryResponse queryResponse = new QueryResponse.Builder().bankAccounts(bankAccounts).build();
+
+ // set additional attributes
+ prepareResponse(request, response, queryResponse);
+ return queryResponse;
+ }
+
+ /**
+ * Method to Get All BankAccounts for a given customer specifying the count of records to be returned
+ *
+ * @param customerId
+ * @param count
+ * @return
+ * @throws BaseException
+ */
+ @SuppressWarnings("unchecked")
+ public QueryResponse getAllBankAccounts(String customerId, int count) throws BaseException {
+
+ logger.debug("Enter BankAccountService::getAllBankAccounts");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/bank-accounts"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ if(count > 0 ) {
+ apiUrl = apiUrl + "?count="+ count;
+ }
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference> typeReference = new TypeReference>() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ List bankAccounts = (List) response.getResponseObject();
+ QueryResponse queryResponse = new QueryResponse.Builder().bankAccounts(bankAccounts).build();
+
+ // set additional attributes
+ prepareResponse(request, response, queryResponse);
+ return queryResponse;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/CardService.java b/payments-api/src/main/java/com/intuit/payment/services/CardService.java
new file mode 100644
index 00000000..6909651c
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/CardService.java
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services;
+
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+import com.intuit.payment.data.Card;
+import com.intuit.payment.data.QueryResponse;
+import com.intuit.payment.data.Token;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.services.base.ServiceBase;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Provides operations for Card API
+ *
+ * @author dderose
+ *
+ */
+public class CardService extends ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ private RequestContext requestContext;
+
+ public CardService(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Hiding the default constructor
+ */
+ protected CardService() {
+ }
+
+ public RequestContext getRequestContext() {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Method to create Card for a given customer
+ *
+ * @param card
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ public Card create(Card card, String customerId) throws BaseException {
+
+ logger.debug("Enter CardService::create");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(card)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Card cardResponse = (Card) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, cardResponse);
+ return cardResponse;
+ }
+
+ /**
+ * Method to create a Card for a given customer using Token value
+ *
+ * @param token
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ public Card createFromToken(Token token, String customerId) throws BaseException {
+
+ logger.debug("Enter CardService::createFromToken");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/createFromToken"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(token)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Card cardResponse = (Card) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, cardResponse);
+ return cardResponse;
+ }
+
+ /**
+ * Method to delete a card
+ *
+ * @param customerId
+ * @param cardId
+ * @return
+ * @throws BaseException
+ */
+ public Card delete(String customerId, String cardId) throws BaseException {
+
+ logger.debug("Enter CardService::delete");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(cardId)) {
+ logger.error("IllegalArgumentException {}", cardId);
+ throw new IllegalArgumentException("cardId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/{card_id}"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString())
+ .replaceAll("\\{" + "card_id" + "\\}", cardId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.DELETE, apiUrl).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // For delete, there's not body returned back, hence initializing a
+ // dummy object to return other attributes
+ Card cardResponse = new Card();
+
+ // set additional attributes
+ prepareResponse(request, response, cardResponse);
+ return cardResponse;
+ }
+
+ /**
+ * Method to retrieve a card based on a cardId for a given customer
+ *
+ * @param customerId
+ * @param cardId
+ * @return
+ * @throws BaseException
+ */
+ public Card getCard(String customerId, String cardId) throws BaseException {
+
+ logger.debug("Enter CardService::getCard");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(cardId)) {
+ logger.error("IllegalArgumentException {}", cardId);
+ throw new IllegalArgumentException("cardId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards/{card_id}"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString())
+ .replaceAll("\\{" + "card_id" + "\\}", cardId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Card cardResponse = (Card) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, cardResponse);
+ return cardResponse;
+ }
+
+ /**
+ * Method to Get All Cards for a given customer
+ *
+ * @param customerId
+ * @return
+ * @throws BaseException
+ */
+ @SuppressWarnings("unchecked")
+ public QueryResponse getAllCards(String customerId) throws BaseException {
+
+ logger.debug("Enter CardService::getAllCards");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference> typeReference = new TypeReference>() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ List cards = (List) response.getResponseObject();
+ QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build();
+
+ // set additional attributes
+ prepareResponse(request, response, queryResponse);
+ return queryResponse;
+ }
+
+ /**
+ * Method to Get All Cards for a given customer specifying the count of records to be returned
+ *
+ * @param customerId
+ * @param count
+ * @return
+ * @throws BaseException
+ */
+ @SuppressWarnings("unchecked")
+ public QueryResponse getAllCards(String customerId, int count) throws BaseException {
+
+ logger.debug("Enter CardService::getAllCards");
+
+ if (StringUtils.isBlank(customerId)) {
+ logger.error("IllegalArgumentException {}", customerId);
+ throw new IllegalArgumentException("customerId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl().replaceAll("payments", "customers") + "{id}/cards"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", customerId.toString());
+ if(count > 0 ) {
+ apiUrl = apiUrl + "?count="+ count;
+ }
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference> typeReference = new TypeReference>() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ List cards = (List) response.getResponseObject();
+ QueryResponse queryResponse = new QueryResponse.Builder().cards(cards).build();
+
+ // set additional attributes
+ prepareResponse(request, response, queryResponse);
+ return queryResponse;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/ChargeService.java b/payments-api/src/main/java/com/intuit/payment/services/ChargeService.java
new file mode 100644
index 00000000..75a873f3
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/ChargeService.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+import com.intuit.payment.data.Capture;
+import com.intuit.payment.data.Charge;
+import com.intuit.payment.data.Refund;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.services.base.ServiceBase;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Provides operations for Charge API
+ *
+ * @author dderose
+ *
+ */
+public class ChargeService extends ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ private RequestContext requestContext;
+
+ public ChargeService(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Hiding the default constructor
+ */
+ protected ChargeService() {
+ }
+
+ public RequestContext getRequestContext() {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Method to create Charge
+ *
+ * @param charge
+ * @return
+ * @throws BaseException
+ */
+ public Charge create(Charge charge) throws BaseException {
+
+ logger.debug("Enter ChargeService::create");
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "charges".replaceAll("\\{format\\}", "json");
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(charge)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Charge chargeResponse = (Charge) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, chargeResponse);
+ return chargeResponse;
+ }
+
+ /**
+ * Method to retrieve Charge
+ *
+ * @param chargeId
+ * @return
+ * @throws BaseException
+ */
+ public Charge retrieve(String chargeId) throws BaseException {
+
+ logger.debug("Enter ChargeService::retrieve");
+
+ if (StringUtils.isBlank(chargeId)) {
+ logger.error("IllegalArgumentException {}", chargeId);
+ throw new IllegalArgumentException("chargeId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "charges/{id}".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", chargeId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Charge chargeResponse = (Charge) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, chargeResponse);
+ return chargeResponse;
+ }
+
+ /**
+ * Method to capture Charge
+ *
+ * @param chargeId
+ * @param capture
+ * @return
+ * @throws BaseException
+ */
+ public Charge capture(String chargeId, Capture capture) throws BaseException {
+
+ logger.debug("Enter ChargeService::capture");
+
+ if (StringUtils.isBlank(chargeId)) {
+ logger.error("IllegalArgumentException {}", chargeId);
+ throw new IllegalArgumentException("chargeId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl()
+ + "charges/{id}/capture".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(capture)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Charge chargeResponse = (Charge) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, chargeResponse);
+ return chargeResponse;
+ }
+
+ /**
+ * Method to refund Charge
+ *
+ * @param chargeId
+ * @param refund
+ * @return
+ * @throws BaseException
+ */
+ public Refund refund(String chargeId, Refund refund) throws BaseException {
+
+ logger.debug("Enter ChargeService::refund");
+
+ if (StringUtils.isBlank(chargeId)) {
+ logger.error("IllegalArgumentException {}", chargeId);
+ throw new IllegalArgumentException("chargeId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl()
+ + "charges/{id}/refunds".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(refund)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Refund refundResponse = (Refund) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, refundResponse);
+ return refundResponse;
+ }
+
+ /**
+ * Method to retrieve Refund for Charge
+ *
+ * @param chargeId
+ * @param refundId
+ * @return
+ * @throws BaseException
+ */
+ public Refund getRefund(String chargeId, String refundId) throws BaseException {
+
+ logger.debug("Enter ChargeService::getRefund");
+
+ if (StringUtils.isBlank(chargeId)) {
+ logger.error("IllegalArgumentException {}", chargeId);
+ throw new IllegalArgumentException("chargeId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(refundId)) {
+ logger.error("IllegalArgumentException {}", refundId);
+ throw new IllegalArgumentException("refundId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "charges/{id}/refunds/{refund_id}"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", chargeId.toString())
+ .replaceAll("\\{" + "refund_id" + "\\}", refundId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Refund refundResponse = (Refund) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, refundResponse);
+ return refundResponse;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/ECheckService.java b/payments-api/src/main/java/com/intuit/payment/services/ECheckService.java
new file mode 100644
index 00000000..a333f0c0
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/ECheckService.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+import com.intuit.payment.data.ECheck;
+import com.intuit.payment.data.Refund;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.services.base.ServiceBase;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Provides operations for ECheck API
+ *
+ * @author dderose
+ *
+ */
+public class ECheckService extends ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ private RequestContext requestContext;
+
+ public ECheckService(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Hiding the default constructor
+ */
+ protected ECheckService() {
+
+ }
+
+ public RequestContext getRequestContext() {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Method to create ECheck
+ *
+ * @param eCheck
+ * @return
+ * @throws BaseException
+ */
+ public ECheck create(ECheck eCheck) throws BaseException {
+
+ logger.debug("Enter ECheckService::create");
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "echecks".replaceAll("\\{format\\}", "json");
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(eCheck)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ ECheck eCheckResponse = (ECheck) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, eCheckResponse);
+ return eCheckResponse;
+ }
+
+ /**
+ * Method to retrieve ECheck
+ *
+ * @param eCheckId
+ * @return
+ * @throws BaseException
+ */
+ public ECheck retrieve(String eCheckId) throws BaseException {
+
+ logger.debug("Enter ECheckService::retrieve");
+
+ if (StringUtils.isBlank(eCheckId)) {
+ logger.error("IllegalArgumentException {}", eCheckId);
+ throw new IllegalArgumentException("eCheckId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "echecks/{id}".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", eCheckId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ ECheck eCheckResponse = (ECheck) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, eCheckResponse);
+ return eCheckResponse;
+ }
+
+ /**
+ * Method to refund or void ECheck
+ *
+ * @param eCheckId
+ * @param refund
+ * @return
+ * @throws BaseException
+ */
+ public Refund refund(String eCheckId, Refund refund) throws BaseException {
+
+ logger.debug("Enter ECheckService::refund");
+
+ if (StringUtils.isBlank(eCheckId)) {
+ logger.error("IllegalArgumentException {}", eCheckId);
+ throw new IllegalArgumentException("eCheckId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "echecks/{id}/refunds".replaceAll("\\{format\\}", "json")
+ .replaceAll("\\{" + "id" + "\\}", eCheckId.toString());
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(refund)
+ .typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Refund refundResponse = (Refund) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, refundResponse);
+ return refundResponse;
+ }
+
+ /**
+ * Method to retrieve Refund for ECheck
+ *
+ * @param eCheckId
+ * @param refundId
+ * @return
+ * @throws BaseException
+ */
+ public Refund getRefund(String eCheckId, String refundId) throws BaseException {
+
+ logger.debug("Enter ECheckService::getRefund");
+
+ if (StringUtils.isBlank(eCheckId)) {
+ logger.error("IllegalArgumentException {}", eCheckId);
+ throw new IllegalArgumentException("eCheckId cannot be empty or null");
+ }
+
+ if (StringUtils.isBlank(refundId)) {
+ logger.error("IllegalArgumentException {}", refundId);
+ throw new IllegalArgumentException("refundId cannot be empty or null");
+ }
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "echecks/{id}/refunds/{refund_id}"
+ .replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}", eCheckId.toString())
+ .replaceAll("\\{" + "refund_id" + "\\}", refundId);
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
+ .context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+
+ // retrieve response
+ Refund refundResponse = (Refund) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, refundResponse);
+ return refundResponse;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/TokenService.java b/payments-api/src/main/java/com/intuit/payment/services/TokenService.java
new file mode 100644
index 00000000..411b2fc3
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/TokenService.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services;
+
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.config.RequestContext;
+import com.intuit.payment.data.Token;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.services.base.ServiceBase;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Provides operations for Token API
+ *
+ * @author dderose
+ *
+ */
+public class TokenService extends ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ private RequestContext requestContext;
+
+ public TokenService(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Hiding the default constructor
+ */
+ protected TokenService() {
+
+ }
+
+ public RequestContext getRequestContext() {
+ return requestContext;
+ }
+
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ /**
+ * Method to create BankAccount
+ *
+ * @param token
+ * @return
+ * @throws BaseException
+ */
+ public Token createToken(Token token) throws BaseException {
+
+ logger.debug("Enter TokenService::createToken");
+
+ // prepare API url
+ String apiUrl = requestContext.getBaseUrl() + "tokens";
+ logger.info("apiUrl - " + apiUrl);
+
+ // assign TypeReference for deserialization
+ TypeReference typeReference = new TypeReference() {
+ };
+
+ // prepare service request
+ Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).ignoreAuthHeader(true)
+ .requestObject(token).typeReference(typeReference).context(requestContext).build();
+
+ // make API call
+ Response response = sendRequest(request);
+ // retrieve response
+ Token tokenResponse = (Token) response.getResponseObject();
+
+ // set additional attributes
+ prepareResponse(request, response, tokenResponse);
+ return tokenResponse;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/services/base/ServiceBase.java b/payments-api/src/main/java/com/intuit/payment/services/base/ServiceBase.java
new file mode 100644
index 00000000..8ec740ec
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/services/base/ServiceBase.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.services.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpStatus;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.data.Entity;
+import com.intuit.payment.data.Error;
+import com.intuit.payment.data.Errors;
+import com.intuit.payment.exception.AuthorizationException;
+import com.intuit.payment.exception.BadRequestException;
+import com.intuit.payment.exception.BaseException;
+import com.intuit.payment.exception.SerializationException;
+import com.intuit.payment.exception.ServiceException;
+import com.intuit.payment.http.HttpRequestClient;
+import com.intuit.payment.http.MethodType;
+import com.intuit.payment.http.Request;
+import com.intuit.payment.http.Response;
+import com.intuit.payment.util.JsonUtil;
+import com.intuit.payment.util.LoggerImpl;
+
+/**
+ * Base service class that makes the HTTP call.
+ * - Serializes the request
+ * - Prepares HttpRequestClient and makes API call
+ * - Deserialize the response
+ * - Handle success/error scenarios
+ * - Returns the response back
+ *
+ * @author dderose
+ *
+ */
+public class ServiceBase {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+
+ /**
+ * @param serviceRequest
+ * @return
+ * @throws BaseException
+ */
+ public Response sendRequest(Request serviceRequest) throws BaseException {
+
+ logger.debug("Enter ServiceBase::sendRequest");
+
+ // serialize the request object to send POST data
+ if (serviceRequest.getMethod().equals(MethodType.POST)) {
+ String payload = JsonUtil.serialize(serviceRequest.getRequestObject());
+ serviceRequest.setPostJson(payload);
+ logger.debug("request payload" + payload);
+ }
+
+ //prepare httpclient request
+ HttpRequestClient client = new HttpRequestClient(serviceRequest.getContext().getProxyConfig());
+
+ //call API
+ Response serviceResponse = client.makeRequest(serviceRequest);
+
+ //handle null response
+ if (serviceResponse == null) {
+ logger.error("No response from Service: it is null");
+ throw new BaseException("Unexpected Error , service response object was null ");
+ }
+
+ int httpStatusCode = serviceResponse.getStatusCode();
+ logger.info("httpStatusCode::" + httpStatusCode);
+
+ // handle successful response - 200 to 299
+ if (httpStatusCode >= HttpStatus.SC_OK && httpStatusCode <= 299) {
+ logger.info("API call succeeded");
+
+ // response may not have an real payload in some cases example void requests
+ if (!serviceResponse.getContent().isEmpty() && serviceRequest.getTypeReference() != null) {
+ Object object = JsonUtil.deserialize(serviceResponse.getContent(), serviceRequest.getTypeReference());
+ serviceResponse.setResponseObject(object);
+ }
+ return serviceResponse;
+
+ } else {
+ // handle error scenarios - deserialize error object
+ Errors errors = null;
+ if (StringUtils.isNotBlank(serviceResponse.getContent())) {
+ try {
+ TypeReference typeReference = new TypeReference() {
+ };
+ errors = (Errors) JsonUtil.deserialize(serviceResponse.getContent(), typeReference);
+ serviceResponse.setErrors(errors);
+ } catch (SerializationException se) {
+ logger.debug("unable to deserialize to an error list", se);
+ }
+ }
+ /**
+ * if there is no error list at this time, that means we were
+ * unsuccessful in creating the errorlist from the response. So
+ * create one manually and set the httpstatus code and the payload
+ * back
+ **/
+ if (errors == null) {
+ errors = new Errors();
+ List errorList = new ArrayList();
+ Error error = new Error();
+ error.setCode("HttpStatusCode-" + httpStatusCode);
+ error.setDetail("ResponsePayload: " + serviceResponse.getContent());
+ errorList.add(error);
+ errors.setErrorList(errorList);
+ serviceResponse.setErrors(errors);
+ }
+
+ /**
+ * Prepare exeception classes based on http status codes
+ * 401- AuthorizationException
+ * 400 - 499 excluding 401 - BadRequestException
+ * 500 - 599 - ServiceException
+ * everything else - BaseException
+ **/
+ if (httpStatusCode == HttpStatus.SC_UNAUTHORIZED) {
+ logger.error("Authorization Error httpStatusCode {}", httpStatusCode);
+ AuthorizationException exception = new AuthorizationException(errors);
+ throw exception;
+ } else if (httpStatusCode >= HttpStatus.SC_BAD_REQUEST && httpStatusCode <= 499) {
+ logger.error("Bad Request Exception {}", httpStatusCode);
+ BadRequestException badRequestException = new BadRequestException(errors);
+ logger.debug("Client Side Error httpStatusCode {}", httpStatusCode);
+ throw badRequestException;
+ } else if (httpStatusCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR && httpStatusCode <= 599) {
+ logger.error("Service exception {}", httpStatusCode);
+ ServiceException serviceException = new ServiceException(errors);
+ throw serviceException;
+ } else { // catch all status code
+ logger.error("unexpected exception {}", httpStatusCode);
+ BaseException baseException = new BaseException(errors);
+ throw baseException;
+ }
+
+ }
+
+ }
+
+ /**
+ * Sets additional attributes to the entity
+ *
+ * @param request
+ * @param res
+ * @param entity
+ */
+ public void prepareResponse(Request request, Response response, Entity entity) {
+ entity.setIntuit_tid(response.getIntuit_tid());
+ entity.setRequestId(request.getContext().getRequestId());
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/util/JsonUtil.java b/payments-api/src/main/java/com/intuit/payment/util/JsonUtil.java
new file mode 100644
index 00000000..946ef3c6
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/util/JsonUtil.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.intuit.payment.exception.SerializationException;
+
+
+/**
+ * Class to serialize/deserialze data using jackson library
+ *
+ * @author dderose
+ *
+ */
+public class JsonUtil {
+
+ private static final Logger logger = LoggerImpl.getInstance();
+ public static ObjectMapper mapper;
+
+ public static final String TIMEZONE_UTC = "UTC";
+ public static final String DATETIMEFORMAT = "yyyy-MM-dd'T'HH:mm:ss";
+
+ static {
+ mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ DateFormat dateFormat = new SimpleDateFormat(DATETIMEFORMAT);
+ dateFormat.setTimeZone(TimeZone.getTimeZone(TIMEZONE_UTC));
+ mapper.setDateFormat(dateFormat);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ }
+
+ /**
+ * Serialize object to String
+ *
+ * @param obj
+ * @return
+ * @throws SerializationException
+ */
+ public static String serialize(Object obj) throws SerializationException {
+ try {
+ if (obj != null) {
+ return mapper.writeValueAsString(obj);
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ logger.error("SerializationException {}", e.getMessage());
+ throw new SerializationException(e.getMessage());
+ }
+ }
+
+ /**
+ * Deserialize String to object of TypeReference
+ *
+ * @param json
+ * @param typeReference
+ * @return
+ * @throws SerializationException
+ */
+ public static Object deserialize(String json, TypeReference> typeReference) throws SerializationException {
+ try {
+ logger.debug("Json string to deserialize {} ", json);
+ return mapper.readValue(json, typeReference);
+ } catch (IOException e) {
+ logger.error("SerializationException {}", e.getMessage());
+ SerializationException serializationException = new SerializationException(e);
+ throw serializationException;
+ }
+ }
+
+}
+
diff --git a/payments-api/src/main/java/com/intuit/payment/util/LoggerImpl.java b/payments-api/src/main/java/com/intuit/payment/util/LoggerImpl.java
new file mode 100644
index 00000000..1cd1991a
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/util/LoggerImpl.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Wrapper class for logger
+ *
+ * @author dderose
+ *
+ */
+public final class LoggerImpl {
+
+ private volatile Logger slf4jLogger;
+
+ private static Logger sInstance;
+
+ public static Logger getInstance() {
+ if (null == sInstance) {
+ sInstance = new LoggerImpl().getLogger();
+
+ }
+ return sInstance;
+ }
+
+ //Prevent instantiation
+ private LoggerImpl() {}
+
+ public Logger getLogger() {
+ if (null == slf4jLogger) {
+ synchronized (this) {
+ if (null == slf4jLogger) {
+ slf4jLogger = LoggerFactory.getLogger("com.intuit.payment");
+ }
+ }
+ }
+ return slf4jLogger;
+ }
+
+}
diff --git a/payments-api/src/main/java/com/intuit/payment/util/PropertiesConfig.java b/payments-api/src/main/java/com/intuit/payment/util/PropertiesConfig.java
new file mode 100644
index 00000000..1eefd8f7
--- /dev/null
+++ b/payments-api/src/main/java/com/intuit/payment/util/PropertiesConfig.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+
+/**
+ * Class to read the attributes from properties file payment.properties
+ *
+ * @author dderose
+ *
+ */
+public class PropertiesConfig {
+
+ protected Logger logger = LoggerImpl.getInstance();
+ private static Properties prop = new Properties();
+ private static PropertiesConfig config = null;
+
+ private static final String PROP_FILE_NAME = "payment.properties";
+
+ //Prevent instantiation
+ private PropertiesConfig() {
+
+ }
+
+ public static synchronized PropertiesConfig getInstance() {
+
+ if (config == null) {
+ config = new PropertiesConfig();
+ config.readProperties();
+ }
+ return config;
+ }
+
+ /**
+ * Method to read propeties file and store the data
+ *
+ */
+ private void readProperties() {
+
+ InputStream input = null;
+ try {
+
+ input = getClass().getClassLoader().getResourceAsStream(PROP_FILE_NAME);
+ if(input==null){
+ logger.info("Unnable to find " + PROP_FILE_NAME);
+ return;
+ }
+ prop.load(input);
+
+ } catch (Exception e) {
+ logger.info("exception in PropertiesConfig readProperties");
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
+ logger.info("exception in PropertiesConfig readProperties finally");
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Method to retrive data use property key
+ * @param key
+ * @return
+ */
+ public String getProperty(String key) {
+ return prop.getProperty(key);
+ }
+
+}
diff --git a/payments-api/src/main/resources/payment.properties b/payments-api/src/main/resources/payment.properties
new file mode 100644
index 00000000..315f0d81
--- /dev/null
+++ b/payments-api/src/main/resources/payment.properties
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2019 Intuit
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+#Payments URL
+PAYMENTS_BASE_URL_PRODUCTION=https://api.intuit.com/quickbooks/v4/payments/
+PAYMENTS_BASE_URL_SANDBOX=https://sandbox.api.intuit.com/quickbooks/v4/payments/
+
+#Version
+version=5.0.0
+
+#TLS Version
+TLS_VERSION=TLSv1.2
\ No newline at end of file
diff --git a/payments-api/src/test/java/com/intuit/payment/exception/ExceptionTest.java b/payments-api/src/test/java/com/intuit/payment/exception/ExceptionTest.java
new file mode 100755
index 00000000..b4c06f4c
--- /dev/null
+++ b/payments-api/src/test/java/com/intuit/payment/exception/ExceptionTest.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.exception;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.intuit.payment.data.Error;
+import com.intuit.payment.data.Errors;
+
+
+/**
+ * @author dderose
+ *
+ */
+public class ExceptionTest {
+
+ @Test
+ public void baseExceptionTest() {
+ try {
+ exceptionTest(BaseException.class, true);
+ } catch (Exception ex) {
+ Assert.assertTrue(false, "Exception test failed : " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void authorizationExceptionExceptionTest() {
+ try {
+ exceptionTest(AuthorizationException.class, true);
+ } catch (Exception ex) {
+ Assert.assertTrue(false, "Exception test failed : " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void badRequestExceptionTest() {
+ try {
+ exceptionTest(BadRequestException.class, true);
+ } catch (Exception ex) {
+ Assert.assertTrue(false, "Exception test failed : " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void serializationExceptionTest() {
+ try {
+ exceptionTest(SerializationException.class, false);
+ } catch (Exception ex) {
+ Assert.assertTrue(false, "Exception test failed : " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void serviceExceptionTest() {
+ try {
+ exceptionTest(ServiceException.class, true);
+ } catch (Exception ex) {
+ Assert.assertTrue(false, "Exception test failed : " + ex.getMessage());
+ }
+ }
+
+ public void exceptionTest(Class exceptionType, boolean isListSupported)
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+ IllegalAccessException, InvocationTargetException {
+
+ String errorMessage = "Test error message " + exceptionType.getName();
+ String errorDetail = "Test error detail " + exceptionType.getName();
+ String errorCode = "Test error Code " + exceptionType.getName();
+ List errorList = null;
+ Class> classTemplate = exceptionType;
+ BaseException exceptionObject = null;
+
+ // Testing the constructor with only message parameter
+ Constructor> constructor = classTemplate.getConstructor(new Class[] { String.class });
+ exceptionObject = (BaseException) constructor.newInstance(errorMessage);
+ try {
+ throw exceptionObject;
+ } catch (BaseException ex) {
+ Assert.assertEquals(ex.getMessage(), errorMessage, "Exception message is not proper");
+ }
+
+ // Testing the constructor with throwable parameter
+ String innerExceptionMessage = "Test InnerException";
+ Exception innerException = new Exception(innerExceptionMessage);
+ constructor = classTemplate.getConstructor(new Class[] { Throwable.class });
+ exceptionObject = (BaseException) constructor.newInstance(innerException);
+ try {
+ throw exceptionObject;
+ } catch (BaseException ex) {
+ Assert.assertEquals(innerExceptionMessage, ex.getThrowable().getMessage(),
+ "The inner exception is not set properly");
+ }
+
+ // Testing the constructor with throwable and message parameters
+ constructor = classTemplate.getConstructor(new Class[] { String.class, Throwable.class });
+ exceptionObject = (BaseException) constructor.newInstance(errorMessage, innerException);
+ try {
+ throw exceptionObject;
+ } catch (BaseException ex) {
+ Assert.assertEquals(innerExceptionMessage, ex.getThrowable().getMessage(),
+ "The inner exception is not set properly");
+ Assert.assertEquals(ex.getMessage(), errorMessage, "Exception message is not proper");
+ }
+
+ // Testing the constructor with List parameter
+ if (isListSupported) {
+ errorList = getDummyErrorList(errorCode, errorDetail, errorMessage);
+ Errors errors = new Errors.Builder(errorList).build();
+ constructor = classTemplate.getConstructor(new Class[] { Errors.class });
+ exceptionObject = (BaseException) constructor.newInstance(errors);
+ try {
+ throw exceptionObject;
+ } catch (BaseException ex) {
+ boolean isListFormatProper = checkMessageFormatForList(errorCode, errorDetail, errorMessage, ex.getMessage());
+ Assert.assertTrue(isListFormatProper, "Exception message is not proper");
+ }
+ }
+ }
+
+ private List getDummyErrorList(String errorCode, String errorDetail, String errorMessage) {
+ ArrayList errorList = new ArrayList();
+ Error error = new Error();
+
+ error.setCode(errorCode);
+ error.setDetail(errorDetail);
+ error.setMessage(errorMessage);
+
+ errorList.add(error);
+ return errorList;
+
+ }
+
+ private boolean checkMessageFormatForList(String errorCode, String errorDetail, String errorMessage, String actualMessageRecieved) {
+
+ String message = "ERROR CODE:" + errorCode + ", ERROR MESSAGE:" + errorMessage + ", ERROR DETAIL:" + errorDetail + ", ERROR INFO LINK:null, ERROR MORE INFO:null, ERROR TYPE:null";
+ actualMessageRecieved = actualMessageRecieved.trim();
+ if (message.equals(actualMessageRecieved)) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+
+}
diff --git a/payments-api/src/test/java/com/intuit/payment/util/JsonUtilTest.java b/payments-api/src/test/java/com/intuit/payment/util/JsonUtilTest.java
new file mode 100755
index 00000000..63147388
--- /dev/null
+++ b/payments-api/src/test/java/com/intuit/payment/util/JsonUtilTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.intuit.payment.data.Card;
+import com.intuit.payment.exception.SerializationException;
+
+/**
+ * @author dderose
+ *
+ */
+public class JsonUtilTest {
+
+
+ @Test
+ public void testSerialize() throws SerializationException{
+ Card card = new Card.Builder().number("12345").build();
+ String cardStr = JsonUtil.serialize(card);
+ Assert.assertNotNull(cardStr);
+ String result = "{\n \"number\" : \"12345\"\n}";
+ Assert.assertEquals(cardStr, result);
+ }
+
+ @Test
+ public void testDeserialize() throws SerializationException {
+ String cardStr = "{\"number\":\"12345\"}";
+ Card card = (Card) JsonUtil.deserialize(cardStr, new TypeReference() {} );
+ Assert.assertEquals(card.getNumber(), "12345");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDeserializeList() throws SerializationException {
+ String cardList = "[{\"number\":\"12345\"}]";
+ List cards = (List) JsonUtil.deserialize(cardList, new TypeReference>() {} );
+ Assert.assertEquals(cards.size(), 1);
+ Assert.assertEquals(cards.get(0).getNumber(), "12345");
+ }
+
+
+}
diff --git a/payments-api/src/test/java/com/intuit/payment/util/LoggerTest.java b/payments-api/src/test/java/com/intuit/payment/util/LoggerTest.java
new file mode 100755
index 00000000..37583130
--- /dev/null
+++ b/payments-api/src/test/java/com/intuit/payment/util/LoggerTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author dderose
+ *
+ */
+public class LoggerTest {
+
+ private org.slf4j.Logger logger;
+ @BeforeClass
+ public void init(){
+ logger = LoggerImpl.getInstance();
+ }
+
+ @Test
+ public void testDebug(){
+ logger.debug("called Debug");
+ logger.debug("called debug with String param : {}", "message");
+ logger.debug("called debug with Object param : {} {}", new Object[] { "message1", "message2"});
+ }
+
+ @Test
+ public void testerror(){
+ logger.error("called Error");
+ logger.debug("called Error with String param : {}", "message");
+ logger.debug("called Error with Object param : {} {}", new Object[] { "message1", "message2"});
+ }
+
+ @Test
+ public void testInfo(){
+ logger.info("called info");
+ logger.debug("called info with String param : {}", "message");
+ logger.debug("called info with Object param : {} {}", new Object[] { "message1", "message2"});
+ }
+
+ @Test
+ public void testwarn(){
+ logger.warn("called warn");
+ logger.debug("called warn with String param : {}", "message");
+ logger.debug("called warn with Object param : {} {}", new Object[] { "message1", "message2"});
+ }
+
+ @Test
+ public void testTrace(){
+ logger.trace("called trace");
+ logger.debug("called trace with String param : {}", "message");
+ logger.debug("called trace with Object param : {} {}", new Object[] { "message1", "message2"});
+ }
+}
diff --git a/payments-api/src/test/java/com/intuit/payment/util/PropertyHelperTest.java b/payments-api/src/test/java/com/intuit/payment/util/PropertyHelperTest.java
new file mode 100755
index 00000000..fb5c14c0
--- /dev/null
+++ b/payments-api/src/test/java/com/intuit/payment/util/PropertyHelperTest.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Intuit
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.intuit.payment.util;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * @author dderose
+ *
+ */
+public class PropertyHelperTest {
+
+ @Test
+ public void testPropertyHelper() {
+ PropertiesConfig propertyHelper = PropertiesConfig.getInstance();
+ Assert.assertNotNull(propertyHelper);
+ }
+
+ @Test
+ public void testPropertyVersion() {
+ PropertiesConfig propertyHelper = PropertiesConfig.getInstance();
+ String version = propertyHelper.getProperty("version");
+ Assert.assertNotNull(version);
+ }
+
+ @Test
+ public void testPropertyTLSVersion() {
+ PropertiesConfig propertyHelper = PropertiesConfig.getInstance();
+ String tlsVersion = propertyHelper.getProperty("TLS_VERSION");
+ Assert.assertNotNull(tlsVersion);
+ Assert.assertEquals("TLSv1.2", tlsVersion);
+ }
+
+ @Test
+ public void testPropertyProdBaseUrl() {
+ PropertiesConfig propertyHelper = PropertiesConfig.getInstance();
+ String baseUrl = propertyHelper.getProperty("PAYMENTS_BASE_URL_PRODUCTION");
+ Assert.assertNotNull(baseUrl);
+ Assert.assertEquals("https://api.intuit.com/quickbooks/v4/payments/", baseUrl);
+ }
+
+ @Test
+ public void testPropertySandboxBaseUrl() {
+ PropertiesConfig propertyHelper = PropertiesConfig.getInstance();
+ String baseUrl = propertyHelper.getProperty("PAYMENTS_BASE_URL_SANDBOX");
+ Assert.assertNotNull(baseUrl);
+ Assert.assertEquals("https://sandbox.api.intuit.com/quickbooks/v4/payments/", baseUrl);
+ }
+}
diff --git a/payments-api/src/test/resources/payment.properties b/payments-api/src/test/resources/payment.properties
new file mode 100644
index 00000000..315f0d81
--- /dev/null
+++ b/payments-api/src/test/resources/payment.properties
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2019 Intuit
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###############################################################################
+#Payments URL
+PAYMENTS_BASE_URL_PRODUCTION=https://api.intuit.com/quickbooks/v4/payments/
+PAYMENTS_BASE_URL_SANDBOX=https://sandbox.api.intuit.com/quickbooks/v4/payments/
+
+#Version
+version=5.0.0
+
+#TLS Version
+TLS_VERSION=TLSv1.2
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d2d198b9..d9309909 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,17 +5,18 @@
com.intuit.quickbooks-online
ipp-v3-java-devkit-pom
- 4.1.1
+ 5.0.0
pom
- QuickBooks V3 Java DevKit
+ IPP V3 Java DevKit
https://github.com/intuit/QuickBooks-V3-Java-SDK
- QuickBooks Java V3 DevKit Parent project for development and test projects
+ IPP Java V3 DevKit Parent project for development and test projects
ipp-v3-java-data
ipp-v3-java-devkit
ipp-java-qbapihelper
oauth2-platform-api
+ payments-api
@@ -27,11 +28,6 @@
${java.home}/../bin/javadoc
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-runtime
- 1.11.1
-
org.slf4j
slf4j-api
@@ -47,33 +43,12 @@
httpcore
4.4.6
-
- oauth.signpost
- signpost-core
- 1.2.1.1
-
-
- oauth.signpost
- signpost-commonshttp4
- 1.2
-
-
- org.jmockit
- jmockit
- 1.16
- test
-
org.testng
testng
6.11
test
-
- commons-logging
- commons-logging
- 1.1.1
-
org.slf4j
slf4j-log4j12
@@ -86,93 +61,9 @@
1.2.17
test
-
- commons-configuration
- commons-configuration
- 1.6
-
-
- com.google.code.gson
- gson
- 2.8.1
-
-
- commons-io
- commons-io
- 2.5
-
-
- junit
- junit
- 4.12
- test
-
-
- cglib
- cglib-nodep
- 2.2.2
-
-
- net.sf.kxml
- kxml2
- 2.2.2
-
-
- com.sun.mail
- javax.mail
- 1.6.1
-
-
- javax.servlet
- servlet-api
- 2.4
- provided
-
-
- javax.xml.bind
- jaxb-api
- 2.2.12
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.2.11
-
-
- com.sun.xml.bind
- jaxb-core
- 2.2.11
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- 2.9.6
-
-
- com.fasterxml.jackson.core
- jackson-core
- 2.9.6
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.9.6
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
- 2.9.6
-
-
- com.fasterxml.jackson.module
- jackson-module-jaxb-annotations
- 2.9.6
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-joda
- 2.9.6
-
+
+
+