@yuno-payments/yuno-sdk-react-native 1.0.17-rc.10 → 1.0.17-rc.12
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/ios/YunoSdk.m +9 -0
- package/ios/YunoSdk.swift +61 -0
- package/package.json +1 -1
package/ios/YunoSdk.m
CHANGED
|
@@ -98,5 +98,14 @@ RCT_EXTERN_METHOD(
|
|
|
98
98
|
rejecter:(RCTPromiseRejectBlock)rejecter
|
|
99
99
|
)
|
|
100
100
|
|
|
101
|
+
// Headless Enrollment Flow
|
|
102
|
+
RCT_EXTERN_METHOD(
|
|
103
|
+
continueEnrollment:(NSDictionary *)enrollmentCollectedData
|
|
104
|
+
customerSession:(NSString *)customerSession
|
|
105
|
+
countryCode:(NSString *)countryCode
|
|
106
|
+
resolver:(RCTPromiseResolveBlock)resolver
|
|
107
|
+
rejecter:(RCTPromiseRejectBlock)rejecter
|
|
108
|
+
)
|
|
109
|
+
|
|
101
110
|
@end
|
|
102
111
|
|
package/ios/YunoSdk.swift
CHANGED
|
@@ -667,6 +667,67 @@ extension YunoSdk {
|
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
+
|
|
671
|
+
// MARK: - Headless Enrollment Flow
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Continue enrollment to create a vaulted token from collected payment data.
|
|
675
|
+
* This method mirrors the native SDK's continueEnrollment() API.
|
|
676
|
+
*
|
|
677
|
+
* @param enrollmentCollectedData The enrollment data as NSDictionary
|
|
678
|
+
* @param customerSession The customer session ID
|
|
679
|
+
* @param countryCode The country code for the enrollment
|
|
680
|
+
* @param resolver Promise resolver
|
|
681
|
+
* @param rejecter Promise rejecter
|
|
682
|
+
*/
|
|
683
|
+
@objc
|
|
684
|
+
func continueEnrollment(
|
|
685
|
+
_ enrollmentCollectedData: NSDictionary,
|
|
686
|
+
customerSession: String,
|
|
687
|
+
countryCode: String,
|
|
688
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
689
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
690
|
+
) {
|
|
691
|
+
Task { @MainActor [weak self] in
|
|
692
|
+
guard let self = self else { return }
|
|
693
|
+
|
|
694
|
+
do {
|
|
695
|
+
// Convert NSDictionary to JSON Data
|
|
696
|
+
guard JSONSerialization.isValidJSONObject(enrollmentCollectedData) else {
|
|
697
|
+
rejecter("INVALID_DATA", "Invalid enrollment collected data", nil)
|
|
698
|
+
return
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
let jsonData = try JSONSerialization.data(withJSONObject: enrollmentCollectedData, options: [])
|
|
702
|
+
print("📦 EnrollmentCollectedData JSON sent to iOS SDK: \(String(data: jsonData, encoding: .utf8) ?? "Invalid JSON")")
|
|
703
|
+
|
|
704
|
+
// Decode to EnrollmentCollectedData using the native SDK's Codable model
|
|
705
|
+
let decoder = JSONDecoder()
|
|
706
|
+
let collectedData = try decoder.decode(EnrollmentCollectedData.self, from: jsonData)
|
|
707
|
+
|
|
708
|
+
// Create API client using the native SDK's factory method
|
|
709
|
+
let apiClient = Yuno.apiClientEnroll(
|
|
710
|
+
countryCode: countryCode,
|
|
711
|
+
customerSession: customerSession
|
|
712
|
+
)
|
|
713
|
+
|
|
714
|
+
// Continue enrollment using async/await (native SDK uses async throws)
|
|
715
|
+
let response = try await apiClient.continueEnrollment(data: collectedData)
|
|
716
|
+
|
|
717
|
+
// The native SDK returns [String: Any] with vaulted_token in "vaulted_token" key
|
|
718
|
+
if let vaultedToken = response["vaulted_token"] as? String {
|
|
719
|
+
let responseDict: [String: Any] = ["vaultedToken": vaultedToken]
|
|
720
|
+
resolver(responseDict)
|
|
721
|
+
} else if let error = response["error"] as? String {
|
|
722
|
+
rejecter("ENROLLMENT_ERROR", error, nil)
|
|
723
|
+
} else {
|
|
724
|
+
rejecter("ENROLLMENT_ERROR", "No vaulted token in response", nil)
|
|
725
|
+
}
|
|
726
|
+
} catch {
|
|
727
|
+
rejecter("ENROLLMENT_ERROR", "Failed to continue enrollment: \(error.localizedDescription)", error)
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
670
731
|
}
|
|
671
732
|
|
|
672
733
|
// Note: TokenCollectedData, CollectedData, CardData, and other related models
|
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.12",
|
|
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",
|