nimbbl-mobile-react-native-sdk 1.1.1 → 1.3.0
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/README.md +161 -170
- package/android/build.gradle +4 -4
- package/android/src/main/AndroidManifest.xml +0 -4
- package/android/src/main/java/com/nimbbl/reactnative/NimbblCheckoutActivity.kt +52 -117
- package/android/src/main/java/com/nimbbl/reactnative/NimbblReactNativeSDKModule.kt +283 -187
- package/ios/NimbblReactNativeSDK.m +6 -2
- package/ios/NimbblReactNativeSDK.podspec +1 -1
- package/ios/NimbblReactNativeSDK.swift +23 -53
- package/lib/NimbblSDK.d.ts +5 -57
- package/lib/NimbblSDK.js +36 -151
- package/lib/constants.d.ts +2 -16
- package/lib/constants.js +3 -20
- package/lib/index.d.ts +3 -3
- package/lib/index.js +2 -5
- package/lib/types.d.ts +18 -84
- package/lib/types.js +1 -1
- package/nimbbl-mobile-react-native-sdk.podspec +1 -1
- package/package.json +23 -4
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/results.bin +0 -1
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/BuildConfig.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblCheckoutActivity$Companion.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblCheckoutActivity.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblReactNativeSDKModule$Companion.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblReactNativeSDKModule$createShopOrder$orderResult$1.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblReactNativeSDKModule.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/NimbblReactNativeSDKPackage.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/TestActivity$Companion.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/nimbbl/reactnative/TestActivity.dex +0 -0
- package/android/build/.transforms/2a0cc55152835fcf4fba7a298d35d4c4/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/b59c320b706dec67ea6e4de5e98939af/results.bin +0 -1
- package/android/build/.transforms/b59c320b706dec67ea6e4de5e98939af/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/com/nimbbl/reactnative/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -23
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/nimbbl-mobile-react-native-sdk_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/nimbbl/reactnative/BuildConfig.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -36
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -23
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/nimbbl-mobile-react-native-sdk_debug.kotlin_module +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblCheckoutActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblCheckoutActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblReactNativeSDKModule$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblReactNativeSDKModule$createShopOrder$orderResult$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblReactNativeSDKModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/NimbblReactNativeSDKPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/TestActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/nimbbl/reactnative/TestActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -42
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/nimbbl-mobile-react-native-sdk_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblCheckoutActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblCheckoutActivity.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblReactNativeSDKModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblReactNativeSDKModule$createShopOrder$orderResult$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblReactNativeSDKModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/NimbblReactNativeSDKPackage.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/TestActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/nimbbl/reactnative/TestActivity.class +0 -0
- package/android/src/main/java/com/nimbbl/reactnative/TestActivity.kt +0 -28
- package/lib/NimbblSDK.d.ts.map +0 -1
- package/lib/NimbblSDK.js.map +0 -1
- package/lib/__tests__/__mocks__/react-native.d.ts +0 -26
- package/lib/__tests__/__mocks__/react-native.d.ts.map +0 -1
- package/lib/__tests__/__mocks__/react-native.js +0 -23
- package/lib/__tests__/__mocks__/react-native.js.map +0 -1
- package/lib/__tests__/setup.d.ts +0 -1
- package/lib/__tests__/setup.d.ts.map +0 -1
- package/lib/__tests__/setup.js +0 -4
- package/lib/__tests__/setup.js.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
|
@@ -2,63 +2,139 @@ package com.nimbbl.reactnative
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
|
-
import android.util.Log
|
|
6
5
|
import com.facebook.react.bridge.*
|
|
7
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
6
|
import tech.nimbbl.webviewsdk.core.NimbblCheckoutSDK
|
|
9
|
-
import tech.nimbbl.webviewsdk.core.
|
|
7
|
+
import tech.nimbbl.webviewsdk.core.NimbblShopOrderCreation
|
|
10
8
|
import tech.nimbbl.webviewsdk.models.NimbblCheckoutOptions
|
|
11
9
|
import tech.nimbbl.webviewsdk.models.interfaces.NimbblCheckoutPaymentListener
|
|
12
10
|
import kotlinx.coroutines.*
|
|
13
11
|
import retrofit2.Response
|
|
12
|
+
import java.io.Serializable
|
|
13
|
+
import org.json.JSONObject
|
|
14
|
+
import org.json.JSONException
|
|
14
15
|
|
|
15
16
|
class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationContext) :
|
|
16
17
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
17
18
|
|
|
18
19
|
companion object {
|
|
19
|
-
private
|
|
20
|
+
private var instance: NimbblReactNativeSDKModule? = null
|
|
21
|
+
|
|
22
|
+
fun handleCheckoutResponse(data: MutableMap<String, Any>) {
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
instance?.let { module ->
|
|
26
|
+
// Convert Map to WritableMap
|
|
27
|
+
val responseData = Arguments.createMap().apply {
|
|
28
|
+
data.forEach { (key, value) ->
|
|
29
|
+
when (value) {
|
|
30
|
+
is String -> {
|
|
31
|
+
// Special handling for 'order' field - parse JSON string to object
|
|
32
|
+
if (key == "order" && value.startsWith("{") && value.endsWith("}")) {
|
|
33
|
+
try {
|
|
34
|
+
val jsonObject = JSONObject(value)
|
|
35
|
+
val orderMap = Arguments.createMap()
|
|
36
|
+
|
|
37
|
+
// Convert JSONObject to WritableMap
|
|
38
|
+
jsonObject.keys().forEach { jsonKey ->
|
|
39
|
+
val jsonValue = jsonObject.get(jsonKey)
|
|
40
|
+
when (jsonValue) {
|
|
41
|
+
is String -> orderMap.putString(jsonKey, jsonValue)
|
|
42
|
+
is Number -> orderMap.putDouble(jsonKey, jsonValue.toDouble())
|
|
43
|
+
is Boolean -> orderMap.putBoolean(jsonKey, jsonValue)
|
|
44
|
+
is JSONObject -> {
|
|
45
|
+
val nestedMap = Arguments.createMap()
|
|
46
|
+
jsonValue.keys().forEach { nestedKey ->
|
|
47
|
+
val nestedValue = jsonValue.get(nestedKey)
|
|
48
|
+
when (nestedValue) {
|
|
49
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
50
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
51
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
52
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
orderMap.putMap(jsonKey, nestedMap)
|
|
56
|
+
}
|
|
57
|
+
else -> orderMap.putString(jsonKey, jsonValue.toString())
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
putMap(key, orderMap)
|
|
62
|
+
} catch (e: JSONException) {
|
|
63
|
+
putString(key, value)
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
putString(key, value)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
is Number -> putDouble(key, value.toDouble())
|
|
70
|
+
is Boolean -> putBoolean(key, value)
|
|
71
|
+
is Map<*, *> -> {
|
|
72
|
+
val nestedMap = Arguments.createMap()
|
|
73
|
+
(value as Map<String, Any>).forEach { (nestedKey, nestedValue) ->
|
|
74
|
+
when (nestedValue) {
|
|
75
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
76
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
77
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
78
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
putMap(key, nestedMap)
|
|
82
|
+
}
|
|
83
|
+
else -> putString(key, value.toString())
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Use callback if available
|
|
89
|
+
if (module.checkoutCallback != null) {
|
|
90
|
+
module.checkoutCallback?.invoke(responseData)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} catch (e: Exception) {
|
|
94
|
+
// Error in handleCheckoutResponse - ignore
|
|
95
|
+
}
|
|
96
|
+
}
|
|
20
97
|
}
|
|
21
98
|
|
|
22
99
|
private var config: MutableMap<String, Any> = mutableMapOf()
|
|
23
100
|
private var isInitialized = false
|
|
101
|
+
private var checkoutCallback: ((WritableMap) -> Unit)? = null
|
|
24
102
|
|
|
25
103
|
init {
|
|
26
104
|
reactContext.addActivityEventListener(this)
|
|
105
|
+
instance = this
|
|
27
106
|
}
|
|
28
107
|
|
|
29
108
|
override fun getName(): String {
|
|
30
109
|
return "NimbblReactNativeSDK"
|
|
31
110
|
}
|
|
32
111
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
112
|
+
|
|
113
|
+
@ReactMethod
|
|
114
|
+
fun addListener(@Suppress("UNUSED_PARAMETER") eventName: String) {
|
|
115
|
+
// Required for NativeEventEmitter - no action needed
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactMethod
|
|
119
|
+
fun removeListeners(@Suppress("UNUSED_PARAMETER") count: Int) {
|
|
120
|
+
// Required for NativeEventEmitter - no action needed
|
|
38
121
|
}
|
|
39
122
|
|
|
123
|
+
|
|
40
124
|
@ReactMethod
|
|
41
|
-
fun
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
putString("message", "Module is working")
|
|
125
|
+
fun setCheckoutCallback(callback: Callback) {
|
|
126
|
+
this.checkoutCallback = { result ->
|
|
127
|
+
try {
|
|
128
|
+
callback.invoke(result)
|
|
129
|
+
} catch (e: Exception) {
|
|
130
|
+
// Error calling React Native callback - ignore
|
|
48
131
|
}
|
|
49
|
-
promise.resolve(result)
|
|
50
|
-
} catch (error: Exception) {
|
|
51
|
-
println("Error in testModule: ${error.message}")
|
|
52
|
-
Log.e(TAG, "Error in testModule: ${error.message}", error)
|
|
53
|
-
promise.reject("TEST_MODULE_FAILED", error.message, error)
|
|
54
132
|
}
|
|
55
133
|
}
|
|
56
134
|
|
|
57
135
|
@ReactMethod
|
|
58
136
|
fun initialize(config: ReadableMap, promise: Promise) {
|
|
59
137
|
try {
|
|
60
|
-
Log.d(TAG, "Initializing Nimbbl SDK")
|
|
61
|
-
|
|
62
138
|
if (config == null) {
|
|
63
139
|
promise.reject("INVALID_CONFIG", "Configuration is required")
|
|
64
140
|
return
|
|
@@ -66,13 +142,14 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
66
142
|
|
|
67
143
|
// Extract configuration
|
|
68
144
|
this.config.clear()
|
|
69
|
-
this.config["
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
145
|
+
this.config["api_base_url"] = config.getString("api_base_url") ?: "https://api.nimbbl.tech"
|
|
146
|
+
|
|
147
|
+
// Set environment URL on the native SDK during initialization
|
|
148
|
+
val apiBaseUrl = this.config["api_base_url"] as? String
|
|
149
|
+
if (!apiBaseUrl.isNullOrEmpty()) {
|
|
150
|
+
// Ensure URL ends with / to prevent URL construction issues
|
|
151
|
+
val normalizedUrl = if (apiBaseUrl.endsWith("/")) apiBaseUrl else apiBaseUrl + "/"
|
|
152
|
+
NimbblCheckoutSDK.getInstance().setEnvironmentUrl(normalizedUrl)
|
|
76
153
|
}
|
|
77
154
|
|
|
78
155
|
isInitialized = true
|
|
@@ -85,48 +162,28 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
85
162
|
promise.resolve(result)
|
|
86
163
|
|
|
87
164
|
} catch (e: Exception) {
|
|
88
|
-
Log.e(TAG, "Error initializing SDK", e)
|
|
89
165
|
promise.reject("INITIALIZATION_FAILED", e.message)
|
|
90
166
|
}
|
|
91
167
|
}
|
|
92
168
|
|
|
93
169
|
@ReactMethod
|
|
94
170
|
fun createShopOrder(orderData: ReadableMap, promise: Promise) {
|
|
95
|
-
Log.d(TAG, "=== CREATE SHOP ORDER METHOD CALLED ===")
|
|
96
|
-
println("NimbblReactNativeSDK createShopOrder method called")
|
|
97
|
-
|
|
98
171
|
try {
|
|
99
172
|
if (!isInitialized) {
|
|
100
|
-
Log.e(TAG, "SDK not initialized")
|
|
101
173
|
promise.reject("NOT_INITIALIZED", "SDK must be initialized before creating orders")
|
|
102
174
|
return
|
|
103
175
|
}
|
|
104
|
-
|
|
105
|
-
Log.d(TAG, "Creating shop order: $orderData")
|
|
106
|
-
println("Creating shop order with data: $orderData")
|
|
107
176
|
|
|
108
177
|
// Extract order data
|
|
109
178
|
val currency = orderData.getString("currency") ?: "INR"
|
|
110
179
|
val amountString = orderData.getString("amount") ?: "0"
|
|
111
180
|
val amount = amountString.toDoubleOrNull() ?: 0.0
|
|
112
181
|
val productId = orderData.getString("product_id") ?: "11"
|
|
113
|
-
val orderLineItems = orderData.getBoolean("orderLineItems")
|
|
114
|
-
val checkoutExperience = orderData.getString("checkout_experience") ?: "redirect"
|
|
115
182
|
val paymentMode = orderData.getString("payment_mode") ?: ""
|
|
116
|
-
val subPaymentMode = orderData.getString("subPaymentMode") ?: ""
|
|
117
183
|
|
|
118
|
-
Log.d(TAG, "Extracted order data:")
|
|
119
|
-
Log.d(TAG, " - currency: $currency")
|
|
120
|
-
Log.d(TAG, " - amount: $amount")
|
|
121
|
-
Log.d(TAG, " - productId: $productId")
|
|
122
|
-
Log.d(TAG, " - orderLineItems: $orderLineItems")
|
|
123
|
-
Log.d(TAG, " - checkoutExperience: $checkoutExperience")
|
|
124
|
-
Log.d(TAG, " - paymentMode: $paymentMode")
|
|
125
|
-
Log.d(TAG, " - subPaymentMode: $subPaymentMode")
|
|
126
184
|
|
|
127
185
|
// Validate required fields
|
|
128
186
|
if (amountString.isEmpty() || currency.isEmpty()) {
|
|
129
|
-
Log.e(TAG, "Amount or currency is empty")
|
|
130
187
|
promise.reject("INVALID_ORDER_DATA", "Amount and currency are required")
|
|
131
188
|
return
|
|
132
189
|
}
|
|
@@ -139,55 +196,22 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
139
196
|
null
|
|
140
197
|
}
|
|
141
198
|
|
|
142
|
-
Log.d(TAG, "User data: $user")
|
|
143
|
-
|
|
144
199
|
// Use the actual Nimbbl Android SDK to create order
|
|
145
200
|
// Set environment URL if provided
|
|
146
201
|
val apiBaseUrl = config["api_base_url"] as? String
|
|
147
202
|
if (!apiBaseUrl.isNullOrEmpty()) {
|
|
148
|
-
|
|
149
|
-
NimbblCheckoutSDK.instance?.setEnvironmentUrl(apiBaseUrl)
|
|
203
|
+
NimbblCheckoutSDK.getInstance().setEnvironmentUrl(apiBaseUrl)
|
|
150
204
|
}
|
|
151
|
-
|
|
205
|
+
|
|
152
206
|
// Extract user details for order creation
|
|
153
207
|
val userEmail = user?.get("email") as? String ?: ""
|
|
154
208
|
val userName = user?.get("name") as? String ?: ""
|
|
155
209
|
val userMobile = user?.get("mobile_number") as? String ?: ""
|
|
156
210
|
|
|
157
|
-
Log.d(TAG, "User details:")
|
|
158
|
-
Log.d(TAG, " - email: $userEmail")
|
|
159
|
-
Log.d(TAG, " - name: $userName")
|
|
160
|
-
Log.d(TAG, " - mobile: $userMobile")
|
|
161
|
-
|
|
162
|
-
Log.d(TAG, "About to attempt Android SDK call")
|
|
163
|
-
println("About to attempt Android SDK call")
|
|
164
|
-
|
|
165
211
|
// Try to use the actual Android SDK for order creation
|
|
166
212
|
try {
|
|
167
|
-
Log.d(TAG, "Attempting to use Android SDK for order creation...")
|
|
168
|
-
println("Attempting to use Android SDK for order creation...")
|
|
169
|
-
|
|
170
213
|
// Get the API base URL from config
|
|
171
|
-
val
|
|
172
|
-
Log.d(TAG, "Using API base URL: $apiBaseUrl")
|
|
173
|
-
println("Using API base URL: $apiBaseUrl")
|
|
174
|
-
|
|
175
|
-
Log.d(TAG, "Calling createOrder with parameters:")
|
|
176
|
-
Log.d(TAG, " - apiBaseUrl: $apiBaseUrl")
|
|
177
|
-
Log.d(TAG, " - amountString: $amountString")
|
|
178
|
-
Log.d(TAG, " - userEmail: $userEmail")
|
|
179
|
-
Log.d(TAG, " - userName: $userName")
|
|
180
|
-
Log.d(TAG, " - userMobile: $userMobile")
|
|
181
|
-
Log.d(TAG, " - productId: $productId")
|
|
182
|
-
Log.d(TAG, " - paymentMode: $paymentMode")
|
|
183
|
-
println("Calling createOrder with parameters:")
|
|
184
|
-
println(" - apiBaseUrl: $apiBaseUrl")
|
|
185
|
-
println(" - amountString: $amountString")
|
|
186
|
-
println(" - userEmail: $userEmail")
|
|
187
|
-
println(" - userName: $userName")
|
|
188
|
-
println(" - userMobile: $userMobile")
|
|
189
|
-
println(" - productId: $productId")
|
|
190
|
-
println(" - paymentMode: $paymentMode")
|
|
214
|
+
val orderApiBaseUrl = config["api_base_url"] as? String ?: "https://api.nimbbl.tech/"
|
|
191
215
|
|
|
192
216
|
// Use direct method call with coroutine (since createOrder is a suspend function)
|
|
193
217
|
// Convert amount string to int
|
|
@@ -195,8 +219,8 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
195
219
|
|
|
196
220
|
// Use coroutine to call suspend function
|
|
197
221
|
val orderResult = runBlocking {
|
|
198
|
-
|
|
199
|
-
|
|
222
|
+
NimbblShopOrderCreation.createShopOrder(
|
|
223
|
+
orderApiBaseUrl,
|
|
200
224
|
amountInt, // Use amount as int
|
|
201
225
|
userEmail,
|
|
202
226
|
userName,
|
|
@@ -207,90 +231,54 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
207
231
|
)
|
|
208
232
|
}
|
|
209
233
|
|
|
210
|
-
Log.d(TAG, "Order creation result: $orderResult")
|
|
211
|
-
println("Order creation result: $orderResult")
|
|
212
|
-
|
|
213
234
|
// The result should be a Response object
|
|
214
235
|
if (orderResult != null) {
|
|
215
|
-
Log.d(TAG, "Order result is not null, checking if successful...")
|
|
216
|
-
println("Order result is not null, checking if successful...")
|
|
217
|
-
|
|
218
236
|
// Check if the response is successful
|
|
219
237
|
if (orderResult.isSuccessful) {
|
|
220
|
-
Log.d(TAG, "Response is successful, getting body...")
|
|
221
|
-
println("Response is successful, getting body...")
|
|
222
|
-
|
|
223
238
|
// Get the response body
|
|
224
239
|
val responseBody = orderResult.body()
|
|
225
|
-
|
|
226
|
-
Log.d(TAG, "Response body: $responseBody")
|
|
227
|
-
println("Response body: $responseBody")
|
|
228
|
-
|
|
240
|
+
|
|
229
241
|
if (responseBody != null) {
|
|
230
|
-
Log.d(TAG, "Response body is not null, extracting token...")
|
|
231
|
-
println("Response body is not null, extracting token...")
|
|
232
|
-
|
|
233
242
|
// Extract token from response body
|
|
234
243
|
val token = responseBody.token
|
|
235
244
|
val orderId = responseBody.orderId
|
|
236
245
|
|
|
237
|
-
Log.d(TAG, "Extracted token: $token")
|
|
238
|
-
Log.d(TAG, "Extracted order ID: $orderId")
|
|
239
|
-
println("Extracted token: $token")
|
|
240
|
-
println("Extracted order ID: $orderId")
|
|
241
|
-
|
|
242
246
|
if (!token.isNullOrEmpty()) {
|
|
243
247
|
val result = Arguments.createMap().apply {
|
|
244
|
-
putString("order_id", orderId
|
|
248
|
+
putString("order_id", orderId)
|
|
245
249
|
putString("token", token)
|
|
246
250
|
putString("status", "created")
|
|
247
251
|
putDouble("amount", amount)
|
|
248
252
|
putString("currency", currency)
|
|
249
253
|
}
|
|
250
|
-
|
|
251
|
-
Log.d(TAG, "Order created successfully with real token: $result")
|
|
252
|
-
println("Order created successfully with real token: $result")
|
|
254
|
+
|
|
253
255
|
promise.resolve(result)
|
|
254
256
|
return
|
|
255
257
|
} else {
|
|
256
|
-
Log.e(TAG, "Token is null or empty in response")
|
|
257
|
-
println("Token is null or empty in response")
|
|
258
258
|
promise.reject("INVALID_RESPONSE", "Token is null or empty in response")
|
|
259
259
|
return
|
|
260
260
|
}
|
|
261
261
|
} else {
|
|
262
|
-
Log.e(TAG, "Response body is null")
|
|
263
|
-
println("Response body is null")
|
|
264
262
|
promise.reject("INVALID_RESPONSE", "Response body is null")
|
|
265
263
|
return
|
|
266
264
|
}
|
|
267
265
|
} else {
|
|
268
266
|
// Get error body for logging
|
|
269
267
|
val errorBody = orderResult.errorBody()
|
|
270
|
-
Log.e(TAG, "Order creation failed, error body: $errorBody")
|
|
271
|
-
println("Order creation failed, error body: $errorBody")
|
|
272
268
|
promise.reject("ORDER_CREATION_FAILED", "Order creation failed: $errorBody")
|
|
273
269
|
return
|
|
274
270
|
}
|
|
275
271
|
} else {
|
|
276
|
-
Log.e(TAG, "Order creation result is null")
|
|
277
|
-
println("Order creation result is null")
|
|
278
272
|
promise.reject("ORDER_CREATION_FAILED", "Order creation result is null")
|
|
279
273
|
return
|
|
280
274
|
}
|
|
281
275
|
|
|
282
276
|
} catch (e: Exception) {
|
|
283
|
-
Log.e(TAG, "Android SDK order creation failed: ${e.message}", e)
|
|
284
|
-
println("Android SDK order creation failed: ${e.message}")
|
|
285
|
-
e.printStackTrace()
|
|
286
277
|
promise.reject("ORDER_CREATION_FAILED", "Android SDK order creation failed: ${e.message}")
|
|
287
278
|
return
|
|
288
279
|
}
|
|
289
280
|
|
|
290
281
|
} catch (e: Exception) {
|
|
291
|
-
Log.e(TAG, "Error creating shop order", e)
|
|
292
|
-
println("Error creating shop order: ${e.message}")
|
|
293
|
-
e.printStackTrace()
|
|
294
282
|
promise.reject("ORDER_CREATION_FAILED", e.message)
|
|
295
283
|
}
|
|
296
284
|
}
|
|
@@ -299,16 +287,11 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
299
287
|
|
|
300
288
|
@ReactMethod
|
|
301
289
|
fun checkout(options: ReadableMap, promise: Promise) {
|
|
302
|
-
Log.d(TAG, "=== CHECKOUT METHOD CALLED ===")
|
|
303
|
-
println("NimbblReactNativeSDK checkout method called")
|
|
304
|
-
|
|
305
290
|
try {
|
|
306
291
|
if (!isInitialized) {
|
|
307
292
|
promise.reject("NOT_INITIALIZED", "SDK must be initialized before checkout")
|
|
308
293
|
return
|
|
309
294
|
}
|
|
310
|
-
|
|
311
|
-
Log.d(TAG, "Opening checkout with options: $options")
|
|
312
295
|
|
|
313
296
|
val orderToken = options.getString("order_token")
|
|
314
297
|
val paymentModeCode = options.getString("payment_mode_code") ?: ""
|
|
@@ -320,45 +303,107 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
320
303
|
promise.reject("INVALID_OPTIONS", "Order token is required")
|
|
321
304
|
return
|
|
322
305
|
}
|
|
323
|
-
|
|
324
|
-
Log.d(TAG, "Building checkout options...")
|
|
325
306
|
|
|
326
307
|
// Get the current Activity
|
|
327
308
|
val currentActivity = reactContext.currentActivity
|
|
328
|
-
Log.d(TAG, "Current activity: $currentActivity")
|
|
329
309
|
|
|
330
310
|
if (currentActivity == null) {
|
|
331
|
-
Log.e(TAG, "Current activity is null!")
|
|
332
311
|
promise.reject("ACTIVITY_ERROR", "Current activity is null")
|
|
333
312
|
return
|
|
334
313
|
}
|
|
335
314
|
|
|
336
|
-
//
|
|
337
|
-
Log.d(TAG, "Starting NimbblCheckoutActivity...")
|
|
338
|
-
println("Starting NimbblCheckoutActivity...")
|
|
315
|
+
// Use the NimbblCheckoutActivity with proper callback setup
|
|
339
316
|
try {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
317
|
+
// Set up the callback to receive the result
|
|
318
|
+
NimbblCheckoutActivity.setResultCallback { result ->
|
|
319
|
+
|
|
320
|
+
// Convert Map to WritableMap
|
|
321
|
+
val responseData = Arguments.createMap().apply {
|
|
322
|
+
result.forEach { (key, value) ->
|
|
323
|
+
when (value) {
|
|
324
|
+
is String -> {
|
|
325
|
+
// Special handling for 'order' field - parse JSON string to object
|
|
326
|
+
if (key == "order" && value.startsWith("{") && value.endsWith("}")) {
|
|
327
|
+
try {
|
|
328
|
+
val jsonObject = JSONObject(value)
|
|
329
|
+
val orderMap = Arguments.createMap()
|
|
330
|
+
|
|
331
|
+
// Convert JSONObject to WritableMap
|
|
332
|
+
jsonObject.keys().forEach { jsonKey ->
|
|
333
|
+
val jsonValue = jsonObject.get(jsonKey)
|
|
334
|
+
when (jsonValue) {
|
|
335
|
+
is String -> orderMap.putString(jsonKey, jsonValue)
|
|
336
|
+
is Number -> orderMap.putDouble(jsonKey, jsonValue.toDouble())
|
|
337
|
+
is Boolean -> orderMap.putBoolean(jsonKey, jsonValue)
|
|
338
|
+
is JSONObject -> {
|
|
339
|
+
val nestedMap = Arguments.createMap()
|
|
340
|
+
jsonValue.keys().forEach { nestedKey ->
|
|
341
|
+
val nestedValue = jsonValue.get(nestedKey)
|
|
342
|
+
when (nestedValue) {
|
|
343
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
344
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
345
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
346
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
orderMap.putMap(jsonKey, nestedMap)
|
|
350
|
+
}
|
|
351
|
+
else -> orderMap.putString(jsonKey, jsonValue.toString())
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
putMap(key, orderMap)
|
|
356
|
+
} catch (e: JSONException) {
|
|
357
|
+
putString(key, value)
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
putString(key, value)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
is Number -> putDouble(key, value.toDouble())
|
|
364
|
+
is Boolean -> putBoolean(key, value)
|
|
365
|
+
is Map<*, *> -> {
|
|
366
|
+
val nestedMap = Arguments.createMap()
|
|
367
|
+
(value as Map<String, Any>).forEach { (nestedKey, nestedValue) ->
|
|
368
|
+
when (nestedValue) {
|
|
369
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
370
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
371
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
372
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
putMap(key, nestedMap)
|
|
376
|
+
}
|
|
377
|
+
else -> putString(key, value.toString())
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Use callback if available
|
|
383
|
+
if (checkoutCallback != null) {
|
|
384
|
+
try {
|
|
385
|
+
checkoutCallback?.invoke(responseData)
|
|
386
|
+
} catch (e: Exception) {
|
|
387
|
+
// Error invoking checkout callback - ignore
|
|
388
|
+
}
|
|
389
|
+
}
|
|
350
390
|
}
|
|
351
391
|
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
|
|
392
|
+
// Add a small delay to ensure callback is properly set up
|
|
393
|
+
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
|
394
|
+
// Start the NimbblCheckoutActivity
|
|
395
|
+
val intent = Intent(currentActivity, NimbblCheckoutActivity::class.java).apply {
|
|
396
|
+
putExtra(NimbblCheckoutActivity.EXTRA_ORDER_TOKEN, orderToken)
|
|
397
|
+
putExtra(NimbblCheckoutActivity.EXTRA_PAYMENT_MODE_CODE, paymentModeCode)
|
|
398
|
+
putExtra(NimbblCheckoutActivity.EXTRA_BANK_CODE, bankCode)
|
|
399
|
+
putExtra(NimbblCheckoutActivity.EXTRA_WALLET_CODE, walletCode)
|
|
400
|
+
putExtra(NimbblCheckoutActivity.EXTRA_PAYMENT_FLOW, paymentFlow)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
currentActivity.startActivity(intent)
|
|
404
|
+
}, 50) // 50ms delay to ensure callback is set up
|
|
355
405
|
|
|
356
|
-
Log.d(TAG, "NimbblCheckoutActivity started successfully")
|
|
357
|
-
println("NimbblCheckoutActivity started successfully")
|
|
358
406
|
} catch (e: Exception) {
|
|
359
|
-
Log.e(TAG, "Error starting NimbblCheckoutActivity: ${e.message}", e)
|
|
360
|
-
println("Error starting NimbblCheckoutActivity: ${e.message}")
|
|
361
|
-
e.printStackTrace()
|
|
362
407
|
promise.reject("CHECKOUT_FAILED", "Error starting checkout activity: ${e.message}")
|
|
363
408
|
return
|
|
364
409
|
}
|
|
@@ -370,52 +415,103 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
370
415
|
promise.resolve(result)
|
|
371
416
|
|
|
372
417
|
} catch (e: Exception) {
|
|
373
|
-
Log.e(TAG, "Error during checkout", e)
|
|
374
418
|
promise.reject("CHECKOUT_FAILED", e.message)
|
|
375
419
|
}
|
|
376
420
|
}
|
|
377
421
|
|
|
378
422
|
|
|
379
|
-
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
380
|
-
try {
|
|
381
|
-
reactContext
|
|
382
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
383
|
-
.emit(eventName, params)
|
|
384
|
-
} catch (e: Exception) {
|
|
385
|
-
Log.e(TAG, "Error sending event: $eventName", e)
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
423
|
|
|
389
424
|
override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
425
|
+
|
|
390
426
|
// Handle NimbblCheckoutActivity results
|
|
391
|
-
if (requestCode == 1001
|
|
392
|
-
val
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
427
|
+
if (requestCode == 1001) {
|
|
428
|
+
val responseData = if (data != null) {
|
|
429
|
+
val rawData = data.getSerializableExtra("response_data") as? MutableMap<String, Any>
|
|
430
|
+
|
|
431
|
+
if (rawData != null) {
|
|
432
|
+
// Convert Map to WritableMap directly
|
|
433
|
+
Arguments.createMap().apply {
|
|
434
|
+
rawData.forEach { (key, value) ->
|
|
435
|
+
when (value) {
|
|
436
|
+
is String -> {
|
|
437
|
+
// Special handling for 'order' field - parse JSON string to object
|
|
438
|
+
if (key == "order" && value.startsWith("{") && value.endsWith("}")) {
|
|
439
|
+
try {
|
|
440
|
+
val jsonObject = JSONObject(value)
|
|
441
|
+
val orderMap = Arguments.createMap()
|
|
442
|
+
|
|
443
|
+
// Convert JSONObject to WritableMap
|
|
444
|
+
jsonObject.keys().forEach { jsonKey ->
|
|
445
|
+
val jsonValue = jsonObject.get(jsonKey)
|
|
446
|
+
when (jsonValue) {
|
|
447
|
+
is String -> orderMap.putString(jsonKey, jsonValue)
|
|
448
|
+
is Number -> orderMap.putDouble(jsonKey, jsonValue.toDouble())
|
|
449
|
+
is Boolean -> orderMap.putBoolean(jsonKey, jsonValue)
|
|
450
|
+
is JSONObject -> {
|
|
451
|
+
val nestedMap = Arguments.createMap()
|
|
452
|
+
jsonValue.keys().forEach { nestedKey ->
|
|
453
|
+
val nestedValue = jsonValue.get(nestedKey)
|
|
454
|
+
when (nestedValue) {
|
|
455
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
456
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
457
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
458
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
orderMap.putMap(jsonKey, nestedMap)
|
|
462
|
+
}
|
|
463
|
+
else -> orderMap.putString(jsonKey, jsonValue.toString())
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
putMap(key, orderMap)
|
|
468
|
+
} catch (e: JSONException) {
|
|
469
|
+
putString(key, value)
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
putString(key, value)
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
is Number -> putDouble(key, value.toDouble())
|
|
476
|
+
is Boolean -> putBoolean(key, value)
|
|
477
|
+
is Map<*, *> -> {
|
|
478
|
+
val nestedMap = Arguments.createMap()
|
|
479
|
+
(value as Map<String, Any>).forEach { (nestedKey, nestedValue) ->
|
|
480
|
+
when (nestedValue) {
|
|
481
|
+
is String -> nestedMap.putString(nestedKey, nestedValue)
|
|
482
|
+
is Number -> nestedMap.putDouble(nestedKey, nestedValue.toDouble())
|
|
483
|
+
is Boolean -> nestedMap.putBoolean(nestedKey, nestedValue)
|
|
484
|
+
else -> nestedMap.putString(nestedKey, nestedValue.toString())
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
putMap(key, nestedMap)
|
|
488
|
+
}
|
|
489
|
+
else -> putString(key, value.toString())
|
|
490
|
+
}
|
|
491
|
+
}
|
|
401
492
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
"failed" -> {
|
|
405
|
-
val params = Arguments.createMap().apply {
|
|
493
|
+
} else {
|
|
494
|
+
Arguments.createMap().apply {
|
|
406
495
|
putString("status", "failed")
|
|
407
|
-
putString("
|
|
496
|
+
putString("message", "No response data received")
|
|
408
497
|
}
|
|
409
|
-
sendEvent("payment_failed", params)
|
|
410
498
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
499
|
+
} else {
|
|
500
|
+
Arguments.createMap().apply {
|
|
501
|
+
putString("status", "failed")
|
|
502
|
+
putString("message", "Payment was cancelled or failed")
|
|
414
503
|
}
|
|
415
504
|
}
|
|
505
|
+
|
|
506
|
+
// Use callback if available
|
|
507
|
+
if (checkoutCallback != null) {
|
|
508
|
+
checkoutCallback?.invoke(responseData)
|
|
509
|
+
}
|
|
510
|
+
// Note: Removed fallback to event emitter for cleaner implementation
|
|
416
511
|
}
|
|
417
512
|
}
|
|
418
513
|
|
|
514
|
+
|
|
419
515
|
override fun onNewIntent(intent: Intent?) {
|
|
420
516
|
// Handle new intents if needed
|
|
421
517
|
}
|
|
@@ -424,5 +520,5 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
424
520
|
super.onCatalystInstanceDestroy()
|
|
425
521
|
reactContext.removeActivityEventListener(this)
|
|
426
522
|
}
|
|
427
|
-
|
|
523
|
+
|
|
428
524
|
}
|