@yuno-payments/yuno-sdk-react-native 1.0.17-rc.3 → 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.
@@ -14,7 +14,7 @@ import com.yuno.sdk.payments.*
14
14
  import com.yuno.sdk.ApiClientPayment
15
15
  import com.yuno.sdk.ApiClientPayment.Companion.generateToken
16
16
  import com.yuno.sdk.ApiClientPayment.Companion.getThreeDSecureChallenge
17
- import com.yuno.sdk.TokenCollectedData
17
+ import com.yuno.sdk.payments.TokenCollectedData
18
18
  import com.yuno.sdk.ThreeDSecureChallengeResponse
19
19
  import com.yuno.presentation.core.components.PaymentSelected
20
20
  import com.yuno.presentation.core.card.CardFormType
@@ -22,6 +22,11 @@ import com.yuno.payments.features.payment.models.OneTimeTokenModel
22
22
  import com.google.gson.Gson
23
23
  import org.json.JSONObject
24
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
25
30
 
26
31
  /**
27
32
  * Yuno SDK React Native Module for Android
@@ -861,33 +866,36 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
861
866
  )
862
867
 
863
868
  // Generate token
864
- apiClient.generateToken(collectedData, reactContext).observe { result ->
865
- try {
866
- when {
867
- result.containsKey("token") && result["token"] != null -> {
868
- val token = result["token"] as String
869
- Log.d(TAG, " Token generated successfully")
870
-
871
- val response = Arguments.createMap().apply {
872
- putString("token", token)
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")
873
891
  }
874
- promise.resolve(response)
875
- }
876
- result.containsKey("error") && result["error"] != null -> {
877
- val error = result["error"] as String
878
- Log.e(TAG, "❌ Token generation failed: $error")
879
- promise.reject("TOKEN_GENERATION_ERROR", error)
880
- }
881
- else -> {
882
- Log.e(TAG, "❌ Unknown response from token generation")
883
- promise.reject("TOKEN_GENERATION_ERROR", "Unknown error occurred")
884
892
  }
893
+ } catch (e: Exception) {
894
+ Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
895
+ promise.reject("TOKEN_GENERATION_ERROR", e.message)
885
896
  }
886
- } catch (e: Exception) {
887
- Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
888
- promise.reject("TOKEN_GENERATION_ERROR", e.message)
889
897
  }
890
- }
898
+ .launchIn(CoroutineScope(Dispatchers.Main))
891
899
  } catch (e: Exception) {
892
900
  Log.e(TAG, "❌ Error in generateToken: ${e.message}")
893
901
  promise.reject("TOKEN_GENERATION_ERROR", e.message)
@@ -919,25 +927,28 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
919
927
  )
920
928
 
921
929
  // Get 3DS challenge
922
- apiClient.getThreeDSecureChallenge(reactContext, checkoutSession).observe { result ->
923
- try {
924
- val response = Arguments.createMap().apply {
925
- putString("type", result.type)
926
- putString("data", result.data)
927
- }
928
-
929
- if (result.type == "URL") {
930
- Log.d(TAG, "✅ 3DS Challenge URL retrieved successfully")
931
- promise.resolve(response)
932
- } else {
933
- Log.e(TAG, "❌ 3DS Challenge failed: ${result.data}")
934
- promise.reject("THREE_DS_ERROR", result.data)
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)
935
949
  }
936
- } catch (e: Exception) {
937
- Log.e(TAG, "❌ Error processing 3DS challenge result: ${e.message}")
938
- promise.reject("THREE_DS_ERROR", e.message)
939
950
  }
940
- }
951
+ .launchIn(CoroutineScope(Dispatchers.Main))
941
952
  } catch (e: Exception) {
942
953
  Log.e(TAG, "❌ Error in getThreeDSecureChallenge: ${e.message}")
943
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",
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",