@yuno-payments/yuno-sdk-react-native 1.0.17-rc.2 → 1.0.17-rc.4
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.
|
@@ -11,12 +11,22 @@ import com.yuno.sdk.YunoConfig
|
|
|
11
11
|
import com.yuno.sdk.YunoLanguage
|
|
12
12
|
import com.yuno.sdk.enrollment.*
|
|
13
13
|
import com.yuno.sdk.payments.*
|
|
14
|
+
import com.yuno.sdk.ApiClientPayment
|
|
15
|
+
import com.yuno.sdk.ApiClientPayment.Companion.generateToken
|
|
16
|
+
import com.yuno.sdk.ApiClientPayment.Companion.getThreeDSecureChallenge
|
|
17
|
+
import com.yuno.sdk.payments.TokenCollectedData
|
|
18
|
+
import com.yuno.sdk.ThreeDSecureChallengeResponse
|
|
14
19
|
import com.yuno.presentation.core.components.PaymentSelected
|
|
15
20
|
import com.yuno.presentation.core.card.CardFormType
|
|
16
21
|
import com.yuno.payments.features.payment.models.OneTimeTokenModel
|
|
17
22
|
import com.google.gson.Gson
|
|
18
23
|
import org.json.JSONObject
|
|
19
24
|
import org.json.JSONArray
|
|
25
|
+
import kotlinx.coroutines.CoroutineScope
|
|
26
|
+
import kotlinx.coroutines.Dispatchers
|
|
27
|
+
import kotlinx.coroutines.flow.launchIn
|
|
28
|
+
import kotlinx.coroutines.flow.onEach
|
|
29
|
+
import androidx.lifecycle.asFlow
|
|
20
30
|
|
|
21
31
|
/**
|
|
22
32
|
* Yuno SDK React Native Module for Android
|
|
@@ -856,33 +866,36 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
856
866
|
)
|
|
857
867
|
|
|
858
868
|
// Generate token
|
|
859
|
-
apiClient.generateToken(collectedData, reactContext)
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
869
|
+
apiClient.generateToken(collectedData, reactContext)
|
|
870
|
+
.asFlow()
|
|
871
|
+
.onEach { result ->
|
|
872
|
+
try {
|
|
873
|
+
when {
|
|
874
|
+
result.containsKey("token") && result["token"] != null -> {
|
|
875
|
+
val token = result["token"] as String
|
|
876
|
+
Log.d(TAG, "✅ Token generated successfully")
|
|
877
|
+
|
|
878
|
+
val response = Arguments.createMap().apply {
|
|
879
|
+
putString("token", token)
|
|
880
|
+
}
|
|
881
|
+
promise.resolve(response)
|
|
882
|
+
}
|
|
883
|
+
result.containsKey("error") && result["error"] != null -> {
|
|
884
|
+
val error = result["error"] as String
|
|
885
|
+
Log.e(TAG, "❌ Token generation failed: $error")
|
|
886
|
+
promise.reject("TOKEN_GENERATION_ERROR", error)
|
|
887
|
+
}
|
|
888
|
+
else -> {
|
|
889
|
+
Log.e(TAG, "❌ Unknown response from token generation")
|
|
890
|
+
promise.reject("TOKEN_GENERATION_ERROR", "Unknown error occurred")
|
|
868
891
|
}
|
|
869
|
-
promise.resolve(response)
|
|
870
|
-
}
|
|
871
|
-
result.containsKey("error") && result["error"] != null -> {
|
|
872
|
-
val error = result["error"] as String
|
|
873
|
-
Log.e(TAG, "❌ Token generation failed: $error")
|
|
874
|
-
promise.reject("TOKEN_GENERATION_ERROR", error)
|
|
875
|
-
}
|
|
876
|
-
else -> {
|
|
877
|
-
Log.e(TAG, "❌ Unknown response from token generation")
|
|
878
|
-
promise.reject("TOKEN_GENERATION_ERROR", "Unknown error occurred")
|
|
879
892
|
}
|
|
893
|
+
} catch (e: Exception) {
|
|
894
|
+
Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
|
|
895
|
+
promise.reject("TOKEN_GENERATION_ERROR", e.message)
|
|
880
896
|
}
|
|
881
|
-
} catch (e: Exception) {
|
|
882
|
-
Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
|
|
883
|
-
promise.reject("TOKEN_GENERATION_ERROR", e.message)
|
|
884
897
|
}
|
|
885
|
-
|
|
898
|
+
.launchIn(CoroutineScope(Dispatchers.Main))
|
|
886
899
|
} catch (e: Exception) {
|
|
887
900
|
Log.e(TAG, "❌ Error in generateToken: ${e.message}")
|
|
888
901
|
promise.reject("TOKEN_GENERATION_ERROR", e.message)
|
|
@@ -914,25 +927,28 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
914
927
|
)
|
|
915
928
|
|
|
916
929
|
// Get 3DS challenge
|
|
917
|
-
apiClient.getThreeDSecureChallenge(reactContext, checkoutSession)
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
+
apiClient.getThreeDSecureChallenge(reactContext, checkoutSession)
|
|
931
|
+
.asFlow()
|
|
932
|
+
.onEach { result ->
|
|
933
|
+
try {
|
|
934
|
+
val response = Arguments.createMap().apply {
|
|
935
|
+
putString("type", result.type)
|
|
936
|
+
putString("data", result.data)
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
if (result.type == "URL") {
|
|
940
|
+
Log.d(TAG, "✅ 3DS Challenge URL retrieved successfully")
|
|
941
|
+
promise.resolve(response)
|
|
942
|
+
} else {
|
|
943
|
+
Log.e(TAG, "❌ 3DS Challenge failed: ${result.data}")
|
|
944
|
+
promise.reject("THREE_DS_ERROR", result.data)
|
|
945
|
+
}
|
|
946
|
+
} catch (e: Exception) {
|
|
947
|
+
Log.e(TAG, "❌ Error processing 3DS challenge result: ${e.message}")
|
|
948
|
+
promise.reject("THREE_DS_ERROR", e.message)
|
|
930
949
|
}
|
|
931
|
-
} catch (e: Exception) {
|
|
932
|
-
Log.e(TAG, "❌ Error processing 3DS challenge result: ${e.message}")
|
|
933
|
-
promise.reject("THREE_DS_ERROR", e.message)
|
|
934
950
|
}
|
|
935
|
-
|
|
951
|
+
.launchIn(CoroutineScope(Dispatchers.Main))
|
|
936
952
|
} catch (e: Exception) {
|
|
937
953
|
Log.e(TAG, "❌ Error in getThreeDSecureChallenge: ${e.message}")
|
|
938
954
|
promise.reject("THREE_DS_ERROR", e.message)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuno-payments/yuno-sdk-react-native",
|
|
3
|
-
"version": "1.0.17-rc.
|
|
3
|
+
"version": "1.0.17-rc.4",
|
|
4
4
|
"description": "Yuno React Native SDK empowers you to create seamless payment experiences in your native Android and iOS apps built with React Native.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|