react-native-payengine 1.0.5
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/LICENSE +20 -0
- package/README.md +152 -0
- package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +18 -0
- package/android/.idea/jarRepositories.xml +35 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +147 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +5 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativepayengine/PayengineModule.java +33 -0
- package/android/src/main/java/com/reactnativepayengine/PayenginePackage.java +64 -0
- package/android/src/main/java/com/reactnativepayengine/collect/VGSCollectModule.java +148 -0
- package/android/src/main/java/com/reactnativepayengine/collect/VGSCollectOnCreateViewInstanceListener.java +6 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSCVCField.java +67 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSCardHolderNameField.java +53 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSCardNumberField.java +57 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSExpDateField.java +54 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSTextField.java +57 -0
- package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSZipCodeField.java +62 -0
- package/android/src/main/java/com/reactnativepayengine/util/JSONObjectUtil.java +138 -0
- package/android/src/main/java/com/reactnativepayengine/util/ResourceUtil.java +14 -0
- package/android/vgscollect-1.7.2-debug.aar +0 -0
- package/ios/Payengine-Bridging-Header.h +2 -0
- package/ios/Payengine.m +55 -0
- package/ios/Payengine.swift +637 -0
- package/ios/Payengine.xcodeproj/project.pbxproj +317 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +34 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +24 -0
- package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/Payengine.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Payengine.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/Pods-Payengine.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/VGSCollectSDK-CardIcon.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/VGSCollectSDK.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
- package/lib/commonjs/components/LoadingIndicator.js +42 -0
- package/lib/commonjs/components/LoadingIndicator.js.map +1 -0
- package/lib/commonjs/components/PayEngine.js +141 -0
- package/lib/commonjs/components/PayEngine.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/CVCField.js +26 -0
- package/lib/commonjs/components/SecureFields/VGS/CVCField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/CardHolderNameField.js +26 -0
- package/lib/commonjs/components/SecureFields/VGS/CardHolderNameField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/CardNumberField.js +26 -0
- package/lib/commonjs/components/SecureFields/VGS/CardNumberField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/CollectManager.js +65 -0
- package/lib/commonjs/components/SecureFields/VGS/CollectManager.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/ExpDateField.js +26 -0
- package/lib/commonjs/components/SecureFields/VGS/ExpDateField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/TextField.js +30 -0
- package/lib/commonjs/components/SecureFields/VGS/TextField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/VGS/ZipCodeField.js +26 -0
- package/lib/commonjs/components/SecureFields/VGS/ZipCodeField.js.map +1 -0
- package/lib/commonjs/components/SecureFields/index.js +34 -0
- package/lib/commonjs/components/SecureFields/index.js.map +1 -0
- package/lib/commonjs/index.js +42 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/utils/index.js +112 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/components/LoadingIndicator.js +28 -0
- package/lib/module/components/LoadingIndicator.js.map +1 -0
- package/lib/module/components/PayEngine.js +124 -0
- package/lib/module/components/PayEngine.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/CVCField.js +14 -0
- package/lib/module/components/SecureFields/VGS/CVCField.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/CardHolderNameField.js +14 -0
- package/lib/module/components/SecureFields/VGS/CardHolderNameField.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/CardNumberField.js +14 -0
- package/lib/module/components/SecureFields/VGS/CardNumberField.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/CollectManager.js +50 -0
- package/lib/module/components/SecureFields/VGS/CollectManager.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/ExpDateField.js +14 -0
- package/lib/module/components/SecureFields/VGS/ExpDateField.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/TextField.js +17 -0
- package/lib/module/components/SecureFields/VGS/TextField.js.map +1 -0
- package/lib/module/components/SecureFields/VGS/ZipCodeField.js +14 -0
- package/lib/module/components/SecureFields/VGS/ZipCodeField.js.map +1 -0
- package/lib/module/components/SecureFields/index.js +17 -0
- package/lib/module/components/SecureFields/index.js.map +1 -0
- package/lib/module/index.js +18 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/utils/index.js +96 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/components/LoadingIndicator.d.ts +2 -0
- package/lib/typescript/components/PayEngine.d.ts +15 -0
- package/lib/typescript/components/SecureFields/VGS/CVCField.d.ts +10 -0
- package/lib/typescript/components/SecureFields/VGS/CardHolderNameField.d.ts +10 -0
- package/lib/typescript/components/SecureFields/VGS/CardNumberField.d.ts +10 -0
- package/lib/typescript/components/SecureFields/VGS/CollectManager.d.ts +12 -0
- package/lib/typescript/components/SecureFields/VGS/ExpDateField.d.ts +10 -0
- package/lib/typescript/components/SecureFields/VGS/TextField.d.ts +14 -0
- package/lib/typescript/components/SecureFields/VGS/ZipCodeField.d.ts +10 -0
- package/lib/typescript/components/SecureFields/index.d.ts +16 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/utils/index.d.ts +45 -0
- package/package.json +154 -0
- package/react-native-payengine.podspec +38 -0
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
set DIRNAME=%~dp0
|
|
12
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
|
13
|
+
set APP_BASE_NAME=%~n0
|
|
14
|
+
set APP_HOME=%DIRNAME%
|
|
15
|
+
|
|
16
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
17
|
+
set DEFAULT_JVM_OPTS=
|
|
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 Windows variants
|
|
50
|
+
|
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
52
|
+
|
|
53
|
+
:win9xME_args
|
|
54
|
+
@rem Slurp the command line arguments.
|
|
55
|
+
set CMD_LINE_ARGS=
|
|
56
|
+
set _SKIP=2
|
|
57
|
+
|
|
58
|
+
:win9xME_args_slurp
|
|
59
|
+
if "x%~1" == "x" goto execute
|
|
60
|
+
|
|
61
|
+
set CMD_LINE_ARGS=%*
|
|
62
|
+
|
|
63
|
+
:execute
|
|
64
|
+
@rem Setup the command line
|
|
65
|
+
|
|
66
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
67
|
+
|
|
68
|
+
@rem Execute Gradle
|
|
69
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
70
|
+
|
|
71
|
+
:end
|
|
72
|
+
@rem End local scope for the variables with windows NT shell
|
|
73
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
74
|
+
|
|
75
|
+
:fail
|
|
76
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
77
|
+
rem the _cmd.exe /c_ return code!
|
|
78
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
79
|
+
exit /b 1
|
|
80
|
+
|
|
81
|
+
:mainEnd
|
|
82
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
83
|
+
|
|
84
|
+
:omega
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
+
# as it contains information specific to your local configuration.
|
|
3
|
+
#
|
|
4
|
+
# Location of the SDK. This is only used by Gradle.
|
|
5
|
+
# For customization when using a Version Control System, please read the
|
|
6
|
+
# header note.
|
|
7
|
+
#Tue Sep 20 09:54:08 ICT 2022
|
|
8
|
+
sdk.dir=/Users/tringuyen/Library/Android/sdk
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.reactnativepayengine;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Promise;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
10
|
+
|
|
11
|
+
@ReactModule(name = PayengineModule.NAME)
|
|
12
|
+
public class PayengineModule extends ReactContextBaseJavaModule {
|
|
13
|
+
public static final String NAME = "Payengine";
|
|
14
|
+
|
|
15
|
+
public PayengineModule(ReactApplicationContext reactContext) {
|
|
16
|
+
super(reactContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
@NonNull
|
|
21
|
+
public String getName() {
|
|
22
|
+
return NAME;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Example method
|
|
27
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
28
|
+
@ReactMethod
|
|
29
|
+
public void multiply(double a, double b, Promise promise) {
|
|
30
|
+
promise.resolve(a * b);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.reactnativepayengine;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
import com.reactnativepayengine.collect.VGSCollectModule;
|
|
10
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
11
|
+
import com.reactnativepayengine.collect.fields.VGSCVCField;
|
|
12
|
+
import com.reactnativepayengine.collect.fields.VGSCardHolderNameField;
|
|
13
|
+
import com.reactnativepayengine.collect.fields.VGSCardNumberField;
|
|
14
|
+
import com.reactnativepayengine.collect.fields.VGSExpDateField;
|
|
15
|
+
import com.reactnativepayengine.collect.fields.VGSTextField;
|
|
16
|
+
import com.reactnativepayengine.collect.fields.VGSZipCodeField;
|
|
17
|
+
import com.verygoodsecurity.vgscollect.view.InputFieldView;
|
|
18
|
+
|
|
19
|
+
import java.util.ArrayList;
|
|
20
|
+
import java.util.List;
|
|
21
|
+
|
|
22
|
+
public class PayenginePackage implements ReactPackage, VGSCollectOnCreateViewInstanceListener {
|
|
23
|
+
|
|
24
|
+
private VGSCollectModule module;
|
|
25
|
+
|
|
26
|
+
public VGSCollectOnCreateViewInstanceListener getListener() {
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public VGSCollectModule getVGSCollectModule() {
|
|
31
|
+
return module;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@NonNull
|
|
36
|
+
@Override
|
|
37
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
38
|
+
module = new VGSCollectModule(reactContext);
|
|
39
|
+
|
|
40
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
41
|
+
modules.add(new PayengineModule(reactContext));
|
|
42
|
+
modules.add(module);
|
|
43
|
+
|
|
44
|
+
return modules;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@NonNull
|
|
48
|
+
@Override
|
|
49
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
50
|
+
List<ViewManager> views = new ArrayList<>();
|
|
51
|
+
views.add(new VGSExpDateField(this, reactContext));
|
|
52
|
+
views.add(new VGSCardNumberField(this, reactContext));
|
|
53
|
+
views.add(new VGSCardHolderNameField(this, reactContext));
|
|
54
|
+
views.add(new VGSCVCField(this, reactContext));
|
|
55
|
+
views.add(new VGSZipCodeField(this, reactContext));
|
|
56
|
+
views.add(new VGSTextField(this, reactContext));
|
|
57
|
+
return views;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public void onCreateViewInstance(InputFieldView inputFieldView) {
|
|
62
|
+
module.bindView(inputFieldView);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.Promise;
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
14
|
+
import com.reactnativepayengine.util.JSONObjectUtil;
|
|
15
|
+
import com.verygoodsecurity.vgscollect.VGSCollectLogger;
|
|
16
|
+
import com.verygoodsecurity.vgscollect.core.Environment;
|
|
17
|
+
import com.verygoodsecurity.vgscollect.core.HTTPMethod;
|
|
18
|
+
import com.verygoodsecurity.vgscollect.core.VGSCollect;
|
|
19
|
+
import com.verygoodsecurity.vgscollect.core.model.network.VGSRequest;
|
|
20
|
+
import com.verygoodsecurity.vgscollect.core.model.network.VGSResponse;
|
|
21
|
+
import com.verygoodsecurity.vgscollect.core.model.state.FieldState;
|
|
22
|
+
import com.verygoodsecurity.vgscollect.view.InputFieldView;
|
|
23
|
+
|
|
24
|
+
import org.json.JSONException;
|
|
25
|
+
import org.json.JSONObject;
|
|
26
|
+
|
|
27
|
+
import java.util.HashMap;
|
|
28
|
+
import java.util.List;
|
|
29
|
+
import java.util.Optional;
|
|
30
|
+
|
|
31
|
+
public class VGSCollectModule extends ReactContextBaseJavaModule {
|
|
32
|
+
|
|
33
|
+
private static ReactApplicationContext reactContext;
|
|
34
|
+
|
|
35
|
+
private VGSCollect collect;
|
|
36
|
+
|
|
37
|
+
public VGSCollectModule(ReactApplicationContext c) {
|
|
38
|
+
super(c);
|
|
39
|
+
reactContext = c;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public void initialize() {
|
|
44
|
+
super.initialize();
|
|
45
|
+
// Activity activity = reactContext.getCurrentActivity();
|
|
46
|
+
// collect = new VGSCollect.Builder(activity, "")
|
|
47
|
+
// .create();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@NonNull
|
|
51
|
+
@Override
|
|
52
|
+
public String getName() {
|
|
53
|
+
return "VGSCollectManager";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@ReactMethod
|
|
57
|
+
public void setConfiguration(String vaultId, String environment, String cname, double vgsSatellitePort) {
|
|
58
|
+
Log.e("test", "Create event called with name: " + vaultId + " and location: " + environment + " cname: " + cname);
|
|
59
|
+
|
|
60
|
+
VGSCollectLogger.INSTANCE.setLogLevel(VGSCollectLogger.Level.DEBUG);
|
|
61
|
+
|
|
62
|
+
Activity activity = reactContext.getCurrentActivity();
|
|
63
|
+
collect = new VGSCollect.Builder(activity, vaultId)
|
|
64
|
+
.setEnvironment(environment)
|
|
65
|
+
// .setHostname(cname)
|
|
66
|
+
// .setPort((int) Math.round(vgsSatellitePort))
|
|
67
|
+
.create();
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactMethod
|
|
72
|
+
public void createCard(String merchantId, Promise promise) {
|
|
73
|
+
this.submit("/api/cards", merchantId, promise);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod
|
|
77
|
+
public void createBankAccount(String merchantId, Promise promise) {
|
|
78
|
+
this.submit("/api/bank-accounts", merchantId, promise);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private void submit(String path, String merchantId, Promise promise) {
|
|
82
|
+
HashMap<String, Object> customData = new HashMap<>();
|
|
83
|
+
customData.put("pci_vault_provider", "vgs");
|
|
84
|
+
if (merchantId != null && !merchantId.isEmpty()) {
|
|
85
|
+
customData.put("merchant_id", merchantId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
HashMap<String, String> headers = new HashMap<>();
|
|
89
|
+
headers.put("CUSTOM-HEADER", "custom-header");
|
|
90
|
+
|
|
91
|
+
List<FieldState> states = collect.getAllStates();
|
|
92
|
+
|
|
93
|
+
for (int i = 0; i < states.size(); i++) {
|
|
94
|
+
FieldState state = states.get(i);
|
|
95
|
+
|
|
96
|
+
if (!state.isValid()) {
|
|
97
|
+
String message = new StringBuilder("Field ")
|
|
98
|
+
.append(state.getFieldName())
|
|
99
|
+
.append(" is not valid.")
|
|
100
|
+
.toString();
|
|
101
|
+
promise.reject("validation_error", message);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (state instanceof FieldState.CardNumberState) {
|
|
105
|
+
FieldState.CardNumberState cardState = (FieldState.CardNumberState) state;
|
|
106
|
+
customData.put("last_4", cardState.getNumber());
|
|
107
|
+
customData.put("bin", cardState.getBin());
|
|
108
|
+
customData.put("brand", cardState.getCardBrand());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
VGSRequest request = new VGSRequest.VGSRequestBuilder()
|
|
113
|
+
.setMethod(HTTPMethod.POST)
|
|
114
|
+
.setPath(path)
|
|
115
|
+
.setCustomHeader(headers)
|
|
116
|
+
.setCustomData(customData)
|
|
117
|
+
.build();
|
|
118
|
+
|
|
119
|
+
VGSResponse response = collect.submit(request);
|
|
120
|
+
Log.e("test", "response " + response.getBody());
|
|
121
|
+
if (response instanceof VGSResponse.SuccessResponse) {
|
|
122
|
+
VGSResponse.SuccessResponse result = (VGSResponse.SuccessResponse) response;
|
|
123
|
+
try {
|
|
124
|
+
JSONObject jsonObj = new JSONObject(result.getBody());
|
|
125
|
+
promise.resolve(JSONObjectUtil.convertJsonToMap(jsonObj.getJSONObject("data")));
|
|
126
|
+
return;
|
|
127
|
+
} catch (JSONException e) {
|
|
128
|
+
e.printStackTrace();
|
|
129
|
+
promise.reject("invalid_response", "We got success response but unable to parse it");
|
|
130
|
+
}
|
|
131
|
+
} else if (response instanceof VGSResponse.ErrorResponse) {
|
|
132
|
+
VGSResponse.ErrorResponse error = (VGSResponse.ErrorResponse) response;
|
|
133
|
+
promise.reject(String.valueOf(error.getErrorCode()), error.getLocalizeMessage());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
|
139
|
+
if (collect != null) {
|
|
140
|
+
collect.onActivityResult(requestCode, resultCode, data);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public void bindView(InputFieldView inputFieldView) {
|
|
145
|
+
Log.e("test", "collect bindView " + inputFieldView.getFieldName() + " - Collect " + collect.getAllStates());
|
|
146
|
+
collect.bindView(inputFieldView);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect.fields;
|
|
2
|
+
|
|
3
|
+
import android.graphics.Rect;
|
|
4
|
+
import android.graphics.drawable.Drawable;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
11
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
12
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
13
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
14
|
+
import com.verygoodsecurity.vgscollect.view.card.CardType;
|
|
15
|
+
import com.verygoodsecurity.vgscollect.view.cvc.CVCIconAdapter;
|
|
16
|
+
import com.verygoodsecurity.vgscollect.widget.CardVerificationCodeEditText;
|
|
17
|
+
import com.verygoodsecurity.vgscollect.widget.VGSCardNumberEditText;
|
|
18
|
+
import com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout;
|
|
19
|
+
|
|
20
|
+
import org.jetbrains.annotations.NotNull;
|
|
21
|
+
|
|
22
|
+
public class VGSCVCField extends SimpleViewManager<VGSTextInputLayout> {
|
|
23
|
+
private final VGSCollectOnCreateViewInstanceListener listener;
|
|
24
|
+
|
|
25
|
+
private CardVerificationCodeEditText editText;
|
|
26
|
+
private VGSTextInputLayout vgsTextInputLayout;
|
|
27
|
+
|
|
28
|
+
ReactApplicationContext mCallerContext;
|
|
29
|
+
|
|
30
|
+
public VGSCVCField(VGSCollectOnCreateViewInstanceListener listener, ReactApplicationContext reactContext) {
|
|
31
|
+
this.listener = listener;
|
|
32
|
+
mCallerContext = reactContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public String getName() {
|
|
37
|
+
return "VGSCVCField";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@NonNull
|
|
41
|
+
@Override
|
|
42
|
+
protected VGSTextInputLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
43
|
+
vgsTextInputLayout = new VGSTextInputLayout(reactContext);
|
|
44
|
+
vgsTextInputLayout.setHint("CVC");
|
|
45
|
+
editText = new CardVerificationCodeEditText(reactContext);
|
|
46
|
+
editText.setIsRequired(true);
|
|
47
|
+
editText.setFieldName("card_cvc");
|
|
48
|
+
CVCIconAdapter adapter = new CVCIconAdapter(reactContext) {
|
|
49
|
+
@Override
|
|
50
|
+
protected Drawable getIcon(@NotNull CardType cardType, @Nullable String cardBrand, int cvcLength, @NotNull Rect r) {
|
|
51
|
+
return super.getIcon(cardType, cardBrand, cvcLength, r);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
editText.setPreviewIconAdapter(adapter);
|
|
55
|
+
editText.setPadding(10, 0, 10, 0);
|
|
56
|
+
|
|
57
|
+
vgsTextInputLayout.addView(editText);
|
|
58
|
+
|
|
59
|
+
this.listener.onCreateViewInstance(editText);
|
|
60
|
+
return vgsTextInputLayout;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactProp(name = "placeholder")
|
|
64
|
+
public void setPlaceholder(VGSTextInputLayout view, @Nullable String placeholder) {
|
|
65
|
+
vgsTextInputLayout.setHint(placeholder);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/android/src/main/java/com/reactnativepayengine/collect/fields/VGSCardHolderNameField.java
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect.fields;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
11
|
+
import com.verygoodsecurity.vgscollect.widget.ExpirationDateEditText;
|
|
12
|
+
import com.verygoodsecurity.vgscollect.widget.PersonNameEditText;
|
|
13
|
+
import com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout;
|
|
14
|
+
|
|
15
|
+
public class VGSCardHolderNameField extends SimpleViewManager<VGSTextInputLayout> {
|
|
16
|
+
private final VGSCollectOnCreateViewInstanceListener listener;
|
|
17
|
+
|
|
18
|
+
private PersonNameEditText editText;
|
|
19
|
+
private VGSTextInputLayout vgsTextInputLayout;
|
|
20
|
+
|
|
21
|
+
ReactApplicationContext mCallerContext;
|
|
22
|
+
|
|
23
|
+
public VGSCardHolderNameField(VGSCollectOnCreateViewInstanceListener listener, ReactApplicationContext reactContext) {
|
|
24
|
+
this.listener = listener;
|
|
25
|
+
mCallerContext = reactContext;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public String getName() {
|
|
30
|
+
return "VGSCardHolderNameField";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@NonNull
|
|
34
|
+
@Override
|
|
35
|
+
protected VGSTextInputLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
36
|
+
vgsTextInputLayout = new VGSTextInputLayout(reactContext);
|
|
37
|
+
vgsTextInputLayout.setHint("Card holder name");
|
|
38
|
+
editText = new PersonNameEditText(reactContext);
|
|
39
|
+
editText.setIsRequired(true);
|
|
40
|
+
editText.setFieldName("card_holder");
|
|
41
|
+
editText.setPadding(10, 0, 10, 0);
|
|
42
|
+
|
|
43
|
+
vgsTextInputLayout.addView(editText);
|
|
44
|
+
|
|
45
|
+
this.listener.onCreateViewInstance(editText);
|
|
46
|
+
return vgsTextInputLayout;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactProp(name = "placeholder")
|
|
50
|
+
public void setPlaceholder(VGSTextInputLayout view, @Nullable String placeholder) {
|
|
51
|
+
vgsTextInputLayout.setHint(placeholder);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect.fields;
|
|
2
|
+
|
|
3
|
+
import android.view.Gravity;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
10
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
11
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
12
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
13
|
+
import com.verygoodsecurity.vgscollect.widget.PersonNameEditText;
|
|
14
|
+
import com.verygoodsecurity.vgscollect.widget.VGSCardNumberEditText;
|
|
15
|
+
import com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout;
|
|
16
|
+
|
|
17
|
+
public class VGSCardNumberField extends SimpleViewManager<VGSTextInputLayout> {
|
|
18
|
+
private final VGSCollectOnCreateViewInstanceListener listener;
|
|
19
|
+
|
|
20
|
+
private VGSCardNumberEditText editText;
|
|
21
|
+
private VGSTextInputLayout vgsTextInputLayout;
|
|
22
|
+
|
|
23
|
+
ReactApplicationContext mCallerContext;
|
|
24
|
+
|
|
25
|
+
public VGSCardNumberField(VGSCollectOnCreateViewInstanceListener listener, ReactApplicationContext reactContext) {
|
|
26
|
+
this.listener = listener;
|
|
27
|
+
mCallerContext = reactContext;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public String getName() {
|
|
32
|
+
return "VGSCardNumberField";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@NonNull
|
|
36
|
+
@Override
|
|
37
|
+
protected VGSTextInputLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
38
|
+
vgsTextInputLayout = new VGSTextInputLayout(reactContext);
|
|
39
|
+
vgsTextInputLayout.setHint("Card number");
|
|
40
|
+
editText = new VGSCardNumberEditText(reactContext);
|
|
41
|
+
editText.setIsRequired(true);
|
|
42
|
+
editText.setFieldName("card_number");
|
|
43
|
+
editText.setDivider(' ');
|
|
44
|
+
editText.setCardBrandIconGravity(Gravity.END);
|
|
45
|
+
editText.setPadding(10, 0, 10, 0);
|
|
46
|
+
|
|
47
|
+
vgsTextInputLayout.addView(editText);
|
|
48
|
+
|
|
49
|
+
this.listener.onCreateViewInstance(editText);
|
|
50
|
+
return vgsTextInputLayout;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ReactProp(name = "placeholder")
|
|
54
|
+
public void setPlaceholder(VGSTextInputLayout view, @Nullable String placeholder) {
|
|
55
|
+
vgsTextInputLayout.setHint(placeholder);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect.fields;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
11
|
+
import com.verygoodsecurity.vgscollect.widget.ExpirationDateEditText;
|
|
12
|
+
import com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout;
|
|
13
|
+
|
|
14
|
+
public class VGSExpDateField extends SimpleViewManager<VGSTextInputLayout> {
|
|
15
|
+
private final VGSCollectOnCreateViewInstanceListener listener;
|
|
16
|
+
|
|
17
|
+
private ExpirationDateEditText editText;
|
|
18
|
+
private VGSTextInputLayout vgsTextInputLayout;
|
|
19
|
+
|
|
20
|
+
ReactApplicationContext mCallerContext;
|
|
21
|
+
|
|
22
|
+
public VGSExpDateField(VGSCollectOnCreateViewInstanceListener listener, ReactApplicationContext reactContext) {
|
|
23
|
+
this.listener = listener;
|
|
24
|
+
mCallerContext = reactContext;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return "VGSExpDateField";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@NonNull
|
|
33
|
+
@Override
|
|
34
|
+
protected VGSTextInputLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
35
|
+
vgsTextInputLayout = new VGSTextInputLayout(reactContext);
|
|
36
|
+
vgsTextInputLayout.setHint("Exp Date");
|
|
37
|
+
editText = new ExpirationDateEditText(reactContext);
|
|
38
|
+
editText.setIsRequired(true);
|
|
39
|
+
editText.setDateRegex("MM/yy");
|
|
40
|
+
editText.setFieldName("card_exp");
|
|
41
|
+
editText.setPadding(10, 0, 10, 0);
|
|
42
|
+
|
|
43
|
+
vgsTextInputLayout.addView(editText);
|
|
44
|
+
|
|
45
|
+
this.listener.onCreateViewInstance(editText);
|
|
46
|
+
return vgsTextInputLayout;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactProp(name = "placeholder")
|
|
50
|
+
public void setPlaceholder(VGSTextInputLayout view, @Nullable String placeholder) {
|
|
51
|
+
vgsTextInputLayout.setHint(placeholder);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package com.reactnativepayengine.collect.fields;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
import com.reactnativepayengine.collect.VGSCollectOnCreateViewInstanceListener;
|
|
11
|
+
import com.verygoodsecurity.vgscollect.widget.VGSEditText;
|
|
12
|
+
import com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout;
|
|
13
|
+
|
|
14
|
+
public class VGSTextField extends SimpleViewManager<VGSTextInputLayout> {
|
|
15
|
+
private final VGSCollectOnCreateViewInstanceListener listener;
|
|
16
|
+
|
|
17
|
+
private VGSEditText editText;
|
|
18
|
+
private VGSTextInputLayout vgsTextInputLayout;
|
|
19
|
+
|
|
20
|
+
ReactApplicationContext mCallerContext;
|
|
21
|
+
|
|
22
|
+
public VGSTextField(VGSCollectOnCreateViewInstanceListener listener, ReactApplicationContext reactContext) {
|
|
23
|
+
this.listener = listener;
|
|
24
|
+
mCallerContext = reactContext;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return "VGSTextField";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@NonNull
|
|
33
|
+
@Override
|
|
34
|
+
protected VGSTextInputLayout createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
35
|
+
vgsTextInputLayout = new VGSTextInputLayout(reactContext);
|
|
36
|
+
vgsTextInputLayout.setHint("");
|
|
37
|
+
editText = new VGSEditText(reactContext);
|
|
38
|
+
editText.setFieldName("custom_text");
|
|
39
|
+
editText.setPadding(10, 0, 10, 0);
|
|
40
|
+
|
|
41
|
+
vgsTextInputLayout.addView(editText);
|
|
42
|
+
|
|
43
|
+
this.listener.onCreateViewInstance(editText);
|
|
44
|
+
return vgsTextInputLayout;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactProp(name = "placeholder")
|
|
48
|
+
public void setPlaceholder(VGSTextInputLayout view, @Nullable String placeholder) {
|
|
49
|
+
vgsTextInputLayout.setHint(placeholder);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactProp(name = "maxlength")
|
|
53
|
+
public void setMaxLength(VGSTextInputLayout view, @Nullable double maxLength) {
|
|
54
|
+
editText.setMaxLength((int) maxLength);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|