react-native-hyperswitch-dev-sdk 0.4.4 → 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.
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt +1 -5
- package/ios/Modules/ReactNative/HyperModule.mm +8 -8
- package/ios/Views/Native/NativePaymentWidget.swift +99 -99
- package/ios/hyperswitchSDK/Core/HyperCVCWidget/CVCWidget.swift +7 -6
- package/ios/hyperswitchSDK/Core/HyperPaymentWidget/PaymentWidget.swift +21 -18
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModuleImpl.swift +125 -123
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +11 -11
- package/package.json +3 -3
package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt
CHANGED
|
@@ -111,11 +111,7 @@ class ReactNativeHyperswitchModule(reactContext: ReactApplicationContext) :
|
|
|
111
111
|
putAll(params?.toHashMap().orEmpty())
|
|
112
112
|
put("type", "payment")
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
val map: Map<String, Any?> = mapOf(
|
|
116
|
-
"props" to props
|
|
117
|
-
)
|
|
118
|
-
val bundle = launchOptions?.toBundle(map)
|
|
114
|
+
val bundle = launchOptions?.getBundleWithHyperParams(props)
|
|
119
115
|
bundle?.let {
|
|
120
116
|
val isFragment = paymentSessionReactLauncher?.presentSheet(bundle)
|
|
121
117
|
// isPresented.set(true)
|
|
@@ -36,7 +36,7 @@ RCT_EXPORT_MODULE(HyperModule)
|
|
|
36
36
|
|
|
37
37
|
- (NSArray<NSString *> *)supportedEvents
|
|
38
38
|
{
|
|
39
|
-
|
|
39
|
+
return @[ @"confirm" ];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
+ (BOOL)requiresMainQueueSetup
|
|
@@ -97,7 +97,7 @@ RCT_EXPORT_MODULE(HyperModule)
|
|
|
97
97
|
|
|
98
98
|
- (void)exitWidgetPaymentsheet:(double)rootTag result:(NSString *)result reset:(BOOL)reset
|
|
99
99
|
{
|
|
100
|
-
[HyperModuleImpl.shared exitWidgetPaymentsheet:@(rootTag) result:result reset:reset];
|
|
100
|
+
// [HyperModuleImpl.shared exitWidgetPaymentsheet:@(rootTag) result:result reset:reset];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// MARK: - Widget
|
|
@@ -114,7 +114,7 @@ RCT_EXPORT_MODULE(HyperModule)
|
|
|
114
114
|
|
|
115
115
|
- (void)launchWidgetPaymentSheet:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
116
116
|
{
|
|
117
|
-
[HyperModuleImpl.shared launchWidgetPaymentSheet:requestObj callback:callback];
|
|
117
|
+
// [HyperModuleImpl.shared launchWidgetPaymentSheet:requestObj callback:callback];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
- (void)updateWidgetHeight:(double)height
|
|
@@ -124,31 +124,31 @@ RCT_EXPORT_MODULE(HyperModule)
|
|
|
124
124
|
|
|
125
125
|
- (void)notifyWidgetPaymentResult:(double)rootTag result:(NSString *)result
|
|
126
126
|
{
|
|
127
|
-
[HyperModuleImpl.shared notifyWidgetPaymentResult:@(rootTag) result:result];
|
|
127
|
+
// [HyperModuleImpl.shared notifyWidgetPaymentResult:@(rootTag) result:result];
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// MARK: - Payment method management
|
|
131
131
|
|
|
132
132
|
- (void)onAddPaymentMethod:(NSString *)data
|
|
133
133
|
{
|
|
134
|
-
[HyperModuleImpl.shared onAddPaymentMethod:data];
|
|
134
|
+
// [HyperModuleImpl.shared onAddPaymentMethod:data];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// MARK: - Payment events
|
|
138
138
|
|
|
139
139
|
- (void)emitPaymentEvent:(double)rootTag eventType:(NSString *)eventType payload:(NSDictionary *)payload
|
|
140
140
|
{
|
|
141
|
-
[HyperModuleImpl.shared emitPaymentEvent:@(rootTag) eventType:eventType payload:payload];
|
|
141
|
+
// [HyperModuleImpl.shared emitPaymentEvent:@(rootTag) eventType:eventType payload:payload];
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
- (void)onUpdateIntentEvent:(double)rootTag type:(NSString *)type result:(NSString *)result
|
|
145
145
|
{
|
|
146
|
-
[HyperModuleImpl.shared onUpdateIntentEvent:@(rootTag) type:type result:result];
|
|
146
|
+
// [HyperModuleImpl.shared onUpdateIntentEvent:@(rootTag) type:type result:result];
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
- (void)onPaymentConfirmButtonClick:(double)rootTag payload:(NSString *)payload callback:(RCTResponseSenderBlock)callback
|
|
150
150
|
{
|
|
151
|
-
[HyperModuleImpl.shared onPaymentConfirmButtonClick:@(rootTag) payload:payload callback:callback];
|
|
151
|
+
// [HyperModuleImpl.shared onPaymentConfirmButtonClick:@(rootTag) payload:payload callback:callback];
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// MARK: - 3DS / DDC iframe bridge
|
|
@@ -34,34 +34,34 @@ internal class NativePaymentWidget: RCTViewManager {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@objc func confirmPayment(_ reactTag: NSNumber, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: reactTag) as? NativePaymentWidgetView {
|
|
46
|
-
// view.confirmPayment(rnCallback)
|
|
47
|
-
// return
|
|
48
|
-
// }
|
|
49
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: rootTag) as? NativePaymentWidgetView {
|
|
60
|
-
// view.updateIntentInit(rnCallback)
|
|
61
|
-
// return
|
|
62
|
-
// }
|
|
63
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// if let view = NativePaymentWidgetViewRegistry.shared().view(forTag: rootTag) as? NativePaymentWidgetView {
|
|
78
|
-
// view.updateIntentComplete(sdkAuthorization: sdkAuthorization, resolve: rnCallback)
|
|
79
|
-
// return
|
|
80
|
-
// }
|
|
81
|
-
|
|
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,17 +88,17 @@ internal class NativePaymentWidget: RCTViewManager {
|
|
|
88
88
|
_ paymentMethodId: String,
|
|
89
89
|
_ rnCallback: @escaping RCTResponseSenderBlock
|
|
90
90
|
) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -343,66 +343,66 @@ public class NativePaymentWidgetView: UIView {
|
|
|
343
343
|
|
|
344
344
|
@objc public func confirmPayment(_ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
345
345
|
// avoiding duplicate confirm calls (confirmPayment triggered multiple times from RN layer)
|
|
346
|
-
if self.responseSenderCallback != nil {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
self.responseSenderCallback = rnCallback
|
|
353
|
-
guard let paymentWidget = paymentWidget else {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
paymentWidget.confirm()
|
|
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
363
|
}
|
|
364
364
|
|
|
365
365
|
@objc public func updateIntentInit(_ resolve: @escaping RCTResponseSenderBlock) {
|
|
366
|
-
guard let tag = rctRootTag else {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
366
|
+
// guard let tag = rctRootTag else {
|
|
367
|
+
// resolve([["status": "failed", "message": "Widget root tag not found"]])
|
|
368
|
+
// return
|
|
369
|
+
// }
|
|
370
370
|
|
|
371
|
-
WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentInit) { [weak self] response, _ in
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
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
375
|
|
|
376
|
-
let eventData: [String: Any] = ["rootTag": tag]
|
|
377
|
-
RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
)
|
|
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
383
|
}
|
|
384
384
|
|
|
385
385
|
@objc public func updateIntentComplete(sdkAuthorization: String, resolve: @escaping RCTResponseSenderBlock) {
|
|
386
|
-
guard let tag = rctRootTag else {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
WidgetResponseRegistry.shared.register(rootTag: tag, action: .updateIntentComplete) { [weak self] response, _ in
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
let eventData: [String: Any] = [
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
]
|
|
400
|
-
RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
)
|
|
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
|
+
// )
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
internal func confirmCVCPayment(paymentToken: String, paymentMethodId: String, resolve: @escaping RCTResponseSenderBlock) {
|
|
@@ -112,12 +112,13 @@ public class CVCWidget: UIControl {
|
|
|
112
112
|
"paymentToken": paymentToken,
|
|
113
113
|
"paymentMethodId": paymentMethodId as Any,
|
|
114
114
|
]
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
// Bridge-based widget emit removed for payment-sheet-only build.
|
|
116
|
+
// RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
117
|
+
// "RCTDeviceEventEmitter",
|
|
118
|
+
// method: "emit",
|
|
119
|
+
// args: ["triggerWidgetAction", payload],
|
|
120
|
+
// completion: nil
|
|
121
|
+
// )
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
internal func dispatchPaymentEvent(type: String, payload: [String: Any]) {
|
|
@@ -124,12 +124,13 @@ public class PaymentWidget: UIControl {
|
|
|
124
124
|
.sink { [weak self] in
|
|
125
125
|
guard let self = self else { return }
|
|
126
126
|
let payload: [String: Any] = ["rootTag": self.widgetReactTag ?? -1]
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
// Bridge-based widget emit removed for payment-sheet-only build.
|
|
128
|
+
// RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
129
|
+
// "RCTDeviceEventEmitter",
|
|
130
|
+
// method: "emit",
|
|
131
|
+
// args: ["updateIntentInit", payload],
|
|
132
|
+
// completion: nil
|
|
133
|
+
// )
|
|
133
134
|
}
|
|
134
135
|
.store(in: &cancellables)
|
|
135
136
|
|
|
@@ -141,12 +142,13 @@ public class PaymentWidget: UIControl {
|
|
|
141
142
|
"rootTag": self.widgetReactTag ?? -1,
|
|
142
143
|
"sdkAuthorization": sdkAuthorization,
|
|
143
144
|
]
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
// Bridge-based widget emit removed for payment-sheet-only build.
|
|
146
|
+
// RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
147
|
+
// "RCTDeviceEventEmitter",
|
|
148
|
+
// method: "emit",
|
|
149
|
+
// args: ["updateIntentComplete", payload],
|
|
150
|
+
// completion: nil
|
|
151
|
+
// )
|
|
150
152
|
}
|
|
151
153
|
.store(in: &cancellables)
|
|
152
154
|
}
|
|
@@ -156,12 +158,13 @@ public class PaymentWidget: UIControl {
|
|
|
156
158
|
"rootTag": self.widgetReactTag ?? -1,
|
|
157
159
|
"actionType": "CONFIRM_PAYMENT_ACTION",
|
|
158
160
|
]
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
// Bridge-based widget emit removed for payment-sheet-only build.
|
|
162
|
+
// RNViewManager.sharedInstance.bridge?.enqueueJSCall(
|
|
163
|
+
// "RCTDeviceEventEmitter",
|
|
164
|
+
// method: "emit",
|
|
165
|
+
// args: ["triggerWidgetAction", payload],
|
|
166
|
+
// completion: nil
|
|
167
|
+
// )
|
|
165
168
|
}
|
|
166
169
|
|
|
167
170
|
internal func setPaymentEventListener(_ listener: PaymentEventListener?) {
|
|
@@ -38,8 +38,8 @@ public class HyperModuleImpl: NSObject {
|
|
|
38
38
|
activePaymentSheetVC = vc
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
private var bridge: RCTBridge? { eventEmitter?.bridge }
|
|
41
|
+
// Bridge-backed widget helpers removed for the new-arch/bridgeless build.
|
|
42
|
+
// private var bridge: RCTBridge? { eventEmitter?.bridge }
|
|
43
43
|
|
|
44
44
|
// MARK: - Events
|
|
45
45
|
|
|
@@ -69,16 +69,16 @@ public class HyperModuleImpl: NSObject {
|
|
|
69
69
|
self.presentCallback = callback
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// MARK: - Widget
|
|
72
|
+
// MARK: - Widget (commented out — relies on RCTBridge/uiManager)
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
let request = HyperModuleImpl.jsonObject(from: requestObj)
|
|
76
|
-
expressCheckoutHandler.launchPaymentSheet(paymentResult: request, callBack: callback)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
PaymentMethodManagementWidget.onAddPaymentMethod?()
|
|
81
|
-
|
|
74
|
+
@objc public func launchWidgetPaymentSheet(_ requestObj: String, callback: @escaping RCTResponseSenderBlock) {
|
|
75
|
+
// let request = HyperModuleImpl.jsonObject(from: requestObj)
|
|
76
|
+
// expressCheckoutHandler.launchPaymentSheet(paymentResult: request, callBack: callback)
|
|
77
|
+
}
|
|
78
|
+
//
|
|
79
|
+
@objc public func onAddPaymentMethod(_ rnMessage: String) {
|
|
80
|
+
// PaymentMethodManagementWidget.onAddPaymentMethod?()
|
|
81
|
+
}
|
|
82
82
|
|
|
83
83
|
// MARK: - Payment sheet exits
|
|
84
84
|
|
|
@@ -101,12 +101,12 @@ public class HyperModuleImpl: NSObject {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
let result = paymentResult(from: rnMessage)
|
|
106
|
-
withWidget(reactTag) { w in
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
104
|
+
@objc public func exitWidgetPaymentsheet(_ reactTag: NSNumber, result rnMessage: String, reset: Bool) {
|
|
105
|
+
// let result = paymentResult(from: rnMessage)
|
|
106
|
+
// withWidget(reactTag) { w in
|
|
107
|
+
// w.handleConfirmPaymentResponse(result)
|
|
108
|
+
// }
|
|
109
|
+
}
|
|
110
110
|
|
|
111
111
|
@objc public func exitPaymentMethodManagement(_ reactTag: NSNumber, result rnMessage: String, reset: Bool) {
|
|
112
112
|
exitSheet(rnMessage)
|
|
@@ -116,49 +116,49 @@ public class HyperModuleImpl: NSObject {
|
|
|
116
116
|
exitCardFormInternal(rnMessage)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// MARK: - Payment result / events
|
|
119
|
+
// MARK: - Payment result / events (commented out — rely on RCTBridge/uiManager)
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
let result = paymentResult(from: rnMessage)
|
|
123
|
-
guard case .failed = result else { return }
|
|
124
|
-
withNativePaymentWidgetView(rootTag) { view in
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
121
|
+
@objc public func notifyWidgetPaymentResult(_ rootTag: NSNumber, result rnMessage: String) {
|
|
122
|
+
// let result = paymentResult(from: rnMessage)
|
|
123
|
+
// guard case .failed = result else { return }
|
|
124
|
+
// withNativePaymentWidgetView(rootTag) { view in
|
|
125
|
+
// view.handleConfirmPaymentResponse(result)
|
|
126
|
+
// }
|
|
127
|
+
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
withWidget(rootTag) { widget in
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
129
|
+
@objc public func onUpdateIntentEvent(_ rootTag: NSNumber, type: String, result: String) {
|
|
130
|
+
// withWidget(rootTag) { widget in
|
|
131
|
+
// widget.handleUpdateIntentEvent(type: type, result: result)
|
|
132
|
+
// }
|
|
133
|
+
}
|
|
134
134
|
|
|
135
135
|
@objc public func emitPaymentEvent(_ rootTag: NSNumber, eventType: String, payload: NSDictionary) {
|
|
136
|
-
let map = (payload as? [String: Any]) ?? [:]
|
|
137
|
-
resolveSubscribingTarget(rootTag) { target in
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
136
|
+
// let map = (payload as? [String: Any]) ?? [:]
|
|
137
|
+
// resolveSubscribingTarget(rootTag) { target in
|
|
138
|
+
// if let widget = target as? PaymentWidget, widget.paymentEventListener != nil {
|
|
139
|
+
// widget.dispatchPaymentEvent(type: eventType, payload: map)
|
|
140
|
+
// } else if let cvc = target as? CVCWidget, cvc.paymentEventListener != nil {
|
|
141
|
+
// cvc.dispatchPaymentEvent(type: eventType, payload: map)
|
|
142
|
+
// } else if let sheet = target as? PaymentSheet, sheet.paymentEventListener != nil {
|
|
143
|
+
// sheet.dispatchPaymentEvent(type: eventType, payload: map)
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
@objc public func onPaymentConfirmButtonClick(_ rootTag: NSNumber, payload: String, callback: @escaping RCTResponseSenderBlock) {
|
|
149
|
-
resolveSubscribingTarget(rootTag) { target in
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
149
|
+
// resolveSubscribingTarget(rootTag) { target in
|
|
150
|
+
// if let widget = target as? PaymentWidget {
|
|
151
|
+
// widget.handleShouldProceedWithPayment(payload: payload) { shouldProceed in
|
|
152
|
+
// callback([shouldProceed])
|
|
153
|
+
// }
|
|
154
|
+
// } else if let sheet = target as? PaymentSheet {
|
|
155
|
+
// sheet.handleShouldProceedWithPayment(payload: payload) { shouldProceed in
|
|
156
|
+
// callback([shouldProceed])
|
|
157
|
+
// }
|
|
158
|
+
// } else {
|
|
159
|
+
// callback([true])
|
|
160
|
+
// }
|
|
161
|
+
// }
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
// MARK: - 3DS / DDC iframe bridge
|
|
@@ -313,74 +313,76 @@ public class HyperModuleImpl: NSObject {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
let
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
316
|
+
// MARK: - Bridge-backed view lookup helpers (commented out for new-arch/bridgeless build)
|
|
317
|
+
|
|
318
|
+
// private func withWidget(_ rootTag: NSNumber, _ block: @escaping (PaymentWidget) -> Void) {
|
|
319
|
+
// guard let bridge = self.bridge else { return }
|
|
320
|
+
// RCTGetUIManagerQueue().async {
|
|
321
|
+
// bridge.uiManager.addUIBlock { _, viewRegistry in
|
|
322
|
+
// guard let view = viewRegistry?[rootTag] else { return }
|
|
323
|
+
// var current: UIView? = view
|
|
324
|
+
// while let v = current {
|
|
325
|
+
// if let widget = v as? PaymentWidget {
|
|
326
|
+
// block(widget)
|
|
327
|
+
// return
|
|
328
|
+
// }
|
|
329
|
+
// current = v.superview
|
|
330
|
+
// }
|
|
331
|
+
// }
|
|
332
|
+
// }
|
|
333
|
+
// }
|
|
334
|
+
//
|
|
335
|
+
// private func withNativePaymentWidgetView(_ rootTag: NSNumber, _ block: @escaping (PaymentWidget) -> Void) {
|
|
336
|
+
// guard let bridge = self.bridge else { return }
|
|
337
|
+
// RCTGetUIManagerQueue().async {
|
|
338
|
+
// bridge.uiManager.addUIBlock { _, viewRegistry in
|
|
339
|
+
// guard let view = viewRegistry?[rootTag] else { return }
|
|
340
|
+
// var current: UIView? = view
|
|
341
|
+
// while let v = current {
|
|
342
|
+
// if let nativeWidget = v as? PaymentWidget {
|
|
343
|
+
// block(nativeWidget)
|
|
344
|
+
// return
|
|
345
|
+
// }
|
|
346
|
+
// current = v.superview
|
|
347
|
+
// }
|
|
348
|
+
// }
|
|
349
|
+
// }
|
|
350
|
+
// }
|
|
351
|
+
//
|
|
352
|
+
// private func resolveSubscribingTarget(_ rootTag: NSNumber, _ block: @escaping (AnyObject?) -> Void) {
|
|
353
|
+
// guard let bridge = self.bridge else {
|
|
354
|
+
// DispatchQueue.main.async { block(nil) }
|
|
355
|
+
// return
|
|
356
|
+
// }
|
|
357
|
+
// RCTGetUIManagerQueue().async {
|
|
358
|
+
// bridge.uiManager.addUIBlock { _, viewRegistry in
|
|
359
|
+
// guard let view = viewRegistry?[rootTag] else {
|
|
360
|
+
// DispatchQueue.main.async { block(nil) }
|
|
361
|
+
// return
|
|
362
|
+
// }
|
|
363
|
+
// var current: UIView? = view
|
|
364
|
+
// while let v = current {
|
|
365
|
+
// if v is PaymentWidget || v is CVCWidget {
|
|
366
|
+
// DispatchQueue.main.async { block(v) }
|
|
367
|
+
// return
|
|
368
|
+
// }
|
|
369
|
+
// current = v.superview
|
|
370
|
+
// }
|
|
371
|
+
// let sheet = (view.reactViewController() as? HyperUIViewController)?.paymentSheet
|
|
372
|
+
// DispatchQueue.main.async { block(sheet) }
|
|
373
|
+
// }
|
|
374
|
+
// }
|
|
375
|
+
// }
|
|
376
|
+
//
|
|
377
|
+
// private func withPaymentSheet(_ rootTag: NSNumber, _ block: @escaping (UIViewController?, PaymentSheet?) -> Void) {
|
|
378
|
+
// guard let bridge = self.bridge else { return }
|
|
379
|
+
// RCTGetUIManagerQueue().async {
|
|
380
|
+
// bridge.uiManager.addUIBlock { _, viewRegistry in
|
|
381
|
+
// let view = viewRegistry?[rootTag]
|
|
382
|
+
// let vc = view?.reactViewController() as? HyperUIViewController
|
|
383
|
+
// let sheet = vc?.paymentSheet
|
|
384
|
+
// DispatchQueue.main.async { block(vc, sheet) }
|
|
385
|
+
// }
|
|
386
|
+
// }
|
|
387
|
+
// }
|
|
386
388
|
}
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
// runtime under-initialised, so `getEnforcing('DeviceInfo')` fails and the bundle
|
|
17
17
|
// can't boot — the sheet renders blank.
|
|
18
18
|
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
19
|
+
// The bridge is intentionally kept alive (Fabric-on-bridge) for now because the
|
|
20
|
+
// legacy widget code still uses `bridge.enqueueJSCall` / `bridge.uiManager`.
|
|
21
|
+
// For the payment-sheet-only build we do not capture or expose the bridge here.
|
|
21
22
|
//
|
|
22
23
|
// Created by Shivam Shashank on 09/11/22.
|
|
23
24
|
//
|
|
@@ -34,9 +35,8 @@ internal class RNViewManager: RCTDefaultReactNativeFactoryDelegate {
|
|
|
34
35
|
|
|
35
36
|
private var reactNativeFactory: RCTReactNativeFactory?
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
private weak var capturedBridge: RCTBridge?
|
|
38
|
+
// Bridge capture removed for the payment-sheet-only/bridgeless build.
|
|
39
|
+
// private weak var capturedBridge: RCTBridge?
|
|
40
40
|
|
|
41
41
|
internal static let sharedInstance = RNViewManager()
|
|
42
42
|
|
|
@@ -54,9 +54,9 @@ internal class RNViewManager: RCTDefaultReactNativeFactoryDelegate {
|
|
|
54
54
|
/// The bridge backing the embedded runtime. Kept for the SDK's widget commands
|
|
55
55
|
/// (`bridge.enqueueJSCall` / `bridge.uiManager`). Available after the first view
|
|
56
56
|
/// is created.
|
|
57
|
-
internal var bridge: RCTBridge? {
|
|
58
|
-
|
|
59
|
-
}
|
|
57
|
+
// internal var bridge: RCTBridge? {
|
|
58
|
+
// return capturedBridge
|
|
59
|
+
// }
|
|
60
60
|
|
|
61
61
|
internal func viewForModule(_ moduleName: String, initialProperties: [String: Any]?) -> UIView {
|
|
62
62
|
let view = factory().rootViewFactory.view(
|
|
@@ -76,8 +76,8 @@ internal class RNViewManager: RCTDefaultReactNativeFactoryDelegate {
|
|
|
76
76
|
|
|
77
77
|
// MARK: - Arch configuration
|
|
78
78
|
|
|
79
|
-
/// Keep
|
|
80
|
-
///
|
|
79
|
+
/// Keep a bridge-backed Fabric runtime so the bundled payment sheet can boot.
|
|
80
|
+
/// (The bridge itself is not exposed here; only the factory/rootView is used.)
|
|
81
81
|
public override func bridgelessEnabled() -> Bool {
|
|
82
82
|
return false
|
|
83
83
|
}
|
|
@@ -88,7 +88,7 @@ internal class RNViewManager: RCTDefaultReactNativeFactoryDelegate {
|
|
|
88
88
|
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
89
89
|
// Called while the embedded bridge loads its JS — capture it for the SDK's
|
|
90
90
|
// bridge-dependent widget commands.
|
|
91
|
-
self.capturedBridge = bridge
|
|
91
|
+
// self.capturedBridge = bridge
|
|
92
92
|
return bundleURL()
|
|
93
93
|
}
|
|
94
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-hyperswitch-dev-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Hyperswitch SDK for React Native",
|
|
5
5
|
"main": "lib/commonjs/index.bundle.js",
|
|
6
6
|
"module": "lib/module/index.bundle.js",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
],
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "https://github.com/
|
|
62
|
+
"url": "https://github.com/juspay/react-native-hyperswitch",
|
|
63
63
|
"directory": "packages/react-native-hyperswitch"
|
|
64
64
|
},
|
|
65
65
|
"author": "Hyperswitch",
|
|
66
66
|
"license": "Apache-2.0",
|
|
67
67
|
"bugs": {
|
|
68
|
-
"url": "https://github.com/
|
|
68
|
+
"url": "https://github.com/juspay/react-native-hyperswitch"
|
|
69
69
|
},
|
|
70
70
|
"homepage": "https://hyperswitch.io",
|
|
71
71
|
"publishConfig": {
|