@yuno-payments/yuno-sdk-react-native 1.0.17-rc.1 → 1.0.17-rc.10
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/android/src/main/java/com/yunosdkreactnative/YunoSdkModule.kt +294 -0
- package/ios/YunoSdk.m +16 -0
- package/ios/YunoSdk.swift +114 -0
- package/lib/commonjs/YunoPaymentMethods.js.map +1 -1
- package/lib/commonjs/YunoSdk.js +131 -4
- package/lib/commonjs/YunoSdk.js.map +1 -1
- package/lib/commonjs/core/types/HeadlessTypes.js +20 -0
- package/lib/commonjs/core/types/HeadlessTypes.js.map +1 -0
- package/lib/module/YunoPaymentMethods.js.map +1 -1
- package/lib/module/YunoSdk.js +131 -4
- package/lib/module/YunoSdk.js.map +1 -1
- package/lib/module/core/types/HeadlessTypes.js +16 -0
- package/lib/module/core/types/HeadlessTypes.js.map +1 -0
- package/package.json +1 -1
- package/src/YunoPaymentMethods.tsx +5 -5
- package/src/YunoSdk.ts +163 -6
- package/src/core/types/HeadlessTypes.ts +110 -0
- package/src/core/types/OneTimeTokenInfo.ts +0 -1
- package/src/core/types/index.ts +17 -0
|
@@ -11,12 +11,26 @@ 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.ApiClientEnroll
|
|
18
|
+
import com.yuno.sdk.ApiClientEnroll.Companion.continueEnrollment
|
|
19
|
+
import com.yuno.sdk.payments.TokenCollectedData
|
|
20
|
+
import com.yuno.sdk.enrollment.EnrollmentCollectedData
|
|
21
|
+
import com.yuno.sdk.ThreeDSecureChallengeResponse
|
|
14
22
|
import com.yuno.presentation.core.components.PaymentSelected
|
|
15
23
|
import com.yuno.presentation.core.card.CardFormType
|
|
16
24
|
import com.yuno.payments.features.payment.models.OneTimeTokenModel
|
|
17
25
|
import com.google.gson.Gson
|
|
18
26
|
import org.json.JSONObject
|
|
19
27
|
import org.json.JSONArray
|
|
28
|
+
import kotlinx.coroutines.CoroutineScope
|
|
29
|
+
import kotlinx.coroutines.Dispatchers
|
|
30
|
+
import kotlinx.coroutines.flow.launchIn
|
|
31
|
+
import kotlinx.coroutines.flow.onEach
|
|
32
|
+
import kotlinx.coroutines.flow.catch
|
|
33
|
+
import androidx.lifecycle.asFlow
|
|
20
34
|
|
|
21
35
|
/**
|
|
22
36
|
* Yuno SDK React Native Module for Android
|
|
@@ -821,4 +835,284 @@ class YunoSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
821
835
|
}
|
|
822
836
|
return array
|
|
823
837
|
}
|
|
838
|
+
|
|
839
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
843
|
+
* This method mirrors the native SDK's generateToken() API.
|
|
844
|
+
*
|
|
845
|
+
* @param tokenCollectedData Map containing checkout_session, customer_session, and payment_method data
|
|
846
|
+
* @param checkoutSession The checkout session ID
|
|
847
|
+
* @param countryCode The country code for the payment
|
|
848
|
+
* @param promise Promise to resolve with token or error
|
|
849
|
+
*/
|
|
850
|
+
@ReactMethod
|
|
851
|
+
fun generateToken(
|
|
852
|
+
tokenCollectedData: ReadableMap,
|
|
853
|
+
checkoutSession: String,
|
|
854
|
+
countryCode: String,
|
|
855
|
+
promise: Promise
|
|
856
|
+
) {
|
|
857
|
+
try {
|
|
858
|
+
Log.d(TAG, "generateToken called with checkoutSession: $checkoutSession")
|
|
859
|
+
|
|
860
|
+
val activity = currentActivity
|
|
861
|
+
if (activity == null) {
|
|
862
|
+
promise.reject("ACTIVITY_UNAVAILABLE", "Current activity is null. Cannot generate token.")
|
|
863
|
+
return
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// Convert ReadableMap to TokenCollectedData using Gson
|
|
867
|
+
val gson = Gson()
|
|
868
|
+
val jsonString = convertReadableMapToJson(tokenCollectedData)
|
|
869
|
+
Log.d(TAG, "JSON String: $jsonString")
|
|
870
|
+
val collectedData = gson.fromJson(jsonString, TokenCollectedData::class.java)
|
|
871
|
+
Log.d(TAG, "Parsed TokenCollectedData: checkoutSession=${collectedData.checkoutSession}, paymentMethod=${collectedData.paymentMethod}")
|
|
872
|
+
|
|
873
|
+
// Create API client
|
|
874
|
+
val apiClient = Yuno.apiClientPayment(
|
|
875
|
+
checkoutSession = checkoutSession,
|
|
876
|
+
countryCode = countryCode,
|
|
877
|
+
context = activity.applicationContext
|
|
878
|
+
)
|
|
879
|
+
|
|
880
|
+
// Generate token - pass activity for WebView context
|
|
881
|
+
apiClient.generateToken(collectedData, activity)
|
|
882
|
+
.asFlow()
|
|
883
|
+
.onEach { result ->
|
|
884
|
+
try {
|
|
885
|
+
when {
|
|
886
|
+
result.containsKey("token") && result["token"] != null -> {
|
|
887
|
+
val token = result["token"] as String
|
|
888
|
+
Log.d(TAG, "✅ Token generated successfully")
|
|
889
|
+
|
|
890
|
+
val response = Arguments.createMap().apply {
|
|
891
|
+
putString("token", token)
|
|
892
|
+
}
|
|
893
|
+
promise.resolve(response)
|
|
894
|
+
}
|
|
895
|
+
result.containsKey("error") && result["error"] != null -> {
|
|
896
|
+
val error = result["error"] as String
|
|
897
|
+
Log.e(TAG, "❌ Token generation failed: $error")
|
|
898
|
+
promise.reject("TOKEN_GENERATION_ERROR", error)
|
|
899
|
+
}
|
|
900
|
+
else -> {
|
|
901
|
+
Log.e(TAG, "❌ Unknown response from token generation")
|
|
902
|
+
promise.reject("TOKEN_GENERATION_ERROR", "Unknown error occurred")
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
} catch (e: Exception) {
|
|
906
|
+
Log.e(TAG, "❌ Error processing token generation result: ${e.message}")
|
|
907
|
+
promise.reject("TOKEN_GENERATION_ERROR", e.message)
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
.catch { e ->
|
|
911
|
+
Log.e(TAG, "❌ Flow error in token generation: ${e.message}")
|
|
912
|
+
promise.reject("TOKEN_GENERATION_ERROR", e.message ?: "Unknown error in token generation flow")
|
|
913
|
+
}
|
|
914
|
+
.launchIn(CoroutineScope(Dispatchers.Main))
|
|
915
|
+
} catch (e: Exception) {
|
|
916
|
+
Log.e(TAG, "❌ Error in generateToken: ${e.message}")
|
|
917
|
+
promise.reject("TOKEN_GENERATION_ERROR", e.message)
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Get the 3D Secure challenge URL for a checkout session.
|
|
923
|
+
* This method mirrors the native SDK's getThreeDSecureChallenge() API.
|
|
924
|
+
*
|
|
925
|
+
* @param checkoutSession The checkout session ID
|
|
926
|
+
* @param countryCode The country code for the payment
|
|
927
|
+
* @param promise Promise to resolve with URL or error
|
|
928
|
+
*/
|
|
929
|
+
@ReactMethod
|
|
930
|
+
fun getThreeDSecureChallenge(
|
|
931
|
+
checkoutSession: String,
|
|
932
|
+
countryCode: String,
|
|
933
|
+
promise: Promise
|
|
934
|
+
) {
|
|
935
|
+
try {
|
|
936
|
+
Log.d(TAG, "getThreeDSecureChallenge called with checkoutSession: $checkoutSession")
|
|
937
|
+
|
|
938
|
+
val activity = currentActivity
|
|
939
|
+
if (activity == null) {
|
|
940
|
+
promise.reject("ACTIVITY_UNAVAILABLE", "Current activity is null. Cannot get 3DS challenge.")
|
|
941
|
+
return
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// Create API client
|
|
945
|
+
val apiClient = Yuno.apiClientPayment(
|
|
946
|
+
checkoutSession = checkoutSession,
|
|
947
|
+
countryCode = countryCode,
|
|
948
|
+
context = activity.applicationContext
|
|
949
|
+
)
|
|
950
|
+
|
|
951
|
+
// Get 3DS challenge - pass activity for WebView context
|
|
952
|
+
apiClient.getThreeDSecureChallenge(activity, checkoutSession)
|
|
953
|
+
.asFlow()
|
|
954
|
+
.onEach { result ->
|
|
955
|
+
try {
|
|
956
|
+
val response = Arguments.createMap().apply {
|
|
957
|
+
putString("type", result.type)
|
|
958
|
+
putString("data", result.data)
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (result.type == "URL") {
|
|
962
|
+
Log.d(TAG, "✅ 3DS Challenge URL retrieved successfully")
|
|
963
|
+
promise.resolve(response)
|
|
964
|
+
} else {
|
|
965
|
+
Log.e(TAG, "❌ 3DS Challenge failed: ${result.data}")
|
|
966
|
+
promise.reject("THREE_DS_ERROR", result.data)
|
|
967
|
+
}
|
|
968
|
+
} catch (e: Exception) {
|
|
969
|
+
Log.e(TAG, "❌ Error processing 3DS challenge result: ${e.message}")
|
|
970
|
+
promise.reject("THREE_DS_ERROR", e.message)
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
.catch { e ->
|
|
974
|
+
Log.e(TAG, "❌ Flow error in 3DS challenge: ${e.message}")
|
|
975
|
+
promise.reject("THREE_DS_ERROR", e.message ?: "Unknown error in 3DS challenge flow")
|
|
976
|
+
}
|
|
977
|
+
.launchIn(CoroutineScope(Dispatchers.Main))
|
|
978
|
+
} catch (e: Exception) {
|
|
979
|
+
Log.e(TAG, "❌ Error in getThreeDSecureChallenge: ${e.message}")
|
|
980
|
+
promise.reject("THREE_DS_ERROR", e.message)
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// ==================== HEADLESS ENROLLMENT FLOW ====================
|
|
985
|
+
|
|
986
|
+
@ReactMethod
|
|
987
|
+
fun continueEnrollment(
|
|
988
|
+
enrollmentCollectedData: ReadableMap,
|
|
989
|
+
customerSession: String,
|
|
990
|
+
countryCode: String,
|
|
991
|
+
promise: Promise
|
|
992
|
+
) {
|
|
993
|
+
try {
|
|
994
|
+
Log.d(TAG, "continueEnrollment called with customerSession: $customerSession")
|
|
995
|
+
|
|
996
|
+
val activity = currentActivity
|
|
997
|
+
if (activity == null) {
|
|
998
|
+
promise.reject("ACTIVITY_UNAVAILABLE", "Current activity is null. Cannot continue enrollment.")
|
|
999
|
+
return
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// Convert ReadableMap to JSON String
|
|
1003
|
+
val jsonString = convertReadableMapToJson(enrollmentCollectedData)
|
|
1004
|
+
Log.d(TAG, "📦 EnrollmentCollectedData JSON received: $jsonString")
|
|
1005
|
+
|
|
1006
|
+
// Convert JSON String to EnrollmentCollectedData using Gson
|
|
1007
|
+
val gson = Gson()
|
|
1008
|
+
val collectedData = gson.fromJson(jsonString, EnrollmentCollectedData::class.java)
|
|
1009
|
+
|
|
1010
|
+
// Create API client for enrollment
|
|
1011
|
+
val apiClient = Yuno.apiClientEnroll(
|
|
1012
|
+
customerSession = customerSession,
|
|
1013
|
+
countryCode = countryCode,
|
|
1014
|
+
context = activity
|
|
1015
|
+
)
|
|
1016
|
+
|
|
1017
|
+
// Continue enrollment
|
|
1018
|
+
apiClient.continueEnrollment(collectedData, activity)
|
|
1019
|
+
.asFlow()
|
|
1020
|
+
.onEach { result ->
|
|
1021
|
+
try {
|
|
1022
|
+
when {
|
|
1023
|
+
result.containsKey("vaulted_token") && result["vaulted_token"] != null -> {
|
|
1024
|
+
val vaultedToken = result["vaulted_token"] as String
|
|
1025
|
+
Log.d(TAG, "✅ Vaulted token created successfully")
|
|
1026
|
+
|
|
1027
|
+
val response = Arguments.createMap().apply {
|
|
1028
|
+
putString("vaultedToken", vaultedToken)
|
|
1029
|
+
}
|
|
1030
|
+
promise.resolve(response)
|
|
1031
|
+
}
|
|
1032
|
+
result.containsKey("error") && result["error"] != null -> {
|
|
1033
|
+
val error = result["error"] as String
|
|
1034
|
+
Log.e(TAG, "❌ Enrollment failed: $error")
|
|
1035
|
+
promise.reject("ENROLLMENT_ERROR", error)
|
|
1036
|
+
}
|
|
1037
|
+
else -> {
|
|
1038
|
+
Log.e(TAG, "❌ Unknown response from enrollment")
|
|
1039
|
+
promise.reject("ENROLLMENT_ERROR", "Unknown error occurred")
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
} catch (e: Exception) {
|
|
1043
|
+
Log.e(TAG, "❌ Error processing enrollment result: ${e.message}")
|
|
1044
|
+
promise.reject("ENROLLMENT_ERROR", e.message)
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
.catch { e ->
|
|
1048
|
+
Log.e(TAG, "❌ Flow error during enrollment: ${e.message}")
|
|
1049
|
+
promise.reject("ENROLLMENT_FLOW_ERROR", e.message)
|
|
1050
|
+
}
|
|
1051
|
+
.launchIn(CoroutineScope(Dispatchers.Main))
|
|
1052
|
+
} catch (e: Exception) {
|
|
1053
|
+
Log.e(TAG, "❌ Error in continueEnrollment: ${e.message}")
|
|
1054
|
+
promise.reject("ENROLLMENT_ERROR", e.message)
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Helper function to convert ReadableMap to JSON string.
|
|
1060
|
+
*/
|
|
1061
|
+
private fun convertReadableMapToJson(readableMap: ReadableMap): String {
|
|
1062
|
+
val json = JSONObject()
|
|
1063
|
+
val iterator = readableMap.keySetIterator()
|
|
1064
|
+
|
|
1065
|
+
while (iterator.hasNextKey()) {
|
|
1066
|
+
val key = iterator.nextKey()
|
|
1067
|
+
val value = when (readableMap.getType(key)) {
|
|
1068
|
+
ReadableType.Boolean -> readableMap.getBoolean(key)
|
|
1069
|
+
ReadableType.Number -> readableMap.getDouble(key)
|
|
1070
|
+
ReadableType.String -> readableMap.getString(key)
|
|
1071
|
+
ReadableType.Map -> convertReadableMapToJsonObject(readableMap.getMap(key)!!)
|
|
1072
|
+
ReadableType.Array -> convertReadableArrayToJsonArray(readableMap.getArray(key)!!)
|
|
1073
|
+
ReadableType.Null -> JSONObject.NULL
|
|
1074
|
+
}
|
|
1075
|
+
json.put(key, value)
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
return json.toString()
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
private fun convertReadableMapToJsonObject(readableMap: ReadableMap): JSONObject {
|
|
1082
|
+
val json = JSONObject()
|
|
1083
|
+
val iterator = readableMap.keySetIterator()
|
|
1084
|
+
|
|
1085
|
+
while (iterator.hasNextKey()) {
|
|
1086
|
+
val key = iterator.nextKey()
|
|
1087
|
+
val value = when (readableMap.getType(key)) {
|
|
1088
|
+
ReadableType.Boolean -> readableMap.getBoolean(key)
|
|
1089
|
+
ReadableType.Number -> readableMap.getDouble(key)
|
|
1090
|
+
ReadableType.String -> readableMap.getString(key)
|
|
1091
|
+
ReadableType.Map -> convertReadableMapToJsonObject(readableMap.getMap(key)!!)
|
|
1092
|
+
ReadableType.Array -> convertReadableArrayToJsonArray(readableMap.getArray(key)!!)
|
|
1093
|
+
ReadableType.Null -> JSONObject.NULL
|
|
1094
|
+
}
|
|
1095
|
+
json.put(key, value)
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
return json
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
private fun convertReadableArrayToJsonArray(readableArray: ReadableArray): JSONArray {
|
|
1102
|
+
val json = JSONArray()
|
|
1103
|
+
|
|
1104
|
+
for (i in 0 until readableArray.size()) {
|
|
1105
|
+
val value = when (readableArray.getType(i)) {
|
|
1106
|
+
ReadableType.Boolean -> readableArray.getBoolean(i)
|
|
1107
|
+
ReadableType.Number -> readableArray.getDouble(i)
|
|
1108
|
+
ReadableType.String -> readableArray.getString(i)
|
|
1109
|
+
ReadableType.Map -> convertReadableMapToJsonObject(readableArray.getMap(i))
|
|
1110
|
+
ReadableType.Array -> convertReadableArrayToJsonArray(readableArray.getArray(i))
|
|
1111
|
+
ReadableType.Null -> JSONObject.NULL
|
|
1112
|
+
}
|
|
1113
|
+
json.put(value)
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
return json
|
|
1117
|
+
}
|
|
824
1118
|
}
|
package/ios/YunoSdk.m
CHANGED
|
@@ -82,5 +82,21 @@ RCT_EXTERN_METHOD(addListener:(NSString *)eventName)
|
|
|
82
82
|
|
|
83
83
|
RCT_EXTERN_METHOD(removeListeners:(double)count)
|
|
84
84
|
|
|
85
|
+
// Headless Payment Flow
|
|
86
|
+
RCT_EXTERN_METHOD(
|
|
87
|
+
generateToken:(NSDictionary *)tokenCollectedData
|
|
88
|
+
checkoutSession:(NSString *)checkoutSession
|
|
89
|
+
countryCode:(NSString *)countryCode
|
|
90
|
+
resolver:(RCTPromiseResolveBlock)resolver
|
|
91
|
+
rejecter:(RCTPromiseRejectBlock)rejecter
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
RCT_EXTERN_METHOD(
|
|
95
|
+
getThreeDSecureChallenge:(NSString *)checkoutSession
|
|
96
|
+
countryCode:(NSString *)countryCode
|
|
97
|
+
resolver:(RCTPromiseResolveBlock)resolver
|
|
98
|
+
rejecter:(RCTPromiseRejectBlock)rejecter
|
|
99
|
+
)
|
|
100
|
+
|
|
85
101
|
@end
|
|
86
102
|
|
package/ios/YunoSdk.swift
CHANGED
|
@@ -559,3 +559,117 @@ extension YunoSdk: YunoEnrollmentDelegate {
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
+
// MARK: - Headless Payment Flow
|
|
563
|
+
extension YunoSdk {
|
|
564
|
+
/**
|
|
565
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
566
|
+
* This method mirrors the native SDK's generateToken() API.
|
|
567
|
+
*
|
|
568
|
+
* @param tokenCollectedData Dictionary containing checkout_session and payment_method data
|
|
569
|
+
* @param checkoutSession The checkout session ID
|
|
570
|
+
* @param countryCode The country code for the payment
|
|
571
|
+
* @param resolver Promise resolver
|
|
572
|
+
* @param rejecter Promise rejecter
|
|
573
|
+
*/
|
|
574
|
+
@objc
|
|
575
|
+
func generateToken(
|
|
576
|
+
_ tokenCollectedData: NSDictionary,
|
|
577
|
+
checkoutSession: String,
|
|
578
|
+
countryCode: String,
|
|
579
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
580
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
581
|
+
) {
|
|
582
|
+
Task { @MainActor [weak self] in
|
|
583
|
+
guard let self = self else { return }
|
|
584
|
+
|
|
585
|
+
do {
|
|
586
|
+
// Convert NSDictionary to JSON Data
|
|
587
|
+
guard JSONSerialization.isValidJSONObject(tokenCollectedData) else {
|
|
588
|
+
rejecter("INVALID_DATA", "Invalid token collected data", nil)
|
|
589
|
+
return
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
let jsonData = try JSONSerialization.data(withJSONObject: tokenCollectedData, options: [])
|
|
593
|
+
|
|
594
|
+
// Debug: Print the JSON string
|
|
595
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
596
|
+
print("🐛 iOS generateToken JSON: \(jsonString)")
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Decode to TokenCollectedData using the native SDK's Codable model
|
|
600
|
+
// Note: Don't use .convertFromSnakeCase because the SDK's models have custom decoders
|
|
601
|
+
// that already handle snake_case field names (checkout_session, payment_method, etc)
|
|
602
|
+
let decoder = JSONDecoder()
|
|
603
|
+
let collectedData = try decoder.decode(TokenCollectedData.self, from: jsonData)
|
|
604
|
+
|
|
605
|
+
// Create API client using the native SDK's factory method
|
|
606
|
+
let apiClient = Yuno.apiClientPayment(
|
|
607
|
+
countryCode: countryCode,
|
|
608
|
+
checkoutSession: checkoutSession
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
// Generate token using async/await (native SDK uses async throws)
|
|
612
|
+
let response = try await apiClient.generateToken(data: collectedData)
|
|
613
|
+
|
|
614
|
+
// The native SDK returns [String: Any] with token in "token" key
|
|
615
|
+
if let token = response["token"] as? String {
|
|
616
|
+
let responseDict: [String: Any] = ["token": token]
|
|
617
|
+
resolver(responseDict)
|
|
618
|
+
} else if let error = response["error"] as? String {
|
|
619
|
+
rejecter("TOKEN_GENERATION_ERROR", error, nil)
|
|
620
|
+
} else {
|
|
621
|
+
rejecter("TOKEN_GENERATION_ERROR", "No token in response", nil)
|
|
622
|
+
}
|
|
623
|
+
} catch {
|
|
624
|
+
rejecter("TOKEN_GENERATION_ERROR", "Failed to generate token: \(error.localizedDescription)", error)
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Get the 3D Secure challenge URL for a checkout session.
|
|
631
|
+
* This method mirrors the native SDK's getThreeDSecureChallenge() API.
|
|
632
|
+
*
|
|
633
|
+
* @param checkoutSession The checkout session ID
|
|
634
|
+
* @param countryCode The country code for the payment
|
|
635
|
+
* @param resolver Promise resolver
|
|
636
|
+
* @param rejecter Promise rejecter
|
|
637
|
+
*/
|
|
638
|
+
@objc
|
|
639
|
+
func getThreeDSecureChallenge(
|
|
640
|
+
_ checkoutSession: String,
|
|
641
|
+
countryCode: String,
|
|
642
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
643
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
644
|
+
) {
|
|
645
|
+
Task { @MainActor [weak self] in
|
|
646
|
+
guard let self = self else { return }
|
|
647
|
+
|
|
648
|
+
do {
|
|
649
|
+
// Create API client using the native SDK's factory method
|
|
650
|
+
let apiClient = Yuno.apiClientPayment(
|
|
651
|
+
countryCode: countryCode,
|
|
652
|
+
checkoutSession: checkoutSession
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
// Get 3DS challenge using async/await (native SDK uses async throws)
|
|
656
|
+
let response = try await apiClient.getThreeDSecureChallenge(checkoutSession: checkoutSession)
|
|
657
|
+
|
|
658
|
+
// The native SDK returns ThreeDSecureChallengeResponse with url property
|
|
659
|
+
let responseDict: [String: Any] = [
|
|
660
|
+
"type": "URL",
|
|
661
|
+
"data": response.url
|
|
662
|
+
]
|
|
663
|
+
|
|
664
|
+
resolver(responseDict)
|
|
665
|
+
} catch {
|
|
666
|
+
rejecter("THREE_DS_ERROR", "Failed to get 3DS challenge: \(error.localizedDescription)", error)
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// Note: TokenCollectedData, CollectedData, CardData, and other related models
|
|
673
|
+
// are provided by the YunoSDK framework (imported at the top).
|
|
674
|
+
// We don't need to redefine them here.
|
|
675
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","LINKING_ERROR","Platform","select","ios","YunoSdkNative","NativeModules","YunoSdk","eventEmitter","NativeEventEmitter","NativeYunoPaymentMethodsView","requireNativeComponent","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","useEffect","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement","exports"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOsB,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEtB;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AA2BA;;AAQA,MAAMkB,aAAa,GACjB,gHAAgH,GAChHC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEZ,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B,GAC/B,0CAA0C;;AAE5C;AACA,MAAMa,aAAa,GAAGC,0BAAa,CAACC,OAAO;;AAE3C;AACA,IAAIC,YAAuC,GAAG,IAAI;AAClD,IAAIH,aAAa,EAAE;EACjBG,YAAY,GAAG,IAAIC,+BAAkB,CAACJ,aAAa,CAAC;AACtD;;AAEA;AACA,MAAMK,4BAA4B,
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","LINKING_ERROR","Platform","select","ios","YunoSdkNative","NativeModules","YunoSdk","eventEmitter","NativeEventEmitter","NativeYunoPaymentMethodsView","requireNativeComponent","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","useEffect","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement","exports"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOsB,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAEtB;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;A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AoB,EAAE;MACxB,MAAMW,aAAa,GAAGnB,YAAY,CAACgB,WAAW,CAC5C,sBAAsB,EACrBC,KAA8B,IAAK;QAClCT,oBAAoB,CAACS,KAAK,CAAC;MAC7B,CACF,CAAC;MACDH,aAAa,CAACI,IAAI,CAACC,aAAa,CAAC;IACnC;;IAEA;IACA,OAAO,MAAM;MACXL,aAAa,CAACM,OAAO,CAAEC,GAAG,IAAK;QAC7B,IAAIA,GAAG,IAAIA,GAAG,CAACC,MAAM,EAAE;UACrBD,GAAG,CAACC,MAAM,CAAC,CAAC;QACd;MACF,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,EAAE,CAACf,uBAAuB,EAAEC,oBAAoB,CAAC,CAAC;EAEnD,oBACEtC,MAAA,CAAAc,OAAA,CAAAuC,aAAA,CAACrB,4BAA4B;IAC3BQ,MAAM,EAAEA,MAAO;IACfL,eAAe,EAAEA,eAAgB;IACjCC,WAAW,EAAEA,WAAY;IACzBG,KAAK,EAAEA;EAAM,CACd,CAAC;AAEN,CAAC;AAACe,OAAA,CAAApB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/lib/commonjs/YunoSdk.js
CHANGED
|
@@ -74,10 +74,10 @@ class YunoSdk {
|
|
|
74
74
|
/**
|
|
75
75
|
* Marks the SDK as initialized without calling the native initialize method.
|
|
76
76
|
* This is useful when the SDK has been initialized from the native side (e.g., in MainActivity/YunoActivity).
|
|
77
|
-
*
|
|
77
|
+
*
|
|
78
78
|
* @param countryCode - ISO country code (e.g., 'US', 'BR', 'CO')
|
|
79
79
|
* @param language - Optional language setting (defaults to EN)
|
|
80
|
-
*
|
|
80
|
+
*
|
|
81
81
|
* @internal
|
|
82
82
|
*/
|
|
83
83
|
static markAsInitialized(countryCode = 'CO', language = _enums.YunoLanguage.EN) {
|
|
@@ -325,10 +325,10 @@ class YunoSdk {
|
|
|
325
325
|
/**
|
|
326
326
|
* Clears the last OTT tokens stored by the SDK.
|
|
327
327
|
* This is useful to ensure clean state before starting a new payment flow.
|
|
328
|
-
*
|
|
328
|
+
*
|
|
329
329
|
* Note: This is automatically called at the start of each payment/enrollment flow,
|
|
330
330
|
* but you can call it manually if needed.
|
|
331
|
-
*
|
|
331
|
+
*
|
|
332
332
|
* @example
|
|
333
333
|
* ```typescript
|
|
334
334
|
* // Clear OTT before starting a new payment
|
|
@@ -482,6 +482,133 @@ class YunoSdk {
|
|
|
482
482
|
}
|
|
483
483
|
return this.language;
|
|
484
484
|
}
|
|
485
|
+
|
|
486
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
490
|
+
* This method allows you to tokenize payment information without using the UI components.
|
|
491
|
+
*
|
|
492
|
+
* @param tokenCollectedData The payment data to tokenize
|
|
493
|
+
* @param checkoutSession The checkout session ID
|
|
494
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
495
|
+
* @returns Promise resolving to the generated token or rejecting with an error
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
500
|
+
*
|
|
501
|
+
* try {
|
|
502
|
+
* const result = await YunoSdk.generateToken({
|
|
503
|
+
* checkoutSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
504
|
+
* paymentMethod: {
|
|
505
|
+
* type: 'CARD',
|
|
506
|
+
* vaultedToken: null,
|
|
507
|
+
* card: {
|
|
508
|
+
* save: false,
|
|
509
|
+
* detail: {
|
|
510
|
+
* expirationMonth: 11,
|
|
511
|
+
* expirationYear: 25,
|
|
512
|
+
* number: '4000000000001091',
|
|
513
|
+
* securityCode: '123',
|
|
514
|
+
* holderName: 'John Doe',
|
|
515
|
+
* type: CardType.CREDIT,
|
|
516
|
+
* },
|
|
517
|
+
* },
|
|
518
|
+
* },
|
|
519
|
+
* }, 'checkoutSessionId', 'BR');
|
|
520
|
+
*
|
|
521
|
+
* console.log('Token:', result.token);
|
|
522
|
+
* } catch (error) {
|
|
523
|
+
* console.error('Token generation failed:', error);
|
|
524
|
+
* }
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
static async generateToken(tokenCollectedData, checkoutSession, countryCode) {
|
|
528
|
+
const native = getYunoNative();
|
|
529
|
+
const country = countryCode || this.getCountryCode();
|
|
530
|
+
return native.generateToken(tokenCollectedData, checkoutSession, country);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Get the 3D Secure challenge URL for a checkout session using the headless flow.
|
|
535
|
+
* This is typically called after successfully generating a token to handle 3DS verification.
|
|
536
|
+
*
|
|
537
|
+
* @param checkoutSession The checkout session ID
|
|
538
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
539
|
+
* @returns Promise resolving to the 3DS challenge response
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```typescript
|
|
543
|
+
* import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
|
|
544
|
+
*
|
|
545
|
+
* try {
|
|
546
|
+
* // First generate token
|
|
547
|
+
* const tokenResult = await YunoSdk.generateToken(paymentData, checkoutSession, 'BR');
|
|
548
|
+
*
|
|
549
|
+
* // Then get 3DS challenge URL if needed
|
|
550
|
+
* const challengeResult = await YunoSdk.getThreeDSecureChallenge(checkoutSession, 'BR');
|
|
551
|
+
*
|
|
552
|
+
* if (challengeResult.type === 'URL') {
|
|
553
|
+
* console.log('3DS URL:', challengeResult.data);
|
|
554
|
+
* // Open this URL in a WebView for the user to complete 3DS verification
|
|
555
|
+
* }
|
|
556
|
+
* } catch (error) {
|
|
557
|
+
* console.error('3DS challenge failed:', error);
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
static async getThreeDSecureChallenge(checkoutSession, countryCode) {
|
|
562
|
+
const native = getYunoNative();
|
|
563
|
+
const country = countryCode || this.getCountryCode();
|
|
564
|
+
return native.getThreeDSecureChallenge(checkoutSession, country);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// ==================== HEADLESS ENROLLMENT FLOW ====================
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Continue enrollment to create a vaulted token from collected payment data using the headless flow.
|
|
571
|
+
* This method allows you to save payment information without using the UI components.
|
|
572
|
+
*
|
|
573
|
+
* @param enrollmentCollectedData The enrollment data to process
|
|
574
|
+
* @param customerSession The customer session ID
|
|
575
|
+
* @param countryCode The country code for the enrollment (optional, uses initialized value if not provided)
|
|
576
|
+
* @returns Promise resolving to the vaulted token or rejecting with an error
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
581
|
+
*
|
|
582
|
+
* try {
|
|
583
|
+
* const result = await YunoSdk.continueEnrollment({
|
|
584
|
+
* customerSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
585
|
+
* paymentMethod: {
|
|
586
|
+
* type: 'CARD',
|
|
587
|
+
* card: {
|
|
588
|
+
* save: true,
|
|
589
|
+
* detail: {
|
|
590
|
+
* expirationMonth: 11,
|
|
591
|
+
* expirationYear: 25,
|
|
592
|
+
* number: '4000000000001091',
|
|
593
|
+
* securityCode: '123',
|
|
594
|
+
* holderName: 'John Doe',
|
|
595
|
+
* type: CardType.CREDIT,
|
|
596
|
+
* },
|
|
597
|
+
* },
|
|
598
|
+
* },
|
|
599
|
+
* }, 'customerSessionId', 'BR');
|
|
600
|
+
*
|
|
601
|
+
* console.log('Vaulted Token:', result.vaultedToken);
|
|
602
|
+
* } catch (error) {
|
|
603
|
+
* console.error('Enrollment failed:', error);
|
|
604
|
+
* }
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
static async continueEnrollment(enrollmentCollectedData, customerSession, countryCode) {
|
|
608
|
+
const native = getYunoNative();
|
|
609
|
+
const country = countryCode || this.getCountryCode();
|
|
610
|
+
return native.continueEnrollment(enrollmentCollectedData, customerSession, country);
|
|
611
|
+
}
|
|
485
612
|
}
|
|
486
613
|
exports.YunoSdk = YunoSdk;
|
|
487
614
|
//# sourceMappingURL=YunoSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_enums","LINKING_ERROR","Platform","select","ios","default","getYunoNative","native","NativeModules","YunoSdk","Error","getYunoEventEmitter","NativeEventEmitter","countryCode","language","isInitialized","markAsInitialized","YunoLanguage","EN","initialize","params","apiKey","yunoConfig","iosConfig","androidConfig","config","lang","cardFlow","CardFlow","ONE_STEP","saveCardEnabled","keepLoader","isDynamicViewEnabled","cardFormDeployed","enrollmentPayment","checkInitialized","args","getCountryCode","startPaymentLite","code","startPayment","showPaymentStatus","continuePayment","checkoutSession","startPaymentSeamlessLite","statusString","getLanguage","hideLoader","receiveDeeplink","url","OS","console","warn","getLastOneTimeToken","getLastOneTimeTokenInfo","clearLastOneTimeToken","clearLastPaymentStatus","onPaymentStatus","listener","emitter","subscription","addListener","remove","onEnrollmentStatus","onOneTimeToken","onOneTimeTokenInfo","exports"],"sourceRoot":"../../src","sources":["YunoSdk.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_enums","LINKING_ERROR","Platform","select","ios","default","getYunoNative","native","NativeModules","YunoSdk","Error","getYunoEventEmitter","NativeEventEmitter","countryCode","language","isInitialized","markAsInitialized","YunoLanguage","EN","initialize","params","apiKey","yunoConfig","iosConfig","androidConfig","config","lang","cardFlow","CardFlow","ONE_STEP","saveCardEnabled","keepLoader","isDynamicViewEnabled","cardFormDeployed","enrollmentPayment","checkInitialized","args","getCountryCode","startPaymentLite","code","startPayment","showPaymentStatus","continuePayment","checkoutSession","startPaymentSeamlessLite","statusString","getLanguage","hideLoader","receiveDeeplink","url","OS","console","warn","getLastOneTimeToken","getLastOneTimeTokenInfo","clearLastOneTimeToken","clearLastPaymentStatus","onPaymentStatus","listener","emitter","subscription","addListener","remove","onEnrollmentStatus","onOneTimeToken","onOneTimeTokenInfo","generateToken","tokenCollectedData","country","getThreeDSecureChallenge","continueEnrollment","enrollmentCollectedData","customerSession","exports"],"sourceRoot":"../../src","sources":["YunoSdk.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAeA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GACjB,sFAAsF,GACtFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA,SAASC,aAAaA,CAAA,EAAQ;EAC5B,MAAMC,MAAM,GAAGC,0BAAa,CAACC,OAAO;EACpC,IAAI,CAACF,MAAM,EAAE;IACX,MAAM,IAAIG,KAAK,CAACT,aAAa,CAAC;EAChC;EACA,OAAOM,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA,SAASI,mBAAmBA,CAAA,EAAuB;EACjD,MAAMJ,MAAM,GAAGD,aAAa,CAAC,CAAC;EAC9B,OAAO,IAAIM,+BAAkB,CAACL,MAAM,CAAC;AACvC;;AAEA;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,OAAO,CAAC;EACnB,OAAeI,WAAW,GAAkB,IAAI;EAChD,OAAeC,QAAQ,GAAwB,IAAI;EACnD,OAAeC,aAAa,GAAY,KAAK;;EAE7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,iBAAiBA,CACtBH,WAAmB,GAAG,IAAI,EAC1BC,QAAsB,GAAGG,mBAAY,CAACC,EAAE,EAClC;IACN,IAA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9B,MAAM8D,OAAO,GAAGvD,WAAW,IAAI,IAAI,CAACwB,cAAc,CAAC,CAAC;IAEpD,OAAO9B,MAAM,CAAC2D,aAAa,CAACC,kBAAkB,EAAExB,eAAe,EAAEyB,OAAO,CAAC;EAC3E;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,wBAAwBA,CACnC1B,eAAuB,EACvB9B,WAAoB,EACoB;IACxC,MAAMN,MAAM,GAAGD,aAAa,CAAC,CAAC;IAC9B,MAAM8D,OAAO,GAAGvD,WAAW,IAAI,IAAI,CAACwB,cAAc,CAAC,CAAC;IAEpD,OAAO9B,MAAM,CAAC8D,wBAAwB,CAAC1B,eAAe,EAAEyB,OAAO,CAAC;EAClE;;EAEA;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaE,kBAAkBA,CAC7BC,uBAAgD,EAChDC,eAAuB,EACvB3D,WAAoB,EACiB;IACrC,MAAMN,MAAM,GAAGD,aAAa,CAAC,CAAC;IAC9B,MAAM8D,OAAO,GAAGvD,WAAW,IAAI,IAAI,CAACwB,cAAc,CAAC,CAAC;IAEpD,OAAO9B,MAAM,CAAC+D,kBAAkB,CAC9BC,uBAAuB,EACvBC,eAAe,EACfJ,OACF,CAAC;EACH;AACF;AAACK,OAAA,CAAAhE,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CardType = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Headless Payment Flow Types
|
|
9
|
+
* These types mirror the native SDK's TokenCollectedData structure
|
|
10
|
+
*/
|
|
11
|
+
let CardType = exports.CardType = /*#__PURE__*/function (CardType) {
|
|
12
|
+
CardType["CREDIT"] = "CREDIT";
|
|
13
|
+
CardType["DEBIT"] = "DEBIT";
|
|
14
|
+
return CardType;
|
|
15
|
+
}({});
|
|
16
|
+
/**
|
|
17
|
+
* Headless Enrollment Flow Types
|
|
18
|
+
* These types mirror the native SDK's EnrollmentCollectedData structure
|
|
19
|
+
*/
|
|
20
|
+
//# sourceMappingURL=HeadlessTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CardType","exports"],"sourceRoot":"../../../../src","sources":["core/types/HeadlessTypes.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAHA,IAKYA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAqFpB;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","YunoSdkNative","YunoSdk","eventEmitter","NativeYunoPaymentMethodsView","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,
|
|
1
|
+
{"version":3,"names":["React","useEffect","requireNativeComponent","NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","YunoSdkNative","YunoSdk","eventEmitter","NativeYunoPaymentMethodsView","YunoPaymentMethods","checkoutSession","countryCode","onPaymentMethodSelected","onPaymentMethodError","style","testID","console","warn","subscriptions","selectionListener","addListener","event","push","errorListener","forEach","sub","remove","createElement"],"sourceRoot":"../../src","sources":["YunoPaymentMethods.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SACEC,sBAAsB,EACtBC,aAAa,EACbC,kBAAkB,EAGlBC,QAAQ,QACH,cAAc;;AAErB;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AA2BA;;AAQA,MAAMC,aAAa,GACjB,gHAAgH,GAChHD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B,GAC/B,0CAA0C;;AAE5C;AACA,MAAMC,aAAa,GAAGP,aAAa,CAACQ,OAAO;;AAE3C;AACA,IAAIC,YAAuC,GAAG,IAAI;AAClD,IAAIF,aAAa,EAAE;EACjBE,YAAY,GAAG,IAAIR,kBAAkB,CAACM,aAAa,CAAC;AACtD;;AAEA;AACA,MAAMG,4BAA4B,GAChCX,sBAAsB,CACpB,wBACF,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,kBAAqD,GAAGA,CAAC;EACpEC,eAAe;EACfC,WAAW;EACXC,uBAAuB;EACvBC,oBAAoB;EACpBC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ;EACAnB,SAAS,CAAC,MAAM;IACd,IAAI,CAACW,YAAY,EAAE;MACjBS,OAAO,CAACC,IAAI,CAAChB,aAAa,CAAC;MAC3B;IACF;IAEA,MAAMiB,aAAoB,GAAG,EAAE;;IAE/B;IACA,IAAIN,uBAAuB,EAAE;MAC3B,MAAMO,iBAAiB,GAAGZ,YAAY,CAACa,WAAW,CAChD,yBAAyB,EACxBC,KAAiC,IAAK;QACrCT,uBAAuB,CAACS,KAAK,CAAC;MAChC,CACF,CAAC;MACDH,aAAa,CAACI,IAAI,CAACH,iBAAiB,CAAC;IACvC;;IAEA;IACA,IAAIN,oBAAoB,EAAE;MACxB,MAAMU,aAAa,GAAGhB,YAAY,CAACa,WAAW,CAC5C,sBAAsB,EACrBC,KAA8B,IAAK;QAClCR,oBAAoB,CAACQ,KAAK,CAAC;MAC7B,CACF,CAAC;MACDH,aAAa,CAACI,IAAI,CAACC,aAAa,CAAC;IACnC;;IAEA;IACA,OAAO,MAAM;MACXL,aAAa,CAACM,OAAO,CAAEC,GAAG,IAAK;QAC7B,IAAIA,GAAG,IAAIA,GAAG,CAACC,MAAM,EAAE;UACrBD,GAAG,CAACC,MAAM,CAAC,CAAC;QACd;MACF,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,EAAE,CAACd,uBAAuB,EAAEC,oBAAoB,CAAC,CAAC;EAEnD,oBACElB,KAAA,CAAAgC,aAAA,CAACnB,4BAA4B;IAC3BO,MAAM,EAAEA,MAAO;IACfL,eAAe,EAAEA,eAAgB;IACjCC,WAAW,EAAEA,WAAY;IACzBG,KAAK,EAAEA;EAAM,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
package/lib/module/YunoSdk.js
CHANGED
|
@@ -68,10 +68,10 @@ export class YunoSdk {
|
|
|
68
68
|
/**
|
|
69
69
|
* Marks the SDK as initialized without calling the native initialize method.
|
|
70
70
|
* This is useful when the SDK has been initialized from the native side (e.g., in MainActivity/YunoActivity).
|
|
71
|
-
*
|
|
71
|
+
*
|
|
72
72
|
* @param countryCode - ISO country code (e.g., 'US', 'BR', 'CO')
|
|
73
73
|
* @param language - Optional language setting (defaults to EN)
|
|
74
|
-
*
|
|
74
|
+
*
|
|
75
75
|
* @internal
|
|
76
76
|
*/
|
|
77
77
|
static markAsInitialized(countryCode = 'CO', language = YunoLanguage.EN) {
|
|
@@ -319,10 +319,10 @@ export class YunoSdk {
|
|
|
319
319
|
/**
|
|
320
320
|
* Clears the last OTT tokens stored by the SDK.
|
|
321
321
|
* This is useful to ensure clean state before starting a new payment flow.
|
|
322
|
-
*
|
|
322
|
+
*
|
|
323
323
|
* Note: This is automatically called at the start of each payment/enrollment flow,
|
|
324
324
|
* but you can call it manually if needed.
|
|
325
|
-
*
|
|
325
|
+
*
|
|
326
326
|
* @example
|
|
327
327
|
* ```typescript
|
|
328
328
|
* // Clear OTT before starting a new payment
|
|
@@ -476,5 +476,132 @@ export class YunoSdk {
|
|
|
476
476
|
}
|
|
477
477
|
return this.language;
|
|
478
478
|
}
|
|
479
|
+
|
|
480
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
484
|
+
* This method allows you to tokenize payment information without using the UI components.
|
|
485
|
+
*
|
|
486
|
+
* @param tokenCollectedData The payment data to tokenize
|
|
487
|
+
* @param checkoutSession The checkout session ID
|
|
488
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
489
|
+
* @returns Promise resolving to the generated token or rejecting with an error
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
494
|
+
*
|
|
495
|
+
* try {
|
|
496
|
+
* const result = await YunoSdk.generateToken({
|
|
497
|
+
* checkoutSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
498
|
+
* paymentMethod: {
|
|
499
|
+
* type: 'CARD',
|
|
500
|
+
* vaultedToken: null,
|
|
501
|
+
* card: {
|
|
502
|
+
* save: false,
|
|
503
|
+
* detail: {
|
|
504
|
+
* expirationMonth: 11,
|
|
505
|
+
* expirationYear: 25,
|
|
506
|
+
* number: '4000000000001091',
|
|
507
|
+
* securityCode: '123',
|
|
508
|
+
* holderName: 'John Doe',
|
|
509
|
+
* type: CardType.CREDIT,
|
|
510
|
+
* },
|
|
511
|
+
* },
|
|
512
|
+
* },
|
|
513
|
+
* }, 'checkoutSessionId', 'BR');
|
|
514
|
+
*
|
|
515
|
+
* console.log('Token:', result.token);
|
|
516
|
+
* } catch (error) {
|
|
517
|
+
* console.error('Token generation failed:', error);
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
static async generateToken(tokenCollectedData, checkoutSession, countryCode) {
|
|
522
|
+
const native = getYunoNative();
|
|
523
|
+
const country = countryCode || this.getCountryCode();
|
|
524
|
+
return native.generateToken(tokenCollectedData, checkoutSession, country);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Get the 3D Secure challenge URL for a checkout session using the headless flow.
|
|
529
|
+
* This is typically called after successfully generating a token to handle 3DS verification.
|
|
530
|
+
*
|
|
531
|
+
* @param checkoutSession The checkout session ID
|
|
532
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
533
|
+
* @returns Promise resolving to the 3DS challenge response
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
|
|
538
|
+
*
|
|
539
|
+
* try {
|
|
540
|
+
* // First generate token
|
|
541
|
+
* const tokenResult = await YunoSdk.generateToken(paymentData, checkoutSession, 'BR');
|
|
542
|
+
*
|
|
543
|
+
* // Then get 3DS challenge URL if needed
|
|
544
|
+
* const challengeResult = await YunoSdk.getThreeDSecureChallenge(checkoutSession, 'BR');
|
|
545
|
+
*
|
|
546
|
+
* if (challengeResult.type === 'URL') {
|
|
547
|
+
* console.log('3DS URL:', challengeResult.data);
|
|
548
|
+
* // Open this URL in a WebView for the user to complete 3DS verification
|
|
549
|
+
* }
|
|
550
|
+
* } catch (error) {
|
|
551
|
+
* console.error('3DS challenge failed:', error);
|
|
552
|
+
* }
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
static async getThreeDSecureChallenge(checkoutSession, countryCode) {
|
|
556
|
+
const native = getYunoNative();
|
|
557
|
+
const country = countryCode || this.getCountryCode();
|
|
558
|
+
return native.getThreeDSecureChallenge(checkoutSession, country);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// ==================== HEADLESS ENROLLMENT FLOW ====================
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Continue enrollment to create a vaulted token from collected payment data using the headless flow.
|
|
565
|
+
* This method allows you to save payment information without using the UI components.
|
|
566
|
+
*
|
|
567
|
+
* @param enrollmentCollectedData The enrollment data to process
|
|
568
|
+
* @param customerSession The customer session ID
|
|
569
|
+
* @param countryCode The country code for the enrollment (optional, uses initialized value if not provided)
|
|
570
|
+
* @returns Promise resolving to the vaulted token or rejecting with an error
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```typescript
|
|
574
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
575
|
+
*
|
|
576
|
+
* try {
|
|
577
|
+
* const result = await YunoSdk.continueEnrollment({
|
|
578
|
+
* customerSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
579
|
+
* paymentMethod: {
|
|
580
|
+
* type: 'CARD',
|
|
581
|
+
* card: {
|
|
582
|
+
* save: true,
|
|
583
|
+
* detail: {
|
|
584
|
+
* expirationMonth: 11,
|
|
585
|
+
* expirationYear: 25,
|
|
586
|
+
* number: '4000000000001091',
|
|
587
|
+
* securityCode: '123',
|
|
588
|
+
* holderName: 'John Doe',
|
|
589
|
+
* type: CardType.CREDIT,
|
|
590
|
+
* },
|
|
591
|
+
* },
|
|
592
|
+
* },
|
|
593
|
+
* }, 'customerSessionId', 'BR');
|
|
594
|
+
*
|
|
595
|
+
* console.log('Vaulted Token:', result.vaultedToken);
|
|
596
|
+
* } catch (error) {
|
|
597
|
+
* console.error('Enrollment failed:', error);
|
|
598
|
+
* }
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
static async continueEnrollment(enrollmentCollectedData, customerSession, countryCode) {
|
|
602
|
+
const native = getYunoNative();
|
|
603
|
+
const country = countryCode || this.getCountryCode();
|
|
604
|
+
return native.continueEnrollment(enrollmentCollectedData, customerSession, country);
|
|
605
|
+
}
|
|
479
606
|
}
|
|
480
607
|
//# sourceMappingURL=YunoSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","YunoLanguage","CardFlow","LINKING_ERROR","select","ios","default","getYunoNative","native","YunoSdk","Error","getYunoEventEmitter","countryCode","language","isInitialized","markAsInitialized","EN","initialize","params","apiKey","yunoConfig","iosConfig","androidConfig","config","lang","cardFlow","ONE_STEP","saveCardEnabled","keepLoader","isDynamicViewEnabled","cardFormDeployed","enrollmentPayment","checkInitialized","args","getCountryCode","startPaymentLite","code","startPayment","showPaymentStatus","continuePayment","checkoutSession","startPaymentSeamlessLite","statusString","getLanguage","hideLoader","receiveDeeplink","url","OS","console","warn","getLastOneTimeToken","getLastOneTimeTokenInfo","clearLastOneTimeToken","clearLastPaymentStatus","onPaymentStatus","listener","emitter","subscription","addListener","remove","onEnrollmentStatus","onOneTimeToken","onOneTimeTokenInfo"],"sourceRoot":"../../src","sources":["YunoSdk.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","YunoLanguage","CardFlow","LINKING_ERROR","select","ios","default","getYunoNative","native","YunoSdk","Error","getYunoEventEmitter","countryCode","language","isInitialized","markAsInitialized","EN","initialize","params","apiKey","yunoConfig","iosConfig","androidConfig","config","lang","cardFlow","ONE_STEP","saveCardEnabled","keepLoader","isDynamicViewEnabled","cardFormDeployed","enrollmentPayment","checkInitialized","args","getCountryCode","startPaymentLite","code","startPayment","showPaymentStatus","continuePayment","checkoutSession","startPaymentSeamlessLite","statusString","getLanguage","hideLoader","receiveDeeplink","url","OS","console","warn","getLastOneTimeToken","getLastOneTimeTokenInfo","clearLastOneTimeToken","clearLastPaymentStatus","onPaymentStatus","listener","emitter","subscription","addListener","remove","onEnrollmentStatus","onOneTimeToken","onOneTimeTokenInfo","generateToken","tokenCollectedData","country","getThreeDSecureChallenge","continueEnrollment","enrollmentCollectedData","customerSession"],"sourceRoot":"../../src","sources":["YunoSdk.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAe1E,SAAqBC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAEjE,MAAMC,aAAa,GACjB,sFAAsF,GACtFH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA,SAASC,aAAaA,CAAA,EAAQ;EAC5B,MAAMC,MAAM,GAAGV,aAAa,CAACW,OAAO;EACpC,IAAI,CAACD,MAAM,EAAE;IACX,MAAM,IAAIE,KAAK,CAACP,aAAa,CAAC;EAChC;EACA,OAAOK,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA,SAASG,mBAAmBA,CAAA,EAAuB;EACjD,MAAMH,MAAM,GAAGD,aAAa,CAAC,CAAC;EAC9B,OAAO,IAAIR,kBAAkB,CAACS,MAAM,CAAC;AACvC;;AAEA;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,CAAC;EACnB,OAAeG,WAAW,GAAkB,IAAI;EAChD,OAAeC,QAAQ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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAakD,aAAaA,CACxBC,kBAAsC,EACtCxB,eAAuB,EACvB5B,WAAoB,EACY;IAChC,MAAMJ,MAAM,GAAGD,aAAa,CAAC,CAAC;IAC9B,MAAM0D,OAAO,GAAGrD,WAAW,IAAI,IAAI,CAACsB,cAAc,CAAC,CAAC;IAEpD,OAAO1B,MAAM,CAACuD,aAAa,CAACC,kBAAkB,EAAExB,eAAe,EAAEyB,OAAO,CAAC;EAC3E;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,wBAAwBA,CACnC1B,eAAuB,EACvB5B,WAAoB,EACoB;IACxC,MAAMJ,MAAM,GAAGD,aAAa,CAAC,CAAC;IAC9B,MAAM0D,OAAO,GAAGrD,WAAW,IAAI,IAAI,CAACsB,cAAc,CAAC,CAAC;IAEpD,OAAO1B,MAAM,CAAC0D,wBAAwB,CAAC1B,eAAe,EAAEyB,OAAO,CAAC;EAClE;;EAEA;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaE,kBAAkBA,CAC7BC,uBAAgD,EAChDC,eAAuB,EACvBzD,WAAoB,EACiB;IACrC,MAAMJ,MAAM,GAAGD,aAAa,CAAC,CAAC;IAC9B,MAAM0D,OAAO,GAAGrD,WAAW,IAAI,IAAI,CAACsB,cAAc,CAAC,CAAC;IAEpD,OAAO1B,MAAM,CAAC2D,kBAAkB,CAC9BC,uBAAuB,EACvBC,eAAe,EACfJ,OACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Payment Flow Types
|
|
3
|
+
* These types mirror the native SDK's TokenCollectedData structure
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export let CardType = /*#__PURE__*/function (CardType) {
|
|
7
|
+
CardType["CREDIT"] = "CREDIT";
|
|
8
|
+
CardType["DEBIT"] = "DEBIT";
|
|
9
|
+
return CardType;
|
|
10
|
+
}({});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Headless Enrollment Flow Types
|
|
14
|
+
* These types mirror the native SDK's EnrollmentCollectedData structure
|
|
15
|
+
*/
|
|
16
|
+
//# sourceMappingURL=HeadlessTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CardType"],"sourceRoot":"../../../../src","sources":["core/types/HeadlessTypes.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;;AAqFpB;AACA;AACA;AACA","ignoreList":[]}
|
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.10",
|
|
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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
requireNativeComponent,
|
|
4
4
|
NativeModules,
|
|
@@ -78,9 +78,10 @@ if (YunoSdkNative) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// Require the native component
|
|
81
|
-
const NativeYunoPaymentMethodsView =
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const NativeYunoPaymentMethodsView =
|
|
82
|
+
requireNativeComponent<NativeYunoPaymentMethodsProps>(
|
|
83
|
+
'YunoPaymentMethodsView'
|
|
84
|
+
);
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* YunoPaymentMethods Component
|
|
@@ -195,4 +196,3 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
195
196
|
/>
|
|
196
197
|
);
|
|
197
198
|
};
|
|
198
|
-
|
package/src/YunoSdk.ts
CHANGED
|
@@ -7,6 +7,11 @@ import type {
|
|
|
7
7
|
StartPayment,
|
|
8
8
|
SeamlessArguments,
|
|
9
9
|
OneTimeTokenInfo,
|
|
10
|
+
TokenCollectedData,
|
|
11
|
+
HeadlessTokenResponse,
|
|
12
|
+
ThreeDSecureChallengeResponse,
|
|
13
|
+
EnrollmentCollectedData,
|
|
14
|
+
HeadlessEnrollmentResponse,
|
|
10
15
|
} from './core/types';
|
|
11
16
|
import { YunoStatus, YunoLanguage, CardFlow } from './core/enums';
|
|
12
17
|
|
|
@@ -89,13 +94,16 @@ export class YunoSdk {
|
|
|
89
94
|
/**
|
|
90
95
|
* Marks the SDK as initialized without calling the native initialize method.
|
|
91
96
|
* This is useful when the SDK has been initialized from the native side (e.g., in MainActivity/YunoActivity).
|
|
92
|
-
*
|
|
97
|
+
*
|
|
93
98
|
* @param countryCode - ISO country code (e.g., 'US', 'BR', 'CO')
|
|
94
99
|
* @param language - Optional language setting (defaults to EN)
|
|
95
|
-
*
|
|
100
|
+
*
|
|
96
101
|
* @internal
|
|
97
102
|
*/
|
|
98
|
-
static markAsInitialized(
|
|
103
|
+
static markAsInitialized(
|
|
104
|
+
countryCode: string = 'CO',
|
|
105
|
+
language: YunoLanguage = YunoLanguage.EN
|
|
106
|
+
): void {
|
|
99
107
|
this.countryCode = countryCode;
|
|
100
108
|
this.language = language;
|
|
101
109
|
this.isInitialized = true;
|
|
@@ -255,7 +263,11 @@ export class YunoSdk {
|
|
|
255
263
|
): Promise<void> {
|
|
256
264
|
this.checkInitialized();
|
|
257
265
|
const code = countryCode ?? this.getCountryCode();
|
|
258
|
-
return getYunoNative().continuePayment(
|
|
266
|
+
return getYunoNative().continuePayment(
|
|
267
|
+
checkoutSession,
|
|
268
|
+
code,
|
|
269
|
+
showPaymentStatus
|
|
270
|
+
);
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
/**
|
|
@@ -373,10 +385,10 @@ export class YunoSdk {
|
|
|
373
385
|
/**
|
|
374
386
|
* Clears the last OTT tokens stored by the SDK.
|
|
375
387
|
* This is useful to ensure clean state before starting a new payment flow.
|
|
376
|
-
*
|
|
388
|
+
*
|
|
377
389
|
* Note: This is automatically called at the start of each payment/enrollment flow,
|
|
378
390
|
* but you can call it manually if needed.
|
|
379
|
-
*
|
|
391
|
+
*
|
|
380
392
|
* @example
|
|
381
393
|
* ```typescript
|
|
382
394
|
* // Clear OTT before starting a new payment
|
|
@@ -535,4 +547,149 @@ export class YunoSdk {
|
|
|
535
547
|
}
|
|
536
548
|
return this.language;
|
|
537
549
|
}
|
|
550
|
+
|
|
551
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
555
|
+
* This method allows you to tokenize payment information without using the UI components.
|
|
556
|
+
*
|
|
557
|
+
* @param tokenCollectedData The payment data to tokenize
|
|
558
|
+
* @param checkoutSession The checkout session ID
|
|
559
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
560
|
+
* @returns Promise resolving to the generated token or rejecting with an error
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
565
|
+
*
|
|
566
|
+
* try {
|
|
567
|
+
* const result = await YunoSdk.generateToken({
|
|
568
|
+
* checkoutSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
569
|
+
* paymentMethod: {
|
|
570
|
+
* type: 'CARD',
|
|
571
|
+
* vaultedToken: null,
|
|
572
|
+
* card: {
|
|
573
|
+
* save: false,
|
|
574
|
+
* detail: {
|
|
575
|
+
* expirationMonth: 11,
|
|
576
|
+
* expirationYear: 25,
|
|
577
|
+
* number: '4000000000001091',
|
|
578
|
+
* securityCode: '123',
|
|
579
|
+
* holderName: 'John Doe',
|
|
580
|
+
* type: CardType.CREDIT,
|
|
581
|
+
* },
|
|
582
|
+
* },
|
|
583
|
+
* },
|
|
584
|
+
* }, 'checkoutSessionId', 'BR');
|
|
585
|
+
*
|
|
586
|
+
* console.log('Token:', result.token);
|
|
587
|
+
* } catch (error) {
|
|
588
|
+
* console.error('Token generation failed:', error);
|
|
589
|
+
* }
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
static async generateToken(
|
|
593
|
+
tokenCollectedData: TokenCollectedData,
|
|
594
|
+
checkoutSession: string,
|
|
595
|
+
countryCode?: string
|
|
596
|
+
): Promise<HeadlessTokenResponse> {
|
|
597
|
+
const native = getYunoNative();
|
|
598
|
+
const country = countryCode || this.getCountryCode();
|
|
599
|
+
|
|
600
|
+
return native.generateToken(tokenCollectedData, checkoutSession, country);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Get the 3D Secure challenge URL for a checkout session using the headless flow.
|
|
605
|
+
* This is typically called after successfully generating a token to handle 3DS verification.
|
|
606
|
+
*
|
|
607
|
+
* @param checkoutSession The checkout session ID
|
|
608
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
609
|
+
* @returns Promise resolving to the 3DS challenge response
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
|
|
614
|
+
*
|
|
615
|
+
* try {
|
|
616
|
+
* // First generate token
|
|
617
|
+
* const tokenResult = await YunoSdk.generateToken(paymentData, checkoutSession, 'BR');
|
|
618
|
+
*
|
|
619
|
+
* // Then get 3DS challenge URL if needed
|
|
620
|
+
* const challengeResult = await YunoSdk.getThreeDSecureChallenge(checkoutSession, 'BR');
|
|
621
|
+
*
|
|
622
|
+
* if (challengeResult.type === 'URL') {
|
|
623
|
+
* console.log('3DS URL:', challengeResult.data);
|
|
624
|
+
* // Open this URL in a WebView for the user to complete 3DS verification
|
|
625
|
+
* }
|
|
626
|
+
* } catch (error) {
|
|
627
|
+
* console.error('3DS challenge failed:', error);
|
|
628
|
+
* }
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
static async getThreeDSecureChallenge(
|
|
632
|
+
checkoutSession: string,
|
|
633
|
+
countryCode?: string
|
|
634
|
+
): Promise<ThreeDSecureChallengeResponse> {
|
|
635
|
+
const native = getYunoNative();
|
|
636
|
+
const country = countryCode || this.getCountryCode();
|
|
637
|
+
|
|
638
|
+
return native.getThreeDSecureChallenge(checkoutSession, country);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// ==================== HEADLESS ENROLLMENT FLOW ====================
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Continue enrollment to create a vaulted token from collected payment data using the headless flow.
|
|
645
|
+
* This method allows you to save payment information without using the UI components.
|
|
646
|
+
*
|
|
647
|
+
* @param enrollmentCollectedData The enrollment data to process
|
|
648
|
+
* @param customerSession The customer session ID
|
|
649
|
+
* @param countryCode The country code for the enrollment (optional, uses initialized value if not provided)
|
|
650
|
+
* @returns Promise resolving to the vaulted token or rejecting with an error
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```typescript
|
|
654
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
655
|
+
*
|
|
656
|
+
* try {
|
|
657
|
+
* const result = await YunoSdk.continueEnrollment({
|
|
658
|
+
* customerSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
659
|
+
* paymentMethod: {
|
|
660
|
+
* type: 'CARD',
|
|
661
|
+
* card: {
|
|
662
|
+
* save: true,
|
|
663
|
+
* detail: {
|
|
664
|
+
* expirationMonth: 11,
|
|
665
|
+
* expirationYear: 25,
|
|
666
|
+
* number: '4000000000001091',
|
|
667
|
+
* securityCode: '123',
|
|
668
|
+
* holderName: 'John Doe',
|
|
669
|
+
* type: CardType.CREDIT,
|
|
670
|
+
* },
|
|
671
|
+
* },
|
|
672
|
+
* },
|
|
673
|
+
* }, 'customerSessionId', 'BR');
|
|
674
|
+
*
|
|
675
|
+
* console.log('Vaulted Token:', result.vaultedToken);
|
|
676
|
+
* } catch (error) {
|
|
677
|
+
* console.error('Enrollment failed:', error);
|
|
678
|
+
* }
|
|
679
|
+
* ```
|
|
680
|
+
*/
|
|
681
|
+
static async continueEnrollment(
|
|
682
|
+
enrollmentCollectedData: EnrollmentCollectedData,
|
|
683
|
+
customerSession: string,
|
|
684
|
+
countryCode?: string
|
|
685
|
+
): Promise<HeadlessEnrollmentResponse> {
|
|
686
|
+
const native = getYunoNative();
|
|
687
|
+
const country = countryCode || this.getCountryCode();
|
|
688
|
+
|
|
689
|
+
return native.continueEnrollment(
|
|
690
|
+
enrollmentCollectedData,
|
|
691
|
+
customerSession,
|
|
692
|
+
country
|
|
693
|
+
);
|
|
694
|
+
}
|
|
538
695
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Payment Flow Types
|
|
3
|
+
* These types mirror the native SDK's TokenCollectedData structure
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export enum CardType {
|
|
7
|
+
CREDIT = 'CREDIT',
|
|
8
|
+
DEBIT = 'DEBIT',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Detail {
|
|
12
|
+
expirationMonth?: number;
|
|
13
|
+
expirationYear?: number;
|
|
14
|
+
number?: string;
|
|
15
|
+
securityCode?: string;
|
|
16
|
+
holderName?: string;
|
|
17
|
+
type?: CardType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Installment {
|
|
21
|
+
id: string;
|
|
22
|
+
value: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CardData {
|
|
26
|
+
save?: boolean;
|
|
27
|
+
detail?: Detail;
|
|
28
|
+
installment?: Installment;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Document {
|
|
32
|
+
type: string;
|
|
33
|
+
number: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Phone {
|
|
37
|
+
countryCode: string;
|
|
38
|
+
number: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Address {
|
|
42
|
+
street?: string;
|
|
43
|
+
number?: string;
|
|
44
|
+
complement?: string;
|
|
45
|
+
neighborhood?: string;
|
|
46
|
+
city?: string;
|
|
47
|
+
state?: string;
|
|
48
|
+
zipCode?: string;
|
|
49
|
+
country?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Customer {
|
|
53
|
+
id: string;
|
|
54
|
+
merchantCustomerId: string;
|
|
55
|
+
firstName?: string;
|
|
56
|
+
lastName?: string;
|
|
57
|
+
dateOfBirth?: string;
|
|
58
|
+
email?: string;
|
|
59
|
+
country?: string;
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
updatedAt?: string;
|
|
62
|
+
document?: Document;
|
|
63
|
+
phone?: Phone;
|
|
64
|
+
billingAddress?: Address;
|
|
65
|
+
shippingAddress?: Address;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PaymentMethod {
|
|
69
|
+
type: string;
|
|
70
|
+
vaultedToken?: string | null;
|
|
71
|
+
card?: CardData;
|
|
72
|
+
customer?: Customer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TokenCollectedData {
|
|
76
|
+
checkoutSession?: string;
|
|
77
|
+
customerSession?: string;
|
|
78
|
+
paymentMethod: PaymentMethod;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ThreeDSecureChallengeResponse {
|
|
82
|
+
type: string;
|
|
83
|
+
data: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface HeadlessTokenResponse {
|
|
87
|
+
token?: string;
|
|
88
|
+
error?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Headless Enrollment Flow Types
|
|
93
|
+
* These types mirror the native SDK's EnrollmentCollectedData structure
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
export interface EnrollmentMethod {
|
|
97
|
+
type: string;
|
|
98
|
+
card: CardData;
|
|
99
|
+
customer?: Customer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface EnrollmentCollectedData {
|
|
103
|
+
customerSession: string;
|
|
104
|
+
paymentMethod: EnrollmentMethod;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface HeadlessEnrollmentResponse {
|
|
108
|
+
vaultedToken?: string;
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
package/src/core/types/index.ts
CHANGED
|
@@ -5,3 +5,20 @@ export type { EnrollmentArguments } from './EnrollmentArguments';
|
|
|
5
5
|
export type { StartPayment, MethodSelected } from './StartPayment';
|
|
6
6
|
export type { SeamlessArguments } from './SeamlessArguments';
|
|
7
7
|
export type { OneTimeTokenInfo } from './OneTimeTokenInfo';
|
|
8
|
+
export type {
|
|
9
|
+
TokenCollectedData,
|
|
10
|
+
PaymentMethod,
|
|
11
|
+
CardData,
|
|
12
|
+
Detail,
|
|
13
|
+
Installment,
|
|
14
|
+
Customer,
|
|
15
|
+
Document,
|
|
16
|
+
Phone,
|
|
17
|
+
Address,
|
|
18
|
+
CardType,
|
|
19
|
+
ThreeDSecureChallengeResponse,
|
|
20
|
+
HeadlessTokenResponse,
|
|
21
|
+
EnrollmentCollectedData,
|
|
22
|
+
EnrollmentMethod,
|
|
23
|
+
HeadlessEnrollmentResponse,
|
|
24
|
+
} from './HeadlessTypes';
|