diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..d6559a1
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+globalpayments
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..681f41a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a5f05cd
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..d5d35ec
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..9494940
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,29 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.6.1'
+
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/globalpayments-sdk/.gitignore b/globalpayments-sdk/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/globalpayments-sdk/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/globalpayments-sdk/build.gradle b/globalpayments-sdk/build.gradle
new file mode 100644
index 0000000..31b27d8
--- /dev/null
+++ b/globalpayments-sdk/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.3"
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles 'consumer-rules.pro'
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ debuggable true
+ }
+ }
+ testOptions {
+ unitTests.returnDefaultValues = true
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'net.danlew:android.joda:2.10.6.1'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+}
diff --git a/globalpayments-sdk/consumer-rules.pro b/globalpayments-sdk/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/globalpayments-sdk/proguard-rules.pro b/globalpayments-sdk/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/globalpayments-sdk/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/globalpayments-sdk/src/androidTest/java/com/global/api/ExampleInstrumentedTest.java b/globalpayments-sdk/src/androidTest/java/com/global/api/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..7888522
--- /dev/null
+++ b/globalpayments-sdk/src/androidTest/java/com/global/api/ExampleInstrumentedTest.java
@@ -0,0 +1,27 @@
+package com.global.api;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ assertEquals("com.global.api.test", appContext.getPackageName());
+ }
+}
diff --git a/globalpayments-sdk/src/main/AndroidManifest.xml b/globalpayments-sdk/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..0a9e0aa
--- /dev/null
+++ b/globalpayments-sdk/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
diff --git a/globalpayments-sdk/src/main/java/com/global/api/ConfiguredServices.java b/globalpayments-sdk/src/main/java/com/global/api/ConfiguredServices.java
new file mode 100644
index 0000000..56fcb6c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/ConfiguredServices.java
@@ -0,0 +1,26 @@
+package com.global.api;
+
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+import com.global.api.terminals.abstractions.IDisposable;
+
+public class ConfiguredServices implements IDisposable {
+ private IDeviceInterface deviceInterface;
+ private DeviceController deviceController;
+
+ IDeviceInterface getDeviceInterface() {
+ return deviceInterface;
+ }
+ DeviceController getDeviceController() {
+ return deviceController;
+ }
+ public void setDeviceController(DeviceController deviceController) throws ConfigurationException {
+ this.deviceController = deviceController;
+ deviceInterface = deviceController.configureInterface();
+ }
+
+ public void dispose() {
+ deviceController.dispose();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/ServicesConfig.java b/globalpayments-sdk/src/main/java/com/global/api/ServicesConfig.java
new file mode 100644
index 0000000..64117d2
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/ServicesConfig.java
@@ -0,0 +1,26 @@
+package com.global.api;
+
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.ConnectionConfig;
+
+public class ServicesConfig {
+ private ConnectionConfig deviceConnectionConfig;
+
+ public ConnectionConfig getDeviceConnectionConfig() {
+ return deviceConnectionConfig;
+ }
+
+ public void setDeviceConnectionConfig(ConnectionConfig deviceConnectionConfig) {
+ this.deviceConnectionConfig = deviceConnectionConfig;
+ }
+
+ public void setTimeout(int timeout) {
+ if (deviceConnectionConfig != null)
+ deviceConnectionConfig.setTimeout(timeout);
+ }
+
+ protected void validate() throws ConfigurationException {
+ if (deviceConnectionConfig != null)
+ deviceConnectionConfig.validate();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/ServicesContainer.java b/globalpayments-sdk/src/main/java/com/global/api/ServicesContainer.java
new file mode 100644
index 0000000..330ca13
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/ServicesContainer.java
@@ -0,0 +1,89 @@
+package com.global.api;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.serviceConfigs.Configuration;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+import com.global.api.terminals.abstractions.IDisposable;
+
+import java.util.HashMap;
+
+public class ServicesContainer implements IDisposable {
+ private HashMap configurations;
+ private static ServicesContainer instance;
+
+ public IDeviceInterface getDeviceInterface(String configName) throws ApiException {
+ if (configurations.containsKey(configName))
+ return configurations.get(configName).getDeviceInterface();
+ throw new ApiException("The specified configuration has not been configured for terminal interaction.");
+ }
+
+ public DeviceController getDeviceController(String configName) throws ApiException {
+ if (configurations.containsKey(configName))
+ return configurations.get(configName).getDeviceController();
+ throw new ApiException("The specified configuration has not been configured for terminal interaction.");
+ }
+
+ public static ServicesContainer getInstance() {
+ if (instance == null)
+ instance = new ServicesContainer();
+ return instance;
+ }
+
+ public static void configure(ServicesConfig config) throws ConfigurationException {
+ configure(config, "default");
+ }
+
+ public static void configure(ServicesConfig config, String configName) throws ConfigurationException {
+ config.validate();
+
+ // configure devices
+ configureService(config.getDeviceConnectionConfig(), configName);
+
+ ConfiguredServices cs = new ConfiguredServices();
+
+ // configure devices
+ if (config.getDeviceConnectionConfig() != null) {
+
+ }
+ }
+
+ public static void configureService(T config) throws ConfigurationException {
+ configureService(config, "default");
+ }
+
+ public static void configureService(T config, String configName) throws ConfigurationException {
+ if (config == null)
+ return;
+
+ if (!config.isValidated())
+ config.validate();
+
+ ConfiguredServices cs = getInstance().getConfiguration(configName);
+ config.configureContainer(cs);
+
+ getInstance().addConfiguration(configName, cs);
+ }
+
+ private ServicesContainer() {
+ configurations = new HashMap();
+ }
+
+ private ConfiguredServices getConfiguration(String configName) {
+ if (configurations.containsKey(configName))
+ return configurations.get(configName);
+ return new ConfiguredServices();
+ }
+
+ private void addConfiguration(String configName, ConfiguredServices cs) {
+ if (configurations.containsKey(configName))
+ configurations.remove(configName);
+ configurations.put(configName, cs);
+ }
+
+ public void dispose() {
+ for (ConfiguredServices cs : configurations.values())
+ cs.dispose();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/BaseBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/builders/BaseBuilder.java
new file mode 100644
index 0000000..ced9696
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/BaseBuilder.java
@@ -0,0 +1,30 @@
+package com.global.api.builders;
+
+import com.global.api.builders.validations.Validations;
+import com.global.api.entities.exceptions.ApiException;
+
+public abstract class BaseBuilder {
+ protected Validations validations;
+
+ public Validations getValidations() {
+ return validations;
+ }
+ public void setValidations(Validations validations) {
+ this.validations = validations;
+ }
+
+ public BaseBuilder() {
+ validations = new Validations();
+ setupValidations();
+ }
+
+ public TResult execute() throws ApiException {
+ return execute("default");
+ }
+ public TResult execute(String configName) throws ApiException {
+ validations.validate(this);
+ return null;
+ }
+
+ public abstract void setupValidations();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/ReportBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/builders/ReportBuilder.java
new file mode 100644
index 0000000..1766141
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/ReportBuilder.java
@@ -0,0 +1,36 @@
+package com.global.api.builders;
+
+import com.global.api.entities.enums.ReportType;
+import com.global.api.entities.enums.TimeZoneConversion;
+
+public abstract class ReportBuilder extends BaseBuilder {
+ private ReportType reportType;
+ private TimeZoneConversion timeZoneConversion;
+ private Class clazz;
+
+ public ReportType getReportType() {
+ return reportType;
+ }
+ public void setReportType(ReportType reportType) {
+ this.reportType = reportType;
+ }
+ public TimeZoneConversion getTimeZoneConversion() {
+ return timeZoneConversion;
+ }
+ public void setTimeZoneConversion(TimeZoneConversion timeZoneConversion) {
+ this.timeZoneConversion = timeZoneConversion;
+ }
+
+ public ReportBuilder(ReportType type, Class clazz) {
+ super();
+ this.reportType = type;
+ this.clazz = clazz;
+ }
+
+// public TResult execute(String configName) throws ApiException {
+// super.execute(configName);
+//
+// IPaymentGateway client = ServicesContainer.getInstance().getGateway(configName);
+// return client.processReport(this, clazz);
+// }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionBuilder.java
new file mode 100644
index 0000000..41184e0
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionBuilder.java
@@ -0,0 +1,65 @@
+package com.global.api.builders;
+
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.paymentMethods.IPaymentMethod;
+
+public abstract class TransactionBuilder extends BaseBuilder {
+ protected boolean forceGatewayTimeout;
+ protected TransactionType transactionType;
+ protected IPaymentMethod paymentMethod;
+
+ // network fields
+ protected int batchNumber;
+ protected String companyId;
+ protected int sequenceNumber;
+ protected int systemTraceAuditNumber;
+ protected String uniqueDeviceId;
+
+ public TransactionType getTransactionType() {
+ return transactionType;
+ }
+
+ public void setTransactionType(TransactionType transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public IPaymentMethod getPaymentMethod() {
+ return paymentMethod;
+ }
+
+ public void setPaymentMethod(IPaymentMethod paymentMethod) {
+ this.paymentMethod = paymentMethod;
+ }
+
+ public boolean isForceGatewayTimeout() {
+ return forceGatewayTimeout;
+ }
+
+ // network fields
+ public int getBatchNumber() { return batchNumber; }
+
+ public String getCompanyId() {
+ return companyId;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public int getSystemTraceAuditNumber() {
+ return systemTraceAuditNumber;
+ }
+
+ public String getUniqueDeviceId() {
+ return uniqueDeviceId;
+ }
+
+ public TransactionBuilder(TransactionType type) {
+ this(type, null);
+ }
+ public TransactionBuilder(TransactionType type, IPaymentMethod paymentMethod){
+ super();
+ this.transactionType = type;
+ this.paymentMethod = paymentMethod;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionReportBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionReportBuilder.java
new file mode 100644
index 0000000..e61286e
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/TransactionReportBuilder.java
@@ -0,0 +1,83 @@
+package com.global.api.builders;
+
+import com.global.api.entities.enums.ReportType;
+import com.global.api.entities.enums.TimeZoneConversion;
+import com.global.api.entities.reporting.SearchCriteria;
+import com.global.api.entities.reporting.SearchCriteriaBuilder;
+
+import java.util.Date;
+
+public class TransactionReportBuilder extends ReportBuilder {
+ private String deviceId;
+ private Date endDate;
+ private Date startDate;
+ private String transactionId;
+ private SearchCriteriaBuilder _searchBuilder;
+
+ public String getDeviceId() {
+ return getSearchBuilder().getUniqueDeviceId();
+ }
+
+ public Date getEndDate() {
+ return getSearchBuilder().getEndDate();
+ }
+
+ public Date getStartDate() {
+ return getSearchBuilder().getStartDate();
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public TransactionReportBuilder withDeviceId(String value) {
+ this.deviceId = value;
+ return this;
+ }
+
+ public TransactionReportBuilder withEndDate(Date value) {
+ this.endDate = value;
+ return this;
+ }
+
+ public TransactionReportBuilder withStartDate(Date value) {
+ this.startDate = value;
+ return this;
+ }
+
+ public TransactionReportBuilder withTransactionId(String value) {
+ this.transactionId = value;
+ return this;
+ }
+
+ public TransactionReportBuilder withTimeZoneConversion(TimeZoneConversion value) {
+ setTimeZoneConversion(value);
+ return this;
+ }
+
+ public TransactionReportBuilder(ReportType type, Class clazz) {
+ super(type, clazz);
+ }
+
+ public SearchCriteriaBuilder getSearchBuilder() {
+ if (_searchBuilder == null) {
+ _searchBuilder = new SearchCriteriaBuilder(this);
+ }
+ return _searchBuilder;
+ }
+
+ public SearchCriteriaBuilder where(SearchCriteria criteria, T value) {
+ return getSearchBuilder().and(criteria, value);
+ }
+
+ public void setupValidations() {
+ this.validations.of(ReportType.TransactionDetail)
+ .check("transactionId").isNotNull();
+
+ this.validations.of(ReportType.Activity).check("transactionId").isNull();
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/validations/MyCallable.java b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/MyCallable.java
new file mode 100644
index 0000000..2be63ee
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/MyCallable.java
@@ -0,0 +1,12 @@
+package com.global.api.builders.validations;
+
+import java.util.concurrent.Callable;
+
+class MyCallable implements Callable {
+ public Boolean call() throws Exception {
+ return call(null);
+ }
+ public Boolean call(Object builder) throws Exception {
+ return true;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationClause.java b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationClause.java
new file mode 100644
index 0000000..a773cf9
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationClause.java
@@ -0,0 +1,188 @@
+package com.global.api.builders.validations;
+
+import java.lang.reflect.Field;
+
+public class ValidationClause {
+ private Validations parent;
+ private ValidationTarget target;
+ private String propertyName;
+ private MyCallable callback;
+ private String message;
+ private boolean precondition;
+
+ public MyCallable getCallback() {
+ return callback;
+ }
+ public String getMessage() {
+ return message;
+ }
+
+ public ValidationClause(Validations parent, ValidationTarget target, String propertyName) {
+ this(parent, target, propertyName, false);
+ }
+ public ValidationClause(Validations parent, ValidationTarget target, String propertyName,
+ boolean precondition) {
+ this.parent = parent;
+ this.target = target;
+ this.propertyName = propertyName;
+ this.precondition = precondition;
+ }
+
+ public ValidationTarget isNull() {
+ return isNull(null);
+ }
+ public ValidationTarget isNull(String message){
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return value == null;
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s cannot be null for this " +
+ "transaction type.", propertyName);
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ public ValidationTarget isNotNull() {
+ return isNotNull(null);
+ }
+ public ValidationTarget isNotNull(String message){
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return value != null;
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s cannot be null for this " +
+ "transaction type.", propertyName);
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ public ValidationTarget isClass(Class clazz) {
+ return isClass(clazz, null);
+ }
+ public ValidationTarget isClass(Class clazz, String message) {
+ final Class checkClass = clazz;
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return value.getClass() == checkClass;
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s must be an instance of " +
+ "the %s class.", propertyName, clazz.getName());
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ public ValidationTarget isInstanceOf(Class clazz) {
+ return isInstanceOf(clazz, null);
+ }
+ public ValidationTarget isInstanceOf(Class clazz, String message) {
+ final Class checkClass = clazz;
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return checkClass.isAssignableFrom(value.getClass());
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s must be an instance of " +
+ "the %s class.", propertyName, clazz.getName());
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ public ValidationTarget isEqualTo(final Object expected) {
+ return isEqualTo(expected,
+ null);
+ }
+ public ValidationTarget isEqualTo(final Object expected, String message) {
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return value.equals(expected);
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s was not the expected " +
+ "value %s", propertyName, expected.toString());
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ public ValidationTarget isNotEqual(final Object expected) {
+ return isNotEqual(expected,
+ null);
+ }
+ public ValidationTarget isNotEqual(final Object expected, String message) {
+ callback = new MyCallable() {
+ public Boolean call(Object builder) throws Exception {
+ try {
+ Field f = getField(builder.getClass(), propertyName);
+ Object value = f.get(builder);
+ return !value.equals(expected);
+ }
+ catch(NoSuchFieldException exc) {
+ return false;
+ }
+ }
+ };
+ this.message = (message != null) ? message : String.format("%s cannot be the " +
+ "value %s.", propertyName, expected.toString());
+ if(precondition)
+ return target;
+ return parent.of(target.getType()).with(target.getConstraint());
+ }
+
+ private Field getField(Class clazz, String fieldName) throws NoSuchFieldException {
+ try{
+ Field f = clazz.getDeclaredField(fieldName);
+ f.setAccessible(true);
+ return f;
+ }
+ catch(NoSuchFieldException e) {
+ Class superClass = clazz.getSuperclass();
+ if(superClass == null)
+ throw e;
+ else {
+ return getField(superClass, fieldName);
+ }
+ }
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationTarget.java b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationTarget.java
new file mode 100644
index 0000000..14f108d
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/ValidationTarget.java
@@ -0,0 +1,45 @@
+package com.global.api.builders.validations;
+
+import com.global.api.entities.enums.IFlag;
+
+public class ValidationTarget {
+ private Validations parent;
+ private ValidationClause precondition;
+ private ValidationClause clause;
+
+ private Validations.ValidationKey type;
+ private IFlag constraint;
+
+ public Validations.ValidationKey getType() {
+ return type;
+ }
+ public IFlag getConstraint() {
+ return constraint;
+ }
+ public ValidationClause getClause() {
+ return clause;
+ }
+ public ValidationClause getPrecondition() {
+ return precondition;
+ }
+
+ public ValidationTarget(Validations parent, Validations.ValidationKey type) {
+ this.parent = parent;
+ this.type = type;
+ }
+
+ public ValidationTarget with(IFlag constraint) {
+ this.constraint = constraint;
+ return this;
+ }
+
+ public ValidationClause check(String propertyName) {
+ clause = new ValidationClause(parent, this, propertyName);
+ return clause;
+ }
+
+ public ValidationClause when(String propertyName) {
+ precondition = new ValidationClause(parent, this, propertyName, true);
+ return precondition;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/builders/validations/Validations.java b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/Validations.java
new file mode 100644
index 0000000..7a10f7e
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/builders/validations/Validations.java
@@ -0,0 +1,146 @@
+package com.global.api.builders.validations;
+
+import com.global.api.builders.BaseBuilder;
+import com.global.api.builders.TransactionBuilder;
+import com.global.api.entities.enums.IFlag;
+import com.global.api.entities.exceptions.BuilderException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+public class Validations {
+ class ValidationKey {
+ private Class> type;
+ private long value;
+
+ public Type getType() {
+ return type;
+ }
+ public long getValue() {
+ return value;
+ }
+
+ ValidationKey(Class type, long value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ Set> getSet() {
+ try {
+ Method method = type.getMethod("getSet", long.class);
+ return (Set>)method.invoke(this.type, this.value);
+ }
+ catch(Exception exc) { return null; }
+ }
+ }
+
+ private HashMap> rules;
+
+ public Validations() {
+ rules = new HashMap>();
+ }
+
+ public ValidationTarget of(Set types) {
+ Class clazz = types.iterator().next().getClass();
+ return of(new ValidationKey(clazz, getSetValue(types)));
+ }
+ public ValidationTarget of(IFlag type) {
+ return of(new ValidationKey(type.getClass(), type.getLongValue()));
+ }
+ ValidationTarget of(ValidationKey key) {
+ if(!rules.containsKey(key))
+ rules.put(key, new ArrayList());
+
+ ValidationTarget target = new ValidationTarget(this, key);
+ rules.get(key).add(target);
+ return target;
+ }
+
+ public void validate(BaseBuilder builder) throws BuilderException {
+ for(ValidationKey key: rules.keySet()) {
+ IFlag value = getPropertyValue(builder, key.getType());
+ if(value == null && builder instanceof TransactionBuilder) {
+ value = getPropertyValue(((TransactionBuilder)builder).getPaymentMethod(), key.getType());
+ if(value == null)
+ continue;
+ }
+
+ Set> values = key.getSet();
+ if(values.contains(value)) {
+ for(ValidationTarget validation: rules.get(key)) {
+ ValidationClause clause = validation.getClause();
+ if(clause == null) continue;
+
+ // modifier
+ IFlag constraint = validation.getConstraint();
+ if(constraint != null) {
+ IFlag modifier = getPropertyValue(builder, constraint.getClass());
+ if(!constraint.equals(modifier))
+ continue;
+ }
+
+ // check precondition
+ ValidationClause precondition = validation.getPrecondition();
+ if(precondition != null) {
+ try {
+ if (!precondition.getCallback().call(builder))
+ continue;
+ }
+ catch(Exception exc) {
+ throw new BuilderException(exc.getMessage());
+ }
+ }
+
+ // run actual validation
+ try{
+ if(!clause.getCallback().call(builder))
+ throw new BuilderException(clause.getMessage());
+ }
+ catch(Exception e) {
+ throw new BuilderException(e.getMessage());
+ }
+ }
+ }
+ }
+ }
+
+ private Field getField(Class clazz, String name) throws NoSuchFieldException {
+ try {
+ Field field = clazz.getDeclaredField(name);
+ field.setAccessible(true);
+ return field;
+ }
+ catch(NoSuchFieldException e) {
+ Class superClazz = clazz.getSuperclass();
+ if(superClazz != null)
+ return getField(superClazz, name);
+ else throw e;
+ }
+ }
+ private IFlag getPropertyValue(Object obj, Object comp) {
+ if(obj == null) return null;
+
+ String name = ((Class)comp).getSimpleName();
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+
+ try{
+ Field field = getField(obj.getClass(), name);
+ return (IFlag)field.get(obj);
+ }
+ catch(Exception e) {
+ return null;
+ }
+ }
+ private long getSetValue(Set flags) {
+ long value = 0;
+ for(IFlag type : flags) {
+ value |= type.getLongValue();
+ }
+ return value;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/LodgingData.java b/globalpayments-sdk/src/main/java/com/global/api/entities/LodgingData.java
new file mode 100644
index 0000000..3b4ac65
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/LodgingData.java
@@ -0,0 +1,133 @@
+package com.global.api.entities;
+
+import com.global.api.entities.enums.AdvancedDepositType;
+import com.global.api.entities.enums.ExtraChargeType;
+import com.global.api.entities.enums.PrestigiousPropertyLimit;
+
+import org.joda.time.DateTime;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class LodgingData {
+ private AdvancedDepositType advancedDepositType;
+ private DateTime checkInDate;
+ private DateTime checkOutDate;
+ private HashMap extraCharges;
+ private String folioNumber;
+ private boolean noShow = false;
+ private boolean preferredCustomer = false;
+ private PrestigiousPropertyLimit prestigiousPropertyLimit;
+ private BigDecimal rate;
+ private Integer stayDuration;
+ private String lodgingDataEdit;
+
+ public AdvancedDepositType getAdvancedDepositType() {
+ return advancedDepositType;
+ }
+
+ public void setAdvancedDepositType(AdvancedDepositType advancedDepositType) {
+ this.advancedDepositType = advancedDepositType;
+ }
+
+ public DateTime getCheckInDate() {
+ return checkInDate;
+ }
+
+ public void setCheckInDate(DateTime checkInDate) {
+ this.checkInDate = checkInDate;
+ }
+
+ public DateTime getCheckOutDate() {
+ return checkOutDate;
+ }
+
+ public void setCheckOutDate(DateTime checkOutDate) {
+ this.checkOutDate = checkOutDate;
+ }
+
+ public String getFolioNumber() {
+ return folioNumber;
+ }
+
+ public void setFolioNumber(String folioNumber) {
+ this.folioNumber = folioNumber;
+ }
+
+ public boolean isNoShow() {
+ return noShow;
+ }
+
+ public void setNoShow(boolean noShow) {
+ this.noShow = noShow;
+ }
+
+ public boolean isPreferredCustomer() {
+ return preferredCustomer;
+ }
+
+ public void setPreferredCustomer(boolean preferredCustomer) {
+ this.preferredCustomer = preferredCustomer;
+ }
+
+ public PrestigiousPropertyLimit getPrestigiousPropertyLimit() {
+ return prestigiousPropertyLimit;
+ }
+
+ public void setPrestigiousPropertyLimit(PrestigiousPropertyLimit prestigiousPropertyLimit) {
+ this.prestigiousPropertyLimit = prestigiousPropertyLimit;
+ }
+
+ public BigDecimal getRate() {
+ return rate;
+ }
+
+ public void setRate(BigDecimal rate) {
+ this.rate = rate;
+ }
+
+ public Integer getStayDuration() {
+ return stayDuration;
+ }
+
+ public void setStayDuration(Integer stayDuration) {
+ this.stayDuration = stayDuration;
+ }
+
+ public HashMap getExtraCharges() {
+ return extraCharges;
+ }
+
+ public BigDecimal getExtraChargeAmount() {
+ BigDecimal total = new BigDecimal("0");
+ for (BigDecimal amount : extraCharges.values()) {
+ total = total.add(amount);
+ }
+ return total;
+ }
+
+ public String getLodgingDataEdit() {
+ return lodgingDataEdit;
+ }
+
+ public void setLodgingDataEdit(String value) {
+ lodgingDataEdit = value;
+ }
+
+ public LodgingData addExtraCharge(ExtraChargeType extraChargeType) {
+ return addExtraCharge(extraChargeType, new BigDecimal("0"));
+ }
+
+ public LodgingData addExtraCharge(ExtraChargeType extraChargeType, BigDecimal amount) {
+ if (extraCharges == null) {
+ extraCharges = new HashMap();
+ }
+
+ if (!extraCharges.containsKey(extraChargeType)) {
+ extraCharges.put(extraChargeType, new BigDecimal("0"));
+ }
+
+ extraCharges.put(extraChargeType, extraCharges.get(extraChargeType).add(amount));
+ return this;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/TransactionSummary.java b/globalpayments-sdk/src/main/java/com/global/api/entities/TransactionSummary.java
new file mode 100644
index 0000000..fbec695
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/TransactionSummary.java
@@ -0,0 +1,705 @@
+package com.global.api.entities;
+
+import android.location.Address;
+
+import java.math.BigDecimal;
+
+import com.global.api.entities.reporting.AltPaymentData;
+import com.global.api.entities.reporting.CheckData;
+
+import org.joda.time.DateTime;
+
+public class TransactionSummary {
+ private String accountDataSource;
+ private AltPaymentData altPaymentData;
+ private BigDecimal amount;
+ private BigDecimal amountDue;
+ private BigDecimal authorizedAmount;
+ private String authCode;
+ private String avsResponseCode;
+ private DateTime batchCloseDate;
+ private String batchId;
+ private String batchSequenceNumber;
+ private Address billingAddress;
+ private BigDecimal captureAmount;
+ private String cardEntryMethod;
+ private String cardHolderFirstName;
+ private String cardHolderLastName;
+ private String cardSwiped;
+ private String cardType;
+ private BigDecimal cashBackAmount;
+ private String cavvResponseCode;
+ private CheckData checkData;
+ private String clerkId;
+ private String clientTransactionId;
+ private String companyName;
+ private BigDecimal convenienceAmount;
+ private String customerFirstName;
+ private String customerId;
+ private String customerLastName;
+ private String cvnResponseCode;
+ private boolean debtRepaymentIndicator;
+ private String description;
+ private int deviceId;
+ private String eciIndicator;
+ private String emvChipCondition;
+ private String fraudRuleInfo;
+ private boolean fullyCaptured;
+ private BigDecimal gratuityAmount;
+ private boolean hasEcomPaymentData;
+ private boolean hasEmvTags;
+ private Boolean hostTimeOut;
+ private String invoiceNumber;
+ private String issuerResponseCode;
+ private String issuerResponseMessage;
+ private String issuerTransactionId;
+ private String gatewayResponseCode;
+ private String gatewayResponseMessage;
+ private String giftCurrency;
+ private LodgingData lodgingData;
+ private String maskedAlias;
+ private String maskedCardNumber;
+ private boolean oneTimePayment;
+ private String originalTransactionId;
+ private String paymentMethodKey;
+ private String paymentType;
+ private String poNumber;
+ private String recurringDataCode;
+ private String referenceNumber;
+ private int repeatCount;
+ private DateTime responseDate;
+ private String scheduleId;
+ private String serviceName;
+ private BigDecimal settlementAmount;
+ private BigDecimal shippingAmount;
+ private String siteTrace;
+ private String status;
+ private BigDecimal surchargeAmount;
+ private BigDecimal taxAmount;
+ private String taxType;
+ private String tokenPanLastFour;
+ private DateTime transactionDate;
+ private String transactionDescriptor;
+ private String transactionId;
+ private String transactionStatus;
+ private String transactionType;
+ private String uniqueDeviceId;
+ private String username;
+ private String xid;
+
+ public String getAccountDataSource() {
+ return accountDataSource;
+ }
+
+ public void setAccountDataSource(String accountDataSource) {
+ this.accountDataSource = accountDataSource;
+ }
+
+ public AltPaymentData getAltPaymentData() {
+ return altPaymentData;
+ }
+
+ public void setAltPaymentData(AltPaymentData altPaymentData) {
+ this.altPaymentData = altPaymentData;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ public BigDecimal getAmountDue() {
+ return amountDue;
+ }
+
+ public void setAmountDue(BigDecimal amountDue) {
+ this.amountDue = amountDue;
+ }
+
+ public BigDecimal getAuthorizedAmount() {
+ return authorizedAmount;
+ }
+
+ public void setAuthorizedAmount(BigDecimal authorizedAmount) {
+ this.authorizedAmount = authorizedAmount;
+ }
+
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ public String getAvsResponseCode() {
+ return avsResponseCode;
+ }
+
+ public void setAvsResponseCode(String avsResponseCode) {
+ this.avsResponseCode = avsResponseCode;
+ }
+
+ public DateTime getBatchCloseDate() {
+ return batchCloseDate;
+ }
+
+ public void setBatchCloseDate(DateTime batchCloseDate) {
+ this.batchCloseDate = batchCloseDate;
+ }
+
+ public String getBatchId() {
+ return batchId;
+ }
+
+ public void setBatchId(String batchId) {
+ this.batchId = batchId;
+ }
+
+ public String getBatchSequenceNumber() {
+ return batchSequenceNumber;
+ }
+
+ public void setBatchSequenceNumber(String batchSequenceNumber) {
+ this.batchSequenceNumber = batchSequenceNumber;
+ }
+
+ public Address getBillingAddress() {
+ return billingAddress;
+ }
+
+ public void setBillingAddress(Address billingAddress) {
+ this.billingAddress = billingAddress;
+ }
+
+ public BigDecimal getCaptureAmount() {
+ return captureAmount;
+ }
+
+ public void setCaptureAmount(BigDecimal captureAmount) {
+ this.captureAmount = captureAmount;
+ }
+
+ public String getCardEntryMethod() {
+ return cardEntryMethod;
+ }
+
+ public void setCardEntryMethod(String cardEntryMethod) {
+ this.cardEntryMethod = cardEntryMethod;
+ }
+
+ public String getCardHolderFirstName() {
+ return cardHolderFirstName;
+ }
+
+ public void setCardHolderFirstName(String cardHolderFirstName) {
+ this.cardHolderFirstName = cardHolderFirstName;
+ }
+
+ public String getCardHolderLastName() {
+ return cardHolderLastName;
+ }
+
+ public void setCardHolderLastName(String cardHolderLastName) {
+ this.cardHolderLastName = cardHolderLastName;
+ }
+
+ public String getCardSwiped() {
+ return cardSwiped;
+ }
+
+ public void setCardSwiped(String cardSwiped) {
+ this.cardSwiped = cardSwiped;
+ }
+
+ public String getCardType() {
+ return cardType;
+ }
+
+ public void setCardType(String cardType) {
+ this.cardType = cardType;
+ }
+
+ public BigDecimal getCashBackAmount() {
+ return cashBackAmount;
+ }
+
+ public void setCashBackAmount(BigDecimal cashBackAmount) {
+ this.cashBackAmount = cashBackAmount;
+ }
+
+ public String getCavvResponseCode() {
+ return cavvResponseCode;
+ }
+
+ public void setCavvResponseCode(String cavvResponseCode) {
+ this.cavvResponseCode = cavvResponseCode;
+ }
+
+ public CheckData getCheckData() {
+ return checkData;
+ }
+
+ public void setCheckData(CheckData checkData) {
+ this.checkData = checkData;
+ }
+
+ public String getClerkId() {
+ return clerkId;
+ }
+
+ public void setClerkId(String clerkId) {
+ this.clerkId = clerkId;
+ }
+
+ public String getClientTransactionId() {
+ return clientTransactionId;
+ }
+
+ public void setClientTransactionId(String clientTransactionId) {
+ this.clientTransactionId = clientTransactionId;
+ }
+
+ public String getCompanyName() {
+ return companyName;
+ }
+
+ public void setCompanyName(String companyName) {
+ this.companyName = companyName;
+ }
+
+ public BigDecimal getConvenienceAmount() {
+ return convenienceAmount;
+ }
+
+ public void setConvenienceAmount(BigDecimal convenienceAmount) {
+ this.convenienceAmount = convenienceAmount;
+ }
+
+ public String getCustomerFirstName() {
+ return customerFirstName;
+ }
+
+ public void setCustomerFirstName(String customerFirstName) {
+ this.customerFirstName = customerFirstName;
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+ public String getCustomerLastName() {
+ return customerLastName;
+ }
+
+ public void setCustomerLastName(String customerLastName) {
+ this.customerLastName = customerLastName;
+ }
+
+ public String getCvnResponseCode() {
+ return cvnResponseCode;
+ }
+
+ public void setCvnResponseCode(String cvnResponseCode) {
+ this.cvnResponseCode = cvnResponseCode;
+ }
+
+ public boolean isDebtRepaymentIndicator() {
+ return debtRepaymentIndicator;
+ }
+
+ public void setDebtRepaymentIndicator(boolean debtRepaymentIndicator) {
+ this.debtRepaymentIndicator = debtRepaymentIndicator;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(int deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ public String getEciIndicator() {
+ return eciIndicator;
+ }
+
+ public void setEciIndicator(String eciIndicator) {
+ this.eciIndicator = eciIndicator;
+ }
+
+ public String getEmvChipCondition() {
+ return emvChipCondition;
+ }
+
+ public void setEmvChipCondition(String emvChipCondition) {
+ this.emvChipCondition = emvChipCondition;
+ }
+
+ public String getFraudRuleInfo() {
+ return fraudRuleInfo;
+ }
+
+ public void setFraudRuleInfo(String fraudRuleInfo) {
+ this.fraudRuleInfo = fraudRuleInfo;
+ }
+
+ public boolean isFullyCaptured() {
+ return fullyCaptured;
+ }
+
+ public void setFullyCaptured(boolean fullyCaptured) {
+ this.fullyCaptured = fullyCaptured;
+ }
+
+ public BigDecimal getGratuityAmount() {
+ return gratuityAmount;
+ }
+
+ public void setGratuityAmount(BigDecimal gratuityAmount) {
+ this.gratuityAmount = gratuityAmount;
+ }
+
+ public boolean isHasEcomPaymentData() {
+ return hasEcomPaymentData;
+ }
+
+ public void setHasEcomPaymentData(boolean hasEcomPaymentData) {
+ this.hasEcomPaymentData = hasEcomPaymentData;
+ }
+
+ public boolean isHasEmvTags() {
+ return hasEmvTags;
+ }
+
+ public void setHasEmvTags(boolean hasEmvTags) {
+ this.hasEmvTags = hasEmvTags;
+ }
+
+ public Boolean getHostTimeOut() {
+ return hostTimeOut;
+ }
+
+ public void setHostTimeOut(Boolean hostTimeOut) {
+ this.hostTimeOut = hostTimeOut;
+ }
+
+ public String getInvoiceNumber() {
+ return invoiceNumber;
+ }
+
+ public void setInvoiceNumber(String invoiceNumber) {
+ this.invoiceNumber = invoiceNumber;
+ }
+
+ public String getIssuerResponseCode() {
+ return issuerResponseCode;
+ }
+
+ public void setIssuerResponseCode(String issuerResponseCode) {
+ this.issuerResponseCode = issuerResponseCode;
+ }
+
+ public String getIssuerResponseMessage() {
+ return issuerResponseMessage;
+ }
+
+ public void setIssuerResponseMessage(String issuerResponseMessage) {
+ this.issuerResponseMessage = issuerResponseMessage;
+ }
+
+ public String getIssuerTransactionId() {
+ return issuerTransactionId;
+ }
+
+ public void setIssuerTransactionId(String issuerTransactionId) {
+ this.issuerTransactionId = issuerTransactionId;
+ }
+
+ public String getGatewayResponseCode() {
+ return gatewayResponseCode;
+ }
+
+ public void setGatewayResponseCode(String gatewayResponseCode) {
+ this.gatewayResponseCode = gatewayResponseCode;
+ }
+
+ public String getGatewayResponseMessage() {
+ return gatewayResponseMessage;
+ }
+
+ public void setGatewayResponseMessage(String gatewayResponseMessage) {
+ this.gatewayResponseMessage = gatewayResponseMessage;
+ }
+
+ public String getGiftCurrency() {
+ return giftCurrency;
+ }
+
+ public void setGiftCurrency(String giftCurrency) {
+ this.giftCurrency = giftCurrency;
+ }
+
+ public LodgingData getLodgingData() {
+ return lodgingData;
+ }
+
+ public void setLodgingData(LodgingData lodgingData) {
+ this.lodgingData = lodgingData;
+ }
+
+ public String getMaskedAlias() {
+ return maskedAlias;
+ }
+
+ public void setMaskedAlias(String maskedAlias) {
+ this.maskedAlias = maskedAlias;
+ }
+
+ public String getMaskedCardNumber() {
+ return maskedCardNumber;
+ }
+
+ public void setMaskedCardNumber(String maskedCardNumber) {
+ this.maskedCardNumber = maskedCardNumber;
+ }
+
+ public boolean isOneTimePayment() {
+ return oneTimePayment;
+ }
+
+ public void setOneTimePayment(boolean oneTimePayment) {
+ this.oneTimePayment = oneTimePayment;
+ }
+
+ public String getOrderId() {
+ return this.clientTransactionId;
+ }
+
+ public void setOrderId(String value) {
+ this.clientTransactionId = value;
+ }
+
+ public String getOriginalTransactionId() {
+ return originalTransactionId;
+ }
+
+ public void setOriginalTransactionId(String originalTransactionId) {
+ this.originalTransactionId = originalTransactionId;
+ }
+
+ public String getPaymentMethodKey() {
+ return paymentMethodKey;
+ }
+
+ public void setPaymentMethodKey(String paymentMethodKey) {
+ this.paymentMethodKey = paymentMethodKey;
+ }
+
+ public String getPaymentType() {
+ return paymentType;
+ }
+
+ public void setPaymentType(String paymentType) {
+ this.paymentType = paymentType;
+ }
+
+ public String getPoNumber() {
+ return poNumber;
+ }
+
+ public void setPoNumber(String poNumber) {
+ this.poNumber = poNumber;
+ }
+
+ public String getRecurringDataCode() {
+ return recurringDataCode;
+ }
+
+ public void setRecurringDataCode(String recurringDataCode) {
+ this.recurringDataCode = recurringDataCode;
+ }
+
+ public String getReferenceNumber() {
+ return referenceNumber;
+ }
+
+ public void setReferenceNumber(String referenceNumber) {
+ this.referenceNumber = referenceNumber;
+ }
+
+ public int getRepeatCount() {
+ return repeatCount;
+ }
+
+ public void setRepeatCount(int repeatCount) {
+ this.repeatCount = repeatCount;
+ }
+
+ public DateTime getResponseDate() {
+ return responseDate;
+ }
+
+ public void setResponseDate(DateTime responseDate) {
+ this.responseDate = responseDate;
+ }
+
+ public String getScheduleId() {
+ return scheduleId;
+ }
+
+ public void setScheduleId(String scheduleId) {
+ this.scheduleId = scheduleId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public BigDecimal getSettlementAmount() {
+ return settlementAmount;
+ }
+
+ public void setSettlementAmount(BigDecimal settlementAmount) {
+ this.settlementAmount = settlementAmount;
+ }
+
+ public BigDecimal getShippingAmount() {
+ return shippingAmount;
+ }
+
+ public void setShippingAmount(BigDecimal shippingAmount) {
+ this.shippingAmount = shippingAmount;
+ }
+
+ public String getSiteTrace() {
+ return siteTrace;
+ }
+
+ public void setSiteTrace(String siteTrace) {
+ this.siteTrace = siteTrace;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public BigDecimal getSurchargeAmount() {
+ return surchargeAmount;
+ }
+
+ public void setSurchargeAmount(BigDecimal surchargeAmount) {
+ this.surchargeAmount = surchargeAmount;
+ }
+
+ public BigDecimal getTaxAmount() {
+ return taxAmount;
+ }
+
+ public void setTaxAmount(BigDecimal taxAmount) {
+ this.taxAmount = taxAmount;
+ }
+
+ public String getTaxType() {
+ return taxType;
+ }
+
+ public void setTaxType(String taxType) {
+ this.taxType = taxType;
+ }
+
+ public String getTokenPanLastFour() {
+ return tokenPanLastFour;
+ }
+
+ public void setTokenPanLastFour(String tokenPanLastFour) {
+ this.tokenPanLastFour = tokenPanLastFour;
+ }
+
+ public DateTime getTransactionDate() {
+ return transactionDate;
+ }
+
+ public void setTransactionDate(DateTime transactionDate) {
+ this.transactionDate = transactionDate;
+ }
+
+ public String getTransactionDescriptor() {
+ return transactionDescriptor;
+ }
+
+ public void setTransactionDescriptor(String transactionDescriptor) {
+ this.transactionDescriptor = transactionDescriptor;
+ }
+
+ public String getTransactionStatus() {
+ return transactionStatus;
+ }
+
+ public void setTransactionStatus(String transactionStatus) {
+ this.transactionStatus = transactionStatus;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public String getTransactionType() {
+ return transactionType;
+ }
+
+ public void setTransactionType(String transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public String getUniqueDeviceId() {
+ return uniqueDeviceId;
+ }
+
+ public void setUniqueDeviceId(String uniqueDeviceId) {
+ this.uniqueDeviceId = uniqueDeviceId;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getXid() {
+ return xid;
+ }
+
+ public void setXid(String xid) {
+ this.xid = xid;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/AdvancedDepositType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/AdvancedDepositType.java
new file mode 100644
index 0000000..16e6083
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/AdvancedDepositType.java
@@ -0,0 +1,22 @@
+package com.global.api.entities.enums;
+
+public enum AdvancedDepositType implements IStringConstant {
+ AssuredReservation("ASSURED_RESERVATION"),
+ CardDeposit("CARD_DEPOSIT"),
+ Purchase("PURCHASE"),
+ Other("OTHER");
+
+ String value;
+
+ AdvancedDepositType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public byte[] getBytes() {
+ return value.getBytes();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ApplicationCryptogramType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ApplicationCryptogramType.java
new file mode 100644
index 0000000..062fcc6
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ApplicationCryptogramType.java
@@ -0,0 +1,6 @@
+package com.global.api.entities.enums;
+
+public enum ApplicationCryptogramType {
+ TC,
+ ARQC
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/BaudRate.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/BaudRate.java
new file mode 100644
index 0000000..d23063c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/BaudRate.java
@@ -0,0 +1,19 @@
+package com.global.api.entities.enums;
+
+public enum BaudRate {
+ r9600(9600),
+ r38400(38400),
+ r57600(57600),
+ r19200(19200),
+ r115200(115200);
+
+ int value;
+
+ BaudRate(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CardType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CardType.java
new file mode 100644
index 0000000..4acaf53
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CardType.java
@@ -0,0 +1,10 @@
+package com.global.api.entities.enums;
+
+public enum CardType {
+ VISA,
+ MC,
+ DISC,
+ AMEX,
+ GIFTCARD,
+ PAYPALECOMMERCE;
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ConnectionModes.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ConnectionModes.java
new file mode 100644
index 0000000..ca7680e
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ConnectionModes.java
@@ -0,0 +1,11 @@
+package com.global.api.entities.enums;
+
+public enum ConnectionModes {
+ SERIAL,
+ TCP_IP,
+ SSL_TCP,
+ HTTP,
+ TCP_IP_SERVER,
+ BLUETOOTH,
+ PAY_AT_TABLE
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ControlCodes.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ControlCodes.java
new file mode 100644
index 0000000..6d0c9f7
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ControlCodes.java
@@ -0,0 +1,36 @@
+package com.global.api.entities.enums;
+
+public enum ControlCodes implements IByteConstant {
+ STX(0x02), // Denotes the beginning of a message frame
+ ETX(0x03), // Denotes the ending of a message frame
+ EOT(0x04), // Indicates communication session terminated
+ ENQ(0x05), // Begin Session sent from the host to the POS
+ ACK(0x06), // Acknowledge of message received
+ NAK(0x15), // Indicates invalid message received
+ FS(0x1C), // Field separator
+ GS(0x1D), // Message ID follows (for non-PIN entry prompts)
+ RS(0x1E), // Message ID follows (for PIN entry prompts)
+ US(0x1F),
+ COMMA(0x2C),
+ COLON(0x3A),
+ PTGS(0x7C),
+ NUM(0x23),
+ GBP(0xA3),
+ SP(0x20);
+
+ private final byte code;
+
+ ControlCodes(int code) {
+ this.code = (byte) code;
+ }
+
+ public byte getByte() {
+ return this.code;
+ }
+
+ @Override
+ public String toString() {
+ String rvalue = super.toString();
+ return String.format("[%s]", rvalue);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CurrencyType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CurrencyType.java
new file mode 100644
index 0000000..7d9a5ad
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/CurrencyType.java
@@ -0,0 +1,23 @@
+package com.global.api.entities.enums;
+
+public enum CurrencyType implements IStringConstant {
+ Currency("USD"),
+ Points("POINTS"),
+ CashBenefits("CASH_BENEFITS"),
+ FoodStamps("FOODSTAMPS"),
+ Voucher("VOUCHER");
+
+ String value;
+
+ CurrencyType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public byte[] getBytes() {
+ return this.value.getBytes();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DataBits.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DataBits.java
new file mode 100644
index 0000000..827a334
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DataBits.java
@@ -0,0 +1,16 @@
+package com.global.api.entities.enums;
+
+public enum DataBits {
+ Seven(7),
+ Eight(8);
+
+ int value;
+
+ DataBits(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DeviceType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DeviceType.java
new file mode 100644
index 0000000..e18ae76
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/DeviceType.java
@@ -0,0 +1,7 @@
+package com.global.api.entities.enums;
+
+public enum DeviceType {
+ PAX_S300,
+ HPA_ISC250,
+ INGENICO
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Environment.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Environment.java
new file mode 100644
index 0000000..22f13c0
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Environment.java
@@ -0,0 +1,6 @@
+package com.global.api.entities.enums;
+
+public enum Environment {
+ TEST,
+ PRODUCTION
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ExtraChargeType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ExtraChargeType.java
new file mode 100644
index 0000000..f144f0b
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ExtraChargeType.java
@@ -0,0 +1,10 @@
+package com.global.api.entities.enums;
+
+public enum ExtraChargeType {
+ GiftShop,
+ Laundry,
+ MiniBar,
+ Other,
+ Restaurant,
+ Telephone
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IByteConstant.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IByteConstant.java
new file mode 100644
index 0000000..6103d36
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IByteConstant.java
@@ -0,0 +1,5 @@
+package com.global.api.entities.enums;
+
+public interface IByteConstant {
+ byte getByte();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IFlag.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IFlag.java
new file mode 100644
index 0000000..bac25a5
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IFlag.java
@@ -0,0 +1,5 @@
+package com.global.api.entities.enums;
+
+public interface IFlag {
+ long getLongValue();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/INumericConstant.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/INumericConstant.java
new file mode 100644
index 0000000..9109df9
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/INumericConstant.java
@@ -0,0 +1,5 @@
+package com.global.api.entities.enums;
+
+public interface INumericConstant {
+ int getValue();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IStringConstant.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IStringConstant.java
new file mode 100644
index 0000000..2041ce6
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/IStringConstant.java
@@ -0,0 +1,6 @@
+package com.global.api.entities.enums;
+
+public interface IStringConstant {
+ byte[] getBytes();
+ String getValue();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/MessageFormat.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/MessageFormat.java
new file mode 100644
index 0000000..2cc07c5
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/MessageFormat.java
@@ -0,0 +1,6 @@
+package com.global.api.entities.enums;
+
+public enum MessageFormat {
+ HPA,
+ Visa2nd
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Parity.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Parity.java
new file mode 100644
index 0000000..3ac5fae
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/Parity.java
@@ -0,0 +1,17 @@
+package com.global.api.entities.enums;
+
+public enum Parity {
+ None(0),
+ Odd(1),
+ Even(2);
+
+ int value;
+
+ Parity(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PaymentMethodType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PaymentMethodType.java
new file mode 100644
index 0000000..0f296ea
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PaymentMethodType.java
@@ -0,0 +1,30 @@
+package com.global.api.entities.enums;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+public enum PaymentMethodType implements IFlag {
+ Reference,
+ Credit,
+ Debit,
+ EBT,
+ Cash,
+ ACH,
+ Gift,
+ Recurring,
+ Other;
+
+ public long getLongValue() {
+ return 1 << this.ordinal();
+ }
+
+ public static Set getSet(long value) {
+ EnumSet flags = EnumSet.noneOf(PaymentMethodType.class);
+ for (PaymentMethodType flag : PaymentMethodType.values()) {
+ long flagValue = flag.getLongValue();
+ if ((flagValue & value) == flagValue)
+ flags.add(flag);
+ }
+ return flags;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PrestigiousPropertyLimit.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PrestigiousPropertyLimit.java
new file mode 100644
index 0000000..ec732c2
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/PrestigiousPropertyLimit.java
@@ -0,0 +1,22 @@
+package com.global.api.entities.enums;
+
+public enum PrestigiousPropertyLimit implements IStringConstant {
+ Limit_500("LIMIT_500"),
+ Limit_1000("LIMIT_1000"),
+ Limit_1500("LIMIT_1500"),
+ NotParticipating("NOT_PARTICIPATING");
+
+ String value;
+
+ PrestigiousPropertyLimit(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public byte[] getBytes() {
+ return value.getBytes();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ReportType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ReportType.java
new file mode 100644
index 0000000..4e83952
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/ReportType.java
@@ -0,0 +1,29 @@
+package com.global.api.entities.enums;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+public enum ReportType implements IFlag {
+ FindTransactions,
+ Activity,
+ BatchDetail,
+ BatchHistory,
+ BatchSummary,
+ OpenAuths,
+ Search,
+ TransactionDetail;
+
+ public long getLongValue() {
+ return 1 << this.ordinal();
+ }
+
+ public static Set getSet(long value) {
+ EnumSet flags = EnumSet.noneOf(ReportType.class);
+ for (ReportType flag : ReportType.values()) {
+ long flagValue = flag.getLongValue();
+ if ((flagValue & value) == flagValue)
+ flags.add(flag);
+ }
+ return flags;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/SendFileType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/SendFileType.java
new file mode 100644
index 0000000..b198c7b
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/SendFileType.java
@@ -0,0 +1,6 @@
+package com.global.api.entities.enums;
+
+public enum SendFileType {
+ Banner,
+ Logo;
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/StopBits.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/StopBits.java
new file mode 100644
index 0000000..93a7194
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/StopBits.java
@@ -0,0 +1,16 @@
+package com.global.api.entities.enums;
+
+public enum StopBits {
+ One(1),
+ Two(2);
+
+ int value;
+
+ StopBits(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TaxType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TaxType.java
new file mode 100644
index 0000000..d19821d
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TaxType.java
@@ -0,0 +1,21 @@
+package com.global.api.entities.enums;
+
+public enum TaxType implements IStringConstant {
+ NotUsed("NOTUSED"),
+ SalesTax("SALESTAX"),
+ TaxExempt("TAXEXEMPT");
+
+ String value;
+
+ TaxType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public byte[] getBytes() {
+ return this.value.getBytes();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TimeZoneConversion.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TimeZoneConversion.java
new file mode 100644
index 0000000..bdd38cd
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TimeZoneConversion.java
@@ -0,0 +1,21 @@
+package com.global.api.entities.enums;
+
+public enum TimeZoneConversion implements IStringConstant {
+ UTC("UTC"),
+ Merchant("Merchant"),
+ Datacenter("Datacenter");
+
+ String value;
+
+ TimeZoneConversion(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public byte[] getBytes() {
+ return this.value.getBytes();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TransactionType.java b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TransactionType.java
new file mode 100644
index 0000000..db386f2
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/enums/TransactionType.java
@@ -0,0 +1,58 @@
+package com.global.api.entities.enums;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+public enum TransactionType implements IFlag {
+ Decline,
+ Verify,
+ Capture,
+ Auth,
+ Refund,
+ Reversal,
+ Sale,
+ Edit,
+ Void,
+ AddValue,
+ Balance,
+ Activate,
+ Alias,
+ Replace,
+ Reward,
+ Deactivate,
+ BatchClose,
+ Create,
+ Delete,
+ BenefitWithdrawal,
+ Fetch,
+ Search,
+ Hold,
+ Release,
+ VerifyEnrolled,
+ VerifySignature,
+ DccRateLookup,
+ Increment,
+ CashOut,
+ DataCollect,
+ VerifyAuthentication,
+ PreAuthCompletion,
+ InitiateAuthentication,
+ SendFile,
+ Cancel,
+ Duplicate,
+ PayAtTable;
+
+ public long getLongValue() {
+ return 1L << this.ordinal();
+ }
+
+ public static Set getSet(long value) {
+ EnumSet flags = EnumSet.noneOf(TransactionType.class);
+ for (TransactionType flag : TransactionType.values()) {
+ long flagValue = flag.getLongValue();
+ if ((flagValue & value) == flagValue)
+ flags.add(flag);
+ }
+ return flags;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ApiException.java b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ApiException.java
new file mode 100644
index 0000000..f4f8dff
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ApiException.java
@@ -0,0 +1,11 @@
+package com.global.api.entities.exceptions;
+
+public class ApiException extends Exception {
+ public ApiException(String message) {
+ this(message, null);
+ }
+
+ public ApiException(String message, Exception innerException) {
+ super(message, innerException);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/BuilderException.java b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/BuilderException.java
new file mode 100644
index 0000000..421fdfe
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/BuilderException.java
@@ -0,0 +1,7 @@
+package com.global.api.entities.exceptions;
+
+public class BuilderException extends ApiException {
+ public BuilderException(String message) {
+ super(message);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ConfigurationException.java b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ConfigurationException.java
new file mode 100644
index 0000000..0dfcc3c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/ConfigurationException.java
@@ -0,0 +1,7 @@
+package com.global.api.entities.exceptions;
+
+public class ConfigurationException extends ApiException {
+ public ConfigurationException(String message) {
+ super(message);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/MessageException.java b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/MessageException.java
new file mode 100644
index 0000000..da4268c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/MessageException.java
@@ -0,0 +1,11 @@
+package com.global.api.entities.exceptions;
+
+public class MessageException extends ApiException {
+ public MessageException(String message) {
+ super(message);
+ }
+
+ public MessageException(String message, Exception innerException) {
+ super(message, innerException);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/UnsupportedTransactionException.java b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/UnsupportedTransactionException.java
new file mode 100644
index 0000000..cd3aba1
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/exceptions/UnsupportedTransactionException.java
@@ -0,0 +1,11 @@
+package com.global.api.entities.exceptions;
+
+public class UnsupportedTransactionException extends ApiException {
+ public UnsupportedTransactionException() {
+ this("Transaction type not supported for this payment method.");
+ }
+
+ public UnsupportedTransactionException(String message) {
+ super(message);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentData.java b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentData.java
new file mode 100644
index 0000000..9b5c011
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentData.java
@@ -0,0 +1,52 @@
+package com.global.api.entities.reporting;
+
+import java.util.Date;
+import java.util.List;
+
+public class AltPaymentData {
+ private String status;
+ private String statusMessage;
+ private String buyerEmailAddress;
+ private Date stateDate;
+ private List processorResponseInfo;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+
+ public String getBuyerEmailAddress() {
+ return buyerEmailAddress;
+ }
+
+ public void setBuyerEmailAddress(String buyerEmailAddress) {
+ this.buyerEmailAddress = buyerEmailAddress;
+ }
+
+ public Date getStateDate() {
+ return stateDate;
+ }
+
+ public void setStateDate(Date stateDate) {
+ this.stateDate = stateDate;
+ }
+
+ public List getProcessorResponseInfo() {
+ return processorResponseInfo;
+ }
+
+ public void setProcessorResponseInfo(List processorResponseInfo) {
+ this.processorResponseInfo = processorResponseInfo;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentProcessorInfo.java b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentProcessorInfo.java
new file mode 100644
index 0000000..82118c4
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/AltPaymentProcessorInfo.java
@@ -0,0 +1,31 @@
+package com.global.api.entities.reporting;
+
+public class AltPaymentProcessorInfo {
+ private String code;
+ private String message;
+ private String type;
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/CheckData.java b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/CheckData.java
new file mode 100644
index 0000000..ca4a4a8
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/CheckData.java
@@ -0,0 +1,58 @@
+package com.global.api.entities.reporting;
+
+public class CheckData {
+ private String accountInfo;
+ private String consumerInfo;
+ private String checkAction;
+ private String checkType;
+ private String dataEntryMode;
+ private String secCode;
+
+ public String getAccountInfo() {
+ return accountInfo;
+ }
+
+ public void setAccountInfo(String accountInfo) {
+ this.accountInfo = accountInfo;
+ }
+
+ public String getConsumerInfo() {
+ return consumerInfo;
+ }
+
+ public void setConsumerInfo(String consumerInfo) {
+ this.consumerInfo = consumerInfo;
+ }
+
+ public String getCheckAction() {
+ return checkAction;
+ }
+
+ public void setCheckAction(String checkAction) {
+ this.checkAction = checkAction;
+ }
+
+ public String getCheckType() {
+ return checkType;
+ }
+
+ public void setCheckType(String checkType) {
+ this.checkType = checkType;
+ }
+
+ public String getDataEntryMode() {
+ return dataEntryMode;
+ }
+
+ public void setDataEntryMode(String dataEntryMode) {
+ this.dataEntryMode = dataEntryMode;
+ }
+
+ public String getSecCode() {
+ return secCode;
+ }
+
+ public void setSecCode(String secCode) {
+ this.secCode = secCode;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteria.java b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteria.java
new file mode 100644
index 0000000..834e4bc
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteria.java
@@ -0,0 +1,40 @@
+package com.global.api.entities.reporting;
+
+public enum SearchCriteria {
+ AccountNumberLastFour,
+ AltPaymentStatus,
+ AuthCode,
+ BankRoutingNumber,
+ BatchId,
+ BatchSequenceNumber,
+ BuyerEmailAddress,
+ CardHolderFirstName,
+ CardHolderLastName,
+ CardHolderPoNumber,
+ CardNumberFirstSix,
+ CardNumberLastFour,
+ CheckFirstName,
+ CheckLastName,
+ CheckName,
+ CheckNumber,
+ ClerkId,
+ ClientTransactionId,
+ CustomerId,
+ DisplayName,
+ EndDate,
+ GiftCurrency,
+ GiftMaskedAlias,
+ FullyCaptured,
+ InvoiceNumber,
+ IssuerResult,
+ IssuerTransactionId,
+ OneTime,
+ PaymentMethodKey,
+ ReferenceNumber,
+ SettlementAmount,
+ ScheduleId,
+ SiteTrace,
+ StartDate,
+ UniqueDeviceId,
+ Username;
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteriaBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteriaBuilder.java
new file mode 100644
index 0000000..62cc1c4
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/entities/reporting/SearchCriteriaBuilder.java
@@ -0,0 +1,411 @@
+package com.global.api.entities.reporting;
+
+import com.global.api.builders.TransactionReportBuilder;
+import com.global.api.entities.enums.CardType;
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.entities.exceptions.ApiException;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class SearchCriteriaBuilder {
+ private TransactionReportBuilder _reportBuilder;
+ private String accountNumberLastFour;
+ private String altPaymentStatus;
+ private String authCode;
+ private String bankRoutingNumber;
+ private String batchId;
+ private String batchSequenceNumber;
+ private String buyerEmailAddress;
+ private String cardHolderFirstName;
+ private String cardHolderLastName;
+ private String cardHolderPoNumber;
+ private String cardNumberFirstSix;
+ private String cardNumberLastFour;
+ private ArrayList cardTypes;
+ private String checkFirstName;
+ private String checkLastName;
+ private String checkName;
+ private String checkNumber;
+ private String clerkId;
+ private String clientTransactionId;
+ private String customerId;
+ private String displayName;
+ private Date endDate;
+ private String giftCurrency;
+ private String giftMaskedAlias;
+ private boolean fullyCaptured;
+ private String invoiceNumber;
+ private String issuerResult;
+ private String issuerTransactionId;
+ private boolean oneTime;
+ private String paymentMethodKey;
+ private ArrayList paymentTypes;
+ private String referenceNumber;
+ private ArrayList transactionType;
+ private BigDecimal settlementAmount;
+ private String scheduleId;
+ private String siteTrace;
+ private Date startDate;
+ private String uniqueDeviceId;
+ private String username;
+
+ public String getAccountNumberLastFour() {
+ return accountNumberLastFour;
+ }
+
+ public void setAccountNumberLastFour(String accountNumberLastFour) {
+ this.accountNumberLastFour = accountNumberLastFour;
+ }
+
+ public String getAltPaymentStatus() {
+ return altPaymentStatus;
+ }
+
+ public void setAltPaymentStatus(String altPaymentStatus) {
+ this.altPaymentStatus = altPaymentStatus;
+ }
+
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ public String getBankRoutingNumber() {
+ return bankRoutingNumber;
+ }
+
+ public void setBankRoutingNumber(String bankRoutingNumber) {
+ this.bankRoutingNumber = bankRoutingNumber;
+ }
+
+ public String getBatchId() {
+ return batchId;
+ }
+
+ public void setBatchId(String batchId) {
+ this.batchId = batchId;
+ }
+
+ public String getBatchSequenceNumber() {
+ return batchSequenceNumber;
+ }
+
+ public void setBatchSequenceNumber(String batchSequenceNumber) {
+ this.batchSequenceNumber = batchSequenceNumber;
+ }
+
+ public String getBuyerEmailAddress() {
+ return buyerEmailAddress;
+ }
+
+ public void setBuyerEmailAddress(String buyerEmailAddress) {
+ this.buyerEmailAddress = buyerEmailAddress;
+ }
+
+ public String getCardHolderFirstName() {
+ return cardHolderFirstName;
+ }
+
+ public void setCardHolderFirstName(String cardHolderFirstName) {
+ this.cardHolderFirstName = cardHolderFirstName;
+ }
+
+ public String getCardHolderLastName() {
+ return cardHolderLastName;
+ }
+
+ public void setCardHolderLastName(String cardHolderLastName) {
+ this.cardHolderLastName = cardHolderLastName;
+ }
+
+ public String getCardHolderPoNumber() {
+ return cardHolderPoNumber;
+ }
+
+ public void setCardHolderPoNumber(String cardHolderPoNumber) {
+ this.cardHolderPoNumber = cardHolderPoNumber;
+ }
+
+ public String getCardNumberFirstSix() {
+ return cardNumberFirstSix;
+ }
+
+ public void setCardNumberFirstSix(String cardNumberFirstSix) {
+ this.cardNumberFirstSix = cardNumberFirstSix;
+ }
+
+ public String getCardNumberLastFour() {
+ return cardNumberLastFour;
+ }
+
+ public void setCardNumberLastFour(String cardNumberLastFour) {
+ this.cardNumberLastFour = cardNumberLastFour;
+ }
+
+ public ArrayList getCardTypes() {
+ return cardTypes;
+ }
+
+ public void setCardTypes(ArrayList cardTypes) {
+ this.cardTypes = cardTypes;
+ }
+
+ public String getCheckFirstName() {
+ return checkFirstName;
+ }
+
+ public void setCheckFirstName(String checkFirstName) {
+ this.checkFirstName = checkFirstName;
+ }
+
+ public String getCheckLastName() {
+ return checkLastName;
+ }
+
+ public void setCheckLastName(String checkLastName) {
+ this.checkLastName = checkLastName;
+ }
+
+ public String getCheckName() {
+ return checkName;
+ }
+
+ public void setCheckName(String checkName) {
+ this.checkName = checkName;
+ }
+
+ public String getCheckNumber() {
+ return checkNumber;
+ }
+
+ public void setCheckNumber(String checkNumber) {
+ this.checkNumber = checkNumber;
+ }
+
+ public String getClerkId() {
+ return clerkId;
+ }
+
+ public void setClerkId(String clerkId) {
+ this.clerkId = clerkId;
+ }
+
+ public String getClientTransactionId() {
+ return clientTransactionId;
+ }
+
+ public void setClientTransactionId(String clientTransactionId) {
+ this.clientTransactionId = clientTransactionId;
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public String getGiftCurrency() {
+ return giftCurrency;
+ }
+
+ public void setGiftCurrency(String giftCurrency) {
+ this.giftCurrency = giftCurrency;
+ }
+
+ public String getGiftMaskedAlias() {
+ return giftMaskedAlias;
+ }
+
+ public void setGiftMaskedAlias(String giftMaskedAlias) {
+ this.giftMaskedAlias = giftMaskedAlias;
+ }
+
+ public boolean isFullyCaptured() {
+ return fullyCaptured;
+ }
+
+ public void setFullyCaptured(boolean fullyCaptured) {
+ this.fullyCaptured = fullyCaptured;
+ }
+
+ public String getInvoiceNumber() {
+ return invoiceNumber;
+ }
+
+ public void setInvoiceNumber(String invoiceNumber) {
+ this.invoiceNumber = invoiceNumber;
+ }
+
+ public String getIssuerResult() {
+ return issuerResult;
+ }
+
+ public void setIssuerResult(String issuerResult) {
+ this.issuerResult = issuerResult;
+ }
+
+ public String getIssuerTransactionId() {
+ return issuerTransactionId;
+ }
+
+ public void setIssuerTransactionId(String issuerTransactionId) {
+ this.issuerTransactionId = issuerTransactionId;
+ }
+
+ public boolean isOneTime() {
+ return oneTime;
+ }
+
+ public void setOneTime(boolean oneTime) {
+ this.oneTime = oneTime;
+ }
+
+ public String getPaymentMethodKey() {
+ return paymentMethodKey;
+ }
+
+ public void setPaymentMethodKey(String paymentMethodKey) {
+ this.paymentMethodKey = paymentMethodKey;
+ }
+
+ public ArrayList getPaymentTypes() {
+ return paymentTypes;
+ }
+
+ public void setPaymentTypes(ArrayList paymentTypes) {
+ this.paymentTypes = paymentTypes;
+ }
+
+ public String getReferenceNumber() {
+ return referenceNumber;
+ }
+
+ public void setReferenceNumber(String referenceNumber) {
+ this.referenceNumber = referenceNumber;
+ }
+
+ public ArrayList getTransactionType() {
+ return transactionType;
+ }
+
+ public void setTransactionType(ArrayList transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public BigDecimal getSettlementAmount() {
+ return settlementAmount;
+ }
+
+ public void setSettlementAmount(BigDecimal settlementAmount) {
+ this.settlementAmount = settlementAmount;
+ }
+
+ public String getScheduleId() {
+ return scheduleId;
+ }
+
+ public void setScheduleId(String scheduleId) {
+ this.scheduleId = scheduleId;
+ }
+
+ public String getSiteTrace() {
+ return siteTrace;
+ }
+
+ public void setSiteTrace(String siteTrace) {
+ this.siteTrace = siteTrace;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public String getUniqueDeviceId() {
+ return uniqueDeviceId;
+ }
+
+ public void setUniqueDeviceId(String uniqueDeviceId) {
+ this.uniqueDeviceId = uniqueDeviceId;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public SearchCriteriaBuilder(TransactionReportBuilder reportBuilder) {
+ _reportBuilder = reportBuilder;
+ }
+
+ public TResult execute() throws ApiException {
+ return execute("default");
+ }
+
+ public TResult execute(String configName) throws ApiException {
+ return _reportBuilder.execute(configName);
+ }
+
+ public SearchCriteriaBuilder and(SearchCriteria criteria, T value) {
+ String criteriaValue = criteria.toString();
+ if (criteriaValue != null) {
+ set(this, criteriaValue, value);
+ }
+ return this;
+ }
+
+ // https://stackoverflow.com/questions/14374878/using-reflection-to-set-an-object-property/14374995
+ private static boolean set(Object object, String fieldName, T fieldValue) {
+ Class> clazz = object.getClass();
+
+ // https://stackoverflow.com/questions/4052840/most-efficient-way-to-make-the-first-character-of-a-string-lower-case
+ char c[] = fieldName.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ fieldName = new String(c);
+
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ field.set(object, fieldValue);
+ return true;
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/gateways/IPaymentGateway.java b/globalpayments-sdk/src/main/java/com/global/api/gateways/IPaymentGateway.java
new file mode 100644
index 0000000..e848e00
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/gateways/IPaymentGateway.java
@@ -0,0 +1,10 @@
+package com.global.api.gateways;
+
+import com.global.api.builders.ReportBuilder;
+import com.global.api.entities.exceptions.ApiException;
+
+public interface IPaymentGateway {
+ T processReport(ReportBuilder builder, Class clazz) throws ApiException;
+
+ boolean supportsHostedPayments();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/IPaymentMethod.java b/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/IPaymentMethod.java
new file mode 100644
index 0000000..35e2222
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/IPaymentMethod.java
@@ -0,0 +1,7 @@
+package com.global.api.paymentMethods;
+
+import com.global.api.entities.enums.PaymentMethodType;
+
+public interface IPaymentMethod {
+ PaymentMethodType getPaymentMethodType();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/TransactionReference.java b/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/TransactionReference.java
new file mode 100644
index 0000000..5bbf5a2
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/paymentMethods/TransactionReference.java
@@ -0,0 +1,144 @@
+package com.global.api.paymentMethods;
+
+import com.global.api.entities.enums.PaymentMethodType;
+
+import java.math.BigDecimal;
+
+public class TransactionReference implements IPaymentMethod {
+ private String alternativePaymentType;
+ private String acquiringInstitutionId;
+ private String authCode;
+ private Integer batchNumber;
+ private String clientTransactionId;
+ private String messageTypeIndicator;
+ private String orderId;
+ private BigDecimal originalAmount;
+ private IPaymentMethod originalPaymentMethod;
+ private String originalProcessingCode;
+ private String originalTransactionTime;
+ private PaymentMethodType paymentMethodType;
+ private int sequenceNumber;
+ private String systemTraceAuditNumber;
+ private String transactionId;
+
+ public String getAlternativePaymentType() {
+ return alternativePaymentType;
+ }
+
+ public void setAlternativePaymentType(String alternativePaymentType) {
+ this.alternativePaymentType = alternativePaymentType;
+ }
+
+ public String getAcquiringInstitutionId() {
+ return acquiringInstitutionId;
+ }
+
+ public void setAcquiringInstitutionId(String acquiringInstitutionId) {
+ this.acquiringInstitutionId = acquiringInstitutionId;
+ }
+
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ public Integer getBatchNumber() {
+ return batchNumber;
+ }
+
+ public void setBatchNumber(Integer batchNumber) {
+ this.batchNumber = batchNumber;
+ }
+
+ public String getClientTransactionId() {
+ return clientTransactionId;
+ }
+
+ public void setClientTransactionId(String clientTransactionId) {
+ this.clientTransactionId = clientTransactionId;
+ }
+
+ public String getMessageTypeIndicator() {
+ return messageTypeIndicator;
+ }
+
+ public void setMessageTypeIndicator(String messageTypeIndicator) {
+ this.messageTypeIndicator = messageTypeIndicator;
+ }
+
+ public String getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(String orderId) {
+ this.orderId = orderId;
+ }
+
+ public BigDecimal getOriginalAmount() {
+ return originalAmount;
+ }
+
+ public void setOriginalAmount(BigDecimal originalAmount) {
+ this.originalAmount = originalAmount;
+ }
+
+ public IPaymentMethod getOriginalPaymentMethod() {
+ return originalPaymentMethod;
+ }
+
+ public void setOriginalPaymentMethod(IPaymentMethod originalPaymentMethod) {
+ this.originalPaymentMethod = originalPaymentMethod;
+ }
+
+ public String getOriginalProcessingCode() {
+ return originalProcessingCode;
+ }
+
+ public void setOriginalProcessingCode(String originalProcessingCode) {
+ this.originalProcessingCode = originalProcessingCode;
+ }
+
+ public String getOriginalTransactionTime() {
+ return originalTransactionTime;
+ }
+
+ public void setOriginalTransactionTime(String originalTransactionTime) {
+ this.originalTransactionTime = originalTransactionTime;
+ }
+
+ public PaymentMethodType getPaymentMethodType() {
+
+ return paymentMethodType;
+ }
+
+ public void setPaymentMethodType(PaymentMethodType paymentMethodType) {
+ this.paymentMethodType = paymentMethodType;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public void setSequenceNumber(int sequenceNumber) {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ public String getSystemTraceAuditNumber() {
+ return systemTraceAuditNumber;
+ }
+
+ public void setSystemTraceAuditNumber(String systemTraceAuditNumber) {
+ this.systemTraceAuditNumber = systemTraceAuditNumber;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/serviceConfigs/Configuration.java b/globalpayments-sdk/src/main/java/com/global/api/serviceConfigs/Configuration.java
new file mode 100644
index 0000000..5d2a4c0
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/serviceConfigs/Configuration.java
@@ -0,0 +1,68 @@
+package com.global.api.serviceConfigs;
+
+import com.global.api.ConfiguredServices;
+import com.global.api.entities.enums.Environment;
+import com.global.api.entities.exceptions.ConfigurationException;
+
+public abstract class Configuration {
+ protected boolean enableLogging = false;
+ protected Environment environment = Environment.TEST;
+ protected boolean forceGatewayTimeout = false;
+ protected String serviceUrl;
+ protected int timeout = 65000;
+ protected boolean validated;
+
+ public int getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ public String getServiceUrl() {
+ return serviceUrl;
+ }
+
+ public void setServiceUrl(String serviceUrl) {
+ this.serviceUrl = serviceUrl;
+ }
+
+ public boolean isEnableLogging() {
+ return enableLogging;
+ }
+
+ public void setEnableLogging(boolean enableLogging) {
+ this.enableLogging = enableLogging;
+ }
+
+ public boolean isForceGatewayTimeout() {
+ return forceGatewayTimeout;
+ }
+
+ public void setForceGatewayTimeout(boolean forceGatewayTimeout) {
+ this.forceGatewayTimeout = forceGatewayTimeout;
+ }
+
+ public Environment getEnvironment() {
+ return environment;
+ }
+
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ public void setValidated(boolean validated) {
+ this.validated = validated;
+ }
+
+ public boolean isValidated() {
+ return validated;
+ }
+
+ public abstract void configureContainer(ConfiguredServices services) throws ConfigurationException;
+
+ public void validate() throws ConfigurationException {
+ this.validated = true;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/services/DeviceService.java b/globalpayments-sdk/src/main/java/com/global/api/services/DeviceService.java
new file mode 100644
index 0000000..787cbaf
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/services/DeviceService.java
@@ -0,0 +1,17 @@
+package com.global.api.services;
+
+import com.global.api.ServicesContainer;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.ConnectionConfig;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+
+public class DeviceService {
+ public static IDeviceInterface create(ConnectionConfig config) throws ApiException {
+ return create(config, "default");
+ }
+
+ public static IDeviceInterface create(ConnectionConfig config, String configName) throws ApiException {
+ ServicesContainer.configureService(config, configName);
+ return ServicesContainer.getInstance().getDeviceInterface(configName);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ConnectionConfig.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ConnectionConfig.java
new file mode 100644
index 0000000..626c0d6
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ConnectionConfig.java
@@ -0,0 +1,122 @@
+package com.global.api.terminals;
+
+import com.global.api.ConfiguredServices;
+import com.global.api.entities.enums.BaudRate;
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.DataBits;
+import com.global.api.entities.enums.DeviceType;
+import com.global.api.entities.enums.Parity;
+import com.global.api.entities.enums.StopBits;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.serviceConfigs.Configuration;
+import com.global.api.terminals.abstractions.ITerminalConfiguration;
+import com.global.api.terminals.ingenico.IngenicoController;
+import com.global.api.terminals.ingenico.variables.DeviceMode;
+import com.global.api.utils.StringUtils;
+
+public class ConnectionConfig extends Configuration implements ITerminalConfiguration {
+ private ConnectionModes connectionMode;
+ private BaudRate baudRate;
+ private Parity parity;
+ private StopBits stopBits;
+ private DataBits dataBits;
+ private String ipAddress;
+ private String port;
+ private DeviceType deviceType;
+ private IRequestIdProvider requestIdProvider;
+
+ public ConnectionModes getConnectionMode() {
+ return connectionMode;
+ }
+
+ public void setConnectionMode(ConnectionModes connectionModes) {
+ this.connectionMode = connectionModes;
+ }
+
+ public BaudRate getBaudRate() {
+ return baudRate;
+ }
+
+ public void setBaudRate(BaudRate baudRate) {
+ this.baudRate = baudRate;
+ }
+
+ public Parity getParity() {
+ return parity;
+ }
+
+ public void setParity(Parity parity) {
+ this.parity = parity;
+ }
+
+ public StopBits getStopBits() {
+ return stopBits;
+ }
+
+ public void setStopBits(StopBits stopBits) {
+ this.stopBits = stopBits;
+ }
+
+ public DataBits getDataBits() {
+ return dataBits;
+ }
+
+ public void setDataBits(DataBits dataBits) {
+ this.dataBits = dataBits;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public DeviceType getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(DeviceType deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public IRequestIdProvider getRequestIdProvider() {
+ return requestIdProvider;
+ }
+
+ public void setRequestIdProvider(IRequestIdProvider requestIdProvider) {
+ this.requestIdProvider = requestIdProvider;
+ }
+
+ public ConnectionConfig() {
+ timeout = 30000;
+ }
+
+ public void configureContainer(ConfiguredServices services) throws ConfigurationException {
+ switch (deviceType) {
+ case HPA_ISC250:
+ case INGENICO:
+ services.setDeviceController(new IngenicoController(this));
+ default:
+ break;
+ }
+ }
+
+ public void validate() throws ConfigurationException {
+ if (connectionMode == ConnectionModes.TCP_IP || connectionMode == ConnectionModes.HTTP) {
+ if (StringUtils.isNullOrEmpty(ipAddress))
+ throw new ConfigurationException("IpAddress is required for TCP or HTTP communication modes.");
+ if (port.isEmpty())
+ throw new ConfigurationException("Port is required for TCP or HTTP communication modes.");
+ }
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceController.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceController.java
new file mode 100644
index 0000000..f14ee63
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceController.java
@@ -0,0 +1,108 @@
+package com.global.api.terminals;
+
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.DeviceType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.abstractions.IDeviceCommInterface;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+import com.global.api.terminals.abstractions.IDeviceMessage;
+import com.global.api.terminals.abstractions.IDisposable;
+import com.global.api.terminals.abstractions.ITerminalConfiguration;
+import com.global.api.terminals.abstractions.ITerminalReport;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+import com.global.api.terminals.builders.TerminalAuthBuilder;
+import com.global.api.terminals.builders.TerminalManageBuilder;
+import com.global.api.terminals.builders.TerminalReportBuilder;
+import com.global.api.terminals.ingenico.pat.PATRequest;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+
+public abstract class DeviceController implements IDisposable {
+ protected ITerminalConfiguration settings;
+ protected IDeviceCommInterface _connector;
+
+ public ConnectionModes getConnectionModes() {
+ if (settings != null)
+ return settings.getConnectionMode();
+ return null;
+ }
+
+ public DeviceType getDeviceType() {
+ if (settings != null)
+ return settings.getDeviceType();
+ return null;
+ }
+
+ public IRequestIdProvider requestIdProvider() {
+ if (settings != null)
+ return settings.getRequestIdProvider();
+ return null;
+ }
+
+ private IMessageSentInterface onMessageSent;
+ private IBroadcastMessageInterface onBroadcastMessage;
+ private IOnPayAtTableRequestInterface onPayAtTableRequest;
+
+ void setOnMessageSentHandler(IMessageSentInterface onMessageSent) {
+ this.onMessageSent = onMessageSent;
+ }
+
+ void setOnBroadcastMessageHandler(IBroadcastMessageInterface onBroadcastMessage) {
+ this.onBroadcastMessage = onBroadcastMessage;
+ }
+
+ void setOnPayAtTableRequestHandler(IOnPayAtTableRequestInterface onPayAtTableRequest) {
+ this.onPayAtTableRequest = onPayAtTableRequest;
+ }
+
+ public DeviceController(ITerminalConfiguration settings) throws ConfigurationException {
+ this.settings = settings;
+ _connector = configureConnector();
+ _connector.setMessageSentHandler(new IMessageSentInterface() {
+ public void messageSent(String message) {
+ if (onMessageSent != null) {
+ onMessageSent.messageSent(message);
+ }
+ }
+ });
+
+ _connector.setBroadcastMessageHandler(new IBroadcastMessageInterface() {
+ public void broadcastReceived(String code, String message) {
+ if (onBroadcastMessage != null) {
+ onBroadcastMessage.broadcastReceived(code, message);
+ }
+ }
+ });
+
+ _connector.setOnPayAtTableRequestHandler(new IOnPayAtTableRequestInterface() {
+ public void onPayAtTableRequest(PATRequest payAtTableRequest) {
+ if (onPayAtTableRequest != null) {
+ onPayAtTableRequest.onPayAtTableRequest(payAtTableRequest);
+ }
+ }
+ });
+ }
+
+ public byte[] send(IDeviceMessage message) throws ApiException {
+ if (_connector != null)
+ return _connector.send(message);
+ return null;
+ }
+
+ public abstract IDeviceCommInterface configureConnector() throws ConfigurationException;
+
+ public abstract IDeviceInterface configureInterface() throws ConfigurationException;
+
+ public abstract ITerminalResponse processTransaction(TerminalAuthBuilder builder) throws ApiException;
+
+ public abstract ITerminalResponse manageTransaction(TerminalManageBuilder builder) throws ApiException;
+
+ public abstract ITerminalReport processReport(TerminalReportBuilder builder) throws ApiException;
+
+ public void dispose() {
+ if (_connector != null)
+ _connector.disconnect();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceInterface.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceInterface.java
new file mode 100644
index 0000000..dcb59ea
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceInterface.java
@@ -0,0 +1,288 @@
+package com.global.api.terminals;
+
+import android.util.Log;
+
+import java.math.BigDecimal;
+
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.SendFileType;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.UnsupportedTransactionException;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.abstractions.IInitializeResponse;
+import com.global.api.terminals.builders.TerminalAuthBuilder;
+import com.global.api.terminals.builders.TerminalManageBuilder;
+import com.global.api.terminals.builders.TerminalReportBuilder;
+import com.global.api.terminals.ingenico.pat.PATRequest;
+import com.global.api.terminals.ingenico.variables.ReceiptType;
+import com.global.api.terminals.ingenico.variables.ReportTypes;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+
+public abstract class DeviceInterface implements IDeviceInterface {
+ protected T _controller;
+ protected IRequestIdProvider _requestIdProvider;
+
+ public IMessageSentInterface onMessageSent;
+ public IBroadcastMessageInterface onBroadcastMessage;
+ public IOnPayAtTableRequestInterface onPayAtTableRequest;
+
+ public void setOnMessageSent(IMessageSentInterface onMessageSent) {
+ this.onMessageSent = onMessageSent;
+ }
+
+ public void setOnBroadcastMessageReceived(IBroadcastMessageInterface onBroadcastMessage) {
+ this.onBroadcastMessage = onBroadcastMessage;
+ }
+
+ public void setOnPayAtTableRequest(IOnPayAtTableRequestInterface onPayAtTableRequest) {
+ this.onPayAtTableRequest = onPayAtTableRequest;
+ }
+
+ public DeviceInterface(T controller) {
+ _controller = controller;
+ _controller.setOnMessageSentHandler(new IMessageSentInterface() {
+ public void messageSent(String message) {
+ if (onMessageSent != null)
+ onMessageSent.messageSent(message);
+ }
+ });
+
+ _controller.setOnBroadcastMessageHandler(new IBroadcastMessageInterface() {
+ public void broadcastReceived(String code, String message) {
+ if (onBroadcastMessage != null)
+ onBroadcastMessage.broadcastReceived(code, message);
+ }
+ });
+
+ _controller.setOnPayAtTableRequestHandler(new IOnPayAtTableRequestInterface() {
+ public void onPayAtTableRequest(PATRequest payAtTableRequest) {
+ if (onPayAtTableRequest != null) {
+ onPayAtTableRequest.onPayAtTableRequest(payAtTableRequest);
+ }
+ }
+ });
+
+ _requestIdProvider = _controller.requestIdProvider();
+ }
+
+ // admin methods
+ public IDeviceResponse cancel() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse closeLane() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse disableHostResponseBeep() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IInitializeResponse initialize() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse addLineItem(String leftText, String rightText, String runningLeftText,
+ String runningRightText) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse openLane() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse reboot() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse reset() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse sendFile(SendFileType fileType, String filePath) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse setStoreAndForwardMode(boolean enabled) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse startCard(PaymentMethodType paymentMethodType) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // credit calls
+ public TerminalAuthBuilder creditAuth(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalManageBuilder creditCapture(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditRefund(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditSale(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditAuth() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalManageBuilder creditCapture() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditRefund() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditSale() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder creditVerify() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalManageBuilder creditVoid() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // debit calls
+ public TerminalAuthBuilder debitSale(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder debitRefund(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder debitSale() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder debitRefund() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // gift calls
+ public TerminalAuthBuilder giftSale(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder giftSale() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder giftAddValue() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder giftAddValue(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalManageBuilder giftVoid() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder giftBalance() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // ebt calls
+ public TerminalAuthBuilder ebtBalance() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtPurchase() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtPurchase(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtRefund() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtRefund(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtWithdrawal() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder ebtWithdrawal(BigDecimal amount) throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // generic calls
+ public TerminalAuthBuilder authorize(BigDecimal amount) throws ApiException {
+ return new TerminalAuthBuilder(TransactionType.Auth, PaymentMethodType.Credit).withAmount(amount);
+ }
+
+ public TerminalManageBuilder capture(BigDecimal amount) throws ApiException {
+ return new TerminalManageBuilder(TransactionType.Capture, PaymentMethodType.Credit).withAmount(amount);
+ }
+
+ public TerminalAuthBuilder refund(BigDecimal amount) throws ApiException {
+ return new TerminalAuthBuilder(TransactionType.Refund, PaymentMethodType.Credit).withAmount(amount);
+ }
+
+ public TerminalAuthBuilder sale(BigDecimal amount) throws ApiException {
+ return new TerminalAuthBuilder(TransactionType.Sale, PaymentMethodType.Credit).withAmount(amount);
+ }
+
+ public TerminalAuthBuilder verify() throws ApiException {
+ return new TerminalAuthBuilder(TransactionType.Verify, PaymentMethodType.Credit)
+ .withAmount(new BigDecimal(0.01));
+ }
+
+ public TerminalReportBuilder getReport(ReportTypes type) throws ApiException {
+ return new TerminalReportBuilder(type);
+ }
+
+ public TerminalReportBuilder getLastReceipt(ReceiptType type) throws ApiException {
+ return new TerminalReportBuilder(type);
+ }
+
+ public IDeviceResponse duplicate() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ // for confirmation to RE
+ public TerminalManageBuilder reverse(BigDecimal amount) throws ApiException {
+ return new TerminalManageBuilder(TransactionType.Reversal, PaymentMethodType.Credit).withAmount(amount);
+ }
+
+ public IDeviceResponse getTerminalConfiguration() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse testConnection() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public IDeviceResponse getTerminalStatus() throws ApiException {
+ throw new UnsupportedTransactionException("This function is not supported by the currently configured device.");
+ }
+
+ public TerminalAuthBuilder payAtTableResponse() throws ApiException {
+ return new TerminalAuthBuilder(TransactionType.PayAtTable, PaymentMethodType.Other);
+ }
+
+ public void dispose() {
+ _controller.dispose();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceMessage.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceMessage.java
new file mode 100644
index 0000000..cabbefe
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceMessage.java
@@ -0,0 +1,47 @@
+package com.global.api.terminals;
+
+import com.global.api.entities.enums.ControlCodes;
+import com.global.api.terminals.abstractions.IDeviceMessage;
+import com.global.api.utils.EnumUtils;
+
+public class DeviceMessage implements IDeviceMessage {
+ byte[] buffer;
+ boolean keepAlive;
+ boolean awaitResponse;
+
+ public DeviceMessage(byte[] buffer){
+ this.buffer = buffer;
+ }
+
+ public byte[] getSendBuffer() { return this.buffer; }
+
+ public boolean isKeepAlive() {
+ return keepAlive;
+ }
+
+ public void setKeepAlive(boolean keepAlive) {
+ this.keepAlive = keepAlive;
+ }
+
+ public boolean isAwaitResponse() {
+ return awaitResponse;
+ }
+
+ public void setAwaitResponse(boolean awaitResponse) {
+ this.awaitResponse = awaitResponse;
+ }
+
+ @Override
+ public String toString(){
+ StringBuilder sb = new StringBuilder();
+ for(byte b : buffer){
+ if(EnumUtils.isDefined(ControlCodes.class, b)){
+ ControlCodes code = EnumUtils.parse(ControlCodes.class, b);
+ sb.append(code.toString());
+ }
+ else sb.append((char)b);
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceResponse.java
new file mode 100644
index 0000000..abe3987
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/DeviceResponse.java
@@ -0,0 +1,60 @@
+package com.global.api.terminals;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+
+public class DeviceResponse implements IDeviceResponse {
+ private String _status;
+ private String _command;
+ private String _version;
+ private String _deviceResponseCode;
+ private String _deviceResponseMessage;
+ private String _referenceNumber;
+
+ public String getStatus() {
+ return _status;
+ }
+
+ public void setStatus(String status) {
+ _status = status;
+ }
+
+ public String getCommand() {
+ return _command;
+ }
+
+ public void setCommand(String command) {
+ _command = command;
+ }
+
+ public String getVersion() {
+ return _version;
+ }
+
+ public void setVersion(String version) {
+ _version = version;
+ }
+
+ public String getDeviceResponseCode() {
+ return _deviceResponseCode;
+ }
+
+ public void setDeviceResponseCode(String deviceResponseCode) {
+ _deviceResponseCode = deviceResponseCode;
+ }
+
+ public String getDeviceResponseText() {
+ return _deviceResponseMessage;
+ }
+
+ public void setDeviceResponseText(String deviceResponseMessage) {
+ _deviceResponseMessage = deviceResponseMessage;
+ }
+
+ public String getReferenceNumber() {
+ return _referenceNumber;
+ }
+
+ public void setReferenceNumber(String refNumber) {
+ _referenceNumber = refNumber;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/IRequestIdProvider.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/IRequestIdProvider.java
new file mode 100644
index 0000000..2c40c34
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/IRequestIdProvider.java
@@ -0,0 +1,5 @@
+package com.global.api.terminals;
+
+public interface IRequestIdProvider {
+ int getRequestId();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalReportType.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalReportType.java
new file mode 100644
index 0000000..6732108
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalReportType.java
@@ -0,0 +1,16 @@
+package com.global.api.terminals;
+
+public enum TerminalReportType {
+
+ LocalDetailReport;
+
+ public static final int SIZE = java.lang.Integer.SIZE;
+
+ public int getValue() {
+ return this.ordinal();
+ }
+
+ public static TerminalReportType forValue(int value) {
+ return values()[value];
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalUtilities.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalUtilities.java
new file mode 100644
index 0000000..08949ad
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/TerminalUtilities.java
@@ -0,0 +1,117 @@
+package com.global.api.terminals;
+
+import android.graphics.Point;
+
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.ControlCodes;
+import com.global.api.entities.enums.IByteConstant;
+import com.global.api.entities.enums.IStringConstant;
+import com.global.api.entities.exceptions.BuilderException;
+import com.global.api.terminals.abstractions.IRequestSubGroup;
+import com.global.api.utils.Extensions;
+import com.global.api.utils.MessageWriter;
+
+import java.nio.charset.StandardCharsets;
+
+public class TerminalUtilities {
+ private static final String version = "1.35";
+
+ public static String getElementString(Object... elements) {
+ StringBuilder sb = new StringBuilder();
+ for (Object element : elements) {
+ if (element instanceof ControlCodes) {
+ sb.append((char) ((ControlCodes) element).getByte());
+ } else if (element instanceof IRequestSubGroup) {
+ sb.append(((IRequestSubGroup) element).getElementString());
+ } else if (element instanceof String[]) {
+ for (String sub_element : (String[]) element) {
+ sb.append(ControlCodes.FS.getByte());
+ sb.append(sub_element);
+ }
+ } else if (element instanceof IStringConstant) {
+ sb.append(((IStringConstant) element).getValue());
+ } else if (element instanceof IByteConstant) {
+ sb.append(((IByteConstant) element).getByte());
+ } else
+ sb.append(element);
+ }
+
+ return sb.toString();
+ }
+
+ public static String getString(byte[] buffer) {
+ return new String(buffer, StandardCharsets.UTF_8);
+ }
+
+ public static Integer headerLength(byte[] buffer) {
+ String fHex = String.format("%02X", buffer[0]);
+ String sHex = String.format("%02X", (buffer[1] & 255));
+ String hex = fHex + sHex;
+ return Integer.parseInt(hex, 16);
+ }
+
+ public static String calculateHeader(byte[] buffer) {
+ String hex = String.format("%04x", buffer.length);
+ String fDigit = Character.toString(hex.charAt(0)) + hex.charAt(1);
+ String sDigit = Character.toString(hex.charAt(2)) + hex.charAt(3);
+
+ return String.format("%c%c", (char) Extensions.parseUnsignedInt(fDigit, 16), (char) Extensions.parseUnsignedInt(sDigit, 16));
+
+ }
+
+ public static DeviceMessage buildIngenicoRequest(String message, ConnectionModes settings) throws BuilderException {
+ MessageWriter buffer = new MessageWriter();
+ byte lrc;
+
+ switch (settings) {
+ case SERIAL:
+ throw new BuilderException("Failed to build request message. Not available for this library.");
+ case PAY_AT_TABLE:
+ buffer.add(ControlCodes.STX.getByte());
+ for (char c : message.toCharArray())
+ buffer.add((byte) c);
+ buffer.add(ControlCodes.ETX.getByte());
+ byte[] arrByte = calculateLRC(message);
+ lrc = arrByte[0];
+ buffer.add(lrc);
+
+ break;
+ case TCP_IP_SERVER:
+ String msg = calculateHeader(message.getBytes(StandardCharsets.UTF_8)) + message;
+ for (char c : msg.toCharArray())
+ buffer.add((byte) c);
+ break;
+ default:
+ throw new BuilderException("Failed to build request message. Unknown Connection mode.");
+ }
+
+ return new DeviceMessage(buffer.toArray());
+ }
+
+ public static byte[] calculateLRC(String requestMessage) {
+ byte[] cCOde = new byte[]{ControlCodes.ETX.getByte()};
+ int index1 = requestMessage.getBytes().length;
+ int index2 = cCOde.length;
+ byte[] bytes = new byte[index1 + index2];
+ System.arraycopy(requestMessage.getBytes(), 0, bytes, 0, index1);
+ System.arraycopy(cCOde, 0, bytes, index1, index2);
+
+ byte lrc = 0;
+ for (int i = 0; i < bytes.length; i++) {
+ lrc ^= bytes[i];
+ }
+ bytes = new byte[]{lrc};
+ return bytes;
+
+ }
+
+ private static Point toPoint(String coordinate) {
+ String[] xy = coordinate.split("\\[COMMA]");
+
+ Point rvalue = new Point();
+ rvalue.x = Integer.parseInt(xy[0]);
+ rvalue.y = Integer.parseInt(xy[1]);
+
+ return rvalue;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceCommInterface.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceCommInterface.java
new file mode 100644
index 0000000..d16a195
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceCommInterface.java
@@ -0,0 +1,21 @@
+package com.global.api.terminals.abstractions;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+
+public interface IDeviceCommInterface {
+ void connect() throws ConfigurationException;
+
+ void disconnect();
+
+ byte[] send(IDeviceMessage message) throws ApiException;
+
+ void setMessageSentHandler(IMessageSentInterface messageInterface);
+
+ void setBroadcastMessageHandler(IBroadcastMessageInterface broadcastInterface);
+
+ void setOnPayAtTableRequestHandler(IOnPayAtTableRequestInterface onPayAtTable);
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceInterface.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceInterface.java
new file mode 100644
index 0000000..387a738
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceInterface.java
@@ -0,0 +1,136 @@
+package com.global.api.terminals.abstractions;
+
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.SendFileType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.builders.TerminalAuthBuilder;
+import com.global.api.terminals.builders.TerminalManageBuilder;
+import com.global.api.terminals.builders.TerminalReportBuilder;
+import com.global.api.terminals.ingenico.variables.ReceiptType;
+import com.global.api.terminals.ingenico.variables.ReportTypes;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+
+import java.math.BigDecimal;
+
+public interface IDeviceInterface extends IDisposable {
+ void setOnMessageSent(IMessageSentInterface onMessageSent);
+
+ void setOnBroadcastMessageReceived(IBroadcastMessageInterface onBroadcastReceived);
+
+ void setOnPayAtTableRequest(IOnPayAtTableRequestInterface onPayAtTableRequest);
+
+ // admin calls
+ IDeviceResponse disableHostResponseBeep() throws ApiException;
+
+ IInitializeResponse initialize() throws ApiException;
+
+ IDeviceResponse reboot() throws ApiException;
+
+ IDeviceResponse reset() throws ApiException;
+
+ IDeviceResponse cancel() throws ApiException;
+
+ IDeviceResponse openLane() throws ApiException;
+
+ IDeviceResponse closeLane() throws ApiException;
+
+ IDeviceResponse startCard(PaymentMethodType paymentMethodType) throws ApiException;
+
+ IDeviceResponse addLineItem(String leftText, String rightText, String runningLeftText, String runningRightText) throws ApiException;
+
+ IDeviceResponse setStoreAndForwardMode(boolean enabled) throws ApiException;
+
+ IDeviceResponse sendFile(SendFileType fileType, String filePath) throws ApiException;
+
+ IDeviceResponse getTerminalConfiguration() throws ApiException;
+
+ IDeviceResponse testConnection() throws ApiException;
+
+ IDeviceResponse getTerminalStatus() throws ApiException;
+
+ // credit calls
+ TerminalAuthBuilder creditAuth(BigDecimal amount) throws ApiException;
+
+ TerminalManageBuilder creditCapture(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder creditRefund(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder creditSale(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder creditAuth() throws ApiException;
+
+ TerminalManageBuilder creditCapture() throws ApiException;
+
+ TerminalAuthBuilder creditRefund() throws ApiException;
+
+ TerminalAuthBuilder creditSale() throws ApiException;
+
+ TerminalAuthBuilder creditVerify() throws ApiException;
+
+ TerminalManageBuilder creditVoid() throws ApiException;
+
+ // debit calls
+ TerminalAuthBuilder debitSale(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder debitRefund(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder debitSale() throws ApiException;
+
+ TerminalAuthBuilder debitRefund() throws ApiException;
+
+ // gift calls
+ TerminalAuthBuilder giftSale(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder giftSale() throws ApiException;
+
+ TerminalAuthBuilder giftAddValue() throws ApiException;
+
+ TerminalAuthBuilder giftAddValue(BigDecimal amount) throws ApiException;
+
+ TerminalManageBuilder giftVoid() throws ApiException;
+
+ TerminalAuthBuilder giftBalance() throws ApiException;
+
+ // ebt calls
+ TerminalAuthBuilder ebtBalance() throws ApiException;
+
+ TerminalAuthBuilder ebtPurchase() throws ApiException;
+
+ TerminalAuthBuilder ebtPurchase(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder ebtRefund() throws ApiException;
+
+ TerminalAuthBuilder ebtRefund(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder ebtWithdrawal() throws ApiException;
+
+ TerminalAuthBuilder ebtWithdrawal(BigDecimal amount) throws ApiException;
+
+ // report calls
+ // SAFSummaryReport safSummaryReport(SafReportSummary safReportIndicator) throws ApiException;
+
+ // generic calls
+ TerminalAuthBuilder authorize(BigDecimal amount) throws ApiException;
+
+ TerminalManageBuilder capture(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder refund(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder sale(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder verify() throws ApiException;
+
+ // reporting
+ TerminalReportBuilder getReport(ReportTypes reportTypes) throws ApiException;
+
+ TerminalReportBuilder getLastReceipt(ReceiptType receiptType) throws ApiException;
+
+ // transaction management
+ IDeviceResponse duplicate() throws ApiException;
+
+ TerminalManageBuilder reverse(BigDecimal amount) throws ApiException;
+
+ TerminalAuthBuilder payAtTableResponse() throws ApiException;
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceMessage.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceMessage.java
new file mode 100644
index 0000000..0607ce7
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceMessage.java
@@ -0,0 +1,13 @@
+package com.global.api.terminals.abstractions;
+
+public interface IDeviceMessage {
+ boolean isKeepAlive();
+
+ void setKeepAlive(boolean keepAlive);
+
+ boolean isAwaitResponse();
+
+ void setAwaitResponse(boolean awaitResponse);
+
+ byte[] getSendBuffer();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceResponse.java
new file mode 100644
index 0000000..2f4132d
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDeviceResponse.java
@@ -0,0 +1,29 @@
+package com.global.api.terminals.abstractions;
+
+public interface IDeviceResponse {
+ String getStatus();
+
+ void setStatus(String status);
+
+ String getCommand();
+
+ void setCommand(String command);
+
+ String getVersion();
+
+ void setVersion(String version);
+
+ String getDeviceResponseCode();
+
+ void setDeviceResponseCode(String deviceResponseCode);
+
+ String getDeviceResponseText();
+
+ void setDeviceResponseText(String deviceResponseMessage);
+
+ String toString();
+
+ String getReferenceNumber();
+
+ void setReferenceNumber(String refNumber);
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDisposable.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDisposable.java
new file mode 100644
index 0000000..4d3a8b5
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IDisposable.java
@@ -0,0 +1,5 @@
+package com.global.api.terminals.abstractions;
+
+public interface IDisposable {
+ void dispose();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IInitializeResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IInitializeResponse.java
new file mode 100644
index 0000000..0001b95
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IInitializeResponse.java
@@ -0,0 +1,5 @@
+package com.global.api.terminals.abstractions;
+
+public interface IInitializeResponse extends IDeviceResponse {
+ String getSerialNumber();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IRequestSubGroup.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IRequestSubGroup.java
new file mode 100644
index 0000000..6a79633
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/IRequestSubGroup.java
@@ -0,0 +1,5 @@
+package com.global.api.terminals.abstractions;
+
+public interface IRequestSubGroup {
+ String getElementString();
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalConfiguration.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalConfiguration.java
new file mode 100644
index 0000000..7b79671
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalConfiguration.java
@@ -0,0 +1,54 @@
+package com.global.api.terminals.abstractions;
+
+import com.global.api.entities.enums.BaudRate;
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.DataBits;
+import com.global.api.entities.enums.DeviceType;
+import com.global.api.entities.enums.Parity;
+import com.global.api.entities.enums.StopBits;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.IRequestIdProvider;
+
+public interface ITerminalConfiguration {
+ ConnectionModes getConnectionMode();
+
+ void setConnectionMode(ConnectionModes connectionMode);
+
+ String getIpAddress();
+
+ void setIpAddress(String ipAddress);
+
+ String getPort();
+
+ void setPort(String port);
+
+ BaudRate getBaudRate();
+
+ void setBaudRate(BaudRate baudRate);
+
+ Parity getParity();
+
+ void setParity(Parity parity);
+
+ StopBits getStopBits();
+
+ void setStopBits(StopBits stopBits);
+
+ DataBits getDataBits();
+
+ void setDataBits(DataBits dataBits);
+
+ int getTimeout();
+
+ void setTimeout(int timeout);
+
+ void validate() throws ConfigurationException;
+
+ DeviceType getDeviceType();
+
+ void setDeviceType(DeviceType type);
+
+ IRequestIdProvider getRequestIdProvider();
+
+ void setRequestIdProvider(IRequestIdProvider requestIdProvider);
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalReport.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalReport.java
new file mode 100644
index 0000000..bfa305c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalReport.java
@@ -0,0 +1,4 @@
+package com.global.api.terminals.abstractions;
+
+public interface ITerminalReport extends IDeviceResponse {
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalResponse.java
new file mode 100644
index 0000000..eb89daf
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/abstractions/ITerminalResponse.java
@@ -0,0 +1,196 @@
+package com.global.api.terminals.abstractions;
+
+import java.math.BigDecimal;
+
+import com.global.api.entities.enums.ApplicationCryptogramType;
+import com.global.api.terminals.ingenico.variables.DynamicCurrencyStatus;
+import com.global.api.terminals.ingenico.variables.PaymentMethod;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+import com.global.api.terminals.ingenico.variables.TransactionSubTypes;
+
+public interface ITerminalResponse extends IDeviceResponse {
+ String getResponseCode();
+
+ void setResponseCode(String responseCode);
+
+ String getResponseText();
+
+ void setResponseText(String responseText);
+
+ String getTransactionId();
+
+ void setTransactionId(String transactionId);
+
+ String getTerminalRefNumber();
+
+ void setTerminalRefNumber(String terminalRefNumber);
+
+ String getToken();
+
+ void setToken(String token);
+
+ String getSignatureStatus();
+
+ void setSignatureStatus(String signatureStatus);
+
+ byte[] getSignatureData();
+
+ void setSignatureData(byte[] signatureData);
+
+ String getTransactionType();
+
+ void setTransactionType(String transactionType);
+
+ String getMaskedCardNumber();
+
+ void setMaskedCardNumber(String maskedCardNumber);
+
+ String getEntryMethod();
+
+ void setEntryMethod(String entryMethod);
+
+ String getAuthorizationCode();
+
+ void setAuthorizationCode(String authorizationCode);
+
+ String getApprovalCode();
+
+ void setApprovalCode(String approvalCode);
+
+ BigDecimal getTransactionAmount();
+
+ void setTransactionAmount(BigDecimal amount);
+
+ BigDecimal getAmountDue();
+
+ void setAmountDue(BigDecimal amountDue);
+
+ BigDecimal getBalanceAmount();
+
+ void setBalanceAmount(BigDecimal balanceAmount);
+
+ String getCardHolderName();
+
+ void setCardHolderName(String cardHolderName);
+
+ String getCardBIN();
+
+ void setCardBIN(String cardBIN);
+
+ boolean getCardPresent();
+
+ void setCardPresent(boolean cardPresent);
+
+ String getExpirationDate();
+
+ void setExpirationDate(String expiradationDate);
+
+ BigDecimal getTipAmount();
+
+ void setTipAmount(BigDecimal tipAmount);
+
+ BigDecimal getCashBackAmount();
+
+ void setCashBackAmount(BigDecimal cashBackAmount);
+
+ String getAvsResponseCode();
+
+ void setAvsResponseCode(String avsResponseCode);
+
+ String getAvsResponseText();
+
+ void setAvsResponseText(String avsResponseText);
+
+ String getCvvResponseCode();
+
+ void setCvvResponseCode(String cvvResponseCode);
+
+ String getCvvResponseText();
+
+ void setCvvResponseText(String cvvResponseText);
+
+ boolean getTaxExempt();
+
+ void setTaxExempt(boolean taxExempt);
+
+ String getTaxExemptId();
+
+ void setTaxExemptId(String taxExemptId);
+
+ String getTicketNumber();
+
+ void setTicketNumber(String ticketNumber);
+
+ String getPaymentType();
+
+ void setPaymentType(String paymentType);
+
+ String getApplicationPreferredName();
+
+ void setApplicationPreferredName(String applicationPreferredName);
+
+ String getApplicationLabel();
+
+ void setApplicationLabel(String applicationLabel);
+
+ String getApplicationId();
+
+ void setApplicationId(String applicationId);
+
+ ApplicationCryptogramType getApplicationCryptogramType();
+
+ void setApplicationCryptogramType(ApplicationCryptogramType applicationCryptogramType);
+
+ String getApplicationCryptogram();
+
+ void setApplicationCryptogram(String applicationCryptogram);
+
+ String getCardHolderVerificationMethod();
+
+ void setCardHolderVerificationMethod(String cardHolderVerificationMethod);
+
+ String getTerminalVerificationResults();
+
+ void setTerminalVerificationResults(String terminalVerificationResults);
+
+ //--
+ String getCurrencyCode();
+
+ void setCurrencyCode(String currencyCode);
+
+ String getPrivateData();
+
+ void setPrivateData(String privateData);
+
+ BigDecimal getFinalTransactionAmount();
+
+ void setFinalTransactionAmount(BigDecimal finalTransactionAmount);
+
+ String getPaymentMethod();
+
+ void setPaymentMethod(PaymentMethod paymentMethod);
+
+ String getTransactionSubType();
+
+ void setTransactionSubType(TransactionSubTypes transactionSubType);
+
+ BigDecimal getSplitSaleAmount();
+
+ void setSplitSaleAmount(BigDecimal splitSaleAmount);
+
+ BigDecimal getDynamicCurrencyCodeAmount();
+
+ void setDyanmicCurrencyCodeAmount(BigDecimal dynamicCurrencyCodeAmount);
+
+ String getDynamicCurrencyCode();
+
+ void setDynamicCurrencyCode(String dynamicCurrencyCode);
+
+ String getDynamicCurrencyCodeStatus();
+
+ void setDynamicCurrencyCodeStatus(DynamicCurrencyStatus status);
+
+ String getPaymentMode();
+
+ void setPaymentMode(PaymentMode paymentMode);
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalAuthBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalAuthBuilder.java
new file mode 100644
index 0000000..c429e55
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalAuthBuilder.java
@@ -0,0 +1,313 @@
+package com.global.api.terminals.builders;
+
+import com.global.api.ServicesContainer;
+import com.global.api.entities.enums.CurrencyType;
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.TaxType;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.paymentMethods.IPaymentMethod;
+import com.global.api.paymentMethods.TransactionReference;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+import com.global.api.terminals.ingenico.variables.PATPaymentMode;
+import com.global.api.terminals.ingenico.variables.PATResponseType;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+import com.global.api.terminals.ingenico.variables.TaxFreeType;
+import com.global.api.terminals.ingenico.variables.TransactionStatus;
+
+import java.math.BigDecimal;
+import java.util.EnumSet;
+
+public class TerminalAuthBuilder extends TerminalBuilder {
+
+ private boolean allowDuplicates;
+ private BigDecimal amount;
+ private BigDecimal cashBackAmount;
+ private CurrencyType currency;
+ private String customerCode;
+ private BigDecimal gratuity;
+ private String invoiceNumber;
+ private String poNumber;
+ private boolean requestMultiUseToken;
+ private boolean signatureCapture;
+ private BigDecimal taxAmount;
+ private String taxExempt;
+ private String taxExemptId;
+ private String transactionId;
+ private String authCode;
+
+ // ingenico properties
+ private String currencyCode;
+ private String tableNumber;
+ private PaymentMode paymentMode;
+ private TaxFreeType taxFreeType;
+ private String xmlPath;
+ private TransactionStatus transactionStatus;
+ private PATResponseType pattResponseType;
+ private PATPaymentMode pattPaymentMode;
+
+ public boolean isAllowDuplicates() {
+ return allowDuplicates;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public String getAuthCode() {
+ if (paymentMethod instanceof TransactionReference)
+ return ((TransactionReference) paymentMethod).getAuthCode();
+ return null;
+ }
+
+ public BigDecimal getCashBackAmount() {
+ return cashBackAmount;
+ }
+
+ public CurrencyType getCurrency() {
+ return currency;
+ }
+
+ public BigDecimal getGratuity() {
+ return gratuity;
+ }
+
+ public String getInvoiceNumber() {
+ return invoiceNumber;
+ }
+
+ public boolean isRequestMultiUseToken() {
+ return requestMultiUseToken;
+ }
+
+ public boolean isSignatureCapture() {
+ return signatureCapture;
+ }
+
+ public String getTransactionId() {
+ if (paymentMethod instanceof TransactionReference)
+ ((TransactionReference) paymentMethod).getTransactionId();
+ return null;
+ }
+
+ public String getCustomerCode() {
+ return customerCode;
+ }
+
+ public String getPoNumber() {
+ return poNumber;
+ }
+
+ public BigDecimal getTaxAmount() {
+ return taxAmount;
+ }
+
+ public String getTaxExempt() {
+ return taxExempt;
+ }
+
+ public String getTaxExemptId() {
+ return taxExemptId;
+ }
+
+ public String getTableNumber() {
+ return tableNumber;
+ }
+
+ public String getCurrencyCode() {
+ return currencyCode;
+ }
+
+ public PaymentMode getPaymentMode() {
+ return paymentMode;
+ }
+
+ public TaxFreeType getTaxFreeType() {
+ return taxFreeType;
+ }
+
+ public String getXMLPath() {
+ return xmlPath;
+ }
+
+ public TransactionStatus getTransactionStatus() {
+ return transactionStatus;
+ }
+
+ public PATResponseType getPATTResponseType() {
+ return pattResponseType;
+ }
+
+ public PATPaymentMode getPATTPaymentMode() {
+ return pattPaymentMode;
+ }
+
+ public TerminalAuthBuilder withAllowDuplicates(boolean allowDuplicates) {
+ this.allowDuplicates = allowDuplicates;
+ return this;
+ }
+
+ public TerminalAuthBuilder withAmount(BigDecimal amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ public TerminalAuthBuilder withAuthCode(String value) {
+ if (paymentMethod == null || !(paymentMethod instanceof TransactionReference))
+ paymentMethod = new TransactionReference();
+ ((TransactionReference) paymentMethod).setAuthCode(value);
+ this.authCode = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withCashBack(BigDecimal value) {
+ this.cashBackAmount = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTaxFree(TaxFreeType value) {
+ this.taxFreeType = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withCurrency(CurrencyType value) {
+ this.currency = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withCustomerCode(String value) {
+ this.customerCode = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withGratuity(BigDecimal gratuity) {
+ this.gratuity = gratuity;
+ return this;
+ }
+
+ public TerminalAuthBuilder withInvoiceNumber(String invoiceNumber) {
+ this.invoiceNumber = invoiceNumber;
+ return this;
+ }
+
+ public TerminalAuthBuilder withPaymentMethod(IPaymentMethod method) {
+ paymentMethod = method;
+ return this;
+ }
+
+ public TerminalAuthBuilder withPoNumber(String value) {
+ this.poNumber = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withRequestMultiUseToken(boolean requestMultiUseToken) {
+ this.requestMultiUseToken = requestMultiUseToken;
+ return this;
+ }
+
+ public TerminalAuthBuilder withSignatureCapture(boolean signatureCapture) {
+ this.signatureCapture = signatureCapture;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTaxAmount(BigDecimal value) {
+ this.taxAmount = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTaxType(TaxType value) {
+ return withTaxType(value, null);
+ }
+
+ public TerminalAuthBuilder withTaxType(TaxType value, String taxExemptId) {
+ this.taxExempt = (value.equals(TaxType.TaxExempt)) ? "1" : "0";
+ this.taxExemptId = taxExemptId;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTransactionId(String value) {
+ if (paymentMethod == null || !(paymentMethod instanceof TransactionReference))
+ paymentMethod = new TransactionReference();
+ ((TransactionReference) paymentMethod).setTransactionId(value);
+ this.transactionId = value;
+ return this;
+ }
+
+ // ingenico methods
+ public TerminalAuthBuilder withCurrencyCode(String value) {
+ this.currencyCode = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTableNumber(String value) {
+ this.tableNumber = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withPaymentMode(PaymentMode value) {
+ this.paymentMode = value;
+ return this;
+ }
+
+ public TerminalAuthBuilder withPATTPaymentMode(PATPaymentMode pattPaymentMode) {
+ this.pattPaymentMode = pattPaymentMode;
+ return this;
+ }
+
+ public TerminalAuthBuilder withPATTResponseType(PATResponseType pattResponseType) {
+ this.pattResponseType = pattResponseType;
+ return this;
+ }
+
+ public TerminalAuthBuilder withXML(String xmlPath) {
+ this.xmlPath = xmlPath;
+ return this;
+ }
+
+ public TerminalAuthBuilder withTransactionStatus(TransactionStatus transactionStatus) {
+ this.transactionStatus = transactionStatus;
+ return this;
+ }
+
+ public TerminalAuthBuilder(TransactionType type, PaymentMethodType paymentType) {
+ super(type, paymentType);
+ }
+
+ public ITerminalResponse execute(String configName) throws ApiException {
+ super.execute(configName);
+
+ DeviceController device = ServicesContainer.getInstance().getDeviceController(configName);
+ return device.processTransaction(this);
+ }
+
+ public void setupValidations() {
+ this.validations.of(EnumSet.of(TransactionType.Sale, TransactionType.Auth))
+ .check("amount").isNotNull();
+ this.validations.of(TransactionType.Refund).check("amount").isNotNull();
+ this.validations.of(TransactionType.Auth).with(PaymentMethodType.Credit)
+ .when("transactionId").isNotNull()
+ .check("authCode").isNotNull();
+ this.validations.of(TransactionType.Refund).with(PaymentMethodType.Credit)
+ .when("transactionId").isNotNull()
+ .check("authCode").isNotNull();
+ this.validations.of(PaymentMethodType.Gift).check("currency").isNotNull();
+ this.validations.of(TransactionType.AddValue).check("amount").isNotNull();
+
+ this.validations.of(PaymentMethodType.EBT).with(TransactionType.Balance)
+ .when("currency").isNotNull()
+ .check("currency").isNotEqual(CurrencyType.Voucher);
+ this.validations.of(TransactionType.BenefitWithdrawal).when("currency")
+ .isNotNull().check("currency")
+ .isEqualTo(CurrencyType.CashBenefits);
+ this.validations.of(PaymentMethodType.EBT).with(TransactionType.Refund)
+ .check("allowDuplicates")
+ .isEqualTo(false);
+ this.validations.of(PaymentMethodType.EBT).with(TransactionType.BenefitWithdrawal)
+ .check("allowDuplicates")
+ .isEqualTo(false);
+ this.validations.of(PaymentMethodType.Other).with(TransactionType.PayAtTable)
+ .when("amount").isNull()
+ .check("xmlPath").isNotNull();
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalBuilder.java
new file mode 100644
index 0000000..6c3c1a7
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalBuilder.java
@@ -0,0 +1,40 @@
+package com.global.api.terminals.builders;
+
+import com.global.api.builders.TransactionBuilder;
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+
+public abstract class TerminalBuilder> extends
+ TransactionBuilder {
+ protected PaymentMethodType paymentMethodType;
+ protected Integer requestId;
+ protected Integer referenceNumber;
+
+ public PaymentMethodType getPaymentMethodType() {
+ return paymentMethodType;
+ }
+
+ public Integer getRequestId() {
+ return requestId;
+ }
+
+ public Integer getReferenceNumber() {
+ return referenceNumber;
+ }
+
+ public T withRequestId(Integer value) {
+ requestId = value;
+ return (T) this;
+ }
+
+ public T withReferenceNumber(Integer value) {
+ referenceNumber = value;
+ return (T) this;
+ }
+
+ TerminalBuilder(TransactionType type, PaymentMethodType paymentType) {
+ super(type);
+ paymentMethodType = paymentType;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalManageBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalManageBuilder.java
new file mode 100644
index 0000000..68d096d
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalManageBuilder.java
@@ -0,0 +1,119 @@
+package com.global.api.terminals.builders;
+
+import com.global.api.ServicesContainer;
+import com.global.api.entities.enums.CurrencyType;
+import com.global.api.entities.enums.PaymentMethodType;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.paymentMethods.TransactionReference;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+
+import java.math.BigDecimal;
+
+public class TerminalManageBuilder extends TerminalBuilder {
+ private BigDecimal amount;
+ private CurrencyType currency;
+ private BigDecimal gratuity;
+ private String currencyCode;
+ private PaymentMode paymentMode;
+ private String authCode;
+ private String tableNumber;
+ private String transactionId;
+
+ public String getTableNumber() {
+ return tableNumber;
+ }
+
+ public String getCurrencyCode() {
+ return currencyCode;
+ }
+
+ public PaymentMode getPaymentMode() {
+ return paymentMode;
+ }
+
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public CurrencyType getCurrency() {
+ return currency;
+ }
+
+ public BigDecimal getGratuity() {
+ return gratuity;
+ }
+
+ public String getTransactionId() {
+ if (paymentMethod instanceof TransactionReference)
+ return ((TransactionReference) paymentMethod).getTransactionId();
+ return null;
+ }
+
+ public TerminalManageBuilder withCurrencyCode(String value) {
+ this.currencyCode = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withTableNumber(String value) {
+ this.tableNumber = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withAuthCode(String value) {
+ if (paymentMethod == null || !(paymentMethod instanceof TransactionReference))
+ paymentMethod = new TransactionReference();
+ ((TransactionReference) paymentMethod).setAuthCode(value);
+ this.authCode = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withAmount(BigDecimal value) {
+ this.amount = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withCurrency(CurrencyType value) {
+ this.currency = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withGratuity(BigDecimal value) {
+ this.gratuity = value;
+ return this;
+ }
+
+ public TerminalManageBuilder withTransactionId(String value) {
+ if (paymentMethod == null || !(paymentMethod instanceof TransactionReference))
+ paymentMethod = new TransactionReference();
+ ((TransactionReference) paymentMethod).setTransactionId(value);
+ this.transactionId = value;
+ return this;
+ }
+
+ public TerminalManageBuilder(TransactionType type, PaymentMethodType paymentType) {
+ super(type, paymentType);
+ }
+
+ @Override
+ public ITerminalResponse execute(String configName) throws ApiException {
+ super.execute(configName);
+
+ DeviceController device = ServicesContainer.getInstance().getDeviceController(configName);
+ return device.manageTransaction(this);
+ }
+
+ public void setupValidations() {
+ this.validations.of(TransactionType.Capture).when("authCode").isNull()
+ .check("transactionId").isNotNull();
+ this.validations.of(TransactionType.Void).check("transactionId").isNotNull();
+ this.validations.of(PaymentMethodType.Gift).check("currency").isNotNull();
+ this.validations.of(TransactionType.Cancel).check("amount").isNotNull();
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalReportBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalReportBuilder.java
new file mode 100644
index 0000000..fd9dc64
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalReportBuilder.java
@@ -0,0 +1,69 @@
+package com.global.api.terminals.builders;
+
+import com.global.api.ServicesContainer;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.TerminalReportType;
+import com.global.api.terminals.abstractions.ITerminalReport;
+import com.global.api.terminals.ingenico.variables.ReceiptType;
+import com.global.api.terminals.ingenico.variables.ReportTypes;
+
+public class TerminalReportBuilder {
+ private TerminalReportType reportType;
+ private ReceiptType receiptType;
+ private ReportTypes type;
+ private TerminalSearchBuilder _searchBuilder;
+
+ public TerminalReportType getReportType() {
+ return reportType;
+ }
+
+ public void setReportType(TerminalReportType reportType) {
+ this.reportType = reportType;
+ }
+
+ public ReceiptType getReceiptType() {
+ return receiptType;
+ }
+
+ public void setReceiptType(ReceiptType receiptType) {
+ this.receiptType = receiptType;
+ }
+
+ public ReportTypes getType() {
+ return type;
+ }
+
+ public void setType(ReportTypes type) {
+ this.type = type;
+ }
+
+ public TerminalSearchBuilder getSearchBuilder() {
+ if (_searchBuilder == null) {
+ _searchBuilder = new TerminalSearchBuilder(this);
+ }
+ return _searchBuilder;
+
+ }
+
+ public TerminalReportBuilder(TerminalReportType reportType) {
+ this.reportType = reportType;
+ }
+
+ public TerminalReportBuilder(ReceiptType receiptType) {
+ this.receiptType = receiptType;
+ }
+
+ public TerminalReportBuilder(ReportTypes type) {
+ this.type = type;
+ }
+
+ public ITerminalReport execute() throws ApiException {
+ return execute("default");
+ }
+
+ public ITerminalReport execute(String configName) throws ApiException {
+ DeviceController device = ServicesContainer.getInstance().getDeviceController(configName);
+ return device.processReport(this);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalSearchBuilder.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalSearchBuilder.java
new file mode 100644
index 0000000..44dc619
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/builders/TerminalSearchBuilder.java
@@ -0,0 +1,98 @@
+package com.global.api.terminals.builders;
+
+import java.lang.reflect.Field;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.abstractions.ITerminalReport;
+
+public class TerminalSearchBuilder {
+ private TerminalReportBuilder _reportBuilder;
+
+ private int recordNumber;
+ private int terminalReferenceNumber;
+ private String authCode;
+ private String referenceNumber;
+ private int merchantId;
+ private String merchantName;
+
+ public int getRecordNumber() {
+ return recordNumber;
+ }
+
+ public void setRecordNumber(int recordNumber) {
+ this.recordNumber = recordNumber;
+ }
+
+ public int getTerminalReferenceNumber() {
+ return terminalReferenceNumber;
+ }
+
+ public void setTerminalReferenceNumber(int terminalReferenceNumber) {
+ this.terminalReferenceNumber = terminalReferenceNumber;
+ }
+
+ public String getAuthCode() {
+ return authCode;
+ }
+
+ public void setAuthCode(String authCode) {
+ this.authCode = authCode;
+ }
+
+ public String getReferenceNumber() {
+ return referenceNumber;
+ }
+
+ public void setReferenceNumber(String referenceNumber) {
+ this.referenceNumber = referenceNumber;
+ }
+
+ public int getMerchantId() {
+ return merchantId;
+ }
+
+ public void setMerchantId(int merchantId) {
+ this.merchantId = merchantId;
+ }
+
+ public String getMerchantName() {
+ return merchantName;
+ }
+
+ public void setMerchantName(String merchantName) {
+ this.merchantName = merchantName;
+ }
+
+ public TerminalSearchBuilder(TerminalReportBuilder reportBuilder) {
+ _reportBuilder = reportBuilder;
+ }
+
+ public ITerminalReport execute() throws ApiException {
+ return execute("default");
+ }
+
+ public ITerminalReport execute(String configName) throws ApiException {
+ return _reportBuilder.execute(configName);
+ }
+
+ private void set(Object object, String fieldName, T fieldValue) {
+ Class> clazz = object.getClass();
+
+ // https://stackoverflow.com/questions/4052840/most-efficient-way-to-make-the-first-character-of-a-string-lower-case
+ char c[] = fieldName.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ fieldName = new String(c);
+
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ field.set(object, fieldValue);
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoController.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoController.java
new file mode 100644
index 0000000..90eafb8
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoController.java
@@ -0,0 +1,357 @@
+package com.global.api.terminals.ingenico;
+
+import android.util.Log;
+
+import java.io.RandomAccessFile;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.DecimalFormat;
+
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.ControlCodes;
+import com.global.api.entities.enums.TransactionType;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.BuilderException;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.DeviceController;
+import com.global.api.terminals.TerminalUtilities;
+import com.global.api.terminals.abstractions.IDeviceCommInterface;
+import com.global.api.terminals.abstractions.IDeviceInterface;
+import com.global.api.terminals.abstractions.IDeviceMessage;
+import com.global.api.terminals.abstractions.ITerminalConfiguration;
+import com.global.api.terminals.abstractions.ITerminalReport;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+import com.global.api.terminals.builders.TerminalAuthBuilder;
+import com.global.api.terminals.builders.TerminalManageBuilder;
+import com.global.api.terminals.builders.TerminalReportBuilder;
+import com.global.api.terminals.ingenico.interfaces.IngenicoTcpInterface;
+import com.global.api.terminals.ingenico.responses.IngenicoTerminalReceiptResponse;
+import com.global.api.terminals.ingenico.responses.IngenicoTerminalReportResponse;
+import com.global.api.terminals.ingenico.responses.IngenicoTerminalResponse;
+import com.global.api.terminals.ingenico.responses.ReverseResponse;
+import com.global.api.terminals.ingenico.variables.INGENICO_REQ_CMD;
+import com.global.api.terminals.ingenico.variables.INGENICO_RESP;
+import com.global.api.terminals.ingenico.variables.PATResponseType;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+import com.global.api.terminals.ingenico.variables.PaymentType;
+import com.global.api.terminals.ingenico.variables.TransactionStatus;
+import com.global.api.utils.Extensions;
+
+public class IngenicoController extends DeviceController {
+ private IDeviceInterface _device;
+
+ public IngenicoController(ITerminalConfiguration settings) throws ConfigurationException {
+ super(settings);
+ }
+
+ @Override
+ public IDeviceInterface configureInterface() throws ConfigurationException {
+ if (_device == null) {
+ _device = new IngenicoInterface(this);
+ }
+ return _device;
+ }
+
+ @Override
+ public IDeviceCommInterface configureConnector() throws ConfigurationException {
+ switch (settings.getConnectionMode()) {
+ case TCP_IP_SERVER:
+ case PAY_AT_TABLE:
+ return new IngenicoTcpInterface(settings);
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ @Override
+ public ITerminalResponse manageTransaction(TerminalManageBuilder builder) throws ApiException {
+ IDeviceMessage request = buildManageTransaction(builder);
+ if (builder.getTransactionType() == TransactionType.Reversal) {
+ return doReverseRequest(request);
+ } else {
+ return doRequest(request);
+ }
+ }
+
+ @Override
+ public ITerminalReport processReport(TerminalReportBuilder builder) throws ApiException {
+ IDeviceMessage request;
+ if (!isObjectNullOrEmpty(builder.getType())) {
+ request = buildReportTransaction(builder);
+ return reportRequest(request);
+ } else {
+ request = TerminalUtilities.buildIngenicoRequest(
+ String.format(new INGENICO_REQ_CMD().RECEIPT, builder.getReceiptType()),
+ settings.getConnectionMode());
+ return receiptRequest(request);
+ }
+ }
+
+ @Override
+ public ITerminalResponse processTransaction(TerminalAuthBuilder builder) throws ApiException {
+ IDeviceMessage request = null;
+ if (settings.getConnectionMode() == ConnectionModes.PAY_AT_TABLE) {
+ request = buildPATTResponseMessage(builder);
+ } else {
+ request = buildRequestMessage(builder);
+ }
+ return doRequest(request);
+ }
+
+ private byte[] getXMLContent(String xmlPath) throws BuilderException {
+ byte[] result;
+ String xmlContent;
+ byte[] xmlByteArr;
+
+ try {
+ if (xmlPath.isEmpty()) {
+ throw new BuilderException("XML Path is Empty");
+ }
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ xmlByteArr = Files.readAllBytes(Paths.get(xmlPath));
+ } else {
+ RandomAccessFile xml = new RandomAccessFile(xmlPath, "r");
+ byte[] b = new byte[(int) xml.length()];
+ xml.readFully(b);
+ xmlByteArr = b;
+ }
+ xmlContent = new String(xmlByteArr, StandardCharsets.UTF_8);
+ result = xmlContent.getBytes(StandardCharsets.UTF_8);
+ } catch (Exception e) {
+ throw new BuilderException(e.getMessage());
+ }
+
+ return result;
+ }
+
+ private IDeviceMessage buildReportTransaction(TerminalReportBuilder builder) throws BuilderException {
+ if (!isObjectNullOrEmpty(builder.getType())) {
+ String message = Extensions.formatWith(new INGENICO_REQ_CMD().REPORT, builder.getType());
+ return TerminalUtilities.buildIngenicoRequest(message, settings.getConnectionMode());
+ } else {
+ throw new BuilderException("Type of report is missing in request.");
+ }
+ }
+
+ private IDeviceMessage buildManageTransaction(TerminalManageBuilder builder) throws BuilderException {
+ Integer referenceNumber = builder.getReferenceNumber();
+ BigDecimal amount = validateAmount(builder.getAmount());
+ Integer returnRep = 1;
+ Integer paymentMode = 0;
+ Integer paymentType = ((IngenicoInterface) _device).getPaymentMethod() == null ? 0
+ : ((IngenicoInterface) _device).getPaymentMethod().getValue();
+ String currencyCode = "826";
+ String privateData = "EXT0100000";
+ String immediateAnswer = "A010";
+ String forceOnline = "B010";
+ String extendedData = "0000000000";
+
+ if (!isObjectNullOrEmpty(builder.getAuthCode())) {
+ extendedData = Extensions.formatWith(new INGENICO_REQ_CMD().AUTHCODE, builder.getAuthCode());
+ } else if (!isObjectNullOrEmpty(builder.getTransactionId())
+ && builder.getTransactionType() == TransactionType.Reversal) {
+ extendedData = Extensions.formatWith(new INGENICO_REQ_CMD().REVERSE_WITH_ID, builder.getTransactionId());
+ } else if (builder.getTransactionType() == TransactionType.Reversal) {
+ extendedData = new INGENICO_REQ_CMD().REVERSE;
+ }
+
+ DecimalFormat decimalFormat = new DecimalFormat("00000000");
+ StringBuilder message = new StringBuilder();
+ message.append(String.format("%02d", referenceNumber));
+ message.append(decimalFormat.format(amount));
+ message.append(returnRep);
+ message.append(paymentMode);
+ message.append(paymentType);
+ message.append(currencyCode);
+ message.append(privateData);
+ message.append(immediateAnswer);
+ message.append(forceOnline);
+ message.append(extendedData);
+
+ return TerminalUtilities.buildIngenicoRequest(message.toString(), settings.getConnectionMode());
+ }
+
+ private IDeviceMessage buildRequestMessage(TerminalAuthBuilder builder) throws BuilderException {
+ Integer referenceNumber = builder.getReferenceNumber();
+ BigDecimal amount = builder.getAmount();
+ Integer returnRep = 1;
+ Integer paymentMode = 0;
+ Integer paymentType = ((IngenicoInterface) _device).getPaymentMethod().getValue();
+ String currencyCode = "826";
+ String privateData = "EXT0100000";
+ String immediateAnswer = "A010";
+ String forceOnline = "B010";
+ String extendedData = "0000000000";
+
+ BigDecimal cashbackAmount = builder.getCashBackAmount();
+ String authCode = builder.getAuthCode();
+ String tableId = builder.getTableNumber();
+
+ if (!isObjectNullOrEmpty(requestIdProvider())) {
+ referenceNumber = requestIdProvider().getRequestId();
+ }
+
+ if (!isObjectNullOrEmpty(builder.getTaxFreeType()) && paymentType == PaymentType.REFUND.getValue()) {
+ Integer taxFree = builder.getTaxFreeType().toInteger();
+ PaymentType[] type = PaymentType.values();
+ for (PaymentType p : type) {
+ Integer typeValue = p.ordinal();
+ if (typeValue == taxFree) {
+ paymentType = typeValue;
+ break;
+ }
+ }
+ }
+
+ amount = validateAmount(amount);
+ paymentMode = validatePaymentMode(builder.getPaymentMode());
+ currencyCode = (!isObjectNullOrEmpty(builder.getCurrencyCode()) ? builder.getCurrencyCode() : currencyCode);
+
+ if (!isObjectNullOrEmpty(tableId)) {
+ validateTableReference(tableId);
+ extendedData = Extensions.formatWith(new INGENICO_REQ_CMD().TABLE_WITH_ID, tableId);
+ } else if (!isObjectNullOrEmpty(authCode)) {
+ extendedData = Extensions.formatWith(new INGENICO_REQ_CMD().AUTHCODE, authCode);
+ } else if (!isObjectNullOrEmpty(cashbackAmount)) {
+ cashbackAmount = validateCashbackAmount(cashbackAmount.toString());
+ extendedData = Extensions.formatWith(new INGENICO_REQ_CMD().CASHBACK, cashbackAmount);
+ }
+
+ DecimalFormat decimalFormat = new DecimalFormat("00000000");
+ StringBuilder message = new StringBuilder();
+ message.append(String.format("%02d", referenceNumber));
+ message.append(decimalFormat.format(amount));
+ message.append(returnRep);
+ message.append(paymentMode);
+ message.append(paymentType);
+ message.append(currencyCode);
+ message.append(privateData);
+ message.append(immediateAnswer);
+ message.append(forceOnline);
+ message.append(extendedData);
+
+ return TerminalUtilities.buildIngenicoRequest(message.toString(), settings.getConnectionMode());
+ }
+
+ private IDeviceMessage buildPATTResponseMessage(TerminalAuthBuilder builder) throws BuilderException {
+ StringBuilder message = new StringBuilder();
+
+ // PAT Functionalities
+ if (builder.getXMLPath() != null) {
+ byte[] content = getXMLContent(builder.getXMLPath());
+ String xml = new String(content, StandardCharsets.ISO_8859_1);
+ message.append(xml);
+ } else {
+ String referenceNumber = new INGENICO_RESP().PAT_EPOS_NUMBER;
+ Integer transactionStatus = TransactionStatus.SUCCESS.getValue();
+ BigDecimal amount = validateAmount(builder.getAmount());
+ Integer paymentMode = builder.getPATTPaymentMode().getValue();
+ String currencyCode = builder.getCurrencyCode();
+ String privateData = PATResponseType.getEnumName(builder.getPATTResponseType().getValue()).toString();
+
+ if (privateData.length() < 10) {
+ for (int i = privateData.length(); i < 10; i++) {
+ privateData += (char) ControlCodes.SP.getByte();
+ }
+ }
+ currencyCode = (!isObjectNullOrEmpty(builder.getCurrencyCode()) ? builder.getCurrencyCode() : currencyCode);
+
+ DecimalFormat decimalFormat = new DecimalFormat("00000000");
+ message.append(referenceNumber);
+ message.append(transactionStatus);
+ message.append(decimalFormat.format(amount));
+ message.append(paymentMode);
+ message.append(currencyCode);
+ message.append(privateData);
+
+ Log.i("MESSAGE", decimalFormat.format(amount));
+ }
+
+ return TerminalUtilities.buildIngenicoRequest(message.toString(), settings.getConnectionMode());
+ }
+
+ private static boolean isObjectNullOrEmpty(Object value) {
+ boolean response = false;
+
+ if (value == null || value.toString().isEmpty()) {
+ response = true;
+ }
+
+ return response;
+ }
+
+ private static void validateTableReference(String value) throws BuilderException {
+ if (value.length() > 8) {
+ throw new BuilderException("The maximum length of table number is 8.");
+ }
+ }
+
+ private static Integer validatePaymentMode(PaymentMode paymentMode) {
+ if (paymentMode == null) {
+ paymentMode = PaymentMode.APPLICATION;
+ }
+
+ return paymentMode.getValue();
+ }
+
+ private static BigDecimal validateCashbackAmount(String value) throws BuilderException {
+ BigDecimal cashbackAmount = new BigDecimal(value);
+
+ BigDecimal amount1hun = new BigDecimal("100");
+ if (cashbackAmount == null) {
+ throw new BuilderException("Cashback Amount must not be less than or equal to 0.");
+ } else if ((cashbackAmount.compareTo(BigDecimal.ZERO) > 0) && (cashbackAmount.compareTo(amount1hun) <= 0)) {
+ cashbackAmount = cashbackAmount.multiply(new BigDecimal("100"));
+ cashbackAmount = cashbackAmount.setScale(0, BigDecimal.ROUND_HALF_EVEN);
+ } else if (cashbackAmount.compareTo(amount1hun) > 0) {
+ throw new BuilderException("Cashback Amount exceeded.");
+ } else {
+ throw new BuilderException("Invalid input amount.");
+ }
+
+ return cashbackAmount;
+ }
+
+ private static BigDecimal validateAmount(BigDecimal amount) throws BuilderException {
+ BigDecimal amount1mil = new BigDecimal("1000000");
+
+ if (amount == null) {
+ throw new BuilderException("Amount cannot be null.");
+ } else if ((amount.compareTo(BigDecimal.ZERO) > 0) && (amount.compareTo(amount1mil) < 0)) {
+ amount = amount.multiply(new BigDecimal("100"));
+ } else if ((amount.compareTo(amount1mil) == 0) && (amount.compareTo(amount1mil) > 0)) {
+ throw new BuilderException("Amount exceeded.");
+ } else {
+ throw new BuilderException("Invalid input amount.");
+ }
+
+ return amount;
+ }
+
+ public ITerminalConfiguration getConfiguration() {
+ return settings;
+ }
+
+ private IngenicoTerminalReceiptResponse receiptRequest(IDeviceMessage request) throws ApiException {
+ byte[] send = send(request);
+ return new IngenicoTerminalReceiptResponse(send);
+ }
+
+ private IngenicoTerminalReportResponse reportRequest(IDeviceMessage request) throws ApiException {
+ byte[] send = send(request);
+ return new IngenicoTerminalReportResponse(send);
+ }
+
+ private IngenicoTerminalResponse doRequest(IDeviceMessage request) throws ApiException {
+ byte[] response = send(request);
+ return new IngenicoTerminalResponse(response, ParseFormat.Transaction);
+ }
+
+ private ReverseResponse doReverseRequest(IDeviceMessage request) throws ApiException {
+ byte[] response = send(request);
+ return new ReverseResponse(response);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoInterface.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoInterface.java
new file mode 100644
index 0000000..21f7ffc
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/IngenicoInterface.java
@@ -0,0 +1,174 @@
+package com.global.api.terminals.ingenico;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.UnsupportedTransactionException;
+import com.global.api.terminals.abstractions.*;
+import com.global.api.terminals.builders.*;
+import com.global.api.terminals.ingenico.responses.CancelResponse;
+import com.global.api.terminals.ingenico.responses.IngenicoTerminalResponse;
+import com.global.api.terminals.ingenico.responses.*;
+import com.global.api.terminals.ingenico.variables.INGENICO_REQ_CMD;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.PaymentType;
+import com.global.api.terminals.ingenico.variables.ReceiptType;
+import com.global.api.terminals.ingenico.variables.ReportTypes;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.*;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+
+import java.math.BigDecimal;
+
+public class IngenicoInterface extends DeviceInterface implements IDeviceInterface {
+ private PaymentType paymentMethod = null;
+
+ IngenicoInterface(IngenicoController controller) {
+ super(controller);
+ }
+
+ public PaymentType getPaymentMethod() {
+ return paymentMethod;
+ }
+
+ public void setPaymentMethod(PaymentType paymentMethod) {
+ this.paymentMethod = paymentMethod;
+ }
+
+ public void setOnMessageSent(IMessageSentInterface onMessageSent) {
+ this.onMessageSent = onMessageSent;
+ }
+
+ public void setOnBroadcastMessageReceived(IBroadcastMessageInterface onBroadcastReceived) {
+ this.onBroadcastMessage = onBroadcastReceived;
+ }
+
+ public void setOnPayAtTableRequest(IOnPayAtTableRequestInterface onPayAtTableRequest) {
+ this.onPayAtTableRequest = onPayAtTableRequest;
+ }
+
+ @Override
+ public TerminalAuthBuilder sale(BigDecimal amount) throws ApiException {
+ paymentMethod = PaymentType.SALE;
+ return super.sale(amount);
+ }
+
+ @Override
+ public TerminalAuthBuilder refund(BigDecimal amount) throws ApiException {
+ paymentMethod = PaymentType.REFUND;
+ return super.refund(amount);
+ }
+
+ @Override
+ public TerminalManageBuilder capture(BigDecimal amount) throws ApiException {
+ paymentMethod = PaymentType.COMPLETION;
+ return super.capture(amount);
+ }
+
+ @Override
+ public TerminalAuthBuilder authorize(BigDecimal amount) throws ApiException {
+ paymentMethod = PaymentType.PREAUTH;
+ return super.authorize(amount);
+ }
+
+ @Override
+ public TerminalAuthBuilder verify() throws ApiException {
+ paymentMethod = PaymentType.ACCOUNT_VERIFICATION;
+ return super.verify();
+ }
+
+ @Override
+ public TerminalReportBuilder getReport(ReportTypes type) throws ApiException {
+ return super.getReport(type);
+ }
+
+ @Override
+ public TerminalReportBuilder getLastReceipt(ReceiptType type) throws ApiException {
+ return super.getLastReceipt(type);
+ }
+
+ @Override
+ public TerminalAuthBuilder payAtTableResponse() throws ApiException {
+ return super.payAtTableResponse();
+ }
+
+ @Override
+ public IDeviceResponse duplicate() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().DUPLICATE);
+
+ byte[] response = _controller
+ .send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new IngenicoTerminalResponse(response, ParseFormat.Transaction);
+ }
+
+ @Override
+ public IDeviceResponse cancel() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().CANCEL);
+
+ byte[] response = _controller
+ .send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new CancelResponse(response);
+ }
+
+ @Override
+ public TerminalManageBuilder reverse(BigDecimal amount) throws ApiException {
+ if (amount != null) {
+ return super.reverse(amount);
+ } else {
+ throw new UnsupportedTransactionException("Amount can't be null");
+ }
+ }
+
+ @Override
+ public IDeviceResponse getTerminalConfiguration() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().CALL_TMS);
+
+ byte[] response = _controller.send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new IngenicoTerminalResponse(response, ParseFormat.Transaction);
+ }
+
+ @Override
+ public IDeviceResponse testConnection() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().LOGON);
+
+ byte[] response = _controller.send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new IngenicoTerminalResponse(response, ParseFormat.Transaction);
+ }
+
+ @Override
+ public IDeviceResponse getTerminalStatus() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().STATE);
+
+ byte[] response = _controller.send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new TerminalStateResponse(response);
+ }
+
+ @Override
+ public IDeviceResponse reboot() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().RESET);
+
+ byte[] response = _controller.send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new IngenicoTerminalResponse(response, ParseFormat.Transaction);
+ }
+
+ @Override
+ public IInitializeResponse initialize() throws ApiException {
+ StringBuilder sb = new StringBuilder();
+ sb.append(new INGENICO_REQ_CMD().REQUEST_MESSAGE);
+ sb.append(new INGENICO_REQ_CMD().PID);
+
+ byte[] response = _controller.send(TerminalUtilities.buildIngenicoRequest(sb.toString(), _controller.getConnectionModes()));
+ return new POSIdentifierResponse(response);
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/interfaces/IngenicoTcpInterface.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/interfaces/IngenicoTcpInterface.java
new file mode 100644
index 0000000..9d90d49
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/interfaces/IngenicoTcpInterface.java
@@ -0,0 +1,340 @@
+package com.global.api.terminals.ingenico.interfaces;
+
+import android.util.Log;
+
+import com.global.api.entities.enums.ConnectionModes;
+import com.global.api.entities.enums.ControlCodes;
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.entities.exceptions.ConfigurationException;
+import com.global.api.terminals.TerminalUtilities;
+import com.global.api.terminals.abstractions.IDeviceCommInterface;
+import com.global.api.terminals.abstractions.IDeviceMessage;
+import com.global.api.terminals.abstractions.ITerminalConfiguration;
+import com.global.api.terminals.ingenico.pat.PATRequest;
+import com.global.api.terminals.ingenico.responses.BroadcastMessage;
+import com.global.api.terminals.ingenico.variables.INGENICO_GLOBALS;
+import com.global.api.terminals.messaging.IBroadcastMessageInterface;
+import com.global.api.terminals.messaging.IMessageSentInterface;
+import com.global.api.terminals.messaging.IOnPayAtTableRequestInterface;
+import com.global.api.utils.MessageWriter;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+
+import static java.nio.charset.StandardCharsets.*;
+
+public class IngenicoTcpInterface implements IDeviceCommInterface {
+ private ServerSocket _serverSocket;
+ private Socket _socket;
+ private ITerminalConfiguration _settings;
+ private byte[] _terminalResponse;
+ private Thread dataReceiving;
+ private boolean _isKeepAlive;
+ private Exception _receivingException;
+ private BroadcastMessage _broadcastMessage;
+ private boolean _isResponseNeeded = false;
+ private DataOutputStream _out;
+ private DataInputStream _in;
+
+ private boolean _readData;
+
+ private IBroadcastMessageInterface onBroadcastMessage;
+ private IMessageSentInterface onMessageSent;
+ private IOnPayAtTableRequestInterface _onPayAtTableRequest;
+
+ public IngenicoTcpInterface(ITerminalConfiguration settings) throws ConfigurationException {
+ try {
+ this._settings = settings;
+ this._socket = new Socket();
+ connect();
+
+ } catch (ConfigurationException e) {
+ throw e;
+ }
+ }
+
+ //region Override methods
+ @Override
+ public void connect() throws ConfigurationException {
+ try {
+ // Start Server socket
+ initializeServer();
+
+ // Accept client
+ acceptClient();
+
+ // Start thread for Receiving data.
+ if (dataReceiving == null) {
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ analyzeReceivedData();
+ } catch (ApiException e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+ }
+
+ } catch (ConfigurationException | IOException e) {
+ throw new ConfigurationException(e.getMessage());
+ }
+ }
+
+ @Override
+ public void disconnect() {
+ try {
+ if (_serverSocket != null || !_serverSocket.isClosed()) {
+ if (!_isKeepAlive) {
+ _socket.setSoTimeout(1000);
+ }
+
+ _readData = false;
+ _in.close();
+ _out.close();
+ _socket.close();
+ _serverSocket.close();
+ }
+ _serverSocket = null;
+ } catch (IOException e) {
+ // Eating the close exception
+ }
+ }
+
+ @Override
+ public byte[] send(IDeviceMessage message) throws ApiException {
+
+ _terminalResponse = null;
+ _isResponseNeeded = true;
+
+ final byte[] buffer = message.getSendBuffer();
+
+ try {
+ if (_serverSocket == null) {
+ throw new ConfigurationException("Error: Server is not running.");
+ }
+
+ // Send request from builder.
+ _socket.setSoTimeout(_settings.getTimeout());
+ _out.write(buffer, 0, buffer.length);
+ _out.flush();
+
+ onMessageSent.messageSent(TerminalUtilities.getString(buffer).substring(2));
+
+ while (_terminalResponse == null) {
+ Thread.sleep(10);
+
+ if (_receivingException != null) {
+
+ _socket.setSoTimeout(0);
+
+ String exceptionMessage = _receivingException.getMessage();
+ _receivingException = null;
+
+ throw new ApiException(exceptionMessage);
+ }
+
+ if (_terminalResponse != null) {
+
+ _socket.setSoTimeout(0);
+
+ _isResponseNeeded = false;
+ return _terminalResponse;
+ }
+ }
+ } catch (InterruptedException | IOException | ApiException e) {
+ throw new ApiException(e.getMessage());
+ }
+ return new byte[0];
+ }
+
+ @Override
+ public void setMessageSentHandler(IMessageSentInterface messageInterface) {
+ this.onMessageSent = messageInterface;
+ }
+
+ @Override
+ public void setBroadcastMessageHandler(IBroadcastMessageInterface broadcastInterface) {
+ this.onBroadcastMessage = broadcastInterface;
+ }
+
+ @Override
+ public void setOnPayAtTableRequestHandler(IOnPayAtTableRequestInterface onPayAtTable) {
+ this._onPayAtTableRequest = onPayAtTable;
+ }
+
+ //endregion
+ private void initializeServer() throws ConfigurationException, IOException {
+ try {
+ if (!_settings.getPort().isEmpty()) {
+ int port = Integer.parseInt(_settings.getPort());
+ if (_serverSocket != null) {
+ _serverSocket.close();
+ }
+
+ // Start listening on set port.
+ _serverSocket = new ServerSocket(port);
+ _readData = true;
+ _receivingException = null;
+
+ _isKeepAlive = false;
+
+ } else {
+ throw new ConfigurationException("Port is missing.");
+ }
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ private void acceptClient() throws IOException {
+ try {
+ if (_serverSocket != null) {
+ // Accept client here
+ _socket = _serverSocket.accept();
+
+ // Set timeout of data read
+
+ // Get input and output stream from client.
+ _out = new DataOutputStream(_socket.getOutputStream());
+ _in = new DataInputStream(_socket.getInputStream());
+ }
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ private void analyzeReceivedData() throws ApiException {
+ try {
+ byte[] headerBuffer = new byte[2];
+
+ while (_readData) {
+ if (_settings.getConnectionMode() == ConnectionModes.PAY_AT_TABLE) {
+ byte[] buffer = new byte[8192];
+ _in.read(buffer, 0, buffer.length);
+
+ MessageWriter byteArr = new MessageWriter();
+ for (int i = 0; i < buffer.length; i++) {
+ byteArr.add(buffer[i]);
+
+ if (buffer[i] == ControlCodes.ETX.getByte()) {
+ byteArr.add(buffer[i + 1]);
+ break;
+ }
+ }
+
+ Integer arrLen = byteArr.toArray().length;
+ if (arrLen > 0) {
+ String raw = TerminalUtilities.getString(byteArr.toArray());
+ String dataETX = raw.substring(1, raw.length() - 2);
+
+ String receivedLRC = raw.substring(raw.length() - 1);
+
+ byte[] calculateLRC = TerminalUtilities.calculateLRC(dataETX);
+ String calculatedLRC = new String(calculateLRC, StandardCharsets.UTF_8);
+
+ if (calculatedLRC.contentEquals(receivedLRC)) {
+ String data = raw.substring(1, raw.length() - 2);
+
+ PATRequest patRequest = new PATRequest(data.getBytes());
+ if (_onPayAtTableRequest != null) {
+ _onPayAtTableRequest.onPayAtTableRequest(patRequest);
+ }
+ }
+ }
+ } else {
+ int readHeader = _in.read(headerBuffer, 0, headerBuffer.length);
+
+ if (!_readData) {
+ break;
+ }
+
+ if (!_isKeepAlive && _isResponseNeeded) {
+ _socket.setSoTimeout(_settings.getTimeout());
+ }
+
+ if (readHeader == -1) {
+ _receivingException = new ApiException("Terminal disconnected");
+ }
+
+ int dataLength = TerminalUtilities.headerLength(headerBuffer);
+ if (dataLength > 0) {
+ byte[] dataBuffer = new byte[dataLength];
+
+ boolean incomplete = true;
+ int offset = 0;
+ int tempLength = dataLength;
+
+ do {
+ int bytesReceived = _in.read(dataBuffer, offset, tempLength);
+
+ if (!_readData) {
+ break;
+ }
+
+ if (bytesReceived != tempLength) {
+ offset += bytesReceived;
+ tempLength -= bytesReceived;
+ } else {
+ incomplete = false;
+ }
+ } while (incomplete);
+
+ byte[] readBuffer = new byte[dataLength];
+ System.arraycopy(dataBuffer, 0, readBuffer, 0, dataLength);
+
+ if (isBroadcast(readBuffer)) {
+ BroadcastMessage broadcastMessage = new BroadcastMessage(readBuffer);
+ if (onBroadcastMessage != null) {
+ onBroadcastMessage.broadcastReceived(broadcastMessage.getCode(),
+ broadcastMessage.getMessage());
+ }
+ } else if (isKeepAlive(readBuffer) && new INGENICO_GLOBALS().KEEPALIVE) {
+ _isKeepAlive = true;
+ byte[] kResponse = keepAliveResponse(readBuffer);
+ _out.write(kResponse);
+ _out.flush();
+ } else {
+ _terminalResponse = readBuffer;
+ Log.i("RESPONSE:", String.valueOf(_terminalResponse.length));
+ }
+ } else {
+ _receivingException = new ApiException("No data received");
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (_isResponseNeeded || _isKeepAlive) {
+ _receivingException = new ApiException("Socket Error: " + e.getMessage());
+ }
+
+ if (_readData) {
+ analyzeReceivedData();
+ }
+ }
+ }
+
+ private boolean isBroadcast(byte[] buffer) {
+ return TerminalUtilities.getString(buffer).contains(new INGENICO_GLOBALS().BROADCAST);
+ }
+
+ private boolean isKeepAlive(byte[] buffer) {
+ return TerminalUtilities.getString(buffer).contains(new INGENICO_GLOBALS().TID_CODE);
+ }
+
+ private byte[] keepAliveResponse(byte[] buffer) {
+ if (buffer.length > 0) {
+ int tidIndex = TerminalUtilities.getString(buffer).indexOf(new INGENICO_GLOBALS().TID_CODE);
+ String terminalId = TerminalUtilities.getString(buffer);
+ String response = String.format(new INGENICO_GLOBALS().KEEP_ALIVE_RESPONSE, terminalId);
+ response = TerminalUtilities.calculateHeader(response.getBytes(UTF_8)) + response;
+
+ return response.getBytes(UTF_8);
+ } else
+ return null;
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/PATRequest.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/PATRequest.java
new file mode 100644
index 0000000..2a091d8
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/PATRequest.java
@@ -0,0 +1,173 @@
+package com.global.api.terminals.ingenico.pat;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.ingenico.variables.INGENICO_GLOBALS;
+import com.global.api.terminals.ingenico.variables.PATPrivateDataCode;
+import com.global.api.terminals.ingenico.variables.PATRequestType;
+import com.global.api.terminals.ingenico.variables.TLVFormat;
+import com.global.api.utils.TypeLengthValue;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+public class PATRequest {
+
+ private TypeLengthValue _tlv;
+ private PATRequestType _requestType;
+ private TransactionOutcome _transactionOutcome;
+
+ private String _waiterId;
+ private String _tableNumber;
+ private String _terminalId;
+ private String _terminalCurrency;
+ private String _rawData;
+ private String _xmlData;
+
+ public PATRequest(byte[] buffer) throws ApiException {
+ parseRequest(buffer);
+ }
+
+ public String getWaiterId() {
+ return _waiterId;
+ }
+
+ public String getTableNumber() {
+ return _tableNumber;
+ }
+
+ public String getTerminalId() {
+ return _terminalId;
+ }
+
+ public String getTerminalCurrency() {
+ return _terminalCurrency;
+ }
+
+ public String getRawRequest() {
+ return _rawData;
+ }
+
+ public TransactionOutcome getTransactionOutcome() {
+ return _transactionOutcome;
+ }
+
+ public String getXMLData() {
+ return _xmlData;
+ }
+
+ public PATRequestType getRequestType() {
+ return _requestType;
+ }
+
+ private void parseRequest(byte[] buffer) throws ApiException {
+ try {
+ if (buffer != null) {
+ _rawData = new String(buffer, StandardCharsets.UTF_8);
+
+ // XML Format
+ if (_rawData.contains(new INGENICO_GLOBALS().XML_TAG)) {
+ _rawData = new String(_rawData.getBytes(), StandardCharsets.ISO_8859_1);
+
+ if (!_rawData.endsWith(">")) {
+ char[] xmlContentArr = _rawData.toCharArray();
+
+ for (int i = _rawData.length() - 1; i <= _rawData.length(); i--) {
+ if (xmlContentArr[i] == '>') {
+ _xmlData = _rawData.substring(0, (i + 1));
+ break;
+ }
+ }
+ } else {
+ _xmlData = _rawData;
+ }
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(new InputSource(new StringReader(_xmlData)));
+
+ String rootTag = doc.getDocumentElement().getNodeName();
+
+ if (rootTag.equals(new INGENICO_GLOBALS().ADDITIONAL_MSG_ROOT)) {
+ _requestType = PATRequestType.ADDITIONAL_MESSAGE;
+ } else if (rootTag.equals(new INGENICO_GLOBALS().TRANSFER_DATA_REQUEST)) {
+ _requestType = PATRequestType.TRANSFER_DATA;
+ } else if (rootTag.equals(new INGENICO_GLOBALS().TRANSACTION_XML)) {
+ NodeList nList = doc.getElementsByTagName("RECEIPT");
+ Node node = nList.item(0);
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ String sType = element.getAttribute("STYPE");
+
+ if (sType.equals("SPLITSALE REPORT")) {
+ _requestType = PATRequestType.SPLITSALE_REPORT;
+ } else if (sType.equals("CUSTOMER")) {
+ _requestType = PATRequestType.TICKET;
+ } else {
+ _requestType = PATRequestType.EOD_REPORT;
+ }
+ } else {
+ throw new ApiException("First child node is not an element");
+ }
+ } else {
+ throw new ApiException("The root tag of the xml cannot recognize");
+ }
+ } else {
+ // Workaround for split sale but not final logic
+ if (_rawData.toLowerCase().contains("split_sale")) {
+ _requestType = PATRequestType.SPLITSALE_REPORT;
+ _xmlData = _rawData;
+ }
+
+ // Message Frame 2 Format
+ else if (buffer.length >= 80) {
+ _requestType = PATRequestType.TRANSACTION_OUTCOME;
+ _transactionOutcome = new TransactionOutcome(buffer);
+ } else {
+ // Message Frame 1 Format
+ Integer type = Integer.parseInt(_rawData.substring(11, 12));
+ _requestType = PATRequestType.getEnumName(type);
+
+ String privData = _rawData.substring(16);
+ if (privData.length() < 55) {
+ switch (_requestType) {
+ case TABLE_LOCK:
+ case TABLE_UNLOCK:
+ _tableNumber = privData;
+ break;
+ default:
+ break;
+ }
+ } else {
+ _tlv = new TypeLengthValue(privData.getBytes());
+
+ _waiterId = (String) _tlv.getValue((byte)
+ PATPrivateDataCode.WaiterId.getValue(),
+ String.class, null);
+ _tableNumber = (String) _tlv.getValue((byte)
+ PATPrivateDataCode.TableId.getValue(),
+ String.class, TLVFormat.PayAtTable);
+ _terminalId = (String) _tlv.getValue((byte)
+ PATPrivateDataCode.TID.getValue(),
+ String.class, null);
+ _terminalCurrency = (String) _tlv.getValue(
+ (byte) PATPrivateDataCode.TerminalCurrency.getValue(),
+ String.class, null);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/TransactionOutcome.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/TransactionOutcome.java
new file mode 100644
index 0000000..176e404
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/pat/TransactionOutcome.java
@@ -0,0 +1,62 @@
+package com.global.api.terminals.ingenico.pat;
+
+import com.global.api.entities.exceptions.ApiException;
+import com.global.api.terminals.DeviceResponse;
+import com.global.api.terminals.ingenico.responses.DataResponse;
+import com.global.api.terminals.ingenico.variables.TransactionStatus;
+
+import java.nio.charset.StandardCharsets;
+
+public class TransactionOutcome extends DeviceResponse {
+ private DataResponse _repFields;
+ private TransactionStatus _transactionStatus;
+ private String _amount;
+ private String _currencyCode;
+ private String _privateData;
+
+ public TransactionOutcome(byte[] buffer) throws ApiException {
+ parseData(buffer);
+ }
+
+ public TransactionStatus getTransactionStatus() {
+ return _transactionStatus;
+ }
+
+
+ public String getAmount() {
+ return _amount;
+ }
+
+ public String getCurrencyCode() {
+ return _currencyCode;
+ }
+
+ public String getPrivateData() {
+ return _privateData;
+ }
+
+ public DataResponse getRepFields() {
+ return _repFields;
+ }
+
+ private void parseData(byte[] buffer) throws ApiException {
+ try {
+ String strBuffer = new String(buffer, StandardCharsets.UTF_8);
+
+ _transactionStatus = TransactionStatus.getEnumName(
+ Integer.parseInt(strBuffer.substring(2, 3)));
+ _amount = strBuffer.substring(3, 11);
+ _repFields = new DataResponse(strBuffer.substring(12, 67).getBytes());
+ _currencyCode = strBuffer.substring(67, 70);
+ _privateData = strBuffer.substring(70, strBuffer.length());
+ setDeviceResponseText(strBuffer);
+ } catch (Exception e) {
+ throw new ApiException(e.getMessage());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getDeviceResponseText();
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/BroadcastMessage.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/BroadcastMessage.java
new file mode 100644
index 0000000..be4f91c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/BroadcastMessage.java
@@ -0,0 +1,61 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.util.Hashtable;
+
+import com.global.api.entities.exceptions.MessageException;
+import com.global.api.terminals.TerminalUtilities;
+
+public class BroadcastMessage {
+ private byte[] buffer;
+ private String code;
+ private String message;
+ private Hashtable broadcastData = new Hashtable();
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ private void putBroadcastData() {
+ broadcastData.put("A0", "CONNECTING");
+ broadcastData.put("A1", "CONNECTION MADE");
+ broadcastData.put("A2", "APPROVED");
+ broadcastData.put("A3", "DECLINED");
+ broadcastData.put("A4", "INSERT CARD");
+ broadcastData.put("A5", "CARD ERROR");
+ broadcastData.put("A6", "PROCESSING ERROR");
+ broadcastData.put("A7", "REMOVE CARD");
+ broadcastData.put("A8", "TRY AGAIN");
+ broadcastData.put("A9", "PRESENT CARD");
+ broadcastData.put("AA", "RE-PRESENT CARD");
+ broadcastData.put("AB", "CARD NOT SUPPORTED");
+ broadcastData.put("AC", "PRESENT ONLY ONE CARD");
+ broadcastData.put("AD", "PLEASE WAIT");
+ broadcastData.put("AE", "BAD SWIPE");
+ broadcastData.put("AF", "CARD EXPIRED");
+ broadcastData.put("B0", "DECLINED BY CARD");
+ broadcastData.put("B1", "PIN ENTRY");
+ broadcastData.put("B2", "CASHBACK AMOUNT ENTRY");
+ broadcastData.put("B3", "PAPER OUT");
+ }
+
+ public BroadcastMessage(byte[] buffer) throws MessageException {
+ putBroadcastData();
+ this.buffer = buffer;
+ parseBroadcast(this.buffer);
+ }
+
+ private void parseBroadcast(byte[] broadcast) throws MessageException {
+ if (broadcast.length > 0) {
+ String sBroadcast = TerminalUtilities.getString(broadcast);
+ int index = sBroadcast.indexOf("BROADCAST CODE");
+ int length = 14 + 2; // additional 2 is for extra char
+ code = sBroadcast.substring(index + length, index + length + 2);
+ message = broadcastData.get(code);
+ } else
+ throw new MessageException("No broadcast message.");
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/CancelResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/CancelResponse.java
new file mode 100644
index 0000000..1d34eb3
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/CancelResponse.java
@@ -0,0 +1,31 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.CancelStatus;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+
+import java.nio.charset.StandardCharsets;
+
+public class CancelResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+
+ private byte[] _buffer;
+
+ public CancelResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ String status = CancelStatus.getEnumName(Integer.parseInt(rawData.substring(2, 3))).toString();
+ setStatus(status);
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/DataResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/DataResponse.java
new file mode 100644
index 0000000..a638c48
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/DataResponse.java
@@ -0,0 +1,159 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.ingenico.variables.DynamicCurrencyStatus;
+import com.global.api.terminals.ingenico.variables.PaymentMethod;
+import com.global.api.terminals.ingenico.variables.RepFieldCode;
+import com.global.api.terminals.ingenico.variables.TransactionSubTypes;
+import com.global.api.utils.TypeLengthValue;
+
+import java.math.BigDecimal;
+
+public class DataResponse {
+
+ private String _authCode;
+ private BigDecimal _finalAmount;
+ private PaymentMethod _paymentMethod;
+ private BigDecimal _cashbackAmount;
+ private BigDecimal _gratuityAmount;
+ private BigDecimal _availableAmount;
+ private String _dccCode;
+ private BigDecimal _dccAmount;
+ private TransactionSubTypes _txnSubType;
+ private BigDecimal _splitSaleAmount;
+ private DynamicCurrencyStatus _dccStatus;
+ private TypeLengthValue _tlv;
+
+ public DataResponse(byte[] buffer) {
+ _tlv = new TypeLengthValue(buffer);
+ ParseData();
+ }
+
+ public String getAuthorizationCode() {
+ return _authCode != null ? _authCode : "";
+ }
+
+ public void setAuthorizationCode(String value) {
+ _authCode = value;
+ }
+
+ public BigDecimal getFinalAmount() {
+ return _finalAmount;
+ }
+
+ public void setFinalAmount(BigDecimal value) {
+ _finalAmount = value;
+ }
+
+ public PaymentMethod getPaymentMethod() {
+ return _paymentMethod;
+ }
+
+ public void setPaymentMethod(PaymentMethod value) {
+ _paymentMethod = value;
+ }
+
+ public BigDecimal getCashbackAmount() {
+
+ return _cashbackAmount;
+ }
+
+ public void setCashbackAmount(BigDecimal value) {
+ _cashbackAmount = value;
+ }
+
+ public BigDecimal getGratuityAmount() {
+ return _gratuityAmount;
+ }
+
+ public void setGratuityAmount(BigDecimal value) {
+ _gratuityAmount = value;
+ }
+
+ public BigDecimal getAvailableAmount() {
+ return _availableAmount;
+ }
+
+ public void setAvailableAmount(BigDecimal value) {
+ _availableAmount = value;
+ }
+
+ public String getDccCode() {
+ return _dccCode;
+ }
+
+ public void setDccCode(String value) {
+ _dccCode = value;
+ }
+
+ public BigDecimal getDccAmount() {
+ return _dccAmount;
+ }
+
+ public void setDccAmount(BigDecimal value) {
+ _dccAmount = value;
+ }
+
+ public TransactionSubTypes getTransactionSubType() {
+ return _txnSubType;
+ }
+
+ public void setTransactionSubType(TransactionSubTypes value) {
+ _txnSubType = value;
+ }
+
+ public BigDecimal getSplitSaleAmount() {
+ return _splitSaleAmount;
+ }
+
+ public void setSplitSaleAmount(BigDecimal value) {
+ _splitSaleAmount = value;
+ }
+
+ public DynamicCurrencyStatus getDccStatus() {
+ return _dccStatus;
+ }
+
+ public void setDccStatus(DynamicCurrencyStatus value) {
+ _dccStatus = value;
+ }
+
+ private void ParseData() {
+ try {
+ _authCode = (String) _tlv.getValue((byte)
+ RepFieldCode.Authcode.getRepFieldCode(),
+ String.class, null);
+ _cashbackAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.CashbackAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _gratuityAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.GratuityAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _finalAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.FinalTransactionAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _availableAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.AvailableAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _dccCode = (String) _tlv.getValue((byte)
+ RepFieldCode.DccCurrency.getRepFieldCode(),
+ String.class, null);
+ _dccAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.DccConvertedAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _txnSubType = (TransactionSubTypes) _tlv.getValue((byte)
+ RepFieldCode.TransactionSubType.getRepFieldCode(),
+ TransactionSubTypes.class, null);
+ _dccStatus = (DynamicCurrencyStatus) _tlv.getValue((byte)
+ RepFieldCode.DccOperationStatus.getRepFieldCode(),
+ DynamicCurrencyStatus.class, null);
+ _splitSaleAmount = (BigDecimal) _tlv.getValue((byte)
+ RepFieldCode.SplitSalePaidAmount.getRepFieldCode(),
+ BigDecimal.class, null);
+ _paymentMethod = (PaymentMethod) _tlv.getValue((byte)
+ RepFieldCode.PaymentMethod.getRepFieldCode(),
+ PaymentMethod.class, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoBaseResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoBaseResponse.java
new file mode 100644
index 0000000..f5c1ce0
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoBaseResponse.java
@@ -0,0 +1,176 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+
+import com.global.api.terminals.DeviceResponse;
+import com.global.api.terminals.TerminalUtilities;
+import com.global.api.terminals.ingenico.variables.DynamicCurrencyStatus;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.PaymentMethod;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+import com.global.api.terminals.ingenico.variables.TransactionStatus;
+import com.global.api.terminals.ingenico.variables.TransactionSubTypes;
+
+public abstract class IngenicoBaseResponse extends DeviceResponse {
+ protected byte[] _buffer;
+ protected ParseFormat _format;
+ protected DataResponse _respField;
+
+ private String _dccCurrency;
+ private DynamicCurrencyStatus _dccStatus;
+ private BigDecimal _dccAmount;
+ private PaymentMode _paymentMode;
+ private String _currencyCode;
+ private String _privateData;
+ private BigDecimal _finalTransactionAmount;
+ private String _amount;
+
+ public IngenicoBaseResponse(byte[] buffer, ParseFormat format) {
+ if (buffer != null) {
+ _buffer = buffer;
+ _format = format;
+
+ if (_format != ParseFormat.XML) {
+ parseResponse(_buffer);
+ }
+ }
+ }
+
+// public abstract void parseResponse() throws ApiException;
+
+ public void parseResponse(byte[] response) {
+ if (response != null) {
+ String strBuffer = TerminalUtilities.getString(response);
+
+ setReferenceNumber(strBuffer.substring(0, 2));
+ setStatus(TransactionStatus.getEnumName(
+ Integer.parseInt(strBuffer.substring(2, 3))).toString());
+ setAmount(strBuffer.substring(3, 11));
+ setPaymentMode(PaymentMode.getEnumName(
+ Integer.parseInt(strBuffer.substring(11, 12))));
+ setCurrencyCode(strBuffer.substring(67, 70));
+ setPrivateData(strBuffer.substring(70));
+
+ if (_format == ParseFormat.Transaction) {
+ String respField = strBuffer.substring(12, 67);
+ _respField = new DataResponse(respField.getBytes());
+
+ setFinalTransactionAmount(_respField.getFinalAmount());
+ setDccAmount(_respField.getDccAmount());
+ setDccCurrency(_respField.getDccCode());
+ setDccStatus(_respField.getDccStatus());
+ }
+ }
+ }
+
+ public String getDccCurrency() {
+ return _dccCurrency;
+ }
+
+ public void setDccCurrency(String dccCurrency) {
+ _dccCurrency = dccCurrency;
+ }
+
+ public String getDccStatus() {
+ DynamicCurrencyStatus dccStatus = null;
+
+ if (_respField.getDccStatus() != null) {
+ int iDccStatus = _respField.getDccStatus().getValue();
+ dccStatus = DynamicCurrencyStatus.getEnumName(iDccStatus);
+ }
+
+ return dccStatus == null ? "" : dccStatus.toString();
+ }
+
+ public void setDccStatus(DynamicCurrencyStatus dccStatus) {
+ _dccStatus = dccStatus;
+ }
+
+ public BigDecimal getDccAmount() {
+ return _dccAmount;
+ }
+
+ public void setDccAmount(BigDecimal dccAmount) {
+ _dccAmount = dccAmount;
+ }
+
+ public String getTransactionSubType() {
+ return _respField.getTransactionSubType().toString();
+ }
+
+ public void setTransactionSubType(TransactionSubTypes transactionSubType) {
+ _respField.setTransactionSubType(transactionSubType);
+ }
+
+ public BigDecimal getSplitSaleAmount() {
+ return _respField.getSplitSaleAmount();
+ }
+
+ public void setSplitSaleAmount(BigDecimal splitSaleAmount) {
+ _respField.setSplitSaleAmount(splitSaleAmount);
+ }
+
+ public String getPaymentMode() {
+ return _paymentMode.toString();
+ }
+
+ public void setPaymentMode(PaymentMode paymentMode) {
+ _paymentMode = paymentMode;
+ }
+
+ public String getCurrencyCode() {
+ return _currencyCode;
+ }
+
+ public void setCurrencyCode(String currencyCode) {
+ _currencyCode = currencyCode;
+ }
+
+ public String getPrivateData() {
+ return _privateData;
+ }
+
+ public void setPrivateData(String privateData) {
+ _privateData = privateData;
+ }
+
+ public BigDecimal getFinalTransactionAmount() {
+ return _finalTransactionAmount;
+ }
+
+ public void setFinalTransactionAmount(BigDecimal finalTransactionAmount) {
+ _finalTransactionAmount = finalTransactionAmount;
+ }
+
+ public String getAmount() {
+ return _amount;
+ }
+
+ public void setAmount(String amount) {
+ _amount = amount;
+ }
+
+ public String getPaymentMethod() {
+ PaymentMethod paymentMethod = null;
+
+ if (_respField.getPaymentMethod() != null) {
+ int iPaymentMethod = _respField.getPaymentMethod().getValue();
+ paymentMethod = PaymentMethod.getEnumName(iPaymentMethod);
+ }
+
+ return paymentMethod == null ? "" : paymentMethod.toString();
+ }
+
+ public void setPaymentMethod(PaymentMethod value) {
+ _respField.setPaymentMethod(value);
+ }
+
+ @Override
+ public String toString() {
+ String rawData = new String(_buffer, StandardCharsets.UTF_8);
+ setDeviceResponseText(rawData);
+
+ return getDeviceResponseText();
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReceiptResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReceiptResponse.java
new file mode 100644
index 0000000..2594245
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReceiptResponse.java
@@ -0,0 +1,23 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.nio.charset.StandardCharsets;
+
+import com.global.api.terminals.abstractions.ITerminalReport;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+
+public class IngenicoTerminalReceiptResponse extends IngenicoBaseResponse implements ITerminalReport {
+ private byte[] buffer;
+
+ public IngenicoTerminalReceiptResponse(byte[] buffer) {
+ super(buffer, ParseFormat.XML);
+ _buffer = buffer;
+
+ String status = _buffer.length > 0 ? "SUCCESS" : "FAILED";
+ setStatus(status);
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.ISO_8859_1);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReportResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReportResponse.java
new file mode 100644
index 0000000..7b929db
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalReportResponse.java
@@ -0,0 +1,12 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.ITerminalReport;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+
+public class IngenicoTerminalReportResponse extends IngenicoTerminalResponse implements ITerminalReport {
+
+ public IngenicoTerminalReportResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ super.parseResponse(buffer);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalResponse.java
new file mode 100644
index 0000000..67823ee
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/IngenicoTerminalResponse.java
@@ -0,0 +1,390 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.math.BigDecimal;
+
+import com.global.api.entities.enums.ApplicationCryptogramType;
+import com.global.api.terminals.abstractions.ITerminalResponse;
+import com.global.api.terminals.ingenico.variables.DynamicCurrencyStatus;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.PaymentMode;
+import com.global.api.terminals.ingenico.variables.TransactionSubTypes;
+import com.global.api.utils.Extensions;
+
+public class IngenicoTerminalResponse extends IngenicoBaseResponse implements ITerminalResponse {
+ private String responseText;
+ private String responseCode;
+ private String transactionId;
+ private String token;
+ private String signatureStatus;
+ private byte[] signatureData;
+ private String transactionType;
+ private String maskedCardNumber;
+ private String entryMethod;
+ private String approvalCode;
+ private BigDecimal amountDue;
+ private String cardHolderName;
+ private String cardBIN;
+ private boolean cardPresent;
+ private String expirationDate;
+ private String avsResponseCode;
+ private String avsResponseText;
+ private String cvvResponseCode;
+ private String cvvResponseText;
+ private boolean taxExempt;
+ private String taxExemptId;
+ private String ticketNumber;
+ private ApplicationCryptogramType applicationCryptogramType;
+ private String applicationCryptogram;
+ private String cardHolderVerificationMethod;
+ private String terminalVerificationResults;
+ private String applicationPreferredName;
+ private String applicationLabel;
+ private String applicationId;
+ private String paymentType;
+
+ public IngenicoTerminalResponse(byte[] buffer, ParseFormat format) {
+ super(buffer, format);
+ }
+
+ public BigDecimal getTransactionAmount() {
+ return Extensions.toAmount(getAmount());
+ }
+
+ public void setTransactionAmount(BigDecimal transactionAmount) {
+ setAmount(transactionAmount.toString());
+ }
+
+ public BigDecimal getBalanceAmount() {
+ return _respField.getAvailableAmount();
+ }
+
+ public void setBalanceAmount(BigDecimal balanceAmount) {
+ _respField.setAvailableAmount(balanceAmount);
+ }
+
+ public String getAuthorizationCode() {
+ return _respField.getAuthorizationCode();
+ }
+
+ public void setAuthorizationCode(String authorizationCode) {
+ _respField.setAuthorizationCode(authorizationCode);
+ }
+
+ public BigDecimal getCashBackAmount() {
+ return _respField.getCashbackAmount();
+ }
+
+ public void setCashBackAmount(BigDecimal cashBackAmount) {
+ _respField.setCashbackAmount(cashBackAmount);
+ }
+
+ public BigDecimal getTipAmount() {
+ return _respField.getGratuityAmount();
+ }
+
+ public void setTipAmount(BigDecimal tipAmount) {
+ _respField.setGratuityAmount(tipAmount);
+ }
+
+ public String getTerminalRefNumber() {
+ return getReferenceNumber();
+ }
+
+ public void setTerminalRefNumber(String terminalRefNumber) {
+ setReferenceNumber(terminalRefNumber);
+ }
+
+ public String getPaymentMethod() {
+ return super.getPaymentMethod();
+ }
+
+ public String getTransactionSubType() {
+ return super.getTransactionSubType();
+ }
+
+ public void setTransactionSubType(TransactionSubTypes transactionSubType) {
+ super.setTransactionSubType(transactionSubType);
+ }
+
+ public BigDecimal getDynamicCurrencyCodeAmount() {
+ return super.getDccAmount();
+ }
+
+ public void setDyanmicCurrencyCodeAmount(BigDecimal dynamicCurrencyCodeAmount) {
+ super.setDccAmount(dynamicCurrencyCodeAmount);
+ }
+
+ public String getDynamicCurrencyCode() {
+ return super.getDccCurrency();
+ }
+
+ public void setDynamicCurrencyCode(String dynamicCurrencyCode) {
+ super.setDccCurrency(dynamicCurrencyCode);
+ }
+
+ public String getDynamicCurrencyCodeStatus() {
+ return super.getDccStatus();
+ }
+
+ public void setDynamicCurrencyCodeStatus(DynamicCurrencyStatus status) {
+ super.setDccStatus(status);
+ }
+
+ public BigDecimal getSplitSaleAmount() {
+ return super.getSplitSaleAmount();
+ }
+
+ public void setSplitSaleAmount(BigDecimal splitSaleAmount) {
+ super.setSplitSaleAmount(splitSaleAmount);
+ }
+
+ public String getPaymentMode() {
+ return super.getPaymentMode();
+ }
+
+ public void setPaymentMode(PaymentMode paymentMode) {
+ super.setPaymentMode(paymentMode);
+ }
+
+ // -------
+
+ public String getPaymentType() {
+ return paymentType;
+ }
+
+ public void setPaymentType(String paymentType) {
+ this.paymentType = paymentType;
+ }
+
+ public String getResponseText() {
+ return responseText;
+ }
+
+ public void setResponseText(String responseText) {
+ this.responseText = responseText;
+ }
+
+ public String getResponseCode() {
+ return responseCode;
+ }
+
+ public void setResponseCode(String responseCode) {
+ this.responseCode = responseCode;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getSignatureStatus() {
+ return signatureStatus;
+ }
+
+ public void setSignatureStatus(String signatureStatus) {
+ this.signatureStatus = signatureStatus;
+ }
+
+ public byte[] getSignatureData() {
+ return signatureData;
+ }
+
+ public void setSignatureData(byte[] signatureData) {
+ this.signatureData = signatureData;
+ }
+
+ public String getTransactionType() {
+ return transactionType;
+ }
+
+ public void setTransactionType(String transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public String getMaskedCardNumber() {
+ return maskedCardNumber;
+ }
+
+ public void setMaskedCardNumber(String maskedCardNumber) {
+ this.maskedCardNumber = maskedCardNumber;
+ }
+
+ public String getEntryMethod() {
+ return entryMethod;
+ }
+
+ public void setEntryMethod(String entryMethod) {
+ this.entryMethod = entryMethod;
+ }
+
+ public String getApprovalCode() {
+ return approvalCode;
+ }
+
+ public void setApprovalCode(String approvalCode) {
+ this.approvalCode = approvalCode;
+ }
+
+ public BigDecimal getAmountDue() {
+ return amountDue;
+ }
+
+ public void setAmountDue(BigDecimal amountDue) {
+ this.amountDue = amountDue;
+ }
+
+ public String getCardHolderName() {
+ return cardHolderName;
+ }
+
+ public void setCardHolderName(String cardHolderName) {
+ this.cardHolderName = cardHolderName;
+ }
+
+ public String getCardBIN() {
+ return cardBIN;
+ }
+
+ public void setCardBIN(String cardBIN) {
+ this.cardBIN = cardBIN;
+ }
+
+ public boolean getCardPresent() {
+ return cardPresent;
+ }
+
+ public void setCardPresent(boolean cardPresent) {
+ this.cardPresent = cardPresent;
+ }
+
+ public String getExpirationDate() {
+ return expirationDate;
+ }
+
+ public void setExpirationDate(String expirationDate) {
+ this.expirationDate = expirationDate;
+ }
+
+ public String getAvsResponseCode() {
+ return avsResponseCode;
+ }
+
+ public void setAvsResponseCode(String avsResponseCode) {
+ this.avsResponseCode = avsResponseCode;
+ }
+
+ public String getAvsResponseText() {
+ return avsResponseText;
+ }
+
+ public void setAvsResponseText(String avsResponseText) {
+ this.avsResponseText = avsResponseText;
+ }
+
+ public String getCvvResponseCode() {
+ return cvvResponseCode;
+ }
+
+ public void setCvvResponseCode(String cvvResponseCode) {
+ this.cvvResponseCode = cvvResponseCode;
+ }
+
+ public String getCvvResponseText() {
+ return cvvResponseText;
+ }
+
+ public void setCvvResponseText(String cvvResponseText) {
+ this.cvvResponseText = cvvResponseText;
+ }
+
+ public boolean getTaxExempt() {
+ return taxExempt;
+ }
+
+ public void setTaxExempt(boolean taxExempt) {
+ this.taxExempt = taxExempt;
+ }
+
+ public String getTaxExemptId() {
+ return taxExemptId;
+ }
+
+ public void setTaxExemptId(String taxExemptId) {
+ this.taxExemptId = taxExemptId;
+ }
+
+ public String getTicketNumber() {
+ return ticketNumber;
+ }
+
+ public void setTicketNumber(String ticketNumber) {
+ this.ticketNumber = ticketNumber;
+ }
+
+ public ApplicationCryptogramType getApplicationCryptogramType() {
+ return applicationCryptogramType;
+ }
+
+ public void setApplicationCryptogramType(ApplicationCryptogramType applicationCryptogramType) {
+ this.applicationCryptogramType = applicationCryptogramType;
+ }
+
+ public String getApplicationCryptogram() {
+ return applicationCryptogram;
+ }
+
+ public void setApplicationCryptogram(String applicationCryptogram) {
+ this.applicationCryptogram = applicationCryptogram;
+ }
+
+ public String getCardHolderVerificationMethod() {
+ return cardHolderVerificationMethod;
+ }
+
+ public void setCardHolderVerificationMethod(String cardHolderVerificationMethod) {
+ this.cardHolderVerificationMethod = cardHolderVerificationMethod;
+ }
+
+ public String getTerminalVerificationResults() {
+ return terminalVerificationResults;
+ }
+
+ public void setTerminalVerificationResults(String terminalVerificationResults) {
+ this.terminalVerificationResults = terminalVerificationResults;
+ }
+
+ public String getApplicationPreferredName() {
+ return applicationPreferredName;
+ }
+
+ public void setApplicationPreferredName(String applicationPreferredName) {
+ this.applicationPreferredName = applicationPreferredName;
+ }
+
+ public String getApplicationLabel() {
+ return applicationLabel;
+ }
+
+ public void setApplicationLabel(String applicationLabel) {
+ this.applicationLabel = applicationLabel;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/LogOnResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/LogOnResponse.java
new file mode 100644
index 0000000..9084af0
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/LogOnResponse.java
@@ -0,0 +1,29 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.LogOnStatus;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+
+import java.nio.charset.StandardCharsets;
+
+public class LogOnResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+ private byte[] _buffer;
+
+ public LogOnResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ setStatus(LogOnStatus.getEnumName(Integer.parseInt(rawData.substring(2, 3))).toString());
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/POSIdentifierResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/POSIdentifierResponse.java
new file mode 100644
index 0000000..022e55c
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/POSIdentifierResponse.java
@@ -0,0 +1,36 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.nio.charset.StandardCharsets;
+
+import com.global.api.terminals.abstractions.IInitializeResponse;
+import com.global.api.terminals.ingenico.variables.POSIdentifier;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+
+public class POSIdentifierResponse extends IngenicoTerminalResponse implements IInitializeResponse {
+
+ private byte[] _buffer;
+ private String _serialNumber;
+
+ public POSIdentifierResponse(byte[] buffer) {
+ super(buffer, ParseFormat.PID);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ public String getSerialNumber() {
+ return _serialNumber;
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ _serialNumber = rawData.substring(12, 67).trim();
+ setStatus(POSIdentifier.getEnumName(Integer.parseInt(rawData.substring(2, 3))).toString());
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
\ No newline at end of file
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/ReverseResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/ReverseResponse.java
new file mode 100644
index 0000000..f0ecd74
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/ReverseResponse.java
@@ -0,0 +1,32 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.ReverseStatus;
+
+import java.nio.charset.StandardCharsets;
+
+public class ReverseResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+ private byte[] _buffer;
+
+ public ReverseResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ if (response.length > 0) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ setStatus(ReverseStatus.getEnumName(
+ Integer.parseInt(rawData.substring(2, 3))).toString());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalConfigResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalConfigResponse.java
new file mode 100644
index 0000000..0c2fea3
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalConfigResponse.java
@@ -0,0 +1,30 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.TerminalConfigStatus;
+
+import java.nio.charset.StandardCharsets;
+
+public class TerminalConfigResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+ private byte[] _buffer;
+
+ public TerminalConfigResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ setStatus(TerminalConfigStatus.getEnumName(
+ Integer.parseInt(rawData.substring(2, 3))).toString());
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalResetResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalResetResponse.java
new file mode 100644
index 0000000..a10bd79
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalResetResponse.java
@@ -0,0 +1,30 @@
+package com.global.api.terminals.ingenico.responses;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.TerminalResetStatus;
+
+import java.nio.charset.StandardCharsets;
+
+public class TerminalResetResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+ private byte[] _buffer;
+
+ public TerminalResetResponse(byte[] buffer) {
+ super(buffer, ParseFormat.Transaction);
+ _buffer = buffer;
+ parseResponse(buffer);
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ super.parseResponse(response);
+ String rawData = new String(response, StandardCharsets.UTF_8);
+ setStatus(TerminalResetStatus.getEnumName(
+ Integer.parseInt(rawData.substring(2, 3))).toString());
+ }
+
+ @Override
+ public String toString() {
+ return new String(_buffer, StandardCharsets.UTF_8);
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalStateResponse.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalStateResponse.java
new file mode 100644
index 0000000..707f723
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/responses/TerminalStateResponse.java
@@ -0,0 +1,97 @@
+package com.global.api.terminals.ingenico.responses;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+import com.global.api.terminals.abstractions.IDeviceResponse;
+import com.global.api.terminals.ingenico.variables.INGENICO_GLOBALS;
+import com.global.api.terminals.ingenico.variables.ParseFormat;
+import com.global.api.terminals.ingenico.variables.SalesMode;
+import com.global.api.terminals.ingenico.variables.StatusResponseCode;
+import com.global.api.terminals.ingenico.variables.TLVFormat;
+import com.global.api.terminals.ingenico.variables.TerminalStatus;
+import com.global.api.utils.Extensions;
+import com.global.api.utils.TypeLengthValue;
+
+public class TerminalStateResponse extends IngenicoTerminalResponse implements IDeviceResponse {
+ private TerminalStatus terminalStatus;
+ private SalesMode salesMode;
+ private String terminalCapabilities;
+ private String additionalTerminalCap;
+ private String appVersion;
+ private String handsetNumber;
+ private String terminalId;
+
+ public TerminalStateResponse(byte[] buffer) {
+ super(buffer, ParseFormat.State);
+ }
+
+ public TerminalStatus getTerminalStatus() {
+ return terminalStatus;
+ }
+
+ public SalesMode getSalesMode() {
+ return salesMode;
+ }
+
+ public String getTerminalCapabilities() {
+ return terminalCapabilities;
+ }
+
+ public String getAdditionalTerminalCapabilities() {
+ return additionalTerminalCap;
+ }
+
+ public String getAppVersion() {
+ return appVersion;
+ }
+
+ public String getHandsetNumber() {
+ return handsetNumber;
+ }
+
+ public String getTerminalId() {
+ return terminalId;
+ }
+
+ @Override
+ public void parseResponse(byte[] response) {
+ try {
+ if (response != null) {
+ if (response.length < new INGENICO_GLOBALS().RAW_RESPONSE_LENGTH) {
+ byte[] responseLength = new byte[new INGENICO_GLOBALS().RAW_RESPONSE_LENGTH];
+ response = Arrays.copyOfRange(response, 0, responseLength.length);
+ }
+
+ super.parseResponse(response);
+ String test = new String(response, StandardCharsets.UTF_8);
+ String t1 = test;
+
+ TypeLengthValue tlv = new TypeLengthValue(
+ Extensions.subArray(response, 12, 67));
+ tlv.setTLVFormat(TLVFormat.State);
+
+ String terminalStatusData = (String) tlv
+ .getValue((byte) StatusResponseCode.Status.getStatusResponseCode(),
+ String.class, null);
+ terminalStatus = TerminalStatus.getEnumName(
+ Integer.parseInt(terminalStatusData.substring(0, 1)));
+ salesMode = SalesMode.getEnumName(
+ Integer.parseInt(terminalStatusData.substring(1, 2)));
+ terminalCapabilities = terminalStatusData.substring(2, 8);
+ additionalTerminalCap = terminalStatusData.substring(8, 18);
+ appVersion = (String) tlv.getValue((byte)
+ StatusResponseCode.AppVersion.getStatusResponseCode(),
+ String.class, null);
+ handsetNumber = (String) tlv.getValue((byte)
+ StatusResponseCode.HandsetNumber.getStatusResponseCode(),
+ String.class, null);
+ terminalId = (String) tlv.getValue((byte)
+ StatusResponseCode.TerminalId.getStatusResponseCode(),
+ String.class, null);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/variables/CancelStatus.java b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/variables/CancelStatus.java
new file mode 100644
index 0000000..81600de
--- /dev/null
+++ b/globalpayments-sdk/src/main/java/com/global/api/terminals/ingenico/variables/CancelStatus.java
@@ -0,0 +1,28 @@
+package com.global.api.terminals.ingenico.variables;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum CancelStatus {
+ CANCEL_DONE(9), CANCEL_FAILED(7);
+
+ private final int status;
+ private final static Map map = new HashMap