@aptos-scp/scp-component-rn-device-services 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +47 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradlew +164 -0
- package/android/gradlew.bat +90 -0
- package/android/src/main/AndroidManifest.xml +10 -0
- package/android/src/main/java/com/aptos/scp/paymentterminal/RNMapper.java +212 -0
- package/android/src/main/java/com/aptos/scp/paymentterminal/VendorPaymentTerminal.java +46 -0
- package/android/src/main/java/com/aptos/scp/paymentterminal/VendorPaymentTerminalPackage.java +33 -0
- package/android/src/main/java/com/aptos/scp/paymentterminal/adyen/AdyenPaymentTerminal.java +53 -0
- package/android/src/main/java/com/aptos/scp/paymentterminal/aurus/AurusPaymentTerminal.java +54 -0
- package/package.json +2 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
repositories {
|
|
5
|
+
mavenCentral()
|
|
6
|
+
}
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath 'com.android.tools.build:gradle:2.1.3'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: 'com.android.library'
|
|
13
|
+
|
|
14
|
+
android {
|
|
15
|
+
compileSdkVersion 23
|
|
16
|
+
buildToolsVersion "23.0.1"
|
|
17
|
+
|
|
18
|
+
defaultConfig {
|
|
19
|
+
minSdkVersion 16
|
|
20
|
+
targetSdkVersion 22
|
|
21
|
+
versionCode 1
|
|
22
|
+
versionName "1.0"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
buildTypes {
|
|
26
|
+
release {
|
|
27
|
+
minifyEnabled false
|
|
28
|
+
proguardFile getDefaultProguardFile('proguard-android.txt')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
allprojects {
|
|
34
|
+
repositories {
|
|
35
|
+
mavenLocal()
|
|
36
|
+
jcenter()
|
|
37
|
+
maven {
|
|
38
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
39
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
dependencies {
|
|
45
|
+
compile fileTree(dir: "libs", include: ["*.jar"])
|
|
46
|
+
compile 'com.facebook.react:react-native:+'
|
|
47
|
+
}
|
|
Binary file
|
package/android/gradlew
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
##############################################################################
|
|
4
|
+
##
|
|
5
|
+
## Gradle start up script for UN*X
|
|
6
|
+
##
|
|
7
|
+
##############################################################################
|
|
8
|
+
|
|
9
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
10
|
+
DEFAULT_JVM_OPTS=""
|
|
11
|
+
|
|
12
|
+
APP_NAME="Gradle"
|
|
13
|
+
APP_BASE_NAME=`basename "$0"`
|
|
14
|
+
|
|
15
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
16
|
+
MAX_FD="maximum"
|
|
17
|
+
|
|
18
|
+
warn ( ) {
|
|
19
|
+
echo "$*"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
die ( ) {
|
|
23
|
+
echo
|
|
24
|
+
echo "$*"
|
|
25
|
+
echo
|
|
26
|
+
exit 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# OS specific support (must be 'true' or 'false').
|
|
30
|
+
cygwin=false
|
|
31
|
+
msys=false
|
|
32
|
+
darwin=false
|
|
33
|
+
case "`uname`" in
|
|
34
|
+
CYGWIN* )
|
|
35
|
+
cygwin=true
|
|
36
|
+
;;
|
|
37
|
+
Darwin* )
|
|
38
|
+
darwin=true
|
|
39
|
+
;;
|
|
40
|
+
MINGW* )
|
|
41
|
+
msys=true
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
|
|
45
|
+
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
|
46
|
+
if $cygwin ; then
|
|
47
|
+
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Attempt to set APP_HOME
|
|
51
|
+
# Resolve links: $0 may be a link
|
|
52
|
+
PRG="$0"
|
|
53
|
+
# Need this for relative symlinks.
|
|
54
|
+
while [ -h "$PRG" ] ; do
|
|
55
|
+
ls=`ls -ld "$PRG"`
|
|
56
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
57
|
+
if expr "$link" : '/.*' > /dev/null; then
|
|
58
|
+
PRG="$link"
|
|
59
|
+
else
|
|
60
|
+
PRG=`dirname "$PRG"`"/$link"
|
|
61
|
+
fi
|
|
62
|
+
done
|
|
63
|
+
SAVED="`pwd`"
|
|
64
|
+
cd "`dirname \"$PRG\"`/" >&-
|
|
65
|
+
APP_HOME="`pwd -P`"
|
|
66
|
+
cd "$SAVED" >&-
|
|
67
|
+
|
|
68
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
69
|
+
|
|
70
|
+
# Determine the Java command to use to start the JVM.
|
|
71
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
72
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
73
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
74
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
75
|
+
else
|
|
76
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
|
77
|
+
fi
|
|
78
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
79
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
80
|
+
|
|
81
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
82
|
+
location of your Java installation."
|
|
83
|
+
fi
|
|
84
|
+
else
|
|
85
|
+
JAVACMD="java"
|
|
86
|
+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
87
|
+
|
|
88
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
89
|
+
location of your Java installation."
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
# Increase the maximum file descriptors if we can.
|
|
93
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
|
94
|
+
MAX_FD_LIMIT=`ulimit -H -n`
|
|
95
|
+
if [ $? -eq 0 ] ; then
|
|
96
|
+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
97
|
+
MAX_FD="$MAX_FD_LIMIT"
|
|
98
|
+
fi
|
|
99
|
+
ulimit -n $MAX_FD
|
|
100
|
+
if [ $? -ne 0 ] ; then
|
|
101
|
+
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
102
|
+
fi
|
|
103
|
+
else
|
|
104
|
+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
105
|
+
fi
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
# For Darwin, add options to specify how the application appears in the dock
|
|
109
|
+
if $darwin; then
|
|
110
|
+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# For Cygwin, switch paths to Windows format before running java
|
|
114
|
+
if $cygwin ; then
|
|
115
|
+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
116
|
+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
117
|
+
|
|
118
|
+
# We build the pattern for arguments to be converted via cygpath
|
|
119
|
+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
120
|
+
SEP=""
|
|
121
|
+
for dir in $ROOTDIRSRAW ; do
|
|
122
|
+
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
123
|
+
SEP="|"
|
|
124
|
+
done
|
|
125
|
+
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
126
|
+
# Add a user-defined pattern to the cygpath arguments
|
|
127
|
+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
128
|
+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
129
|
+
fi
|
|
130
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
131
|
+
i=0
|
|
132
|
+
for arg in "$@" ; do
|
|
133
|
+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
134
|
+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
135
|
+
|
|
136
|
+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
137
|
+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
138
|
+
else
|
|
139
|
+
eval `echo args$i`="\"$arg\""
|
|
140
|
+
fi
|
|
141
|
+
i=$((i+1))
|
|
142
|
+
done
|
|
143
|
+
case $i in
|
|
144
|
+
(0) set -- ;;
|
|
145
|
+
(1) set -- "$args0" ;;
|
|
146
|
+
(2) set -- "$args0" "$args1" ;;
|
|
147
|
+
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
148
|
+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
149
|
+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
150
|
+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
151
|
+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
152
|
+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
153
|
+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
154
|
+
esac
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
|
158
|
+
function splitJvmOpts() {
|
|
159
|
+
JVM_OPTS=("$@")
|
|
160
|
+
}
|
|
161
|
+
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
|
162
|
+
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
|
163
|
+
|
|
164
|
+
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
@if "%DEBUG%" == "" @echo off
|
|
2
|
+
@rem ##########################################################################
|
|
3
|
+
@rem
|
|
4
|
+
@rem Gradle startup script for Windows
|
|
5
|
+
@rem
|
|
6
|
+
@rem ##########################################################################
|
|
7
|
+
|
|
8
|
+
@rem Set local scope for the variables with windows NT shell
|
|
9
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
10
|
+
|
|
11
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
12
|
+
set DEFAULT_JVM_OPTS=
|
|
13
|
+
|
|
14
|
+
set DIRNAME=%~dp0
|
|
15
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
|
16
|
+
set APP_BASE_NAME=%~n0
|
|
17
|
+
set APP_HOME=%DIRNAME%
|
|
18
|
+
|
|
19
|
+
@rem Find java.exe
|
|
20
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
21
|
+
|
|
22
|
+
set JAVA_EXE=java.exe
|
|
23
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
24
|
+
if "%ERRORLEVEL%" == "0" goto init
|
|
25
|
+
|
|
26
|
+
echo.
|
|
27
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
28
|
+
echo.
|
|
29
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
30
|
+
echo location of your Java installation.
|
|
31
|
+
|
|
32
|
+
goto fail
|
|
33
|
+
|
|
34
|
+
:findJavaFromJavaHome
|
|
35
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
36
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
37
|
+
|
|
38
|
+
if exist "%JAVA_EXE%" goto init
|
|
39
|
+
|
|
40
|
+
echo.
|
|
41
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
42
|
+
echo.
|
|
43
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
44
|
+
echo location of your Java installation.
|
|
45
|
+
|
|
46
|
+
goto fail
|
|
47
|
+
|
|
48
|
+
:init
|
|
49
|
+
@rem Get command-line arguments, handling Windowz variants
|
|
50
|
+
|
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
52
|
+
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
53
|
+
|
|
54
|
+
:win9xME_args
|
|
55
|
+
@rem Slurp the command line arguments.
|
|
56
|
+
set CMD_LINE_ARGS=
|
|
57
|
+
set _SKIP=2
|
|
58
|
+
|
|
59
|
+
:win9xME_args_slurp
|
|
60
|
+
if "x%~1" == "x" goto execute
|
|
61
|
+
|
|
62
|
+
set CMD_LINE_ARGS=%*
|
|
63
|
+
goto execute
|
|
64
|
+
|
|
65
|
+
:4NT_args
|
|
66
|
+
@rem Get arguments from the 4NT Shell from JP Software
|
|
67
|
+
set CMD_LINE_ARGS=%$
|
|
68
|
+
|
|
69
|
+
:execute
|
|
70
|
+
@rem Setup the command line
|
|
71
|
+
|
|
72
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
73
|
+
|
|
74
|
+
@rem Execute Gradle
|
|
75
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
76
|
+
|
|
77
|
+
:end
|
|
78
|
+
@rem End local scope for the variables with windows NT shell
|
|
79
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
80
|
+
|
|
81
|
+
:fail
|
|
82
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
83
|
+
rem the _cmd.exe /c_ return code!
|
|
84
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
85
|
+
exit /b 1
|
|
86
|
+
|
|
87
|
+
:mainEnd
|
|
88
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
89
|
+
|
|
90
|
+
:omega
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
package com.aptos.scp.paymentterminal;
|
|
2
|
+
|
|
3
|
+
import android.os.Bundle;
|
|
4
|
+
import com.facebook.react.bridge.Arguments;
|
|
5
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
8
|
+
import com.facebook.react.bridge.ReadableType;
|
|
9
|
+
import com.facebook.react.bridge.WritableArray;
|
|
10
|
+
import com.facebook.react.bridge.WritableMap;
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
import java.util.Set;
|
|
14
|
+
|
|
15
|
+
public class RNMapper {
|
|
16
|
+
public static Object toBridgedValue(Object value) {
|
|
17
|
+
if (value == null) return null;
|
|
18
|
+
|
|
19
|
+
if (value.getClass().isArray()) {
|
|
20
|
+
return Arguments.fromArray(value);
|
|
21
|
+
} else if (value instanceof Bundle) {
|
|
22
|
+
return Arguments.fromBundle((Bundle) value);
|
|
23
|
+
} else if (value instanceof Map) {
|
|
24
|
+
return toWritableMap(value);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static WritableMap toWritableMap(Object... entries) {
|
|
30
|
+
if (entries.length == 0) {
|
|
31
|
+
return null; // no data, no map
|
|
32
|
+
} else if (entries.length == 1) {
|
|
33
|
+
|
|
34
|
+
// if only 1 entry then we convert the Map -> array of entries, then call toWritableMap with the array
|
|
35
|
+
|
|
36
|
+
Set<Map.Entry<String, Object>> subEntries = ((Map)entries[0]).entrySet();
|
|
37
|
+
Object[] args = new Object[subEntries.size() * 2];
|
|
38
|
+
int i = 0;
|
|
39
|
+
for (Map.Entry<String, Object> subEntry : subEntries) {
|
|
40
|
+
args[i] = subEntry.getKey();
|
|
41
|
+
args[i + 1] = subEntry.getValue();
|
|
42
|
+
i += 2;
|
|
43
|
+
}
|
|
44
|
+
return toWritableMap(args);
|
|
45
|
+
} else if (entries.length % 2 != 0) {
|
|
46
|
+
throw new IllegalArgumentException("toWritableMap expects a Map or a list of name/value pairs");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// create a WritableMap with the entries
|
|
50
|
+
|
|
51
|
+
WritableMap map = Arguments.createMap();
|
|
52
|
+
|
|
53
|
+
for (int i = 0; i < entries.length; i += 2) {
|
|
54
|
+
String key = (String)entries[i];
|
|
55
|
+
Object value = entries[i + 1];
|
|
56
|
+
|
|
57
|
+
if (value == null) {
|
|
58
|
+
map.putNull(key);
|
|
59
|
+
} else if (value.getClass().isArray()) {
|
|
60
|
+
map.putArray(key, toWritableArray(value));
|
|
61
|
+
} else if (value instanceof String) {
|
|
62
|
+
map.putString(key, (String) value);
|
|
63
|
+
} else if (value instanceof Number) {
|
|
64
|
+
if (value instanceof Integer) {
|
|
65
|
+
map.putInt(key, (Integer) value);
|
|
66
|
+
} else {
|
|
67
|
+
map.putDouble(key, ((Number) value).doubleValue());
|
|
68
|
+
}
|
|
69
|
+
} else if (value instanceof Boolean) {
|
|
70
|
+
map.putBoolean(key, (Boolean) value);
|
|
71
|
+
} else if (value instanceof Bundle) {
|
|
72
|
+
map.putMap(key, Arguments.fromBundle((Bundle) value));
|
|
73
|
+
} else if (value instanceof Map) {
|
|
74
|
+
map.putMap(key, toWritableMap(value));
|
|
75
|
+
} else {
|
|
76
|
+
throw new IllegalArgumentException("Unsupported type " + value.getClass());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return map;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public static WritableArray toWritableArray(Object array) {
|
|
83
|
+
WritableArray catalystArray = Arguments.createArray();
|
|
84
|
+
if (array instanceof String[]) {
|
|
85
|
+
for (String v: (String[]) array) {
|
|
86
|
+
catalystArray.pushString(v);
|
|
87
|
+
}
|
|
88
|
+
} else if (array instanceof Bundle[]) {
|
|
89
|
+
for (Bundle v: (Bundle[]) array) {
|
|
90
|
+
catalystArray.pushMap(Arguments.fromBundle(v));
|
|
91
|
+
}
|
|
92
|
+
} else if (array instanceof int[]) {
|
|
93
|
+
for (int v: (int[]) array) {
|
|
94
|
+
catalystArray.pushInt(v);
|
|
95
|
+
}
|
|
96
|
+
} else if (array instanceof float[]) {
|
|
97
|
+
for (float v: (float[]) array) {
|
|
98
|
+
catalystArray.pushDouble(v);
|
|
99
|
+
}
|
|
100
|
+
} else if (array instanceof double[]) {
|
|
101
|
+
for (double v: (double[]) array) {
|
|
102
|
+
catalystArray.pushDouble(v);
|
|
103
|
+
}
|
|
104
|
+
} else if (array instanceof boolean[]) {
|
|
105
|
+
for (boolean v : (boolean[]) array) {
|
|
106
|
+
catalystArray.pushBoolean(v);
|
|
107
|
+
}
|
|
108
|
+
} else if (array instanceof Map[]) {
|
|
109
|
+
for (Map m : (Map[]) array) {
|
|
110
|
+
catalystArray.pushMap(toWritableMap(m));
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
throw new IllegalArgumentException("Unsupported type " + array.getClass());
|
|
114
|
+
}
|
|
115
|
+
return catalystArray;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected static boolean getBooleanMapValue(ReadableMap map, String key, boolean defaultValue) {
|
|
119
|
+
if (map.hasKey(key)) {
|
|
120
|
+
return map.getBoolean(key);
|
|
121
|
+
}
|
|
122
|
+
return defaultValue;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
protected static String getStringMapValue(ReadableMap map, String key, String defaultValue) {
|
|
126
|
+
if (map.hasKey(key)) {
|
|
127
|
+
return map.getString(key);
|
|
128
|
+
}
|
|
129
|
+
return defaultValue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected static int getIntMapValue(ReadableMap map, String key, int defaultValue) {
|
|
133
|
+
if (map.hasKey(key)) {
|
|
134
|
+
return map.getInt(key);
|
|
135
|
+
}
|
|
136
|
+
return defaultValue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
protected static Map fromReadableMap(ReadableMap readableMap) {
|
|
140
|
+
Map<String, Object> map = new HashMap<String, Object>();
|
|
141
|
+
|
|
142
|
+
ReadableMapKeySetIterator iter = readableMap.keySetIterator();
|
|
143
|
+
while(iter.hasNextKey()) {
|
|
144
|
+
String key = iter.nextKey();
|
|
145
|
+
ReadableType type = readableMap.getType(key);
|
|
146
|
+
Object value;
|
|
147
|
+
|
|
148
|
+
switch (type) {
|
|
149
|
+
case Null:
|
|
150
|
+
value = null;
|
|
151
|
+
break;
|
|
152
|
+
case Boolean:
|
|
153
|
+
value = readableMap.getBoolean(key);
|
|
154
|
+
break;
|
|
155
|
+
case Number:
|
|
156
|
+
// Can be int or double.
|
|
157
|
+
value = readableMap.getDouble(key);
|
|
158
|
+
break;
|
|
159
|
+
case String:
|
|
160
|
+
value = readableMap.getString(key);
|
|
161
|
+
break;
|
|
162
|
+
case Map:
|
|
163
|
+
value = fromReadableMap(readableMap.getMap(key));
|
|
164
|
+
break;
|
|
165
|
+
case Array:
|
|
166
|
+
value = fromReadableArray(readableMap.getArray(key));
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
|
|
170
|
+
}
|
|
171
|
+
map.put(key, value);
|
|
172
|
+
}
|
|
173
|
+
return map;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private static Object[] fromReadableArray(ReadableArray readableArray) {
|
|
177
|
+
Object[] array = new Object[readableArray.size()];
|
|
178
|
+
|
|
179
|
+
// create a WritableArray with the entries
|
|
180
|
+
|
|
181
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
182
|
+
Object value;
|
|
183
|
+
ReadableType type = readableArray.getType(i);
|
|
184
|
+
|
|
185
|
+
switch (type) {
|
|
186
|
+
case Null:
|
|
187
|
+
value = null;
|
|
188
|
+
break;
|
|
189
|
+
case Boolean:
|
|
190
|
+
value = readableArray.getBoolean(i);
|
|
191
|
+
break;
|
|
192
|
+
case Number:
|
|
193
|
+
// Can be int or double.
|
|
194
|
+
value = readableArray.getDouble(i);
|
|
195
|
+
break;
|
|
196
|
+
case String:
|
|
197
|
+
value = readableArray.getString(i);
|
|
198
|
+
break;
|
|
199
|
+
case Map:
|
|
200
|
+
value = fromReadableMap(readableArray.getMap(i));
|
|
201
|
+
break;
|
|
202
|
+
case Array:
|
|
203
|
+
value = fromReadableArray(readableArray.getArray(i));
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
throw new IllegalArgumentException("Could not convert object with index: " + i + ".");
|
|
207
|
+
}
|
|
208
|
+
array[i] = value;
|
|
209
|
+
}
|
|
210
|
+
return array;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.aptos.scp.paymentterminal;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.ReactContext;
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
6
|
+
import com.facebook.react.bridge.WritableMap;
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
8
|
+
|
|
9
|
+
import java.util.HashMap;
|
|
10
|
+
import java.util.Map;
|
|
11
|
+
|
|
12
|
+
public abstract class VendorPaymentTerminal extends ReactContextBaseJavaModule {
|
|
13
|
+
|
|
14
|
+
public static final String LOG_TAG = "AptosPos";
|
|
15
|
+
|
|
16
|
+
private ReactContext reactContext;
|
|
17
|
+
|
|
18
|
+
@SuppressWarnings("WeakerAccess")
|
|
19
|
+
public VendorPaymentTerminal(ReactApplicationContext reactContext) {
|
|
20
|
+
super(reactContext);
|
|
21
|
+
this.reactContext = reactContext;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public abstract String getName();
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public Map<String, Object> getConstants() {
|
|
29
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
30
|
+
return constants;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public void emit(String eventName, String param) {
|
|
34
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, param);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void emit(String eventName, Object... params) {
|
|
38
|
+
WritableMap map;
|
|
39
|
+
if (params.length == 1 && params[0] instanceof WritableMap) {
|
|
40
|
+
map = (WritableMap) params[0];
|
|
41
|
+
} else {
|
|
42
|
+
map = RNMapper.toWritableMap(params);
|
|
43
|
+
}
|
|
44
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, map);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.aptos.scp.paymentterminal;
|
|
2
|
+
|
|
3
|
+
import java.util.Arrays;
|
|
4
|
+
import java.util.Collections;
|
|
5
|
+
import java.util.List;
|
|
6
|
+
|
|
7
|
+
import com.aptos.scp.paymentterminal.adyen.AdyenPaymentTerminal;
|
|
8
|
+
import com.aptos.scp.paymentterminal.aurus.AurusPaymentTerminal;
|
|
9
|
+
import com.facebook.react.ReactPackage;
|
|
10
|
+
import com.facebook.react.bridge.NativeModule;
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
13
|
+
import com.facebook.react.bridge.JavaScriptModule;
|
|
14
|
+
|
|
15
|
+
public class VendorPaymentTerminalPackage implements ReactPackage {
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
18
|
+
return Arrays.<NativeModule>asList(
|
|
19
|
+
new AurusPaymentTerminal(reactContext),
|
|
20
|
+
new AdyenPaymentTerminal(reactContext)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Deprecated from RN 0.47
|
|
25
|
+
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
26
|
+
return Collections.emptyList();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
31
|
+
return Collections.emptyList();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// AdyenPaymentTerminal.java
|
|
2
|
+
package com.aptos.scp.paymentterminal.adyen;
|
|
3
|
+
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.aptos.scp.paymentterminal.VendorPaymentTerminal;
|
|
7
|
+
import com.aptos.scp.paymentterminal.RNMapper;
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
10
|
+
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
|
|
14
|
+
public class AdyenPaymentTerminal extends VendorPaymentTerminal {
|
|
15
|
+
// TODO: Refactor and add additional methods as needed. This is a basic example to test component interactions.
|
|
16
|
+
private static final String native_exampleResponse1 = "exampleResponse1";
|
|
17
|
+
private static final String native_exampleResponse1_name = "native_exampleResponse1";
|
|
18
|
+
private static final String native_exampleResponse2 = "exampleResponse2";
|
|
19
|
+
private static final String native_exampleResponse2_name = "native_exampleResponse2";
|
|
20
|
+
|
|
21
|
+
@SuppressWarnings("WeakerAccess")
|
|
22
|
+
public AdyenPaymentTerminal(ReactApplicationContext reactContext) {
|
|
23
|
+
super(reactContext);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
public String getName() {
|
|
28
|
+
return "AdyenPaymentTerminal";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// TODO: Refactor and add additional methods as needed. This is a basic example to test component interactions.
|
|
32
|
+
@ReactMethod
|
|
33
|
+
public void exampleRequest1(String exampleParam1) {
|
|
34
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, String.format("In AdyenPaymentTerminal.exampleRequest1, calling emit(%s, %s)", native_exampleResponse1, exampleParam1));
|
|
35
|
+
this.emit(native_exampleResponse1, exampleParam1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// TODO: Refactor and add additional methods as needed. This is a basic example to test component interactions.
|
|
39
|
+
@ReactMethod
|
|
40
|
+
public void exampleRequest2(String exampleParam2) {
|
|
41
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, String.format("In AdyenPaymentTerminal.exampleRequest2, calling emit(%s, %s)", native_exampleResponse2, exampleParam2));
|
|
42
|
+
this.emit(native_exampleResponse2, exampleParam2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// TODO: Refactor and add additional methods as needed. This is a basic example to test component interactions.
|
|
46
|
+
@Override
|
|
47
|
+
public Map<String, Object> getConstants() {
|
|
48
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
49
|
+
constants.put(native_exampleResponse1_name, native_exampleResponse1);
|
|
50
|
+
constants.put(native_exampleResponse2_name, native_exampleResponse2);
|
|
51
|
+
return constants;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// AurusPaymentTerminal.java
|
|
2
|
+
package com.aptos.scp.paymentterminal.aurus;
|
|
3
|
+
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.aptos.scp.paymentterminal.VendorPaymentTerminal;
|
|
7
|
+
import com.aptos.scp.paymentterminal.RNMapper;
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
10
|
+
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
|
|
14
|
+
public class AurusPaymentTerminal extends VendorPaymentTerminal {
|
|
15
|
+
private static final String native_onAESDKResponse = "onAESDKResponse";
|
|
16
|
+
private static final String native_onAESDKResponse_name = "native_onAESDKResponse";
|
|
17
|
+
|
|
18
|
+
@SuppressWarnings("WeakerAccess")
|
|
19
|
+
public AurusPaymentTerminal(ReactApplicationContext reactContext) {
|
|
20
|
+
super(reactContext);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
public String getName() {
|
|
25
|
+
return "AurusPaymentTerminal";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@ReactMethod
|
|
29
|
+
public void initialize() {
|
|
30
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, "In AurusPaymentTerminal.initialize, creating AurusEnterpriseSDK. This starts the connection and EMV configuration.");
|
|
31
|
+
|
|
32
|
+
// create AESDK object
|
|
33
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, "In AurusPaymentTerminal.initialize, not yet implemented for Android");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
public void OnAESDKProcessRequest(String WithRequest) {
|
|
38
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, String.format("In AurusPaymentTerminal.OnAESDKProcessRequest, calling OnAESDKProcessRequest:%s", WithRequest));
|
|
39
|
+
|
|
40
|
+
// call into AESDK.OnAESDKProcessRequest(WithRequest)
|
|
41
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, "In AurusPaymentTerminal.OnAESDKProcessRequest, not yet implemented for Android");
|
|
42
|
+
|
|
43
|
+
String withResponse = "<AESDKResponse><ResponseCode>404</ResponseCode><ResponseText>Aurus has not been implemented for Android.</ResponseText></AESDKResponse>";
|
|
44
|
+
Log.d(VendorPaymentTerminal.LOG_TAG, String.format("In AurusPaymentTerminal.OnAESDKProcessRequest, calling emit(%s, %s)", native_onAESDKResponse, withResponse));
|
|
45
|
+
this.emit(native_onAESDKResponse, withResponse);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
public Map<String, Object> getConstants() {
|
|
50
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
51
|
+
constants.put(native_onAESDKResponse_name, native_onAESDKResponse);
|
|
52
|
+
return constants;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-scp/scp-component-rn-device-services",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "A react-native component for integrating with devices.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"registry": "https://registry.npmjs.com/"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
|
+
"android",
|
|
14
15
|
"constants",
|
|
15
16
|
"interfaces",
|
|
16
17
|
"ios",
|