@yuno-payments/yuno-sdk-react-native 1.0.21 → 1.0.23

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.
@@ -3,6 +3,7 @@ package com.yunosdkreactnative
3
3
  import android.app.Activity
4
4
  import android.content.Context
5
5
  import android.util.Log
6
+ import android.widget.Toast
6
7
  import androidx.activity.ComponentActivity
7
8
  import com.facebook.react.bridge.*
8
9
  import com.facebook.react.modules.core.DeviceEventManagerModule
@@ -70,6 +71,10 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
70
71
  @Volatile
71
72
  private var lastPaymentStatus: String? = null
72
73
 
74
+ // Store the API client for headless payment flow (reused between generateToken and getThreeDSecureChallenge)
75
+ @Volatile
76
+ private var headlessApiClient: com.yuno.sdk.ApiClientPayment? = null
77
+
73
78
  // Flag to track if we're starting a fresh payment flow
74
79
  @Volatile
75
80
  private var isPaymentFlowCleared: Boolean = false
@@ -847,6 +852,7 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
847
852
  * @param countryCode The country code for the payment
848
853
  * @param promise Promise to resolve with token or error
849
854
  */
855
+
850
856
  @ReactMethod
851
857
  fun generateToken(
852
858
  tokenCollectedData: ReadableMap,
@@ -870,12 +876,13 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
870
876
  val collectedData = gson.fromJson(jsonString, TokenCollectedData::class.java)
871
877
  Log.d(TAG, "Parsed TokenCollectedData: checkoutSession=${collectedData.checkoutSession}, paymentMethod=${collectedData.paymentMethod}")
872
878
 
873
- // Create API client
879
+ // Create API client and store it for later use (e.g., getThreeDSecureChallenge)
874
880
  val apiClient = Yuno.apiClientPayment(
875
881
  checkoutSession = checkoutSession,
876
882
  countryCode = countryCode,
877
883
  context = activity.applicationContext
878
884
  )
885
+ headlessApiClient = apiClient
879
886
 
880
887
  // Generate token - pass activity for WebView context
881
888
  apiClient.generateToken(collectedData, activity)
@@ -941,13 +948,16 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
941
948
  return
942
949
  }
943
950
 
944
- // Create API client
945
- val apiClient = Yuno.apiClientPayment(
951
+ // Reuse existing API client if available (from generateToken), otherwise create new one
952
+ val apiClient = headlessApiClient ?: Yuno.apiClientPayment(
946
953
  checkoutSession = checkoutSession,
947
954
  countryCode = countryCode,
948
955
  context = activity.applicationContext
949
956
  )
950
957
 
958
+ val clientType = if (headlessApiClient != null) "EXISTING" else "NEW"
959
+ Log.d(TAG, "Using ${if (headlessApiClient != null) "existing" else "new"} API client for 3DS challenge")
960
+
951
961
  // Get 3DS challenge - pass activity for WebView context
952
962
  apiClient.getThreeDSecureChallenge(activity, checkoutSession)
953
963
  .asFlow()
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuno-payments/yuno-sdk-react-native",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
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",