@yuno-payments/yuno-sdk-react-native 1.0.22 → 1.0.24

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.
@@ -852,11 +852,6 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
852
852
  * @param countryCode The country code for the payment
853
853
  * @param promise Promise to resolve with token or error
854
854
  */
855
- private fun showToast(message: String) {
856
- currentActivity?.runOnUiThread {
857
- Toast.makeText(currentActivity, message, Toast.LENGTH_LONG).show()
858
- }
859
- }
860
855
 
861
856
  @ReactMethod
862
857
  fun generateToken(
@@ -866,12 +861,10 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
866
861
  promise: Promise
867
862
  ) {
868
863
  try {
869
- showToast("🚀 generateToken: $checkoutSession")
870
864
  Log.d(TAG, "generateToken called with checkoutSession: $checkoutSession")
871
865
 
872
866
  val activity = currentActivity
873
867
  if (activity == null) {
874
- showToast("❌ Activity is null")
875
868
  promise.reject("ACTIVITY_UNAVAILABLE", "Current activity is null. Cannot generate token.")
876
869
  return
877
870
  }
@@ -881,7 +874,6 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
881
874
  val jsonString = convertReadableMapToJson(tokenCollectedData)
882
875
  Log.d(TAG, "JSON String: $jsonString")
883
876
  val collectedData = gson.fromJson(jsonString, TokenCollectedData::class.java)
884
- showToast("📦 Data parsed, calling API...")
885
877
  Log.d(TAG, "Parsed TokenCollectedData: checkoutSession=${collectedData.checkoutSession}, paymentMethod=${collectedData.paymentMethod}")
886
878
 
887
879
  // Create API client and store it for later use (e.g., getThreeDSecureChallenge)
@@ -891,7 +883,6 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
891
883
  context = activity.applicationContext
892
884
  )
893
885
  headlessApiClient = apiClient
894
- showToast("✅ API Client created and stored")
895
886
 
896
887
  // Generate token - pass activity for WebView context
897
888
  apiClient.generateToken(collectedData, activity)
@@ -901,7 +892,6 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
901
892
  when {
902
893
  result.containsKey("token") && result["token"] != null -> {
903
894
  val token = result["token"] as String
904
- showToast("✅ Token generated!")
905
895
  Log.d(TAG, "✅ Token generated successfully")
906
896
 
907
897
  val response = Arguments.createMap().apply {
@@ -911,30 +901,25 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
911
901
  }
912
902
  result.containsKey("error") && result["error"] != null -> {
913
903
  val error = result["error"] as String
914
- showToast("❌ Token error: $error")
915
904
  Log.e(TAG, "❌ Token generation failed: $error")
916
905
  promise.reject("TOKEN_GENERATION_ERROR", error)
917
906
  }
918
907
  else -> {
919
- showToast("❌ Unknown response")
920
908
  Log.e(TAG, "❌ Unknown response from token generation")
921
909
  promise.reject("TOKEN_GENERATION_ERROR", "Unknown error occurred")
922
910
  }
923
911
  }
924
912
  } catch (e: Exception) {
925
- showToast("❌ Exception: ${e.message}")
926
913
  Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
927
914
  promise.reject("TOKEN_GENERATION_ERROR", e.message)
928
915
  }
929
916
  }
930
917
  .catch { e ->
931
- showToast("❌ Flow error: ${e.message}")
932
918
  Log.e(TAG, "❌ Flow error in token generation: ${e.message}")
933
919
  promise.reject("TOKEN_GENERATION_ERROR", e.message ?: "Unknown error in token generation flow")
934
920
  }
935
921
  .launchIn(CoroutineScope(Dispatchers.Main))
936
922
  } catch (e: Exception) {
937
- showToast("❌ Error: ${e.message}")
938
923
  Log.e(TAG, "❌ Error in generateToken: ${e.message}")
939
924
  promise.reject("TOKEN_GENERATION_ERROR", e.message)
940
925
  }
@@ -955,12 +940,10 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
955
940
  promise: Promise
