react-native-hyperswitch-dev-sdk 0.4.3 → 0.4.4
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/HyperswitchSdkReactNative.podspec +4 -0
- package/android/build.gradle +0 -6
- package/ios/Modules/ReactNative/HyperModule.h +25 -0
- package/ios/Modules/ReactNative/HyperModule.mm +169 -0
- package/ios/Modules/ReactNative/HyperswitchModule.swift +223 -165
- package/ios/Modules/ReactNative/NativeHyperswitchModule.mm +17 -12
- package/ios/Modules/ReactNative/NativeHyperswitchModuleImpl.swift +18 -7
- package/ios/Modules/ReactNative/NativePaymentElementModule.mm +122 -122
- package/ios/Views/Fabric/NativePaymentElementView.mm +8 -0
- package/ios/Views/Native/NativePaymentWidget.swift +26 -22
- package/ios/hyperswitchSDK/Core/HyperCVCWidget/CVCWidget.swift +3 -2
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentHandler.swift +1 -1
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +79 -13
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +2 -2
- package/ios/hyperswitchSDK/Core/HyperPaymentWidget/PaymentWidget.swift +5 -4
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +14 -0
- package/ios/hyperswitchSDK/Core/NativeModule/{HyperModule.swift → HyperModuleImpl.swift} +156 -113
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +58 -22
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +84 -29
- package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +2 -0
- package/ios/hyperswitchSDK/Public/RNBridgeFactory.h +28 -0
- package/ios/hyperswitchSDK/Public/RNBridgeFactory.mm +167 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +1 -1
- package/lib/commonjs/index.bundle.js +1 -1
- package/lib/commonjs/index.bundle.js.map +1 -1
- package/lib/module/index.bundle.js +1 -1
- package/lib/module/index.bundle.js.map +1 -1
- package/package.json +6 -2
- package/src/context/PaymentSession.ts +2 -0
- package/src/specs/NativeHyperswitchModule.ts +2 -2
- package/ios/Modules/ReactNative/HyperswitchSdkReactNative.h +0 -5
- package/ios/Modules/ReactNative/HyperswitchSdkReactNative.mm +0 -121
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +0 -31
|
@@ -17,8 +17,12 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
"ios/Modules/**/*.{h,m,mm,cpp,swift}",
|
|
18
18
|
"ios/Views/**/*.{h,m,mm,cpp,swift}",
|
|
19
19
|
"ios/hyperswitchSDK/Core/**/*.{h,m,mm,cpp,swift}",
|
|
20
|
+
"ios/hyperswitchSDK/Public/**/*.{h,m,mm,cpp,swift}",
|
|
20
21
|
"ios/hyperswitchSDK/Shared/**/*.{h,m,mm,cpp,swift}",
|
|
21
22
|
]
|
|
23
|
+
s.public_header_files = [
|
|
24
|
+
"ios/hyperswitchSDK/Public/**/*.h",
|
|
25
|
+
]
|
|
22
26
|
s.private_header_files = [
|
|
23
27
|
"ios/Modules/**/*.h",
|
|
24
28
|
"ios/Views/**/*.h",
|
package/android/build.gradle
CHANGED
|
@@ -140,12 +140,6 @@ android {
|
|
|
140
140
|
pickFirst '**/libreactnativejni.so'
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
rootProject.allprojects { eachProject ->
|
|
144
|
-
eachProject.repositories.maven {
|
|
145
|
-
url "https://maven.juspay.in/hyper-sdk/"
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
143
|
apply from: "./hyperswitch_autolinking.gradle"
|
|
150
144
|
applyHyperswitchAutolinking(project)
|
|
151
145
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
#import <HyperswitchSdkReactNativeSpec/HyperswitchSdkReactNativeSpec.h>
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* RN-facing "HyperModule" native module for the New Architecture.
|
|
6
|
+
*
|
|
7
|
+
* The embedded payment-sheet bundle resolves this as
|
|
8
|
+
* `TurboModuleRegistry.get('HyperModule')`
|
|
9
|
+
* and uses the SAME object for BOTH:
|
|
10
|
+
* • `new NativeEventEmitter(HyperModule)` — hence it subclasses RCTEventEmitter
|
|
11
|
+
* • imperative method calls (sendMessageToNative, launchApplePay, exit*, …)
|
|
12
|
+
*
|
|
13
|
+
* The C++ `getTurboModule:` cannot be expressed in Swift, so this ObjC++ class is
|
|
14
|
+
* the registered module; all business logic lives in the Swift singleton
|
|
15
|
+
* `HyperModuleImpl.shared`, to which every call is forwarded.
|
|
16
|
+
*
|
|
17
|
+
* The generated spec protocol/JSI (`NativeHyperswitchSdkNativeSpec` /
|
|
18
|
+
* `NativeHyperswitchSdkNativeSpecJSI`) is produced by codegen from
|
|
19
|
+
* `src/specs/NativeHyperswitchSdkNative.ts`. Note the spec FILENAME drives those
|
|
20
|
+
* class names; the runtime module name ("HyperModule") comes from
|
|
21
|
+
* `TurboModuleRegistry.get('HyperModule')` + `RCT_EXPORT_MODULE(HyperModule)`.
|
|
22
|
+
*/
|
|
23
|
+
@interface HyperModule : RCTEventEmitter <NativeHyperswitchSdkNativeSpec>
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#import "HyperModule.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTComponent.h>
|
|
4
|
+
#import <memory>
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#if __has_include("HyperswitchSdkReactNative-Swift.h")
|
|
8
|
+
#import "HyperswitchSdkReactNative-Swift.h"
|
|
9
|
+
#else
|
|
10
|
+
// When using use_frameworks! :linkage => :static in Podfile
|
|
11
|
+
#import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ObjC++ bridge for the "HyperModule" TurboModule.
|
|
16
|
+
*
|
|
17
|
+
* Responsibilities:
|
|
18
|
+
* 1. Register the module under the exact name "HyperModule"
|
|
19
|
+
* (matches TurboModuleRegistry.get('HyperModule') in the embedded bundle).
|
|
20
|
+
* 2. Act as the RCTEventEmitter the bundle wraps in `new NativeEventEmitter(...)`.
|
|
21
|
+
* 3. Forward every spec method to the Swift singleton HyperModuleImpl.shared.
|
|
22
|
+
* 4. Vend the codegen JSI TurboModule for the New Architecture.
|
|
23
|
+
*/
|
|
24
|
+
@implementation HyperModule
|
|
25
|
+
|
|
26
|
+
RCT_EXPORT_MODULE(HyperModule)
|
|
27
|
+
|
|
28
|
+
- (instancetype)init
|
|
29
|
+
{
|
|
30
|
+
if (self = [super init]) {
|
|
31
|
+
// Let the Swift logic layer dispatch events / reach the bridge through us.
|
|
32
|
+
HyperModuleImpl.shared.eventEmitter = self;
|
|
33
|
+
}
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
38
|
+
{
|
|
39
|
+
return @[ @"confirm", @"confirmEC", @"triggerWidgetAction", @"updateIntentInit", @"updateIntentComplete" ];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (BOOL)requiresMainQueueSetup
|
|
43
|
+
{
|
|
44
|
+
return YES;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (dispatch_queue_t)methodQueue
|
|
48
|
+
{
|
|
49
|
+
return dispatch_get_main_queue();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// NOTE: `addListener:` and `removeListeners:` required by the spec are inherited
|
|
53
|
+
// from RCTEventEmitter and satisfy the protocol as-is.
|
|
54
|
+
|
|
55
|
+
// MARK: - Generic message passing
|
|
56
|
+
|
|
57
|
+
- (void)sendMessageToNative:(NSString *)message
|
|
58
|
+
{
|
|
59
|
+
[HyperModuleImpl.shared sendMessageToNative:message];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// MARK: - Google Pay (Android only)
|
|
63
|
+
|
|
64
|
+
- (void)launchGPay:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
65
|
+
{
|
|
66
|
+
callback(@[ @"Google Pay is not available on iOS" ]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// MARK: - Apple Pay
|
|
70
|
+
|
|
71
|
+
- (void)launchApplePay:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
72
|
+
{
|
|
73
|
+
[HyperModuleImpl.shared launchApplePay:requestObj callback:callback];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void)startApplePay:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
77
|
+
{
|
|
78
|
+
[HyperModuleImpl.shared startApplePay:requestObj callback:callback];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)presentApplePay:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
82
|
+
{
|
|
83
|
+
[HyperModuleImpl.shared presentApplePay:requestObj callback:callback];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// MARK: - Payment sheet exits
|
|
87
|
+
|
|
88
|
+
- (void)exitPaymentsheet:(double)rootTag result:(NSString *)result reset:(BOOL)reset
|
|
89
|
+
{
|
|
90
|
+
[HyperModuleImpl.shared exitPaymentsheet:@(rootTag) result:result reset:reset];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void)exitPaymentMethodManagement:(double)rootTag result:(NSString *)result reset:(BOOL)reset
|
|
94
|
+
{
|
|
95
|
+
[HyperModuleImpl.shared exitPaymentMethodManagement:@(rootTag) result:result reset:reset];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void)exitWidgetPaymentsheet:(double)rootTag result:(NSString *)result reset:(BOOL)reset
|
|
99
|
+
{
|
|
100
|
+
[HyperModuleImpl.shared exitWidgetPaymentsheet:@(rootTag) result:result reset:reset];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// MARK: - Widget
|
|
104
|
+
|
|
105
|
+
- (void)exitWidget:(NSString *)result widgetType:(NSString *)widgetType
|
|
106
|
+
{
|
|
107
|
+
// No dedicated iOS implementation (Android-oriented); no-op.
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (void)exitCardForm:(NSString *)result
|
|
111
|
+
{
|
|
112
|
+
[HyperModuleImpl.shared exitCardForm:result];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (void)launchWidgetPaymentSheet:(NSString *)requestObj callback:(RCTResponseSenderBlock)callback
|
|
116
|
+
{
|
|
117
|
+
[HyperModuleImpl.shared launchWidgetPaymentSheet:requestObj callback:callback];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)updateWidgetHeight:(double)height
|
|
121
|
+
{
|
|
122
|
+
// Height is driven by the native widget view on iOS; no-op.
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (void)notifyWidgetPaymentResult:(double)rootTag result:(NSString *)result
|
|
126
|
+
{
|
|
127
|
+
[HyperModuleImpl.shared notifyWidgetPaymentResult:@(rootTag) result:result];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// MARK: - Payment method management
|
|
131
|
+
|
|
132
|
+
- (void)onAddPaymentMethod:(NSString *)data
|
|
133
|
+
{
|
|
134
|
+
[HyperModuleImpl.shared onAddPaymentMethod:data];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// MARK: - Payment events
|
|
138
|
+
|
|
139
|
+
- (void)emitPaymentEvent:(double)rootTag eventType:(NSString *)eventType payload:(NSDictionary *)payload
|
|
140
|
+
{
|
|
141
|
+
[HyperModuleImpl.shared emitPaymentEvent:@(rootTag) eventType:eventType payload:payload];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)onUpdateIntentEvent:(double)rootTag type:(NSString *)type result:(NSString *)result
|
|
145
|
+
{
|
|
146
|
+
[HyperModuleImpl.shared onUpdateIntentEvent:@(rootTag) type:type result:result];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
- (void)onPaymentConfirmButtonClick:(double)rootTag payload:(NSString *)payload callback:(RCTResponseSenderBlock)callback
|
|
150
|
+
{
|
|
151
|
+
[HyperModuleImpl.shared onPaymentConfirmButtonClick:@(rootTag) payload:payload callback:callback];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// MARK: - 3DS / DDC iframe bridge
|
|
155
|
+
|
|
156
|
+
- (void)openIframeBridge:(NSString *)url timeoutMs:(double)timeoutMs callback:(RCTResponseSenderBlock)callback
|
|
157
|
+
{
|
|
158
|
+
[HyperModuleImpl.shared openIframeBridge:url timeoutMs:@(timeoutMs) callback:callback];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// MARK: - TurboModule (New Architecture) — JSI spec wiring
|
|
162
|
+
|
|
163
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
164
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
165
|
+
{
|
|
166
|
+
return std::make_shared<facebook::react::NativeHyperswitchSdkNativeSpecJSI>(params);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@end
|