react-native-hyperswitch-dev-sdk 0.4.1

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 (262) hide show
  1. package/HyperswitchSdkReactNative.podspec +42 -0
  2. package/LICENSE +201 -0
  3. package/android/build.gradle +161 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/hyperswitch_autolinking.gradle +378 -0
  6. package/android/proguard-rules.pro +72 -0
  7. package/android/src/legacy/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +41 -0
  8. package/android/src/legacy/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +20 -0
  9. package/android/src/legacy/java/com/facebook/react/viewmanagers/NativePaymentWidgetManagerDelegate.java +38 -0
  10. package/android/src/legacy/java/com/facebook/react/viewmanagers/NativePaymentWidgetManagerInterface.java +21 -0
  11. package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativeHyperswitchSdkNativeSpec.java +106 -0
  12. package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativeHyperswitchSdkReactNativeSpec.java +77 -0
  13. package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativePaymentWidgetNativeSpec.java +36 -0
  14. package/android/src/main/AndroidManifest.xml +15 -0
  15. package/android/src/main/assets/hyperswitch.bundle +1535 -0
  16. package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +47 -0
  17. package/android/src/main/java/com/hyperswitchsdkreactnative/modules/NativePaymentWidgetModule.kt +173 -0
  18. package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt +396 -0
  19. package/android/src/main/java/com/hyperswitchsdkreactnative/views/PaymentElementViewManager.kt +99 -0
  20. package/android/src/main/java/io/hyperswitch/HyperswitchReactPackageProvider.kt +19 -0
  21. package/android/src/main/java/io/hyperswitch/PaymentEventType.kt +18 -0
  22. package/android/src/main/java/io/hyperswitch/model/ElementConfiguration.kt +58 -0
  23. package/android/src/main/java/io/hyperswitch/paymentsession/ExitHeadlessCallBackManager.kt +47 -0
  24. package/android/src/main/java/io/hyperswitch/paymentsession/GetPaymentSessionCallBackManager.kt +23 -0
  25. package/android/src/main/java/io/hyperswitch/paymentsession/PaymentMethod.kt +167 -0
  26. package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionHandler.kt +68 -0
  27. package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionHandlerImpl.kt +179 -0
  28. package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionReactLauncher.kt +226 -0
  29. package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSheetCallbackManager.kt +40 -0
  30. package/android/src/main/java/io/hyperswitch/paymentsheet/PaymentResult.kt +63 -0
  31. package/android/src/main/java/io/hyperswitch/react/GooglePayButtonManager.kt +54 -0
  32. package/android/src/main/java/io/hyperswitch/react/HyperActivity.kt +73 -0
  33. package/android/src/main/java/io/hyperswitch/react/HyperEventEmitter.kt +144 -0
  34. package/android/src/main/java/io/hyperswitch/react/HyperFragment.kt +429 -0
  35. package/android/src/main/java/io/hyperswitch/react/HyperFragmentManager.kt +155 -0
  36. package/android/src/main/java/io/hyperswitch/react/HyperHeadlessModule.kt +43 -0
  37. package/android/src/main/java/io/hyperswitch/react/HyperModule.kt +405 -0
  38. package/android/src/main/java/io/hyperswitch/react/HyperPackage.kt +16 -0
  39. package/android/src/main/java/io/hyperswitch/react/ReactNativeController.kt +251 -0
  40. package/android/src/main/java/io/hyperswitch/utils/ConversionUtils.kt +256 -0
  41. package/android/src/main/java/io/hyperswitch/utils/StandardResult.kt +45 -0
  42. package/android/src/main/java/io/hyperswitch/view/GooglePayButtonView.kt +59 -0
  43. package/android/src/main/java/io/hyperswitch/view/PaymentWidgetView.kt +405 -0
  44. package/android/src/main/res/values/attrs.xml +6 -0
  45. package/android/src/main/res/values/strings.xml +5 -0
  46. package/android/src/main/res/values/theme.xml +16 -0
  47. package/ios/Modules/ReactNative/HyperswitchModule.swift +470 -0
  48. package/ios/Modules/ReactNative/HyperswitchSdkReactNative.h +5 -0
  49. package/ios/Modules/ReactNative/HyperswitchSdkReactNative.mm +121 -0
  50. package/ios/Modules/ReactNative/NativeHyperswitchModule.h +18 -0
  51. package/ios/Modules/ReactNative/NativeHyperswitchModule.mm +165 -0
  52. package/ios/Modules/ReactNative/NativeHyperswitchModuleImpl.swift +290 -0
  53. package/ios/Modules/ReactNative/NativePaymentElementModule.mm +129 -0
  54. package/ios/Views/Fabric/ApplePayView.h +14 -0
  55. package/ios/Views/Fabric/ApplePayView.mm +89 -0
  56. package/ios/Views/Fabric/NativePaymentElementView.h +21 -0
  57. package/ios/Views/Fabric/NativePaymentElementView.mm +200 -0
  58. package/ios/Views/Fabric/NativePaymentWidgetViewRegistry.h +37 -0
  59. package/ios/Views/Fabric/NativePaymentWidgetViewRegistry.m +45 -0
  60. package/ios/Views/Native/NativePaymentWidget.m +26 -0
  61. package/ios/Views/Native/NativePaymentWidget.swift +420 -0
  62. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +261 -0
  63. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
  64. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +126 -0
  65. package/ios/hyperswitchSDK/Core/DeviceDataCollection/HeadlessWebView.swift +144 -0
  66. package/ios/hyperswitchSDK/Core/HyperCVCWidget/CVCWidget.swift +136 -0
  67. package/ios/hyperswitchSDK/Core/HyperExpressCheckout/ExpressCheckoutLauncher.swift +116 -0
  68. package/ios/hyperswitchSDK/Core/HyperExpressCheckout/ExpressCheckoutWidget.swift +42 -0
  69. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentCardTextField+SwiftUI.swift +67 -0
  70. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentCardTextField.swift +44 -0
  71. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentHandler.swift +59 -0
  72. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentIntentParams.swift +31 -0
  73. package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentMethodParams.swift +25 -0
  74. package/ios/hyperswitchSDK/Core/HyperPaymentMethodManagement/PaymentManagementConfiguration.swift +213 -0
  75. package/ios/hyperswitchSDK/Core/HyperPaymentMethodManagement/PaymentMethodManagementWidget.swift +92 -0
  76. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheet+Events.swift +36 -0
  77. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+SwiftUI.swift +49 -0
  78. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +49 -0
  79. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +68 -0
  80. package/ios/hyperswitchSDK/Core/HyperPaymentWidget/PaymentWidget.swift +212 -0
  81. package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +228 -0
  82. package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +174 -0
  83. package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +15 -0
  84. package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +108 -0
  85. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +31 -0
  86. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +343 -0
  87. package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +117 -0
  88. package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +47 -0
  89. package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
  90. package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +55 -0
  91. package/ios/hyperswitchSDK/Core/NativeModule/WidgetAction.swift +30 -0
  92. package/ios/hyperswitchSDK/Core/NativeModule/WidgetResponseRegistry.swift +92 -0
  93. package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +12 -0
  94. package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
  95. package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1531 -0
  96. package/ios/hyperswitchSDK/CoreLite/ApplePayHandlerLite.swift +251 -0
  97. package/ios/hyperswitchSDK/CoreLite/PaymentSession+Lite.swift +25 -0
  98. package/ios/hyperswitchSDK/CoreLite/PaymentSheetView+Lite.swift +45 -0
  99. package/ios/hyperswitchSDK/CoreLite/SwiftUI+Lite.swift +48 -0
  100. package/ios/hyperswitchSDK/CoreLite/WebViewController.swift +278 -0
  101. package/ios/hyperswitchSDK/Shared/APIClient.swift +22 -0
  102. package/ios/hyperswitchSDK/Shared/Codable+UIKit.swift +75 -0
  103. package/ios/hyperswitchSDK/Shared/CustomEndpointConfiguration.swift +67 -0
  104. package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
  105. package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
  106. package/ios/hyperswitchSDK/Shared/Extensions.swift +101 -0
  107. package/ios/hyperswitchSDK/Shared/Helper.swift +40 -0
  108. package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventData.swift +125 -0
  109. package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventSubscriptionBuilder.swift +45 -0
  110. package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventType.swift +30 -0
  111. package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +151 -0
  112. package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
  113. package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +27 -0
  114. package/ios/hyperswitchSDK/Shared/Hyperswitch.swift +20 -0
  115. package/ios/hyperswitchSDK/Shared/HyperswitchConfigurationSchema.swift +54 -0
  116. package/ios/hyperswitchSDK/Shared/HyperswitchEnvironment.swift +11 -0
  117. package/ios/hyperswitchSDK/Shared/NativeLogger/Debouncer.swift +37 -0
  118. package/ios/hyperswitchSDK/Shared/NativeLogger/LogBuilder.swift +113 -0
  119. package/ios/hyperswitchSDK/Shared/NativeLogger/LogFileManager.swift +76 -0
  120. package/ios/hyperswitchSDK/Shared/NativeLogger/LogManager.swift +113 -0
  121. package/ios/hyperswitchSDK/Shared/NativeLogger/LogPayload.swift +91 -0
  122. package/ios/hyperswitchSDK/Shared/PaymentMethodType.swift +15 -0
  123. package/ios/hyperswitchSDK/Shared/PaymentSession.swift +98 -0
  124. package/ios/hyperswitchSDK/Shared/PaymentSessionConfiguration.swift +14 -0
  125. package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +33 -0
  126. package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance+Codable.swift +182 -0
  127. package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +238 -0
  128. package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +161 -0
  129. package/ios/hyperswitchSDK/Shared/SDKParams.swift +43 -0
  130. package/ios/hyperswitchSDK/Shared/SavedPaymentMethodsConfiguration.swift +20 -0
  131. package/ios/hyperswitchSDK/Shared/SwiftUIManager.swift +28 -0
  132. package/ios/hyperswitchSDK/Shared/Version.swift +12 -0
  133. package/lib/bs/JuspayTechReactNativeHyperswitch.cmi +0 -0
  134. package/lib/bs/JuspayTechReactNativeHyperswitch.cmj +0 -0
  135. package/lib/bs/JuspayTechReactNativeHyperswitch.cmt +0 -0
  136. package/lib/bs/JuspayTechReactNativeHyperswitch.mlmap +0 -0
  137. package/lib/bs/build.ninja +8 -0
  138. package/lib/bs/install.ninja +9 -0
  139. package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
  140. package/lib/bs/src/context/WidgetRegistry-JuspayTechReactNativeHyperswitch.cmt +0 -0
  141. package/lib/bs/src/core/Hyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
  142. package/lib/bs/src/core/HyperElements-JuspayTechReactNativeHyperswitch.cmt +0 -0
  143. package/lib/bs/src/hooks/usePaymentSession-JuspayTechReactNativeHyperswitch.cmt +0 -0
  144. package/lib/bs/src/hooks/useWidget-JuspayTechReactNativeHyperswitch.cmt +0 -0
  145. package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
  146. package/lib/bs/src/types/HyperTypes-JuspayTechReactNativeHyperswitch.cmt +0 -0
  147. package/lib/bs/src/types/NativeModuleTypes-JuspayTechReactNativeHyperswitch.cmt +0 -0
  148. package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
  149. package/lib/bs/src/utils/AppearanceTransformer-JuspayTechReactNativeHyperswitch.cmt +0 -0
  150. package/lib/bs/src/utils/EventValidator-JuspayTechReactNativeHyperswitch.cmt +0 -0
  151. package/lib/bs/src/utils/NewArchUtils-JuspayTechReactNativeHyperswitch.cmt +0 -0
  152. package/lib/bs/src/utils/PaymentSheetEventManager-JuspayTechReactNativeHyperswitch.cmt +0 -0
  153. package/lib/bs/src/utils/ReactNativeUtils-JuspayTechReactNativeHyperswitch.cmt +0 -0
  154. package/lib/bs/src/utils/ResponseHandler-JuspayTechReactNativeHyperswitch.cmt +0 -0
  155. package/lib/bs/src/views/CVCElement-JuspayTechReactNativeHyperswitch.cmt +0 -0
  156. package/lib/bs/src/views/NativePaymentWidget-JuspayTechReactNativeHyperswitch.cmt +0 -0
  157. package/lib/bs/src/views/NativePaymentWidgetImpl-JuspayTechReactNativeHyperswitch.cmt +0 -0
  158. package/lib/bs/src/views/PaymentElement-JuspayTechReactNativeHyperswitch.cmt +0 -0
  159. package/lib/commonjs/index.bundle.js +2 -0
  160. package/lib/commonjs/index.bundle.js.map +1 -0
  161. package/lib/module/index.bundle.js +2 -0
  162. package/lib/module/index.bundle.js.map +1 -0
  163. package/lib/typescript/babel.config.d.ts +10 -0
  164. package/lib/typescript/babel.config.d.ts.map +1 -0
  165. package/lib/typescript/eslint.config.d.mts +3 -0
  166. package/lib/typescript/eslint.config.d.mts.map +1 -0
  167. package/lib/typescript/rollup.config.d.ts +23 -0
  168. package/lib/typescript/rollup.config.d.ts.map +1 -0
  169. package/lib/typescript/scripts/bootstrap.d.ts +2 -0
  170. package/lib/typescript/scripts/bootstrap.d.ts.map +1 -0
  171. package/lib/typescript/src/context/Elements.d.ts +7 -0
  172. package/lib/typescript/src/context/Elements.d.ts.map +1 -0
  173. package/lib/typescript/src/context/HyperElements.d.ts +23 -0
  174. package/lib/typescript/src/context/HyperElements.d.ts.map +1 -0
  175. package/lib/typescript/src/context/PaymentSession.d.ts +15 -0
  176. package/lib/typescript/src/context/PaymentSession.d.ts.map +1 -0
  177. package/lib/typescript/src/context/SavedPaymentMethods.d.ts +5 -0
  178. package/lib/typescript/src/context/SavedPaymentMethods.d.ts.map +1 -0
  179. package/lib/typescript/src/context/WidgetRegistry.d.ts +8 -0
  180. package/lib/typescript/src/context/WidgetRegistry.d.ts.map +1 -0
  181. package/lib/typescript/src/context/hooks.d.ts +5 -0
  182. package/lib/typescript/src/context/hooks.d.ts.map +1 -0
  183. package/lib/typescript/src/index.d.ts +10 -0
  184. package/lib/typescript/src/index.d.ts.map +1 -0
  185. package/lib/typescript/src/modules/NativeHyperswitchSdk.d.ts +61 -0
  186. package/lib/typescript/src/modules/NativeHyperswitchSdk.d.ts.map +1 -0
  187. package/lib/typescript/src/specs/ApplePayViewNativeComponent.d.ts +10 -0
  188. package/lib/typescript/src/specs/ApplePayViewNativeComponent.d.ts.map +1 -0
  189. package/lib/typescript/src/specs/NativeHyperHeadless.d.ts +14 -0
  190. package/lib/typescript/src/specs/NativeHyperHeadless.d.ts.map +1 -0
  191. package/lib/typescript/src/specs/NativeHyperswitchModule.d.ts +32 -0
  192. package/lib/typescript/src/specs/NativeHyperswitchModule.d.ts.map +1 -0
  193. package/lib/typescript/src/specs/NativeHyperswitchSdkNative.d.ts +33 -0
  194. package/lib/typescript/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
  195. package/lib/typescript/src/specs/NativePaymentElementModule.d.ts +9 -0
  196. package/lib/typescript/src/specs/NativePaymentElementModule.d.ts.map +1 -0
  197. package/lib/typescript/src/specs/PaymentElementNativeComponent.d.ts +19 -0
  198. package/lib/typescript/src/specs/PaymentElementNativeComponent.d.ts.map +1 -0
  199. package/lib/typescript/src/specs/utils.d.ts +15 -0
  200. package/lib/typescript/src/specs/utils.d.ts.map +1 -0
  201. package/lib/typescript/src/types/NativeModuleTypes.d.ts +67 -0
  202. package/lib/typescript/src/types/NativeModuleTypes.d.ts.map +1 -0
  203. package/lib/typescript/src/types/PaymentSheetConfiguration.d.ts +255 -0
  204. package/lib/typescript/src/types/PaymentSheetConfiguration.d.ts.map +1 -0
  205. package/lib/typescript/src/types/definitions.d.ts +85 -0
  206. package/lib/typescript/src/types/definitions.d.ts.map +1 -0
  207. package/lib/typescript/src/types/elements/index.d.ts +23 -0
  208. package/lib/typescript/src/types/elements/index.d.ts.map +1 -0
  209. package/lib/typescript/src/types/paymentresult/index.d.ts +5 -0
  210. package/lib/typescript/src/types/paymentresult/index.d.ts.map +1 -0
  211. package/lib/typescript/src/types/savedPaymentMethods/index.d.ts +69 -0
  212. package/lib/typescript/src/types/savedPaymentMethods/index.d.ts.map +1 -0
  213. package/lib/typescript/src/utils/EventValidator.d.ts +9 -0
  214. package/lib/typescript/src/utils/EventValidator.d.ts.map +1 -0
  215. package/lib/typescript/src/utils/InitializationState.d.ts +13 -0
  216. package/lib/typescript/src/utils/InitializationState.d.ts.map +1 -0
  217. package/lib/typescript/src/utils/LaunchOptions.d.ts +7 -0
  218. package/lib/typescript/src/utils/LaunchOptions.d.ts.map +1 -0
  219. package/lib/typescript/src/utils/NewArchUtils.d.ts +7 -0
  220. package/lib/typescript/src/utils/NewArchUtils.d.ts.map +1 -0
  221. package/lib/typescript/src/utils/ReactNativeUtils.d.ts +3 -0
  222. package/lib/typescript/src/utils/ReactNativeUtils.d.ts.map +1 -0
  223. package/lib/typescript/src/views/CVCElement.d.ts +15 -0
  224. package/lib/typescript/src/views/CVCElement.d.ts.map +1 -0
  225. package/lib/typescript/src/views/NativePaymentWidget.d.ts +3 -0
  226. package/lib/typescript/src/views/NativePaymentWidget.d.ts.map +1 -0
  227. package/lib/typescript/src/views/NativePaymentWidgetImpl.d.ts +5 -0
  228. package/lib/typescript/src/views/NativePaymentWidgetImpl.d.ts.map +1 -0
  229. package/lib/typescript/src/views/PaymentElement.d.ts +18 -0
  230. package/lib/typescript/src/views/PaymentElement.d.ts.map +1 -0
  231. package/package.json +184 -0
  232. package/src/context/Elements.ts +80 -0
  233. package/src/context/HyperElements.tsx +81 -0
  234. package/src/context/PaymentSession.ts +121 -0
  235. package/src/context/SavedPaymentMethods.ts +80 -0
  236. package/src/context/WidgetRegistry.ts +74 -0
  237. package/src/context/hooks.ts +79 -0
  238. package/src/index.ts +53 -0
  239. package/src/modules/NativeHyperswitchSdk.ts +155 -0
  240. package/src/specs/ApplePayViewNativeComponent.ts +11 -0
  241. package/src/specs/NativeHyperHeadless.ts +22 -0
  242. package/src/specs/NativeHyperswitchModule.ts +51 -0
  243. package/src/specs/NativeHyperswitchSdkNative.ts +62 -0
  244. package/src/specs/NativePaymentElementModule.ts +25 -0
  245. package/src/specs/PaymentElementNativeComponent.ts +21 -0
  246. package/src/specs/utils.ts +15 -0
  247. package/src/types/NativeModuleTypes.ts +73 -0
  248. package/src/types/PaymentSheetConfiguration.ts +360 -0
  249. package/src/types/definitions.ts +109 -0
  250. package/src/types/elements/index.ts +33 -0
  251. package/src/types/paymentresult/index.ts +4 -0
  252. package/src/types/savedPaymentMethods/index.ts +74 -0
  253. package/src/utils/EventValidator.ts +39 -0
  254. package/src/utils/InitializationState.ts +28 -0
  255. package/src/utils/LaunchOptions.ts +41 -0
  256. package/src/utils/NewArchUtils.ts +18 -0
  257. package/src/utils/ReactNativeUtils.ts +13 -0
  258. package/src/views/CVCElement.tsx +122 -0
  259. package/src/views/NativePaymentWidget.ts +2 -0
  260. package/src/views/NativePaymentWidgetImpl.ts +16 -0
  261. package/src/views/PaymentElement.tsx +189 -0
  262. package/tsconfig.build.json +21 -0