956
941
  ) {
957
942
  try {
958
- showToast("🔐 get3DS: $checkoutSession")
959
943
  Log.d(TAG, "getThreeDSecureChallenge called with checkoutSession: $checkoutSession")
960
944
 
961
945
  val activity = currentActivity
962
946
  if (activity == null) {
963
- showToast("❌ Activity is null")
964
947
  promise.reject("ACTIVITY_UNAVAILABLE", "Current activity is null. Cannot get 3DS challenge.")
965
948
  return
966
949
  }
@@ -973,7 +956,6 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
973
956
  )
974
957
 
975
958
  val clientType = if (headlessApiClient != null) "EXISTING" else "NEW"
976
- showToast("📦 Using $clientType API client")
977
959
  Log.d(TAG, "Using ${if (headlessApiClient != null) "existing" else "new"} API client for 3DS challenge")
978
960
 
979
961
  // Get 3DS challenge - pass activity for WebView context
@@ -981,35 +963,29 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
981
963
  .asFlow()
982
964
  .onEach { result ->
983
965
  try {
984
- showToast("📥 Result: type=${result.type}")
985
966
  val response = Arguments.createMap().apply {
986
967
  putString("type", result.type)
987
968
  putString("data", result.data)
988
969
  }
989
970
 
990
971
  if (result.type == "URL") {
991
- showToast("✅ 3DS URL received!")
992
972
  Log.d(TAG, "✅ 3DS Challenge URL retrieved successfully")
993
973
  promise.resolve(response)
994
974
  } else {
995
- showToast("❌ 3DS failed: ${result.data}")
996
975
  Log.e(TAG, "❌ 3DS Challenge failed: ${result.data}")
997
976
  promise.reject("THREE_DS_ERROR", result.data)
998
977
  }
999
978
  } catch (e: Exception) {
1000
- showToast("❌ Exception: ${e.message}")
1001
979
  Log.e(TAG, "❌ Error processing 3DS challenge result: ${e.message}")
1002
980
  promise.reject("THREE_DS_ERROR", e.message)
1003
981
  }
1004
982
  }
1005
983
  .catch { e ->
1006
- showToast("❌ Flow error: ${e.message}")
1007
984
  Log.e(TAG, "❌ Flow error in 3DS challenge: ${e.message}")
1008
985
  promise.reject("THREE_DS_ERROR", e.message ?: "Unknown error in 3DS challenge flow")
1009
986
  }
1010
987
  .launchIn(CoroutineScope(Dispatchers.Main))
1011
988
  } catch (e: Exception) {
1012
- showToast("❌ Error: ${e.message}")
1013
989
  Log.e(TAG, "❌ Error in getThreeDSecureChallenge: ${e.message}")
1014
990
  promise.reject("THREE_DS_ERROR", e.message)
1015
991
  }
@@ -46,7 +46,13 @@ class YunoPaymentMethodsView: UIView, YunoPaymentFullDelegate {
46
46
  }
47
47
 
48
48
  var language: String? {
49
- return nil // Use default language
49
+ // Read language from YunoSdk module that was set during initialization
50
+ if let bridge = RCTBridge.current() {
51
+ if let yunoModule = bridge.module(for: YunoSdk.self) as? YunoSdk {
52
+ return yunoModule.getCurrentLanguage()
53
+ }
54
+ }
55
+ return nil // Fallback to default language
50
56
  }
51
57
 
52
58
  var viewController: UIViewController? {
package/ios/YunoSdk.swift CHANGED
@@ -88,9 +88,11 @@ class YunoSdk: RCTEventEmitter {
88
88
  self.currentLanguage = lang
89
89
  }
90
90
 
91
- // Parse card flow (React Native sends "cardType", not "cardFlow")
91
+ // Parse card flow (check both "cardFlow" and "cardType" for compatibility)
92
92
  var cardFlow: CardFormType = .oneStep
93
- if let flow = yunoConfig["cardType"] as? String {
93
+ if let flow = yunoConfig["cardFlow"] as? String {
94
+ cardFlow = self.mapToCardFormType(flow)
95
+ } else if let flow = yunoConfig["cardType"] as? String {
94
96
  cardFlow = self.mapToCardFormType(flow)
95
97
  }
96
98
 
@@ -441,6 +443,15 @@ class YunoSdk: RCTEventEmitter {
441
443
  resolver(true)
442
444
  }
443
445
 
446
+ /**
447
+ * Gets the current language set during initialization.
448
+ * Used internally by YunoPaymentMethodsView to pass language to delegates.
449
+ */
450
+ @objc
451
+ func getCurrentLanguage() -> String? {
452
+ return currentLanguage
453
+ }
454
+
444
455
  // MARK: - Helper Methods
445
456
 
446
457
  private func mapToCardFormType(_ cardFormType: String) -> CardFormType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuno-payments/yuno-sdk-react-native",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
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",