react-native-hyperswitch-dev-sdk 0.4.3 → 0.4.5

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.
Files changed (35) hide show
  1. package/HyperswitchSdkReactNative.podspec +4 -0
  2. package/android/build.gradle +0 -6
  3. package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt +1 -5
  4. package/ios/Modules/ReactNative/HyperModule.h +25 -0
  5. package/ios/Modules/ReactNative/HyperModule.mm +169 -0
  6. package/ios/Modules/ReactNative/HyperswitchModule.swift +223 -165
  7. package/ios/Modules/ReactNative/NativeHyperswitchModule.mm +17 -12
  8. package/ios/Modules/ReactNative/NativeHyperswitchModuleImpl.swift +18 -7
  9. package/ios/Modules/ReactNative/NativePaymentElementModule.mm +122 -122
  10. package/ios/Views/Fabric/NativePaymentElementView.mm +8 -0
  11. package/ios/Views/Native/NativePaymentWidget.swift +125 -121
  12. package/ios/hyperswitchSDK/Core/HyperCVCWidget/CVCWidget.swift +9 -7
  13. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentHandler.swift +1 -1
  14. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +79 -13
  15. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +2 -2
  16. package/ios/hyperswitchSDK/Core/HyperPaymentWidget/PaymentWidget.swift +23 -19
  17. package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +14 -0
  18. package/ios/hyperswitchSDK/Core/NativeModule/HyperModuleImpl.swift +388 -0
  19. package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +58 -22
  20. package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +84 -29
  21. package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +2 -0
  22. package/ios/hyperswitchSDK/Public/RNBridgeFactory.h +28 -0
  23. package/ios/hyperswitchSDK/Public/RNBridgeFactory.mm +167 -0
  24. package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +1 -1
  25. package/lib/commonjs/index.bundle.js +1 -1
  26. package/lib/commonjs/index.bundle.js.map +1 -1
  27. package/lib/module/index.bundle.js +1 -1
  28. package/lib/module/index.bundle.js.map +1 -1
  29. package/package.json +8 -4
  30. package/src/context/PaymentSession.ts +2 -0
  31. package/src/specs/NativeHyperswitchModule.ts +2 -2
  32. package/ios/Modules/ReactNative/HyperswitchSdkReactNative.h +0 -5
  33. package/ios/Modules/ReactNative/HyperswitchSdkReactNative.mm +0 -121
  34. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +0 -31
  35. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +0 -343
@@ -119,9 +119,18 @@ public class NativeHyperswitchModuleImpl: NSObject {
119
119
  ])
120
120
  return
121
121
  }