@@ -0,0 +1,165 @@
1
+ #import "NativeHyperswitchModule.h"
2
+ #import <React/RCTComponent.h>
3
+ #import <memory>
4
+ #if __has_include("HyperswitchSdkReactNative-Swift.h")
5
+ #import "HyperswitchSdkReactNative-Swift.h"
6
+ #else
7
+ // When using use_frameworks! :linkage => :static in Podfile
8
+ #import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
9
+ #endif
10
+
11
+ /**
12
+ * ObjC/TurboModule bridge for NativeHyperswitchModule.
13
+ *
14
+ * All business logic lives in NativeHyperswitchModuleImpl.swift (Swift singleton).
15
+ * This file is responsible only for:
16
+ * 1. Registering the module under the exact name "NativeHyperswitchModule"
17
+ * (must match TurboModuleRegistry.get('NativeHyperswitchModule') in TS)
18
+ * 2. Forwarding every RCT_EXPORT_METHOD call to the Swift impl
19
+ * 3. Wiring up the TurboModule JSI spec for New Architecture
20
+ */
21
+ @implementation NativeHyperswitchModule
22
+
23
+ @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
24
+
25
+ // RCT_EXPORT_MODULE() without arguments uses the ObjC class name as the module
26
+ // name, which is "NativeHyperswitchModule" — exactly what the JS spec expects.
27
+ RCT_EXPORT_MODULE()
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // initialise
31
+ // JS: initialise(publishableKey, platformPublishableKey, profileId, environment, customEndpoints)
32
+ // Android: initialise(String publishableKey, String platformPublishableKey,
33
+ // String profileId, String environment, ReadableMap customEndpoints, Promise)
34
+ // ---------------------------------------------------------------------------
35
+ RCT_EXPORT_METHOD(initialise:(nonnull NSString *)publishableKey
36
+ platformPublishableKey:(nonnull NSString *)platformPublishableKey
37
+ profileId:(nonnull NSString *)profileId
38
+ environment:(nonnull NSString *)environment
39
+ customEndpoints:(nonnull NSDictionary *)customEndpoints
40
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
41
+ reject:(nonnull RCTPromiseRejectBlock)reject)
42
+ {
43
+ [[self moduleImpl] initialiseWithPublishableKey:publishableKey
44
+ platformPublishableKey:platformPublishableKey
45
+ profileId:profileId
46
+ environment:environment
47
+ customEndpoints:customEndpoints
48
+ resolve:resolve
49
+ reject:reject];
50
+ }
51
+
52
+ // ---------------------------------------------------------------------------
53
+ // presentPaymentSheet
54
+ // JS: presentPaymentSheet(params: { hyperswitchConfig, paymentSessionConfig, configuration })
55
+ // Android: presentPaymentSheet(ReadableMap params, Promise)
56
+ // ---------------------------------------------------------------------------
57
+ RCT_EXPORT_METHOD(presentPaymentSheet:(nonnull NSDictionary *)params
58
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
59
+ reject:(nonnull RCTPromiseRejectBlock)reject)
60
+ {
61
+ [[self moduleImpl] presentPaymentSheet:params
62
+ resolve:resolve
63
+ reject:reject];
64
+ }
65
+
66
+ // ---------------------------------------------------------------------------
67
+ // getCustomerSavedPaymentMethods
68
+ // JS: getCustomerSavedPaymentMethods(params?: sessionData)
69
+ // Android: getCustomerSavedPaymentMethods(@Nullable ReadableMap params, Promise)
70
+ // ---------------------------------------------------------------------------
71
+ RCT_EXPORT_METHOD(getCustomerSavedPaymentMethods:(nullable NSDictionary *)params
72
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
73
+ reject:(nonnull RCTPromiseRejectBlock)reject)
74
+ {
75
+ [[self moduleImpl] getCustomerSavedPaymentMethods:params
76
+ resolve:resolve
77
+ reject:reject];
78
+ }
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // getCustomerLastUsedPaymentMethodData
82
+ // JS / Android: getCustomerLastUsedPaymentMethodData(): Promise<string>
83
+ // ---------------------------------------------------------------------------
84
+ RCT_EXPORT_METHOD(getCustomerLastUsedPaymentMethodData:(nonnull RCTPromiseResolveBlock)resolve
85
+ reject:(nonnull RCTPromiseRejectBlock)reject)
86
+ {
87
+ [[self moduleImpl] getCustomerLastUsedPaymentMethodDataWithResolve:resolve
88
+ reject:reject];
89
+ }
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // getCustomerDefaultSavedPaymentMethodData
93
+ // JS / Android: getCustomerDefaultSavedPaymentMethodData(): Promise<string>
94
+ // ---------------------------------------------------------------------------
95
+ RCT_EXPORT_METHOD(getCustomerDefaultSavedPaymentMethodData:(nonnull RCTPromiseResolveBlock)resolve
96
+ reject:(nonnull RCTPromiseRejectBlock)reject)
97
+ {
98
+ [[self moduleImpl] getCustomerDefaultSavedPaymentMethodDataWithResolve:resolve
99
+ reject:reject];
100
+ }
101
+
102
+ // ---------------------------------------------------------------------------
103
+ // getCustomerSavedPaymentMethodData ← NEW — not present in previous iOS module
104
+ // JS / Android: getCustomerSavedPaymentMethodData(): Promise<string>
105
+ // ---------------------------------------------------------------------------
106
+ RCT_EXPORT_METHOD(getCustomerSavedPaymentMethodData:(nonnull RCTPromiseResolveBlock)resolve
107
+ reject:(nonnull RCTPromiseRejectBlock)reject)
108
+ {
109
+ [[self moduleImpl] getCustomerSavedPaymentMethodDataWithResolve:resolve
110
+ reject:reject];
111
+ }
112
+
113
+ // ---------------------------------------------------------------------------
114
+ // confirmWithCustomerLastUsedPaymentMethod (no params — matches Android)
115
+ // Android: confirmWithCustomerLastUsedPaymentMethod(Promise?) → TODO
116
+ // ---------------------------------------------------------------------------
117
+ RCT_EXPORT_METHOD(confirmWithCustomerLastUsedPaymentMethod:(nonnull RCTPromiseResolveBlock)resolve
118
+ reject:(nonnull RCTPromiseRejectBlock)reject)
119
+ {
120
+ [[self moduleImpl] confirmWithCustomerLastUsedPaymentMethodWithResolve:resolve
121
+ reject:reject];
122
+ }
123
+
124
+ // ---------------------------------------------------------------------------
125
+ // confirmWithCustomerDefaultPaymentMethod (no params — matches Android)
126
+ // Android: confirmWithCustomerDefaultPaymentMethod(Promise?) → TODO
127
+ // ---------------------------------------------------------------------------
128
+ RCT_EXPORT_METHOD(confirmWithCustomerDefaultPaymentMethod:(nonnull RCTPromiseResolveBlock)resolve
129
+ reject:(nonnull RCTPromiseRejectBlock)reject)
130
+ {
131
+ [[self moduleImpl] confirmWithCustomerDefaultPaymentMethodWithResolve:resolve
132
+ reject:reject];
133
+ }
134
+
135
+ // ---------------------------------------------------------------------------
136
+ // TurboModule (New Architecture) — JSI spec wiring
137
+ // The generated spec class name follows codegen convention:
138
+ // NativeHyperswitchModuleSpec → NativeHyperswitchModuleSpecJSI
139
+ // ---------------------------------------------------------------------------
140
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
141
+ (const facebook::react::ObjCTurboModule::InitParams &)params
142
+ {
143
+ return std::make_shared<facebook::react::NativeHyperswitchModuleSpecJSI>(params);
144
+ }
145
+
146
+ + (BOOL)requiresMainQueueSetup
147
+ {
148
+ return YES;
149
+ }
150
+
151
+ - (dispatch_queue_t)methodQueue
152
+ {
153
+ return dispatch_get_main_queue();
154
+ }
155
+
156
+ // ---------------------------------------------------------------------------
157
+ // Private helpers
158
+ // ---------------------------------------------------------------------------
159
+
160
+ - (NativeHyperswitchModuleImpl *)moduleImpl
161
+ {
162
+ return NativeHyperswitchModuleImpl.shared;
163
+ }
164
+
165
+ @end
@@ -0,0 +1,290 @@
1
+ //
2
+ // NativeHyperswitchModuleImpl.swift
3
+ // HyperswitchSdkReactNative
4
+ //
5
+ // Mirrors the Android ReactNativeHyperswitchModule (NativeHyperswitchModule) API exactly.
6
+ // Method signatures must stay in sync with:
7
+ // - src/specs/NativeHyperswitchModule.ts
8
+ // - android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt
9
+ //
10
+
11
+ import Foundation
12
+ import React
13
+
14
+ @objc(NativeHyperswitchModuleImpl)
15
+ public class NativeHyperswitchModuleImpl: NSObject {
16
+
17
+ @objc public static let shared: NativeHyperswitchModuleImpl = NativeHyperswitchModuleImpl()
18
+
19
+ private var hyperswitchConfiguration: HyperswitchConfiguration?
20
+ private var activePaymentSession: PaymentSession?
21
+ private var activePaymentSessionHandler: PaymentSessionHandler?
22
+
23
+ // MARK: - initialise
24
+ // Flat params — matches Android's:
25
+ // initialise(publishableKey, platformPublishableKey, profileId, environment, customEndpoints, promise)
26
+
27
+ @objc(initialiseWithPublishableKey:platformPublishableKey:profileId:environment:customEndpoints:resolve:reject:)
28
+ public func initialise(
29
+ publishableKey: String,
30
+ platformPublishableKey: String,
31
+ profileId: String,
32
+ environment: String,
33
+ customEndpoints: [String: Any],
34
+ resolve: @escaping RCTPromiseResolveBlock,
35
+ reject: @escaping RCTPromiseRejectBlock
36
+ ) {
37
+ // Build CustomEndpointConfiguration from the JS-side customEndpoints object
38
+ var endpointsConfig: CustomEndpointConfiguration? = nil
39
+ if let overrideDict = customEndpoints["overrideEndpoints"] as? [String: Any] {
40
+ endpointsConfig = .overrideEndpoints(OverrideEndpointConfiguration(
41
+ customBackendEndpoint: overrideDict["customBackendEndpoint"] as? String,
42
+ customAssetEndpoint: overrideDict["customAssetEndpoint"] as? String,
43
+ customSDKConfigEndpoint: overrideDict["customSDKConfigEndpoint"] as? String,
44
+ customConfirmEndpoint: overrideDict["customConfirmEndpoint"] as? String,
45
+ customAirborneEndpoint: overrideDict["customAirborneEndpoint"] as? String,
46
+ customLoggingEndpoint: overrideDict["customLoggingEndpoint"] as? String
47
+ ))
48
+ } else if let common = customEndpoints["commonEndpoint"] as? String, !common.isEmpty {
49
+ endpointsConfig = .commonEndpoint(common)
50
+ }
51
+
52
+ // Map environment string (Android uses "PROD"/"SANDBOX") to the Swift enum
53
+ let envEnum: HyperswitchEnvironment?
54
+ switch environment.uppercased() {
55
+ case "PROD", "PRODUCTION":
56
+ envEnum = .production
57
+ case "SANDBOX":
58
+ envEnum = .sandbox
59
+ default:
60
+ envEnum = nil
61
+ }
62
+
63
+ hyperswitchConfiguration = HyperswitchConfiguration(
64
+ publishableKey: publishableKey,
65
+ profileId: profileId.isEmpty ? nil : profileId,
66
+ customEndpoints: endpointsConfig,
67
+ environment: envEnum
68
+ )
69
+
70
+ // Resolve with a UUID handle (matches Android behaviour)
71
+ resolve(UUID().uuidString)
72
+ }
73
+
74
+ // MARK: - presentPaymentSheet
75
+ // params: { hyperswitchConfig, paymentSessionConfig: { sdkAuthorization }, configuration }
76
+ // Mirrors Android: presentPaymentSheet(params: ReadableMap?, promise: Promise?)
77
+
78
+ @objc(presentPaymentSheet:resolve:reject:)
79
+ public func presentPaymentSheet(
80
+ params: [String: Any],
81
+ resolve: @escaping RCTPromiseResolveBlock,
82
+ reject: @escaping RCTPromiseRejectBlock
83
+ ) {
84
+ guard let hyperswitchConfig = hyperswitchConfiguration else {
85
+ resolve([
86
+ "status": "failed",
87
+ "code": "NOT_INITIALIZED",
88
+ "message": "SDK not initialized. Call initialise first.",
89
+ ])
90
+ return
91
+ }
92
+
93
+ guard
94
+ let sessionConfig = params["paymentSessionConfig"] as? [String: Any],
95
+ let sdkAuthorization = sessionConfig["sdkAuthorization"] as? String,
96
+ !sdkAuthorization.isEmpty
97
+ else {
98
+ resolve([
99
+ "status": "failed",
100
+ "code": "INVALID_PARAMS",
101
+ "message": "paymentSessionConfig.sdkAuthorization is required",
102
+ ])
103
+ return
104
+ }
105
+
106
+ let session = PaymentSession(
107
+ paymentSessionConfiguration: PaymentSessionConfiguration(sdkAuthorization: sdkAuthorization),
108
+ hyperswitchConfiguration: hyperswitchConfig
109
+ )
110
+ activePaymentSession = session
111
+ activePaymentSessionHandler = nil
112
+
113
+ DispatchQueue.main.async {
114
+ guard let vc = RCTPresentedViewController() else {
115
+ resolve([
116
+ "status": "failed",
117
+ "code": "NO_VIEW_CONTROLLER",
118
+ "message": "Could not find presented view controller",
119
+ ])
120
+ return
121
+ }
122
+ session.presentPaymentSheetWithParams(
123
+ viewController: vc,
124
+ params: params,
125
+ completion: { result in
126
+ switch result {
127
+ case .completed(let data):
128
+ resolve(["status": "completed", "message": data])
129
+ case .failed(let error as NSError):
130
+ resolve([
131
+ "status": "failed",
132
+ "code": error.domain,
133
+ "message": "Payment failed: \(error.userInfo["message"] ?? "Failed")",
134
+ ])
135
+ case .canceled(let data):
136
+ resolve(["status": "cancelled", "message": data])
137
+ }
138
+ }
139
+ )
140
+ }
141
+ }
142
+
143
+ // MARK: - getCustomerSavedPaymentMethods
144
+ // params: { hyperswitchConfig, paymentSessionConfig: { sdkAuthorization }, configuration }
145
+ // Mirrors Android: getCustomerSavedPaymentMethods(params: ReadableMap?, promise: Promise)
146
+
147
+ @objc(getCustomerSavedPaymentMethods:resolve:reject:)
148
+ public func getCustomerSavedPaymentMethods(
149
+ params: [String: Any]?,
150
+ resolve: @escaping RCTPromiseResolveBlock,
151
+ reject: @escaping RCTPromiseRejectBlock
152
+ ) {
153
+ guard let hyperswitchConfig = hyperswitchConfiguration else {
154
+ resolve("{\"code\":\"error\",\"message\":\"SDK not initialized. Call initialise first.\"}")
155
+ return
156
+ }
157
+
158
+ guard
159
+ let p = params,
160
+ let sessionConfig = p["paymentSessionConfig"] as? [String: Any],
161
+ let sdkAuthorization = sessionConfig["sdkAuthorization"] as? String,
162
+ !sdkAuthorization.isEmpty
163
+ else {
164
+ resolve("{\"code\":\"error\",\"message\":\"paymentSessionConfig.sdkAuthorization is required\"}")
165
+ return
166
+ }
167
+
168
+ let session = PaymentSession(
169
+ paymentSessionConfiguration: PaymentSessionConfiguration(sdkAuthorization: sdkAuthorization),
170
+ hyperswitchConfiguration: hyperswitchConfig
171
+ )
172
+ activePaymentSession = session
173
+
174
+ session.getCustomerSavedPaymentMethods { [weak self] handler in
175
+ self?.activePaymentSessionHandler = handler
176
+ // Matches Android: JSONObject { "code": "success", "message": "Saved payment methods is initialized" }.toString()
177
+ resolve("{\"code\":\"success\",\"message\":\"Saved payment methods is initialized\"}")
178
+ }
179
+ }
180
+
181
+ // MARK: - getCustomerLastUsedPaymentMethodData
182
+ // Mirrors Android: getCustomerLastUsedPaymentMethodData(promise: Promise)
183
+ // Returns: JSON string of the PaymentMethod (snake_case keys via CodingKeys)
184
+
185
+ @objc(getCustomerLastUsedPaymentMethodDataWithResolve:reject:)
186
+ public func getCustomerLastUsedPaymentMethodData(
187
+ resolve: @escaping RCTPromiseResolveBlock,
188
+ reject: @escaping RCTPromiseRejectBlock
189
+ ) {
190
+ guard let handler = activePaymentSessionHandler else {
191
+ resolve("{\"status\":\"error\",\"message\":\"Payment session handler not initialized.\"}")
192
+ return
193
+ }
194
+
195
+ let result = handler.getCustomerLastUsedPaymentMethodData()
196
+ switch result {
197
+ case .success(let paymentMethod):
198
+ if let jsonData = try? JSONEncoder().encode(paymentMethod),
199
+ let jsonString = String(data: jsonData, encoding: .utf8)
200
+ {
201
+ resolve(jsonString)
202
+ } else {
203
+ resolve("{\"status\":\"error\",\"message\":\"Failed to encode payment method\"}")
204
+ }
205
+ case .failure(let error):
206
+ resolve("{\"status\":\"failed\",\"code\":\"\(error.code)\",\"message\":\"\(error.message)\"}")
207
+ }
208
+ }
209
+
210
+ // MARK: - getCustomerDefaultSavedPaymentMethodData
211
+ // Mirrors Android: getCustomerDefaultSavedPaymentMethodData(promise: Promise)
212
+
213
+ @objc(getCustomerDefaultSavedPaymentMethodDataWithResolve:reject:)
214
+ public func getCustomerDefaultSavedPaymentMethodData(
215
+ resolve: @escaping RCTPromiseResolveBlock,
216
+ reject: @escaping RCTPromiseRejectBlock
217
+ ) {
218
+ guard let handler = activePaymentSessionHandler else {
219
+ resolve("{\"status\":\"error\",\"message\":\"Payment session handler not initialized.\"}")
220
+ return
221
+ }
222
+
223
+ let result = handler.getCustomerDefaultSavedPaymentMethodData()
224
+ switch result {
225
+ case .success(let paymentMethod):
226
+ if let jsonData = try? JSONEncoder().encode(paymentMethod),
227
+ let jsonString = String(data: jsonData, encoding: .utf8)
228
+ {
229
+ resolve(jsonString)
230
+ } else {
231
+ resolve("{\"status\":\"error\",\"message\":\"Failed to encode payment method\"}")
232
+ }
233
+ case .failure(let error):
234
+ resolve("{\"status\":\"failed\",\"code\":\"\(error.code)\",\"message\":\"\(error.message)\"}")
235
+ }
236
+ }
237
+
238
+ // MARK: - getCustomerSavedPaymentMethodData ← NEW (not in prior iOS module)
239
+ // Mirrors Android: getCustomerSavedPaymentMethodData(promise: Promise)
240
+ // Returns: JSON array string of all saved PaymentMethod objects
241
+
242
+ @objc(getCustomerSavedPaymentMethodDataWithResolve:reject:)
243
+ public func getCustomerSavedPaymentMethodData(
244
+ resolve: @escaping RCTPromiseResolveBlock,
245
+ reject: @escaping RCTPromiseRejectBlock
246
+ ) {
247
+ guard let handler = activePaymentSessionHandler else {
248
+ resolve("{\"status\":\"error\",\"message\":\"Payment session handler not initialized.\"}")
249
+ return
250
+ }
251
+
252
+ let result = handler.getCustomerSavedPaymentMethodData()
253
+ switch result {
254
+ case .success(let paymentMethods):
255
+ if let jsonData = try? JSONEncoder().encode(paymentMethods),
256
+ let jsonString = String(data: jsonData, encoding: .utf8)
257
+ {
258
+ resolve(jsonString)
259
+ } else {
260
+ resolve("{\"status\":\"error\",\"message\":\"Failed to encode payment methods\"}")
261
+ }
262
+ case .failure(let error):
263
+ resolve("{\"status\":\"failed\",\"code\":\"\(error.code)\",\"message\":\"\(error.message)\"}")
264
+ }
265
+ }
266
+
267
+ // MARK: - confirmWithCustomerLastUsedPaymentMethod (no params — matches Android)
268
+ // Android: TODO("Not yet implemented")
269
+
270
+ @objc(confirmWithCustomerLastUsedPaymentMethodWithResolve:reject:)
271
+ public func confirmWithCustomerLastUsedPaymentMethod(
272
+ resolve: @escaping RCTPromiseResolveBlock,
273
+ reject: @escaping RCTPromiseRejectBlock
274
+ ) {
275
+ // TODO: Not yet implemented — mirrors Android
276
+ resolve("{\"status\":\"failed\",\"message\":\"Not yet implemented\"}")
277
+ }
278
+
279
+ // MARK: - confirmWithCustomerDefaultPaymentMethod (no params — matches Android)
280
+ // Android: TODO("Not yet implemented")
281
+
282
+ @objc(confirmWithCustomerDefaultPaymentMethodWithResolve:reject:)
283
+ public func confirmWithCustomerDefaultPaymentMethod(
284
+ resolve: @escaping RCTPromiseResolveBlock,
285
+ reject: @escaping RCTPromiseRejectBlock
286
+ ) {
287
+ // TODO: Not yet implemented — mirrors Android
288
+ resolve("{\"status\":\"failed\",\"message\":\"Not yet implemented\"}")
289
+ }
290
+ }
@@ -0,0 +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
+ //
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.
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 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
@@ -0,0 +1,14 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ #ifndef ApplePayButtonNativeComponent_h
5
+ #define ApplePayButtonNativeComponent_h
6
+
7
+ NS_ASSUME_NONNULL_BEGIN
8
+
9
+ @interface ApplePayView : RCTViewComponentView
10
+ @end
11
+
12
+ NS_ASSUME_NONNULL_END
13
+
14
+ #endif /* ApplePayButtonNativeComponent_h */