halo-sdk-react-native 1.0.3 → 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/CHANGELOG.md +56 -27
- package/README.md +735 -735
- package/android/build.gradle +90 -89
- package/android/settings.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +9 -11
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/AnimationActivity.kt +160 -160
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/Const.kt +15 -15
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloCallbacks.kt +126 -126
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloReactActivity.kt +61 -61
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkImplementation.kt +81 -81
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkModule.kt +74 -74
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkPackage.kt +16 -16
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/UIContext.kt +20 -20
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/Utils.kt +154 -154
- package/package.json +34 -34
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.facebook.react.bridge.LifecycleEventListener
|
|
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.bridge.ReadableMap
|
|
10
|
-
import za.co.synthesis.halo.haloCommonInterface.TransactionType
|
|
11
|
-
|
|
12
|
-
class HaloSdkModule(reactContext: ReactApplicationContext) :
|
|
13
|
-
ReactContextBaseJavaModule(reactContext),
|
|
14
|
-
LifecycleEventListener {
|
|
15
|
-
|
|
16
|
-
private val TAG = "HaloSdkModule"
|
|
17
|
-
private val haloSdkImplementation: HaloSdkImplementation = HaloSdkImplementation(reactContext)
|
|
18
|
-
|
|
19
|
-
init {
|
|
20
|
-
reactContext.addLifecycleEventListener(this)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
override fun getName(): String = "HaloSdk"
|
|
24
|
-
|
|
25
|
-
@ReactMethod
|
|
26
|
-
fun initializeHaloSDK(args: ReadableMap, promise: Promise) {
|
|
27
|
-
@Suppress("UNCHECKED_CAST")
|
|
28
|
-
haloSdkImplementation.initializeHaloSDK(promise, args.toHashMap() as HashMap<String, Any>)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@ReactMethod
|
|
32
|
-
fun startTransaction(args: ReadableMap, promise: Promise) {
|
|
33
|
-
@Suppress("UNCHECKED_CAST")
|
|
34
|
-
haloSdkImplementation.startTransaction(promise, args.toHashMap() as HashMap<String, Any>)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@ReactMethod
|
|
38
|
-
fun cardRefundTransaction(args: ReadableMap, promise: Promise) {
|
|
39
|
-
@Suppress("UNCHECKED_CAST")
|
|
40
|
-
haloSdkImplementation.startTransaction(promise, args.toHashMap() as HashMap<String, Any>, TransactionType.Refund)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@ReactMethod
|
|
44
|
-
fun jwtCallback(jwt: String, promise: Promise) {
|
|
45
|
-
haloSdkImplementation.jwtCallback(promise, jwt)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@ReactMethod
|
|
49
|
-
fun cancelTransaction(promise: Promise) {
|
|
50
|
-
haloSdkImplementation.cancelTransaction(promise)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Required for RN NativeEventEmitter
|
|
54
|
-
@ReactMethod
|
|
55
|
-
fun addListener(eventName: String) {}
|
|
56
|
-
|
|
57
|
-
@ReactMethod
|
|
58
|
-
fun removeListeners(count: Int) {}
|
|
59
|
-
|
|
60
|
-
// Keep UIContext activity reference up to date
|
|
61
|
-
override fun onHostResume() {
|
|
62
|
-
Log.d(TAG, "onHostResume")
|
|
63
|
-
UIContext.updateActivity(reactApplicationContext.currentActivity)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
override fun onHostPause() {
|
|
67
|
-
Log.d(TAG, "onHostPause")
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
override fun onHostDestroy() {
|
|
71
|
-
Log.d(TAG, "onHostDestroy")
|
|
72
|
-
UIContext.updateActivity(null)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
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.bridge.ReadableMap
|
|
10
|
+
import za.co.synthesis.halo.haloCommonInterface.TransactionType
|
|
11
|
+
|
|
12
|
+
class HaloSdkModule(reactContext: ReactApplicationContext) :
|
|
13
|
+
ReactContextBaseJavaModule(reactContext),
|
|
14
|
+
LifecycleEventListener {
|
|
15
|
+
|
|
16
|
+
private val TAG = "HaloSdkModule"
|
|
17
|
+
private val haloSdkImplementation: HaloSdkImplementation = HaloSdkImplementation(reactContext)
|
|
18
|
+
|
|
19
|
+
init {
|
|
20
|
+
reactContext.addLifecycleEventListener(this)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun getName(): String = "HaloSdk"
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun initializeHaloSDK(args: ReadableMap, promise: Promise) {
|
|
27
|
+
@Suppress("UNCHECKED_CAST")
|
|
28
|
+
haloSdkImplementation.initializeHaloSDK(promise, args.toHashMap() as HashMap<String, Any>)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactMethod
|
|
32
|
+
fun startTransaction(args: ReadableMap, promise: Promise) {
|
|
33
|
+
@Suppress("UNCHECKED_CAST")
|
|
34
|
+
haloSdkImplementation.startTransaction(promise, args.toHashMap() as HashMap<String, Any>)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ReactMethod
|
|
38
|
+
fun cardRefundTransaction(args: ReadableMap, promise: Promise) {
|
|
39
|
+
@Suppress("UNCHECKED_CAST")
|
|
40
|
+
haloSdkImplementation.startTransaction(promise, args.toHashMap() as HashMap<String, Any>, TransactionType.Refund)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
fun jwtCallback(jwt: String, promise: Promise) {
|
|
45
|
+
haloSdkImplementation.jwtCallback(promise, jwt)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
fun cancelTransaction(promise: Promise) {
|
|
50
|
+
haloSdkImplementation.cancelTransaction(promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Required for RN NativeEventEmitter
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun addListener(eventName: String) {}
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
fun removeListeners(count: Int) {}
|
|
59
|
+
|
|
60
|
+
// Keep UIContext activity reference up to date
|
|
61
|
+
override fun onHostResume() {
|
|
62
|
+
Log.d(TAG, "onHostResume")
|
|
63
|
+
UIContext.updateActivity(reactApplicationContext.currentActivity)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override fun onHostPause() {
|
|
67
|
+
Log.d(TAG, "onHostPause")
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onHostDestroy() {
|
|
71
|
+
Log.d(TAG, "onHostDestroy")
|
|
72
|
+
UIContext.updateActivity(null)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
|
|
8
|
-
class HaloSdkPackage : ReactPackage {
|
|
9
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
-
return listOf(HaloSdkModule(reactContext))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
-
return emptyList()
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class HaloSdkPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(HaloSdkModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import java.lang.ref.WeakReference
|
|
5
|
-
|
|
6
|
-
object UIContext {
|
|
7
|
-
private var activityRef: WeakReference<Activity>? = null
|
|
8
|
-
private var enableSchemeAnimations: Boolean = false
|
|
9
|
-
|
|
10
|
-
fun updateActivity(activity: Activity?) {
|
|
11
|
-
activityRef = activity?.let { WeakReference(it) }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
fun enableSchemeAnimations(enable: Boolean) {
|
|
15
|
-
enableSchemeAnimations = enable
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
fun getActivity(): Activity? = activityRef?.get()
|
|
19
|
-
fun areSchemeAnimationsEnabled(): Boolean = enableSchemeAnimations
|
|
20
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import java.lang.ref.WeakReference
|
|
5
|
+
|
|
6
|
+
object UIContext {
|
|
7
|
+
private var activityRef: WeakReference<Activity>? = null
|
|
8
|
+
private var enableSchemeAnimations: Boolean = false
|
|
9
|
+
|
|
10
|
+
fun updateActivity(activity: Activity?) {
|
|
11
|
+
activityRef = activity?.let { WeakReference(it) }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fun enableSchemeAnimations(enable: Boolean) {
|
|
15
|
+
enableSchemeAnimations = enable
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun getActivity(): Activity? = activityRef?.get()
|
|
19
|
+
fun areSchemeAnimationsEnabled(): Boolean = enableSchemeAnimations
|
|
20
|
+
}
|
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
import android.util.Base64
|
|
4
|
-
import com.facebook.react.bridge.Arguments
|
|
5
|
-
import com.facebook.react.bridge.WritableArray
|
|
6
|
-
import com.facebook.react.bridge.WritableMap
|
|
7
|
-
import za.co.synthesis.halo.haloCommonInterface.HaloTransactionReceipt
|
|
8
|
-
import za.co.synthesis.halo.haloCommonInterface.HaloTransactionResult
|
|
9
|
-
import za.co.synthesis.halo.sdk.model.HaloAttestationHealthResult
|
|
10
|
-
import za.co.synthesis.halo.sdk.model.HaloCurrencyValue
|
|
11
|
-
import za.co.synthesis.halo.sdk.model.HaloInitializationResult
|
|
12
|
-
import za.co.synthesis.halo.sdk.model.HaloStartTransactionResult
|
|
13
|
-
import za.co.synthesis.halo.sdk.model.HaloUIMessage
|
|
14
|
-
import za.co.synthesis.halo.sdk.model.HaloWarning
|
|
15
|
-
import java.util.Currency
|
|
16
|
-
|
|
17
|
-
internal fun <T> getRest(args: Map<String, Any>, keys: List<String>): Map<String, T> {
|
|
18
|
-
val rest = HashMap<String, T>()
|
|
19
|
-
for (key in args.keys) {
|
|
20
|
-
try {
|
|
21
|
-
if (key !in keys) {
|
|
22
|
-
rest[key] = args[key] as T
|
|
23
|
-
}
|
|
24
|
-
} catch (e: TypeCastException) {
|
|
25
|
-
throw TypeCastException("The value of $key is not of type T")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return rest
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
internal fun makeWritableMap(data: HaloAttestationHealthResult): WritableMap {
|
|
32
|
-
return Arguments.createMap().apply {
|
|
33
|
-
putString("resultType", data.resultType.name)
|
|
34
|
-
putString("errorCode", data.errorCode.name)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
internal fun makeWritableMap(data: HaloTransactionResult): WritableMap {
|
|
39
|
-
return Arguments.createMap().apply {
|
|
40
|
-
putString("resultType", data.resultType.name)
|
|
41
|
-
putString("merchantTransactionReference", data.merchantTransactionReference)
|
|
42
|
-
putString("haloTransactionReference", data.haloTransactionReference)
|
|
43
|
-
putString("paymentProviderReference", data.paymentProviderReference)
|
|
44
|
-
putString("errorCode", data.errorCode.name)
|
|
45
|
-
putArray("errorDetails", data.errorDetails.toWritableArray())
|
|
46
|
-
putMap("receipt", makeWritableMap(data.receipt))
|
|
47
|
-
putMap("customTags", data.customTags?.toWritableMap())
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
internal fun makeWritableMap(data: HaloTransactionReceipt?): WritableMap? {
|
|
52
|
-
if (data == null) return null
|
|
53
|
-
return Arguments.createMap().apply {
|
|
54
|
-
putString("signature", Base64.encodeToString(data.signature, Base64.NO_WRAP))
|
|
55
|
-
putString("transactionDate", data.transactionDate)
|
|
56
|
-
putString("transactionTime", data.transactionTime)
|
|
57
|
-
putString("aid", data.aid)
|
|
58
|
-
putString("applicationLabel", data.applicationLabel)
|
|
59
|
-
putString("applicationPreferredName", data.applicationPreferredName)
|
|
60
|
-
putString("tvr", data.tvr)
|
|
61
|
-
putString("cvr", data.cvr)
|
|
62
|
-
putString("cryptogramType", data.cryptogramType?.name)
|
|
63
|
-
putString("cryptogram", data.cryptogram)
|
|
64
|
-
putString("maskedPAN", data.maskedPAN)
|
|
65
|
-
putString("authorizationCode", data.authorizationCode)
|
|
66
|
-
putString("ISOResponseCode", data.ISOResponseCode)
|
|
67
|
-
putString("association", data.association)
|
|
68
|
-
putString("expiryDate", data.expiryDate)
|
|
69
|
-
putString("mid", data.mid)
|
|
70
|
-
putString("merchantName", data.merchantName)
|
|
71
|
-
putString("tid", data.tid)
|
|
72
|
-
putString("stan", data.stan)
|
|
73
|
-
putString("panEntry", data.panEntry)
|
|
74
|
-
putString("cardType", data.cardType)
|
|
75
|
-
putString("panSequenceNumber", data.panSequenceNumber)
|
|
76
|
-
putString("effectiveDate", data.effectiveDate)
|
|
77
|
-
putString("disposition", data.disposition)
|
|
78
|
-
putString("currencyCode", data.currencyCode?.toString())
|
|
79
|
-
putString("amountAuthorised", data.amountAuthorised?.toString())
|
|
80
|
-
putString("amountOther", data.amountOther?.toString())
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
internal fun makeWritableMap(data: HaloUIMessage): WritableMap {
|
|
85
|
-
return Arguments.createMap().apply {
|
|
86
|
-
putString("msgID", data.msgID.name)
|
|
87
|
-
putInt("holdTimeMS", data.holdTimeMS)
|
|
88
|
-
putArray("languagePreference", data.languagePreference?.toWritableArray())
|
|
89
|
-
putMap("offlineBalance", makeWritableMap(data.offlineBalance))
|
|
90
|
-
putMap("transactionAmount", makeWritableMap(data.transactionAmount))
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
internal fun makeWritableMap(data: HaloCurrencyValue?): WritableMap? {
|
|
95
|
-
if (data == null) return null
|
|
96
|
-
return Arguments.createMap().apply {
|
|
97
|
-
putMap("currency", makeWritableMap(data.currency))
|
|
98
|
-
putDouble("amount", data.amount.toDouble())
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
internal fun makeWritableMap(data: Currency?): WritableMap? {
|
|
103
|
-
if (data == null) return null
|
|
104
|
-
return Arguments.createMap().apply {
|
|
105
|
-
putString("currencyCode", data.currencyCode)
|
|
106
|
-
putInt("defaultFractionDigits", data.defaultFractionDigits)
|
|
107
|
-
putInt("numericCode", data.numericCode)
|
|
108
|
-
putString("displayName", data.displayName)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
internal fun makeWritableMap(data: HaloInitializationResult): WritableMap {
|
|
113
|
-
return Arguments.createMap().apply {
|
|
114
|
-
putString("resultType", data.resultType.name)
|
|
115
|
-
putMap("terminalCurrency", makeWritableMap(data.terminalCurrency))
|
|
116
|
-
putArray("terminalLanguageCodes", data.terminalLanguageCodes?.toWritableArray())
|
|
117
|
-
putString("terminalCountryCode", data.terminalCountryCode)
|
|
118
|
-
putString("errorCode", data.errorCode.name)
|
|
119
|
-
putArray("warnings", data.warnings.toWritableArray { makeWritableMap(it) })
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
internal fun makeWritableMap(data: HaloWarning): WritableMap {
|
|
124
|
-
return Arguments.createMap().apply {
|
|
125
|
-
putString("errorCode", data.errorCode.name)
|
|
126
|
-
putArray("details", data.details?.toWritableArray())
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
internal fun makeWritableMap(data: HaloStartTransactionResult): WritableMap {
|
|
131
|
-
return Arguments.createMap().apply {
|
|
132
|
-
putString("resultType", data.resultType.name)
|
|
133
|
-
putString("errorCode", data.errorCode.name)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private fun Map<String, String>.toWritableMap(): WritableMap {
|
|
138
|
-
return Arguments.createMap().apply {
|
|
139
|
-
this@toWritableMap.forEach { (key, value) -> putString(key, value) }
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private fun List<String>.toWritableArray(): WritableArray {
|
|
144
|
-
return Arguments.createArray().apply {
|
|
145
|
-
this@toWritableArray.forEach { pushString(it) }
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
private fun <T> List<T>.toWritableArray(transform: (T) -> WritableMap): WritableArray {
|
|
151
|
-
return Arguments.createArray().apply {
|
|
152
|
-
this@toWritableArray.forEach { pushMap(transform(it)) }
|
|
153
|
-
}
|
|
154
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
import android.util.Base64
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.WritableArray
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import za.co.synthesis.halo.haloCommonInterface.HaloTransactionReceipt
|
|
8
|
+
import za.co.synthesis.halo.haloCommonInterface.HaloTransactionResult
|
|
9
|
+
import za.co.synthesis.halo.sdk.model.HaloAttestationHealthResult
|
|
10
|
+
import za.co.synthesis.halo.sdk.model.HaloCurrencyValue
|
|
11
|
+
import za.co.synthesis.halo.sdk.model.HaloInitializationResult
|
|
12
|
+
import za.co.synthesis.halo.sdk.model.HaloStartTransactionResult
|
|
13
|
+
import za.co.synthesis.halo.sdk.model.HaloUIMessage
|
|
14
|
+
import za.co.synthesis.halo.sdk.model.HaloWarning
|
|
15
|
+
import java.util.Currency
|
|
16
|
+
|
|
17
|
+
internal fun <T> getRest(args: Map<String, Any>, keys: List<String>): Map<String, T> {
|
|
18
|
+
val rest = HashMap<String, T>()
|
|
19
|
+
for (key in args.keys) {
|
|
20
|
+
try {
|
|
21
|
+
if (key !in keys) {
|
|
22
|
+
rest[key] = args[key] as T
|
|
23
|
+
}
|
|
24
|
+
} catch (e: TypeCastException) {
|
|
25
|
+
throw TypeCastException("The value of $key is not of type T")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return rest
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
internal fun makeWritableMap(data: HaloAttestationHealthResult): WritableMap {
|
|
32
|
+
return Arguments.createMap().apply {
|
|
33
|
+
putString("resultType", data.resultType.name)
|
|
34
|
+
putString("errorCode", data.errorCode.name)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
internal fun makeWritableMap(data: HaloTransactionResult): WritableMap {
|
|
39
|
+
return Arguments.createMap().apply {
|
|
40
|
+
putString("resultType", data.resultType.name)
|
|
41
|
+
putString("merchantTransactionReference", data.merchantTransactionReference)
|
|
42
|
+
putString("haloTransactionReference", data.haloTransactionReference)
|
|
43
|
+
putString("paymentProviderReference", data.paymentProviderReference)
|
|
44
|
+
putString("errorCode", data.errorCode.name)
|
|
45
|
+
putArray("errorDetails", data.errorDetails.toWritableArray())
|
|
46
|
+
putMap("receipt", makeWritableMap(data.receipt))
|
|
47
|
+
putMap("customTags", data.customTags?.toWritableMap())
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
internal fun makeWritableMap(data: HaloTransactionReceipt?): WritableMap? {
|
|
52
|
+
if (data == null) return null
|
|
53
|
+
return Arguments.createMap().apply {
|
|
54
|
+
putString("signature", Base64.encodeToString(data.signature, Base64.NO_WRAP))
|
|
55
|
+
putString("transactionDate", data.transactionDate)
|
|
56
|
+
putString("transactionTime", data.transactionTime)
|
|
57
|
+
putString("aid", data.aid)
|
|
58
|
+
putString("applicationLabel", data.applicationLabel)
|
|
59
|
+
putString("applicationPreferredName", data.applicationPreferredName)
|
|
60
|
+
putString("tvr", data.tvr)
|
|
61
|
+
putString("cvr", data.cvr)
|
|
62
|
+
putString("cryptogramType", data.cryptogramType?.name)
|
|
63
|
+
putString("cryptogram", data.cryptogram)
|
|
64
|
+
putString("maskedPAN", data.maskedPAN)
|
|
65
|
+
putString("authorizationCode", data.authorizationCode)
|
|
66
|
+
putString("ISOResponseCode", data.ISOResponseCode)
|
|
67
|
+
putString("association", data.association)
|
|
68
|
+
putString("expiryDate", data.expiryDate)
|
|
69
|
+
putString("mid", data.mid)
|
|
70
|
+
putString("merchantName", data.merchantName)
|
|
71
|
+
putString("tid", data.tid)
|
|
72
|
+
putString("stan", data.stan)
|
|
73
|
+
putString("panEntry", data.panEntry)
|
|
74
|
+
putString("cardType", data.cardType)
|
|
75
|
+
putString("panSequenceNumber", data.panSequenceNumber)
|
|
76
|
+
putString("effectiveDate", data.effectiveDate)
|
|
77
|
+
putString("disposition", data.disposition)
|
|
78
|
+
putString("currencyCode", data.currencyCode?.toString())
|
|
79
|
+
putString("amountAuthorised", data.amountAuthorised?.toString())
|
|
80
|
+
putString("amountOther", data.amountOther?.toString())
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
internal fun makeWritableMap(data: HaloUIMessage): WritableMap {
|
|
85
|
+
return Arguments.createMap().apply {
|
|
86
|
+
putString("msgID", data.msgID.name)
|
|
87
|
+
putInt("holdTimeMS", data.holdTimeMS)
|
|
88
|
+
putArray("languagePreference", data.languagePreference?.toWritableArray())
|
|
89
|
+
putMap("offlineBalance", makeWritableMap(data.offlineBalance))
|
|
90
|
+
putMap("transactionAmount", makeWritableMap(data.transactionAmount))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
internal fun makeWritableMap(data: HaloCurrencyValue?): WritableMap? {
|
|
95
|
+
if (data == null) return null
|
|
96
|
+
return Arguments.createMap().apply {
|
|
97
|
+
putMap("currency", makeWritableMap(data.currency))
|
|
98
|
+
putDouble("amount", data.amount.toDouble())
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
internal fun makeWritableMap(data: Currency?): WritableMap? {
|
|
103
|
+
if (data == null) return null
|
|
104
|
+
return Arguments.createMap().apply {
|
|
105
|
+
putString("currencyCode", data.currencyCode)
|
|
106
|
+
putInt("defaultFractionDigits", data.defaultFractionDigits)
|
|
107
|
+
putInt("numericCode", data.numericCode)
|
|
108
|
+
putString("displayName", data.displayName)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
internal fun makeWritableMap(data: HaloInitializationResult): WritableMap {
|
|
113
|
+
return Arguments.createMap().apply {
|
|
114
|
+
putString("resultType", data.resultType.name)
|
|
115
|
+
putMap("terminalCurrency", makeWritableMap(data.terminalCurrency))
|
|
116
|
+
putArray("terminalLanguageCodes", data.terminalLanguageCodes?.toWritableArray())
|
|
117
|
+
putString("terminalCountryCode", data.terminalCountryCode)
|
|
118
|
+
putString("errorCode", data.errorCode.name)
|
|
119
|
+
putArray("warnings", data.warnings.toWritableArray { makeWritableMap(it) })
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
internal fun makeWritableMap(data: HaloWarning): WritableMap {
|
|
124
|
+
return Arguments.createMap().apply {
|
|
125
|
+
putString("errorCode", data.errorCode.name)
|
|
126
|
+
putArray("details", data.details?.toWritableArray())
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
internal fun makeWritableMap(data: HaloStartTransactionResult): WritableMap {
|
|
131
|
+
return Arguments.createMap().apply {
|
|
132
|
+
putString("resultType", data.resultType.name)
|
|
133
|
+
putString("errorCode", data.errorCode.name)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private fun Map<String, String>.toWritableMap(): WritableMap {
|
|
138
|
+
return Arguments.createMap().apply {
|
|
139
|
+
this@toWritableMap.forEach { (key, value) -> putString(key, value) }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private fun List<String>.toWritableArray(): WritableArray {
|
|
144
|
+
return Arguments.createArray().apply {
|
|
145
|
+
this@toWritableArray.forEach { pushString(it) }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
private fun <T> List<T>.toWritableArray(transform: (T) -> WritableMap): WritableArray {
|
|
151
|
+
return Arguments.createArray().apply {
|
|
152
|
+
this@toWritableArray.forEach { pushMap(transform(it)) }
|
|
153
|
+
}
|
|
154
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "halo-sdk-react-native",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "React Native plugin for Halo SDK",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"android/src",
|
|
10
|
-
"android/libs",
|
|
11
|
-
"android/build.gradle",
|
|
12
|
-
"android/settings.gradle",
|
|
13
|
-
"README.md",
|
|
14
|
-
"CHANGELOG.md"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsc"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"halo",
|
|
21
|
-
"sdk",
|
|
22
|
-
"react-native",
|
|
23
|
-
"nfc",
|
|
24
|
-
"payment"
|
|
25
|
-
],
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"react-native": "*"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"typescript": "^5.0.0",
|
|
32
|
-
"@types/react-native": "^0.73.0"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "halo-sdk-react-native",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "React Native plugin for Halo SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"android/src",
|
|
10
|
+
"android/libs",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"android/settings.gradle",
|
|
13
|
+
"README.md",
|
|
14
|
+
"CHANGELOG.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"halo",
|
|
21
|
+
"sdk",
|
|
22
|
+
"react-native",
|
|
23
|
+
"nfc",
|
|
24
|
+
"payment"
|
|
25
|
+
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react-native": "*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.0.0",
|
|
32
|
+
"@types/react-native": "^0.73.0"
|
|
33
|
+
}
|
|
34
|
+
}
|