122
+
123
+ // The SDK's getRootViewWithParams wraps the whole `props` dictionary
124
+ // under the `configuration` key, so we must pass the contents that
125
+ // belong inside `configuration`: the merchant-supplied configuration
126
+ // plus the session/hyperswitch metadata.
127
+ var sheetProps = params["configuration"] as? [String: Any] ?? [:]
128
+ sheetProps["hyperswitchConfig"] = params["hyperswitchConfig"]
129
+ sheetProps["paymentSessionConfig"] = params["paymentSessionConfig"]
130
+
122
131
  session.presentPaymentSheetWithParams(
123
132
  viewController: vc,
124
- params: params,
133
+ params: sheetProps,
125
134
  completion: { result in
126
135
  switch result {
127
136
  case .completed(let data):
@@ -264,11 +273,12 @@ public class NativeHyperswitchModuleImpl: NSObject {
264
273
  }
265
274
  }
266
275
 
267
- // MARK: - confirmWithCustomerLastUsedPaymentMethod (no params — matches Android)
268
- // Android: TODO("Not yet implemented")
276
+ // MARK: - confirmWithCustomerLastUsedPaymentMethod
277
+ // JS / Android: confirmWithCustomerLastUsedPaymentMethod(reactTag: Double, promise: Promise?)
269
278
 
270
- @objc(confirmWithCustomerLastUsedPaymentMethodWithResolve:reject:)
279
+ @objc(confirmWithCustomerLastUsedPaymentMethod:resolve:reject:)
271
280
  public func confirmWithCustomerLastUsedPaymentMethod(
281
+ reactTag: Double,
272
282
  resolve: @escaping RCTPromiseResolveBlock,
273
283
  reject: @escaping RCTPromiseRejectBlock
274
284
  ) {
@@ -276,11 +286,12 @@ public class NativeHyperswitchModuleImpl: NSObject {
276
286
  resolve("{\"status\":\"failed\",\"message\":\"Not yet implemented\"}")
277
287
  }
278
288
 
279
- // MARK: - confirmWithCustomerDefaultPaymentMethod (no params — matches Android)
280
- // Android: TODO("Not yet implemented")
289
+ // MARK: - confirmWithCustomerDefaultPaymentMethod
290
+ // JS / Android: confirmWithCustomerDefaultPaymentMethod(reactTag: Double, promise: Promise?)
281
291
 
282
- @objc(confirmWithCustomerDefaultPaymentMethodWithResolve:reject:)
292
+ @objc(confirmWithCustomerDefaultPaymentMethod:resolve:reject:)
283
293
  public func confirmWithCustomerDefaultPaymentMethod(
294
+ reactTag: Double,
284
295
  resolve: @escaping RCTPromiseResolveBlock,
285
296
  reject: @escaping RCTPromiseRejectBlock
286
297
  ) {
@@ -1,129 +1,129 @@
1
+ ////
2
+ //// NativePaymentElementModule.mm
3
+ ////
4
+ //// TurboModule (New Architecture) for NativePaymentElementModule.
5
+ //// Module name: "NativePaymentElementModule"
6
+ ////
7
+ //// Matches Android's NativePaymentWidgetModule (NativePaymentElementModuleSpec):
8
+ //// confirmPayment(reactTag, callback)
9
+ //// updateIntentInitForWidget(reactTag, callback)
10
+ //// updateIntentCompleteForWidget(reactTag, sdkAuthorization, callback)
11
+ ////
12
+ //// Old arch (bridge): the view-manager commands (same methods) live on NativePaymentWidget
13
+ //// (RCTViewManager) which is accessible via NativeModules.NativePaymentWidget.
14
+ //// NativeHyperswitchSdk.ts still uses that path, so both old and new arch work.
15
+ ////
16
+ //// New arch (TurboModule): this module is registered as "NativePaymentElementModule" and is
17
+ //// the spec-compliant TurboModule counterpart. It delegates to the
18
+ //// inner NativePaymentWidgetView found via NativePaymentWidgetViewRegistry.
19
+ ////
1
20
  //
2
- // NativePaymentElementModule.mm
21
+ //#import <React/RCTBridgeModule.h>
22
+ //#import <React/RCTUIManager.h>
3
23
  //
4
- // TurboModule (New Architecture) for NativePaymentElementModule.
5
- // Module name: "NativePaymentElementModule"
24
+ //#if __has_include("HyperswitchSdkReactNative-Swift.h")
25
+ //#import "HyperswitchSdkReactNative-Swift.h"
26
+ //#else
27
+ //#import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
28
+ //#endif
6
29
  //
7
- // Matches Android's NativePaymentWidgetModule (NativePaymentElementModuleSpec):
8
- // confirmPayment(reactTag, callback)
9
- // updateIntentInitForWidget(reactTag, callback)
10
- // updateIntentCompleteForWidget(reactTag, sdkAuthorization, callback)
30
+ //#import "NativePaymentWidgetViewRegistry.h"
11
31
  //
12
- // Old arch (bridge): the view-manager commands (same methods) live on NativePaymentWidget
13
- // (RCTViewManager) which is accessible via NativeModules.NativePaymentWidget.
14
- // NativeHyperswitchSdk.ts still uses that path, so both old and new arch work.
32
+ //#ifdef RCT_NEW_ARCH_ENABLED
33
+ //#import <HyperswitchSdkReactNativeSpec/HyperswitchSdkReactNativeSpec.h>
34
+ //#endif
15
35
  //
16
- // New arch (TurboModule): this module is registered as "NativePaymentElementModule" and is
17
- // the spec-compliant TurboModule counterpart. It delegates to the
18
- // inner NativePaymentWidgetView found via NativePaymentWidgetViewRegistry.
36
+ //// ─────────────────────────────────────────────────────────────────────────────
37
+ //// Private helper: find NativePaymentWidgetView by React tag.
38
+ ////
39
+ //// Checks NativePaymentWidgetViewRegistry first (covers both old-arch direct
40
+ //// NativePaymentWidgetView instances registered there AND the inner widget views
41
+ //// registered by NativePaymentElementView for Fabric).
42
+ //// ─────────────────────────────────────────────────────────────────────────────
43
+ //static NativePaymentWidget * _Nullable widgetViewForTag(NSNumber *tag)
44
+ //{
45
+ // UIView *v = [[NativePaymentWidgetViewRegistry shared] viewForTag:tag];
46
+ // return [v isKindOfClass:[NativePaymentWidget class]]
47
+ // ? (NativePaymentWidget *)v
48
+ // : nil;
49
+ //}
19
50
  //
20
-
21
- #import <React/RCTBridgeModule.h>
22
- #import <React/RCTUIManager.h>
23
-
24
- #if __has_include("HyperswitchSdkReactNative-Swift.h")
25
- #import "HyperswitchSdkReactNative-Swift.h"
26
- #else
27
- #import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
28
- #endif
29
-
30
- #import "NativePaymentWidgetViewRegistry.h"
31
-
32
- #ifdef RCT_NEW_ARCH_ENABLED
33
- #import <HyperswitchSdkReactNativeSpec/HyperswitchSdkReactNativeSpec.h>
34
- #endif
35
-
36
- // ─────────────────────────────────────────────────────────────────────────────
37
- // Private helper: find NativePaymentWidgetView by React tag.
51
+ //// ─────────────────────────────────────────────────────────────────────────────
38
52
  //
39
- // Checks NativePaymentWidgetViewRegistry first (covers both old-arch direct
40
- // NativePaymentWidgetView instances registered there AND the inner widget views
41
- // registered by NativePaymentElementView for Fabric).
42
- // ─────────────────────────────────────────────────────────────────────────────
43
- static NativePaymentWidgetView * _Nullable widgetViewForTag(NSNumber *tag)
44
- {
45
- UIView *v = [[NativePaymentWidgetViewRegistry shared] viewForTag:tag];
46
- return [v isKindOfClass:[NativePaymentWidgetView class]]
47
- ? (NativePaymentWidgetView *)v
48
- : nil;
49
- }
50
-
51
- // ─────────────────────────────────────────────────────────────────────────────
52
-
53
- // Use RCTBridgeModule for both arches; getTurboModule: below handles new arch wiring.
54
- @interface NativePaymentElementModule : NSObject <RCTBridgeModule>
55
- @end
56
-
57
- @implementation NativePaymentElementModule
58
-
59
- RCT_EXPORT_MODULE(NativePaymentElementModule)
60
-
61
- // ── confirmPayment ────────────────────────────────────────────────────────────
62
- // JS / Android: confirmPayment(reactTag: number, callback)
63
- // Mirrors Android NativePaymentWidgetModule.confirmPayment (mostly a stub there).
64
- // On iOS we do the real work via the shared registry.
65
- RCT_EXPORT_METHOD(confirmPayment:(double)reactTag
66
- callback:(RCTResponseSenderBlock)callback)
67
- {
68
- NSNumber *tag = @((NSInteger)reactTag);
69
- dispatch_async(dispatch_get_main_queue(), ^{
70
- NativePaymentWidgetView *view = widgetViewForTag(tag);
71
- if (view) {
72
- [view confirmPayment:callback];
73
- } else {
74
- callback(@[@{@"status": @"failed",
75
- @"code": @"WIDGET_NOT_FOUND",
76
- @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
77
- }
78
- });
79
- }
80
-
81
- // ── updateIntentInitForWidget ─────────────────────────────────────────────────
82
- RCT_EXPORT_METHOD(updateIntentInitForWidget:(double)reactTag
83
- callback:(RCTResponseSenderBlock)callback)
84
- {
85
- NSNumber *tag = @((NSInteger)reactTag);
86
- dispatch_async(dispatch_get_main_queue(), ^{
87
- NativePaymentWidgetView *view = widgetViewForTag(tag);
88
- if (view) {
89
- [view updateIntentInit:callback];
90
- } else {
91
- callback(@[@{@"status": @"failed",
92
- @"code": @"WIDGET_NOT_FOUND",
93
- @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
94
- }
95
- });
96
- }
97
-
98
- // ── updateIntentCompleteForWidget ─────────────────────────────────────────────
99
- RCT_EXPORT_METHOD(updateIntentCompleteForWidget:(double)reactTag
100
- sdkAuthorization:(NSString *)sdkAuthorization
101
- callback:(RCTResponseSenderBlock)callback)
102
- {
103
- NSNumber *tag = @((NSInteger)reactTag);
104
- dispatch_async(dispatch_get_main_queue(), ^{
105
- NativePaymentWidgetView *view = widgetViewForTag(tag);
106
- if (view) {
107
- [view updateIntentCompleteWithSdkAuthorization:sdkAuthorization resolve:callback];
108
- } else {
109
- callback(@[@{@"status": @"failed",
110
- @"code": @"WIDGET_NOT_FOUND",
111
- @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
112
- }
113
- });
114
- }
115
-
116
- // ── TurboModule wiring (New Architecture) ─────────────────────────────────────
117
- // NativePaymentElementModuleSpecJSI is generated by iOS codegen from
118
- // NativePaymentElementModule.ts → HyperswitchSdkReactNativeSpec pod.
119
- #ifdef RCT_NEW_ARCH_ENABLED
120
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
121
- (const facebook::react::ObjCTurboModule::InitParams &)params
122
- {
123
- return std::make_shared<facebook::react::NativePaymentElementModuleSpecJSI>(params);
124
- }
125
- #endif
126
-
127
- + (BOOL)requiresMainQueueSetup { return NO; }
128
-
129
- @end
53
+ //// Use RCTBridgeModule for both arches; getTurboModule: below handles new arch wiring.
54
+ //@interface NativePaymentElementModule : NSObject <RCTBridgeModule>
55
+ //@end
56
+ //
57
+ //@implementation NativePaymentElementModule
58
+ //
59
+ //RCT_EXPORT_MODULE(NativePaymentElementModule)
60
+ //
61
+ //// ── confirmPayment ────────────────────────────────────────────────────────────
62
+ //// JS / Android: confirmPayment(reactTag: number, callback)
63
+ //// Mirrors Android NativePaymentWidgetModule.confirmPayment (mostly a stub there).
64
+ //// On iOS we do the real work via the shared registry.
65
+ //RCT_EXPORT_METHOD(confirmPayment:(double)reactTag
66
+ // callback:(RCTResponseSenderBlock)callback)
67
+ //{
68
+ // NSNumber *tag = @((NSInteger)reactTag);
69
+ //// dispatch_async(dispatch_get_main_queue(), ^{
70
+ //// NativePaymentWidget *view = widgetViewForTag(tag);
71
+ //// if (view) {
72
+ //// [view confirmPayment:callback];
73
+ //// } else {
74
+ //// callback(@[@{@"status": @"failed",
75
+ //// @"code": @"WIDGET_NOT_FOUND",
76
+ //// @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
77
+ //// }
78
+ //// });
79
+ //}
80
+ //
81
+ //// ── updateIntentInitForWidget ─────────────────────────────────────────────────
82
+ //RCT_EXPORT_METHOD(updateIntentInitForWidget:(double)reactTag
83
+ // callback:(RCTResponseSenderBlock)callback)
84
+ //{
85
+ // NSNumber *tag = @((NSInteger)reactTag);
86
+ //// dispatch_async(dispatch_get_main_queue(), ^{
87
+ //// NativePaymentWidgetView *view = widgetViewForTag(tag);
88
+ //// if (view) {
89
+ //// [view updateIntentInit:callback];
90
+ //// } else {
91
+ //// callback(@[@{@"status": @"failed",
92
+ //// @"code": @"WIDGET_NOT_FOUND",
93
+ //// @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
94
+ //// }
95
+ //// });
96
+ //}
97
+ //
98
+ //// ── updateIntentCompleteForWidget ─────────────────────────────────────────────
99
+ //RCT_EXPORT_METHOD(updateIntentCompleteForWidget:(double)reactTag
100
+ // sdkAuthorization:(NSString *)sdkAuthorization
101
+ // callback:(RCTResponseSenderBlock)callback)
102
+ //{
103
+ //// NSNumber *tag = @((NSInteger)reactTag);
104
+ //// dispatch_async(dispatch_get_main_queue(), ^{
105
+ //// NativePaymentWidgetView *view = widgetViewForTag(tag);
106
+ //// if (view) {
107
+ //// [view updateIntentCompleteWithSdkAuthorization:sdkAuthorization resolve:callback];
108
+ //// } else {
109
+ //// callback(@[@{@"status": @"failed",
110
+ //// @"code": @"WIDGET_NOT_FOUND",
111
+ //// @"message": [NSString stringWithFormat:@"Widget not found for tag %@", tag]}]);
112
+ //// }
113
+ //// });
114
+ //}
115
+ //
116
+ //// ── TurboModule wiring (New Architecture) ─────────────────────────────────────
117
+ //// NativePaymentElementModuleSpecJSI is generated by iOS codegen from
118
+ //// NativePaymentElementModule.ts → HyperswitchSdkReactNativeSpec pod.
119
+ //#ifdef RCT_NEW_ARCH_ENABLED
120
+ //- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
121
+ // (const facebook::react::ObjCTurboModule::InitParams &)params
122
+ //{
123
+ // return std::make_shared<facebook::react::NativePaymentElementModuleSpecJSI>(params);
124
+ //}
125
+ //#endif
126
+ //
127
+ //+ (BOOL)requiresMainQueueSetup { return NO; }
128
+ //
129
+ //@end
@@ -22,6 +22,14 @@
22
22
  #import "NativePaymentElementView.h"
23
23
  #import "NativePaymentWidgetViewRegistry.h"
24
24
 
25
+ // Defines RCTPromiseResolveBlock/RCTPromiseRejectBlock and RCTDirectEventBlock,
26
+ // referenced by the HyperswitchModule / NativePaymentWidgetView interfaces
27
+ // declared in the generated Swift header below.
28
+ #import <React/RCTBridgeModule.h>
29
+ #import <React/RCTComponent.h>
30
+
31
+ #include <folly/json.h>
32
+
25
33
  #import <react/renderer/components/HyperswitchSdkReactNativeSpec/ComponentDescriptors.h>
26
34
  #import <react/renderer/components/HyperswitchSdkReactNativeSpec/EventEmitters.h>
27
35
  #import <react/renderer/components/HyperswitchSdkReactNativeSpec/Props.h>
@@ -34,34 +34,34 @@ internal class NativePaymentWidget: RCTViewManager {
34
34
  }
35
35
 
36
36
  @objc func confirmPayment(_ reactTag: NSNumber, _ rnCallback: @escaping RCTResponseSenderBlock) {
37
- bridge.uiManager.addUIBlock { _, viewRegistry in
38
- // Old-arch path: the view is NativePaymentWidgetView directly.
39
- if let view = viewRegistry?[reactTag] as? NativePaymentWidgetView {
40
- view.confirmPayment(rnCallback)
41
- return
42
- }
43
- // New-arch (Fabric) path: the Fabric NativePaymentElementView registered
44
- // the inner NativePaymentWidgetView in the shared registry by the same tag.
45
- // if let view = NativePaymentWidgetViewRegistry.shared.view(forTag: reactTag) as? NativePaymentWidgetView {
46
- // view.confirmPayment(rnCallback)
47
- // return
48
- // }
49
- rnCallback([["status": "failed", "message": "Widget view not found for tag \(reactTag)"]])
50
- }
37
+ // bridge.uiManager.addUIBlock { _, viewRegistry in
38
+ // // Old-arch path: the view is NativePaymentWidgetView directly.
39
+ // if let view = viewRegistry?[reactTag] as? NativePaymentWidgetView {
40
+ // view.confirmPayment(rnCallback)
41
+ // return
42
+ // }
43
+ // // New-arch (Fabric) path: the Fabric NativePaymentElementView registered
44
+ // // the inner NativePaymentWidgetView in the shared registry by the same tag.
45
+ // // if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: reactTag) as? NativePaymentWidgetView {
46
+ // // view.confirmPayment(rnCallback)
47
+ // // return
48
+ // // }
49
+ // rnCallback([["status": "failed", "message": "Widget view not found for tag \(reactTag)"]])
50
+ // }
51
51
  }
52
52
 
53
53
  @objc func updateIntentInitForWidget(_ rootTag: NSNumber, _ rnCallback: @escaping RCTResponseSenderBlock) {
54
- bridge.uiManager.addUIBlock { _, viewRegistry in
55
- if let view = viewRegistry?[rootTag] as? NativePaymentWidgetView {
56
- view.updateIntentInit(rnCallback)
57
- return
58
- }
59
- // if let view = NativePaymentWidgetViewRegistry.shared.view(forTag: rootTag) as? NativePaymentWidgetView {
60
- // view.updateIntentInit(rnCallback)
61
- // return
62
- // }
63
- rnCallback([["status": "failed", "message": "Widget view not found for tag \(rootTag)"]])
64
- }
54
+ // bridge.uiManager.addUIBlock { _, viewRegistry in
55
+ // if let view = viewRegistry?[rootTag] as? NativePaymentWidgetView {
56
+ // view.updateIntentInit(rnCallback)
57
+ // return
58
+ // }
59
+ // // if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: rootTag) as? NativePaymentWidgetView {
60
+ // // view.updateIntentInit(rnCallback)
61
+ // // return
62
+ // // }
63
+ // rnCallback([["status": "failed", "message": "Widget view not found for tag \(rootTag)"]])
64
+ // }
65
65
  }
66
66
 
67
67
  @objc func updateIntentCompleteForWidget(
@@ -69,17 +69,17 @@ internal class NativePaymentWidget: RCTViewManager {
69
69
  _ sdkAuthorization: String,
70
70
  _ rnCallback: @escaping RCTResponseSenderBlock
71
71
  ) {
72
- bridge.uiManager.addUIBlock { _, viewRegistry in
73
- if let view = viewRegistry?[rootTag] as? NativePaymentWidgetView {
74
- view.updateIntentComplete(sdkAuthorization: sdkAuthorization, resolve: rnCallback)
75
- return
76
- }
77
- // if let view = NativePaymentWidgetViewRegistry.shared.view(forTag: rootTag) as? NativePaymentWidgetView {
78
- // view.updateIntentComplete(sdkAuthorization: sdkAuthorization, resolve: rnCallback)
79
- // return
80
- // }
81
- rnCallback([["status": "failed", "message": "Widget view not found for tag \(rootTag)"]])
82
- }
72
+ // bridge.uiManager.addUIBlock { _, viewRegistry in
73
+ // if let view = viewRegistry?[rootTag] as? NativePaymentWidgetView {
74
+ // view.updateIntentComplete(sdkAuthorization: sdkAuthorization, resolve: rnCallback)
75
+ // return
76
+ // }
77
+ // // if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: rootTag) as? NativePaymentWidgetView {
78
+ // // view.updateIntentComplete(sdkAuthorization: sdkAuthorization, resolve: rnCallback)
79
+ // // return
80
+ // // }
81
+ // rnCallback([["status": "failed", "message": "Widget view not found for tag \(rootTag)"]])
82
+ // }
83
83
  }
84
84
 
85
85
  @objc func confirmPaymentCVC(
@@ -88,34 +88,38 @@ internal class NativePaymentWidget: RCTViewManager {
88
88
  _ paymentMethodId: String,
89
89
  _ rnCallback: @escaping RCTResponseSenderBlock
90
90
  ) {
91
- bridge.uiManager.addUIBlock { _, viewRegistry in
92
- if let view = viewRegistry?[reactTag] as? NativePaymentWidgetView {
93
- view.confirmCVCPayment(paymentToken: paymentToken, paymentMethodId: paymentMethodId, resolve: rnCallback)
94
- return
95
- }
96
- // if let view = NativePaymentWidgetViewRegistry.shared.view(forTag: reactTag) as? NativePaymentWidgetView {
97
- // view.confirmCVCPayment(paymentToken: paymentToken, paymentMethodId: paymentMethodId, resolve: rnCallback)
98
- // return
99
- // }
100
- rnCallback([["status": "failed", "message": "Widget view not found for tag \(reactTag)"]])
101
- }
91
+ // bridge.uiManager.addUIBlock { _, viewRegistry in
92
+ // if let view = viewRegistry?[reactTag] as? NativePaymentWidgetView {
93
+ // view.confirmCVCPayment(paymentToken: paymentToken, paymentMethodId: paymentMethodId, resolve: rnCallback)
94
+ // return
95
+ // }
96
+ // // if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: reactTag) as? NativePaymentWidgetView {
97
+ // // view.confirmCVCPayment(paymentToken: paymentToken, paymentMethodId: paymentMethodId, resolve: rnCallback)
98
+ // // return
99
+ // // }
100
+ // rnCallback([["status": "failed", "message": "Widget view not found for tag \(reactTag)"]])
101
+ // }
102
102
  }
103
103
  }
104
104
 
105
- // @objc exposes this class to Objective-C++ so the Fabric component
106
- // (NativePaymentElementView.mm) can instantiate it and type-check it.
105
+ // public + @objc exposes this class (and the members below marked @objc) in the
106
+ // generated HyperswitchSdkReactNative-Swift.h header so the Objective-C++ Fabric
107
+ // component (NativePaymentElementView.mm) and TurboModule (NativePaymentElementModule.mm)
108
+ // can instantiate it, type-check it, and call its commands. Framework targets only emit
109
+ // public declarations into that header, even for callers in the same module.
107
110
  @objc(NativePaymentWidgetView)
108
- internal class NativePaymentWidgetView: UIView {
111
+ public class NativePaymentWidgetView: UIView {
109
112
 
110
113
  private var paymentWidget: PaymentWidget?
111
114
  private var cvcWidget: CVCWidget?
112
115
  internal var cvcWidgetRef: CVCWidget? { cvcWidget }
113
- // Internal (not private) so the Fabric wrapper can set these via the ObjC bridge.
114
- @objc var widgetType: String?
115
- @objc var sdkAuthorization: String?
116
- @objc var options: [String: Any]?
117
- @objc var onPaymentEvent: RCTDirectEventBlock?
118
- @objc var onPaymentResult: RCTDirectEventBlock?
116
+ // Public (not just internal) so these show up in the generated Objective-C
117
+ // header for the Fabric wrapper (NativePaymentElementView.mm) to set via the ObjC bridge.
118
+ @objc public var widgetType: String?
119
+ @objc public var sdkAuthorization: String?
120
+ @objc public var options: [String: Any]?
121
+ @objc public var onPaymentEvent: RCTDirectEventBlock?
122
+ @objc public var onPaymentResult: RCTDirectEventBlock?
119
123
  private var responseSenderCallback: RCTResponseSenderBlock?
120
124
  private var appliedConfigKey: String?
121
125
 
@@ -252,7 +256,7 @@ internal class NativePaymentWidgetView: UIView {
252
256
  }
253
257
  }
254
258
 
255
- @objc func didSetProps() {
259
+ @objc public func didSetProps() {
256
260
  guard isSupportedWidgetType(), let sdkAuthorization = effectiveSdkAuthorization() else { return }
257
261
 
258
262
  let configKey = [widgetType ?? "", effectivePublishableKey() ?? "", effectiveProfileId() ?? "", sdkAuthorization].joined(separator: ":")
@@ -319,11 +323,11 @@ internal class NativePaymentWidgetView: UIView {
319
323
  }
320
324
  }
321
325
 
322
- override func didSetProps(_ changedProps: [String]) {
326
+ public override func didSetProps(_ changedProps: [String]) {
323
327
  self.didSetProps()
324
328
  }
325
329
 
326
- override init(frame: CGRect) {
330
+ public override init(frame: CGRect) {
327
331
  super.init(frame: frame)
328
332
  }
329
333
 
@@ -331,74 +335,74 @@ internal class NativePaymentWidgetView: UIView {
331
335
  fatalError("init(coder:) has not been implemented")
332
336
  }
333
337
 
334
- internal override func layoutSubviews() {
338
+ public override func layoutSubviews() {
335
339
  super.layoutSubviews()
336
340
  paymentWidget?.frame = bounds
337
341
  cvcWidget?.frame = bounds
338
342
  }
339
343
 
340
- internal func confirmPayment(_ rnCallback: @escaping RCTResponseSenderBlock) {
344
+ @objc public func confirmPayment(_ rnCallback: @escaping RCTResponseSenderBlock) {
341
345
  // avoiding duplicate confirm calls (confirmPayment triggered multiple times from RN layer)
342
- if self.responseSenderCallback != nil {
343
- let response = ["status": "failed", "error": "invalid call"]
344
- rnCallback([response])
345
- return
346
- }
347
-
348
- self.responseSenderCallback = rnCallback
349
- guard let paymentWidget = paymentWidget else {
350
- self.responseSenderCallback = nil
351
- rnCallback([[
352
- "status": "failed",
353
- "code": "WIDGET_NOT_READY",
354
- "message": "Widget not ready",
355
- ]])
356
- return
357
- }
358
- paymentWidget.confirm()
359
- }
360
-
361
- internal func updateIntentInit(_ resolve: @escaping RCTResponseSenderBlock) {
362
- guard let tag = rctRootTag else {
363
- resolve([["status": "failed", "message": "Widget root tag not found"]])
364
- return
365
- }
366
-
367
- WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentInit) { [weak self] response, _ in
368
- guard let self = self else { return }
369
- resolve([self.callbackPayload(response["data"])])
370
- }
371
-
372
- let eventData: [String: Any] = ["rootTag": tag]
373
- RNViewManager.sharedInstance.bridge.enqueueJSCall(
374
- "RCTDeviceEventEmitter",
375
- method: "emit",
376
- args: ["updateIntentInit", eventData],
377
- completion: nil
378
- )
379
- }
380
-
381
- internal func updateIntentComplete(sdkAuthorization: String, resolve: @escaping RCTResponseSenderBlock) {
382
- guard let tag = rctRootTag else {
383
- resolve([["status": "failed", "message": "Widget root tag not found"]])
384
- return
385
- }
386
-
387
- WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentComplete) { [weak self] response, _ in
388
- guard let self = self else { return }
389
- resolve([self.callbackPayload(response["data"])])
390
- }
391
-
392
- let eventData: [String: Any] = [
393
- "rootTag": tag,
394
- "sdkAuthorization": sdkAuthorization,
395
- ]
396
- RNViewManager.sharedInstance.bridge.enqueueJSCall(
397
- "RCTDeviceEventEmitter",
398
- method: "emit",
399
- args: ["updateIntentComplete", eventData],
400
- completion: nil
401
- )
346
+ // if self.responseSenderCallback != nil {
347
+ // let response = ["status": "failed", "error": "invalid call"]
348
+ // rnCallback([response])
349
+ // return
350
+ // }
351
+
352
+ // self.responseSenderCallback = rnCallback
353
+ // guard let paymentWidget = paymentWidget else {
354
+ // self.responseSenderCallback = nil
355
+ // rnCallback([[
356
+ // "status": "failed",
357
+ // "code": "WIDGET_NOT_READY",
358
+ // "message": "Widget not ready",
359
+ // ]])
360
+ // return
361
+ // }
362
+ // paymentWidget.confirm()
363
+ }
364
+
365
+ @objc public func updateIntentInit(_ resolve: @escaping RCTResponseSenderBlock) {
366
+ // guard let tag = rctRootTag else {
367
+ // resolve([["status": "failed", "message": "Widget root tag not found"]])
368
+ // return
369
+ // }
370
+
371
+ // WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentInit) { [weak self] response, _ in
372
+ // guard let self = self else { return }
373
+ // resolve([self.callbackPayload(response["data"])])
374
+ // }
375
+
376
+ // let eventData: [String: Any] = ["rootTag": tag]
377
+ // RNViewManager.sharedInstance.bridge?.enqueueJSCall(
378
+ // "RCTDeviceEventEmitter",
379
+ // method: "emit",
380
+ // args: ["updateIntentInit", eventData],
381
+ // completion: nil
382
+ // )
383
+ }
384
+
385
+ @objc public func updateIntentComplete(sdkAuthorization: String, resolve: @escaping RCTResponseSenderBlock) {
386
+ // guard let tag = rctRootTag else {
387
+ // resolve([["status": "failed", "message": "Widget root tag not found"]])
388
+ // return
389
+ // }
390
+
391
+ // WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentComplete) { [weak self] response, _ in
392
+ // guard let self = self else { return }
393
+ // resolve([self.callbackPayload(response["data"])])
394
+ // }
395
+
396
+ // let eventData: [String: Any] = [
397
+ // "rootTag": tag,
398
+ // "sdkAuthorization": sdkAuthorization,
399
+ // ]
400
+ // RNViewManager.sharedInstance.bridge?.enqueueJSCall(
401
+ // "RCTDeviceEventEmitter",
402
+ // method: "emit",
403
+ // args: ["updateIntentComplete", eventData],
404
+ // completion: nil
405
+ // )
402
406
  }
403
407
 
404
408
  internal func confirmCVCPayment(paymentToken: String, paymentMethodId: String, resolve: @escaping RCTResponseSenderBlock) {