@juspay-tech/react-native-hyperswitch 0.2.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 (261) hide show
  1. package/HyperswitchSdkReactNative.podspec +31 -0
  2. package/android/build.gradle +119 -0
  3. package/android/gradle.properties +5 -0
  4. package/android/hyperswitch_autolinking.gradle +378 -0
  5. package/android/proguard-rules.pro +72 -0
  6. package/android/src/main/AndroidManifest.xml +25 -0
  7. package/android/src/main/assets/hyperswitch.bundle +1677 -0
  8. package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +36 -0
  9. package/android/src/main/java/com/hyperswitchsdkreactnative/activity/RedirectActivity.kt +39 -0
  10. package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactHost.kt +314 -0
  11. package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactNativeHost.kt +131 -0
  12. package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactDelegate.kt +423 -0
  13. package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactFragment.kt +335 -0
  14. package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkNativeModule.kt +143 -0
  15. package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkReactNativeModule.kt +92 -0
  16. package/android/src/main/java/com/hyperswitchsdkreactnative/provider/HyperProvider.kt +269 -0
  17. package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonView.kt +60 -0
  18. package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonViewManager.kt +76 -0
  19. package/android/src/main/java/io/hyperswitch/hyperota/HyperOtaLogger.kt +122 -0
  20. package/android/src/main/java/io/hyperswitch/logs/CrashHandler.kt +29 -0
  21. package/android/src/main/java/io/hyperswitch/logs/Debouncer.kt +20 -0
  22. package/android/src/main/java/io/hyperswitch/logs/HyperLogManager.kt +113 -0
  23. package/android/src/main/java/io/hyperswitch/logs/LogData.kt +159 -0
  24. package/android/src/main/java/io/hyperswitch/logs/LogFileManager.kt +60 -0
  25. package/android/src/main/java/io/hyperswitch/networking/HyperNetworking.kt +73 -0
  26. package/android/src/main/java/io/hyperswitch/react/Utils.kt +23 -0
  27. package/android/src/main/res/values/attrs.xml +6 -0
  28. package/android/src/main/res/values/strings.xml +5 -0
  29. package/android/src/main/res/values/theme.xml +16 -0
  30. package/ios/Modules/HyperswitchModule.swift +61 -0
  31. package/ios/Modules/HyperswitchNativeModule.swift +113 -0
  32. package/ios/Modules/HyperswitchSdkNative.h +5 -0
  33. package/ios/Modules/HyperswitchSdkNative.mm +98 -0
  34. package/ios/Modules/HyperswitchSdkReactNative.h +5 -0
  35. package/ios/Modules/HyperswitchSdkReactNative.mm +53 -0
  36. package/ios/Views/ApplePayView.h +14 -0
  37. package/ios/Views/ApplePayView.mm +89 -0
  38. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +249 -0
  39. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
  40. package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +123 -0
  41. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+SwiftUI.swift +49 -0
  42. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +49 -0
  43. package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +80 -0
  44. package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +176 -0
  45. package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +121 -0
  46. package/ios/hyperswitchSDK/Core/Models/LogPayload.swift +53 -0
  47. package/ios/hyperswitchSDK/Core/NativeLogger/Debouncer.swift +37 -0
  48. package/ios/hyperswitchSDK/Core/NativeLogger/LogBuilder.swift +91 -0
  49. package/ios/hyperswitchSDK/Core/NativeLogger/LogFileManager.swift +75 -0
  50. package/ios/hyperswitchSDK/Core/NativeLogger/LogManager.swift +113 -0
  51. package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +16 -0
  52. package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +74 -0
  53. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +28 -0
  54. package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +168 -0
  55. package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +113 -0
  56. package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +45 -0
  57. package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
  58. package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +90 -0
  59. package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +9 -0
  60. package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
  61. package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1673 -0
  62. package/ios/hyperswitchSDK/Shared/APIClient.swift +21 -0
  63. package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
  64. package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
  65. package/ios/hyperswitchSDK/Shared/Extensions.swift +31 -0
  66. package/ios/hyperswitchSDK/Shared/Helper.swift +16 -0
  67. package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +137 -0
  68. package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
  69. package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +25 -0
  70. package/ios/hyperswitchSDK/Shared/PaymentSession.swift +43 -0
  71. package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +30 -0
  72. package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +264 -0
  73. package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +494 -0
  74. package/ios/hyperswitchSDK/Shared/SwiftUIManager.swift +28 -0
  75. package/ios/hyperswitchSDK/Shared/Version.swift +12 -0
  76. package/lib/bs/JuspayTechReactNativeHyperswitch.cmi +0 -0
  77. package/lib/bs/JuspayTechReactNativeHyperswitch.cmj +0 -0
  78. package/lib/bs/JuspayTechReactNativeHyperswitch.cmt +0 -0
  79. package/lib/bs/JuspayTechReactNativeHyperswitch.mlmap +5 -0
  80. package/lib/bs/build.ninja +29 -0
  81. package/lib/bs/install.ninja +25 -0
  82. package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi +0 -0
  83. package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj +0 -0
  84. package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
  85. package/lib/bs/src/context/HyperProvider.ast +0 -0
  86. package/lib/bs/src/context/HyperProvider.d +1 -0
  87. package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi +0 -0
  88. package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj +0 -0
  89. package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
  90. package/lib/bs/src/hooks/useHyper.ast +0 -0
  91. package/lib/bs/src/hooks/useHyper.d +1 -0
  92. package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi +0 -0
  93. package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj +0 -0
  94. package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
  95. package/lib/bs/src/modules/NativeHyperswitchSdk.ast +0 -0
  96. package/lib/bs/src/modules/NativeHyperswitchSdk.d +1 -0
  97. package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi +0 -0
  98. package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj +0 -0
  99. package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
  100. package/lib/bs/src/types/PaymentSheetConfiguration.ast +0 -0
  101. package/lib/bs/src/types/PaymentSheetConfiguration.d +1 -0
  102. package/lib/commonjs/context/HyperProvider.gen.js +16 -0
  103. package/lib/commonjs/context/HyperProvider.gen.js.map +1 -0
  104. package/lib/commonjs/context/HyperProvider.res +78 -0
  105. package/lib/commonjs/context/HyperProvider.res.js +98 -0
  106. package/lib/commonjs/context/HyperProvider.res.js.map +1 -0
  107. package/lib/commonjs/hooks/useHyper.gen.js +15 -0
  108. package/lib/commonjs/hooks/useHyper.gen.js.map +1 -0
  109. package/lib/commonjs/hooks/useHyper.res +142 -0
  110. package/lib/commonjs/hooks/useHyper.res.js +152 -0
  111. package/lib/commonjs/hooks/useHyper.res.js.map +1 -0
  112. package/lib/commonjs/index.js +26 -0
  113. package/lib/commonjs/index.js.map +1 -0
  114. package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js +6 -0
  115. package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js.map +1 -0
  116. package/lib/commonjs/modules/NativeHyperswitchSdk.res +55 -0
  117. package/lib/commonjs/modules/NativeHyperswitchSdk.res.js +14 -0
  118. package/lib/commonjs/modules/NativeHyperswitchSdk.res.js.map +1 -0
  119. package/lib/commonjs/package.json +1 -0
  120. package/lib/commonjs/shims/Js.shim.js +2 -0
  121. package/lib/commonjs/shims/Js.shim.js.map +1 -0
  122. package/lib/commonjs/specs/ApplePayButtonNativeComponent.ts +11 -0
  123. package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js +10 -0
  124. package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
  125. package/lib/commonjs/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
  126. package/lib/commonjs/specs/NativeHyperswitchSdkNative.js +9 -0
  127. package/lib/commonjs/specs/NativeHyperswitchSdkNative.js.map +1 -0
  128. package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js +9 -0
  129. package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
  130. package/lib/commonjs/types/PaymentSheetConfiguration.gen.js +2 -0
  131. package/lib/commonjs/types/PaymentSheetConfiguration.gen.js.map +1 -0
  132. package/lib/commonjs/types/PaymentSheetConfiguration.res +215 -0
  133. package/lib/commonjs/types/PaymentSheetConfiguration.res.js +4 -0
  134. package/lib/commonjs/types/PaymentSheetConfiguration.res.js.map +1 -0
  135. package/lib/module/context/HyperProvider.gen.js +11 -0
  136. package/lib/module/context/HyperProvider.gen.js.map +1 -0
  137. package/lib/module/context/HyperProvider.res +78 -0
  138. package/lib/module/context/HyperProvider.res.js +91 -0
  139. package/lib/module/context/HyperProvider.res.js.map +1 -0
  140. package/lib/module/hooks/useHyper.gen.js +10 -0
  141. package/lib/module/hooks/useHyper.gen.js.map +1 -0
  142. package/lib/module/hooks/useHyper.res +142 -0
  143. package/lib/module/hooks/useHyper.res.js +142 -0
  144. package/lib/module/hooks/useHyper.res.js.map +1 -0
  145. package/lib/module/index.js +5 -0
  146. package/lib/module/index.js.map +1 -0
  147. package/lib/module/modules/NativeHyperswitchSdk.gen.js +4 -0
  148. package/lib/module/modules/NativeHyperswitchSdk.gen.js.map +1 -0
  149. package/lib/module/modules/NativeHyperswitchSdk.res +55 -0
  150. package/lib/module/modules/NativeHyperswitchSdk.res.js +9 -0
  151. package/lib/module/modules/NativeHyperswitchSdk.res.js.map +1 -0
  152. package/lib/module/package.json +1 -0
  153. package/lib/module/shims/Js.shim.js +2 -0
  154. package/lib/module/shims/Js.shim.js.map +1 -0
  155. package/lib/module/specs/ApplePayButtonNativeComponent.ts +11 -0
  156. package/lib/module/specs/GooglePayButtonNativeComponent.android.js +5 -0
  157. package/lib/module/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
  158. package/lib/module/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
  159. package/lib/module/specs/NativeHyperswitchSdkNative.js +5 -0
  160. package/lib/module/specs/NativeHyperswitchSdkNative.js.map +1 -0
  161. package/lib/module/specs/NativeHyperswitchSdkReactNative.js +5 -0
  162. package/lib/module/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
  163. package/lib/module/types/PaymentSheetConfiguration.gen.js +2 -0
  164. package/lib/module/types/PaymentSheetConfiguration.gen.js.map +1 -0
  165. package/lib/module/types/PaymentSheetConfiguration.res +215 -0
  166. package/lib/module/types/PaymentSheetConfiguration.res.js +4 -0
  167. package/lib/module/types/PaymentSheetConfiguration.res.js.map +1 -0
  168. package/lib/typescript/commonjs/babel.config.d.ts +10 -0
  169. package/lib/typescript/commonjs/babel.config.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/eslint.config.d.mts +3 -0
  171. package/lib/typescript/commonjs/eslint.config.d.mts.map +1 -0
  172. package/lib/typescript/commonjs/package.json +1 -0
  173. package/lib/typescript/commonjs/scripts/bootstrap.d.ts +2 -0
  174. package/lib/typescript/commonjs/scripts/bootstrap.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts +17 -0
  176. package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts +20 -0
  178. package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts +10 -0
  180. package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts.map +1 -0
  181. package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts +95 -0
  182. package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/src/index.d.ts +4 -0
  184. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
  186. package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
  188. package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/src/shims/Js.shim.d.ts +4 -0
  190. package/lib/typescript/commonjs/src/shims/Js.shim.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
  192. package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
  194. package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
  196. package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
  198. package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
  200. package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
  202. package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
  204. package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
  205. package/lib/typescript/module/babel.config.d.ts +10 -0
  206. package/lib/typescript/module/babel.config.d.ts.map +1 -0
  207. package/lib/typescript/module/eslint.config.d.mts +3 -0
  208. package/lib/typescript/module/eslint.config.d.mts.map +1 -0
  209. package/lib/typescript/module/package.json +1 -0
  210. package/lib/typescript/module/scripts/bootstrap.d.ts +2 -0
  211. package/lib/typescript/module/scripts/bootstrap.d.ts.map +1 -0
  212. package/lib/typescript/module/src/context/HyperProvider.gen.d.ts +17 -0
  213. package/lib/typescript/module/src/context/HyperProvider.gen.d.ts.map +1 -0
  214. package/lib/typescript/module/src/context/HyperProvider.res.d.ts +20 -0
  215. package/lib/typescript/module/src/context/HyperProvider.res.d.ts.map +1 -0
  216. package/lib/typescript/module/src/hooks/useHyper.gen.d.ts +10 -0
  217. package/lib/typescript/module/src/hooks/useHyper.gen.d.ts.map +1 -0
  218. package/lib/typescript/module/src/hooks/useHyper.res.d.ts +95 -0
  219. package/lib/typescript/module/src/hooks/useHyper.res.d.ts.map +1 -0
  220. package/lib/typescript/module/src/index.d.ts +4 -0
  221. package/lib/typescript/module/src/index.d.ts.map +1 -0
  222. package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
  223. package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
  224. package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
  225. package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
  226. package/lib/typescript/module/src/shims/Js.shim.d.ts +4 -0
  227. package/lib/typescript/module/src/shims/Js.shim.d.ts.map +1 -0
  228. package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
  229. package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
  230. package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
  231. package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
  232. package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
  233. package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
  234. package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
  235. package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
  236. package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
  237. package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
  238. package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
  239. package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
  240. package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
  241. package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
  242. package/package.json +196 -0
  243. package/src/context/HyperProvider.gen.tsx +26 -0
  244. package/src/context/HyperProvider.res +78 -0
  245. package/src/context/HyperProvider.res.js +112 -0
  246. package/src/hooks/useHyper.gen.tsx +18 -0
  247. package/src/hooks/useHyper.res +142 -0
  248. package/src/hooks/useHyper.res.js +157 -0
  249. package/src/index.tsx +13 -0
  250. package/src/modules/NativeHyperswitchSdk.gen.tsx +25 -0
  251. package/src/modules/NativeHyperswitchSdk.res +55 -0
  252. package/src/modules/NativeHyperswitchSdk.res.js +10 -0
  253. package/src/shims/Js.shim.ts +5 -0
  254. package/src/specs/ApplePayButtonNativeComponent.ts +11 -0
  255. package/src/specs/GooglePayButtonNativeComponent.android.ts +12 -0
  256. package/src/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
  257. package/src/specs/NativeHyperswitchSdkNative.ts +33 -0
  258. package/src/specs/NativeHyperswitchSdkReactNative.ts +17 -0
  259. package/src/types/PaymentSheetConfiguration.gen.tsx +202 -0
  260. package/src/types/PaymentSheetConfiguration.res +215 -0
  261. package/src/types/PaymentSheetConfiguration.res.js +2 -0
@@ -0,0 +1,53 @@
1
+ #import "HyperswitchSdkReactNative.h"
2
+
3
+ #if __has_include("HyperswitchSdkReactNative-Swift.h")
4
+ #import "HyperswitchSdkReactNative-Swift.h"
5
+ #else
6
+ // When using use_frameworks! :linkage => :static in Podfile
7
+ #import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
8
+ #endif
9
+
10
+
11
+ @implementation HyperswitchSdkReactNative
12
+ RCT_EXPORT_MODULE()
13
+
14
+ //- (instancetype)init
15
+ //{
16
+ // self = [super init];
17
+ // if (self) {
18
+ // StripeSdkImpl.shared.emitter = self;
19
+ // }
20
+ // return self;
21
+ //}
22
+
23
+ RCT_EXPORT_METHOD(initialise:(nonnull NSString *)publishableKey
24
+ customBackendUrl:(nullable NSString *)customBackendUrl
25
+ customLogUrl:(nullable NSString *)customLogUrl
26
+ customParams:(nullable NSDictionary *)customParams
27
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
28
+ reject:(nonnull RCTPromiseRejectBlock)reject) {
29
+ [HyperswitchModule.shared initialiseWithPublishableKey:publishableKey customBackendUrl:customBackendUrl customLogUrl:customLogUrl customParams:customParams resolve:resolve reject:reject];
30
+ }
31
+
32
+ RCT_EXPORT_METHOD(initPaymentSession:(nonnull NSString *)paymentIntentClientSecret
33
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
34
+ reject:(nonnull RCTPromiseRejectBlock)reject) {
35
+
36
+ [HyperswitchModule.shared initPaymentSessionWithpaymentIntentClientSecret:paymentIntentClientSecret resolve:resolve reject:reject];
37
+ }
38
+
39
+ RCT_EXPORT_METHOD(presentPaymentSheet:(nonnull NSDictionary *)configuration
40
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
41
+ reject:(nonnull RCTPromiseRejectBlock)reject)
42
+ {
43
+ [HyperswitchModule.shared presentPaymentSheetWithConfiguration:configuration resolver:resolve rejecter:reject];
44
+ }
45
+
46
+
47
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
48
+ (const facebook::react::ObjCTurboModule::InitParams &)params
49
+ {
50
+ return std::make_shared<facebook::react::NativeHyperswitchSdkReactNativeSpecJSI>(params);
51
+ }
52
+
53
+ @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 */
@@ -0,0 +1,89 @@
1
+ #import "ApplePayView.h"
2
+ #import <PassKit/PassKit.h>
3
+
4
+ #import <react/renderer/components/HyperswitchSdkReactNativeSpec/ComponentDescriptors.h>
5
+ #import <react/renderer/components/HyperswitchSdkReactNativeSpec/EventEmitters.h>
6
+ #import <react/renderer/components/HyperswitchSdkReactNativeSpec/Props.h>
7
+ #import <react/renderer/components/HyperswitchSdkReactNativeSpec/RCTComponentViewHelpers.h>
8
+
9
+ #import "RCTFabricComponentsPlugins.h"
10
+
11
+ using namespace facebook::react;
12
+
13
+ @interface ApplePayView () <RCTApplePayViewViewProtocol>
14
+
15
+ @property (nonatomic, strong, nullable) PKPaymentButton *button;
16
+
17
+ @end
18
+
19
+ @implementation ApplePayView {
20
+ PKPaymentButton *_paymentButton;
21
+ }
22
+
23
+ + (ComponentDescriptorProvider)componentDescriptorProvider
24
+ {
25
+ return concreteComponentDescriptorProvider<ApplePayViewComponentDescriptor>();
26
+ }
27
+
28
+ - (instancetype)initWithFrame:(CGRect)frame
29
+ {
30
+ if (self = [super initWithFrame:frame]) {
31
+ static const auto defaultProps = std::make_shared<const ApplePayViewProps>();
32
+ _props = defaultProps;
33
+
34
+ [self setupDefaultButton];
35
+ }
36
+
37
+ return self;
38
+ }
39
+
40
+ - (void)setupDefaultButton {
41
+ [self setupButtonWithType:PKPaymentButtonTypePlain style:PKPaymentButtonStyleBlack cornerRadius:4.0];
42
+ }
43
+
44
+ - (void)setupButtonWithType:(PKPaymentButtonType)type style:(PKPaymentButtonStyle)style cornerRadius:(CGFloat)cornerRadius {
45
+ [_paymentButton removeFromSuperview];
46
+
47
+ _paymentButton = [[PKPaymentButton alloc] initWithPaymentButtonType:type paymentButtonStyle:style];
48
+ _paymentButton.cornerRadius = cornerRadius;
49
+
50
+ // [_paymentButton addTarget:self action:@selector(applePayButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
51
+
52
+ [self addSubview:_paymentButton];
53
+ self.contentView = _paymentButton;
54
+ }
55
+
56
+ - (PKPaymentButtonType)paymentButtonTypeFromString:(NSString *)type {
57
+ if ([type isEqualToString:@"buy"]) return PKPaymentButtonTypeBuy;
58
+ if ([type isEqualToString:@"setUp"]) return PKPaymentButtonTypeSetUp;
59
+ if ([type isEqualToString:@"inStore"]) return PKPaymentButtonTypeInStore;
60
+ if ([type isEqualToString:@"donate"]) return PKPaymentButtonTypeDonate;
61
+ if ([type isEqualToString:@"checkout"]) return PKPaymentButtonTypeCheckout;
62
+ if ([type isEqualToString:@"book"]) return PKPaymentButtonTypeBook;
63
+ if ([type isEqualToString:@"subscribe"]) return PKPaymentButtonTypeSubscribe;
64
+ return PKPaymentButtonTypePlain;
65
+ }
66
+
67
+ - (PKPaymentButtonStyle)paymentButtonStyleFromString:(NSString *)style {
68
+ if ([style isEqualToString:@"white"]) return PKPaymentButtonStyleWhite;
69
+ if ([style isEqualToString:@"whiteOutline"]) return PKPaymentButtonStyleWhiteOutline;
70
+ return PKPaymentButtonStyleBlack;
71
+ }
72
+
73
+
74
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
75
+ {
76
+ [super updateProps:props oldProps:oldProps];
77
+ }
78
+
79
+ - (void)layoutSubviews {
80
+ [super layoutSubviews];
81
+ _paymentButton.frame = self.bounds;
82
+ }
83
+
84
+ Class<RCTComponentViewProtocol> ApplePayViewCls(void)
85
+ {
86
+ return ApplePayView.class;
87
+ }
88
+
89
+ @end
@@ -0,0 +1,249 @@
1
+ //
2
+ // ApplePayHandler.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Shivam Shashank on 10/12/22.
6
+ //
7
+
8
+ import Foundation
9
+ import PassKit
10
+ import React
11
+
12
+ internal class ApplePayHandler: NSObject {
13
+
14
+ var paymentStatus: PKPaymentAuthorizationStatus? = .failure
15
+ var callback: RCTResponseSenderBlock?
16
+
17
+ internal func startPayment(rnMessage: String, rnCallback: @escaping RCTResponseSenderBlock, presentCallback: RCTResponseSenderBlock?) {
18
+
19
+ callback = rnCallback
20
+ var requiredBillingContactFields:Set<PKContactField>?
21
+ var requiredShippingContactFields:Set<PKContactField>?
22
+
23
+ guard let dict = rnMessage.toJSON() as? [String: AnyObject] else {
24
+ presentCallback?([])
25
+ rnCallback([["status": "Error", "message": "01"]])
26
+ return
27
+ }
28
+
29
+ guard let payment_request_data = dict["payment_request_data"] else {
30
+ presentCallback?([])
31
+ callback?([["status": "Error", "message": "02"]])
32
+ callback = nil
33
+ return
34
+ }
35
+
36
+ guard let countryCode = payment_request_data["country_code"] as? String else {
37
+ presentCallback?([])
38
+ callback?([["status": "Error", "message": "03"]])
39
+ callback = nil
40
+ return
41
+ }
42
+
43
+ guard let currencyCode = payment_request_data["currency_code"] as? String else {
44
+ presentCallback?([])
45
+ callback?([["status": "Error", "message": "04"]])
46
+ callback = nil
47
+ return
48
+ }
49
+ guard let total = payment_request_data["total"] as? [String: AnyObject] else {
50
+ presentCallback?([])
51
+ callback?([["status": "Error", "message": "05"]])
52
+ callback = nil
53
+ return
54
+ }
55
+
56
+ guard let amount = total["amount"] as? String,
57
+ let label = total["label"] as? String,
58
+ let type = total["type"] as? String else {
59
+ presentCallback?([])
60
+ callback?([["status": "Error", "message": "06"]])
61
+ callback = nil
62
+ return
63
+ }
64
+
65
+ guard let merchant_capabilities_array = payment_request_data["merchant_capabilities"] as? Array<String> else {
66
+ presentCallback?([])
67
+ callback?([["status": "Error", "message": "07"]])
68
+ callback = nil
69
+ return
70
+ }
71
+
72
+ guard let merchantIdentifier = payment_request_data["merchant_identifier"] as? String else{
73
+ presentCallback?([])
74
+ callback?([["status": "Error", "message": "08"]])
75
+ callback = nil
76
+ return
77
+ }
78
+
79
+ guard let supported_networks_array = payment_request_data["supported_networks"] as? Array<String> else{
80
+ presentCallback?([])
81
+ callback?([["status": "Error", "message": "09"]])
82
+ callback = nil
83
+ return
84
+ }
85
+
86
+ let supportedNetworks = supported_networks_array.compactMap { (string) -> PKPaymentNetwork? in
87
+ switch string {
88
+ case "visa":
89
+ return .visa
90
+ case "masterCard":
91
+ return .masterCard
92
+ case "amex":
93
+ return .amex
94
+ case "discover":
95
+ return .discover
96
+ case "quicPay":
97
+ return .quicPay
98
+ default:
99
+ return nil
100
+ }
101
+ }
102
+
103
+ if let required_billing_contact_fields = payment_request_data["required_billing_contact_fields"] as? Array<String> {
104
+ requiredBillingContactFields = Set(required_billing_contact_fields.compactMap(mapToPKContactField))
105
+ }
106
+
107
+ if let required_shipping_contact_fields = payment_request_data["required_shipping_contact_fields"] as? Array<String> {
108
+ requiredShippingContactFields = Set(required_shipping_contact_fields.compactMap(mapToPKContactField))
109
+ }
110
+
111
+ let paymentSummaryItems = PKPaymentSummaryItem(label: label, amount: NSDecimalNumber(string: amount), type: (type == "final") ? .final : .pending)
112
+ let paymentRequest = PKPaymentRequest()
113
+ paymentRequest.paymentSummaryItems = [paymentSummaryItems]
114
+ paymentRequest.merchantIdentifier = merchantIdentifier
115
+ paymentRequest.countryCode = countryCode
116
+ paymentRequest.currencyCode = currencyCode
117
+ paymentRequest.requiredShippingContactFields = requiredShippingContactFields ?? []
118
+ paymentRequest.requiredBillingContactFields = requiredBillingContactFields ?? []
119
+ paymentRequest.supportedNetworks = supportedNetworks
120
+ for val in merchant_capabilities_array {
121
+ paymentRequest.merchantCapabilities = (val == "supports3DS") ? .threeDSecure : .debit
122
+ }
123
+
124
+ /// Create and present the PKPaymentAuthorizationController
125
+ guard
126
+ PKPaymentAuthorizationController.canMakePayments(),
127
+ !paymentRequest.merchantIdentifier.isEmpty,
128
+ PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) != nil
129
+ else {
130
+ presentCallback?([])
131
+ callback?([["status": "Error", "message": "10"]])
132
+ callback = nil
133
+ return
134
+ }
135
+ let paymentController = PKPaymentAuthorizationController(paymentRequest: paymentRequest)
136
+ paymentController.delegate = self
137
+ paymentController.present(completion: { presented in
138
+ presentCallback?([])
139
+ if presented {
140
+ self.paymentStatus = nil
141
+ } else {
142
+ self.callback?([["status": "Error", "message": "11"]])
143
+ self.callback = nil
144
+ }
145
+ })
146
+ }
147
+ }
148
+
149
+ /// Extension to conform to PKPaymentAuthorizationControllerDelegate
150
+ extension ApplePayHandler: PKPaymentAuthorizationControllerDelegate {
151
+
152
+ /// Handle successful payment authorization
153
+ internal func paymentAuthorizationController(_ controller: PKPaymentAuthorizationController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) {
154
+
155
+ let errors = [Error]()
156
+ let status = PKPaymentAuthorizationStatus.success
157
+ self.paymentStatus = status
158
+
159
+ let dataString = payment.token.paymentData.base64EncodedString()
160
+
161
+ var paymentType = "debit"
162
+ switch payment.token.paymentMethod.type {
163
+ case .debit: paymentType = "debit"
164
+ case .credit: paymentType = "credit"
165
+ case .store: paymentType = "store"
166
+ case .prepaid: paymentType = "prepaid"
167
+ case .eMoney: paymentType = "eMoney"
168
+ default: paymentType = "unknown"
169
+ }
170
+
171
+ self.callback?(
172
+ [[
173
+ "status": "Success",
174
+ "payment_data": dataString,
175
+ "payment_method": [
176
+ "type": paymentType,
177
+ "network": payment.token.paymentMethod.network ?? "",
178
+ "display_name": payment.token.paymentMethod.displayName ?? ""
179
+ ],
180
+ "transaction_identifier": payment.token.transactionIdentifier,
181
+ "billing_contact": convertPKContactToDictionary(payment.billingContact),
182
+ "shipping_contact": convertPKContactToDictionary(payment.shippingContact)
183
+ ]]
184
+ )
185
+ completion(PKPaymentAuthorizationResult(status: paymentStatus ?? .failure, errors: errors))
186
+ }
187
+ /// Handle completion of the payment authorization flow
188
+ internal func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) {
189
+ controller.dismiss {
190
+ DispatchQueue.main.async {
191
+ if self.paymentStatus == .failure {
192
+ self.callback?([["status": "Failed"]])
193
+ } else if self.paymentStatus == nil {
194
+ self.callback?([["status": "Cancelled"]])
195
+ }
196
+ }
197
+ }
198
+ }
199
+
200
+ private func mapToPKContactField(_ string: String) -> PKContactField? {
201
+ switch string {
202
+ case "postalAddress": return .postalAddress
203
+ case "email": return .emailAddress
204
+ case "phone": return .phoneNumber
205
+ case "name": return .name
206
+ case "phoneticName": return .phoneticName
207
+ default: return nil
208
+ }
209
+ }
210
+
211
+ private func convertPKContactToDictionary(_ contact: PKContact?) -> [String: Any] {
212
+ var contactDict = [String: Any]()
213
+
214
+ if let name = contact?.name {
215
+ var nameDict = [String: Any]()
216
+ nameDict["givenName"] = name.givenName
217
+ nameDict["familyName"] = name.familyName
218
+ nameDict["namePrefix"] = name.namePrefix
219
+ nameDict["nameSuffix"] = name.nameSuffix
220
+ nameDict["nickname"] = name.nickname
221
+ nameDict["middleName"] = name.middleName
222
+ // nameDict["phoneticRepresentation"] = name.phoneticRepresentation
223
+ contactDict["name"] = nameDict
224
+ }
225
+
226
+ if let postalAddress = contact?.postalAddress {
227
+ var addressDict = [String: Any]()
228
+ addressDict["street"] = postalAddress.street
229
+ addressDict["city"] = postalAddress.city
230
+ addressDict["state"] = postalAddress.state
231
+ addressDict["postalCode"] = postalAddress.postalCode
232
+ addressDict["country"] = postalAddress.country
233
+ addressDict["subLocality"] = postalAddress.subLocality
234
+ addressDict["subAdministrativeArea"] = postalAddress.subAdministrativeArea
235
+ addressDict["isoCountryCode"] = postalAddress.isoCountryCode
236
+ contactDict["postalAddress"] = addressDict
237
+ }
238
+
239
+ if let phoneNumber = contact?.phoneNumber {
240
+ contactDict["phoneNumber"] = phoneNumber.stringValue
241
+ }
242
+
243
+ if let emailAddress = contact?.emailAddress {
244
+ contactDict["emailAddress"] = emailAddress
245
+ }
246
+
247
+ return contactDict
248
+ }
249
+ }
@@ -0,0 +1,18 @@
1
+ //
2
+ // ApplePayViewManager.m
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 20/06/24.
6
+ //
7
+
8
+ #import <React/RCTViewManager.h>
9
+
10
+ @interface RCT_EXTERN_MODULE(ApplePayViewManager, RCTViewManager)
11
+
12
+ RCT_EXPORT_VIEW_PROPERTY(buttonStyle, NSString)
13
+ RCT_EXPORT_VIEW_PROPERTY(buttonType, NSString)
14
+ RCT_EXPORT_VIEW_PROPERTY(color, NSString)
15
+ RCT_EXPORT_VIEW_PROPERTY(cornerRadius,CGFloat)
16
+ RCT_EXPORT_VIEW_PROPERTY(onPaymentResultCallback, RCTDirectEventBlock)
17
+
18
+ @end
@@ -0,0 +1,123 @@
1
+ //
2
+ // ApplePayViewManager.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 20/06/24.
6
+ //
7
+
8
+ import UIKit
9
+ import PassKit
10
+ import React
11
+
12
+
13
+ @objc(ApplePayViewManager)
14
+ internal class ApplePayViewManager: RCTViewManager {
15
+
16
+ override func view() -> (ApplePayView) {
17
+ return ApplePayView()
18
+ }
19
+
20
+ @objc override static func requiresMainQueueSetup() -> Bool {
21
+ return false
22
+ }
23
+ }
24
+
25
+ internal class ApplePayView : UIView {
26
+
27
+ private var button: PKPaymentButton?
28
+ private var paymentHandler = ApplePayHandler()
29
+ @objc private var onPaymentResultCallback: RCTDirectEventBlock?
30
+
31
+ @objc var buttonStyle: String = "" {
32
+ didSet {
33
+ setButton(setButtonType:buttonType, setButtonStyle: buttonStyle, setButtonCornerRadius: cornerRadius)
34
+ }
35
+ }
36
+ @objc var buttonType: String = "" {
37
+ didSet {
38
+ setButton(setButtonType:buttonType, setButtonStyle: buttonStyle, setButtonCornerRadius: cornerRadius)
39
+ }
40
+ }
41
+ @objc var color: String = "" {
42
+ didSet {
43
+ setButton(setButtonType:buttonType, setButtonStyle: buttonStyle, setButtonCornerRadius: cornerRadius)
44
+ }
45
+ }
46
+ @objc var cornerRadius: CGFloat = 0.0 {
47
+ didSet {
48
+ setButton(setButtonType: buttonType, setButtonStyle: buttonStyle, setButtonCornerRadius: cornerRadius)
49
+ }
50
+ }
51
+
52
+ override init(frame: CGRect) {
53
+ super.init(frame: frame)
54
+
55
+ let cornerRadiusValue: CGFloat = 4.0
56
+ let buttonType = "plain"
57
+ let buttonStyle = "black"
58
+ setButton(setButtonType: buttonType, setButtonStyle: buttonStyle, setButtonCornerRadius: cornerRadiusValue)
59
+ }
60
+
61
+ required init?(coder: NSCoder) {
62
+ super.init(coder: coder)
63
+ }
64
+
65
+ private func setButton(setButtonType: String?, setButtonStyle: String?, setButtonCornerRadius cornerRadius: CGFloat?) {
66
+ for view in subviews {
67
+ view.removeFromSuperview()
68
+ }
69
+
70
+ var type: PKPaymentButtonType
71
+ var style: PKPaymentButtonStyle
72
+
73
+ switch setButtonType {
74
+ case "buy":
75
+ type = .buy
76
+ case "setUp":
77
+ type = .setUp
78
+ case "inStore":
79
+ type = .inStore
80
+ case "donate":
81
+ type = .donate
82
+ case "checkout":
83
+ type = .checkout
84
+ case "book":
85
+ type = .book
86
+ case "subscribe":
87
+ type = .subscribe
88
+ default:
89
+ type = .plain
90
+ }
91
+
92
+ switch setButtonStyle {
93
+ case "white":
94
+ style = .white
95
+ case "whiteOutline":
96
+ style = .whiteOutline
97
+ default:
98
+ style = .black
99
+ }
100
+
101
+ button = PKPaymentButton(paymentButtonType: type, paymentButtonStyle: style)
102
+ button?.addTarget(self, action: #selector(touchUpInside(_:)), for: .touchUpInside)
103
+ if let cornerRadius = cornerRadius {
104
+ button?.cornerRadius = cornerRadius
105
+ }
106
+
107
+ if let buttonView = button{
108
+ addSubview(buttonView)
109
+ }
110
+ }
111
+
112
+ @objc private func touchUpInside(_ button: PKPaymentButton) {
113
+ if let onPaymentResultCallback = onPaymentResultCallback {
114
+ onPaymentResultCallback(nil)
115
+ }
116
+
117
+ }
118
+
119
+ internal override func layoutSubviews() {
120
+ super.layoutSubviews()
121
+ button?.frame = bounds
122
+ }
123
+ }
@@ -0,0 +1,49 @@
1
+ //
2
+ // PaymentSheetView+SwiftUI.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Balaganesh on 09/12/22.
6
+ //
7
+
8
+ import Foundation
9
+ import SwiftUI
10
+ import React
11
+
12
+ /// Extension on the PaymentSheet class to provide a SwiftUI integration for presenting the payment sheet.
13
+ extension PaymentSheet {
14
+
15
+ /// A SwiftUI View struct that represents a button for presenting the payment sheet.
16
+ @available(iOS 13.0, *)
17
+ public struct PaymentButton<Content: View>: View {
18
+ private let paymentSession: PaymentSession
19
+ private let configuration: Configuration
20
+ private let content: Content
21
+ private let completion: (PaymentSheetResult) -> ()
22
+
23
+ @Environment(\.viewController) private var viewControllerHolder: UIViewController?
24
+
25
+ /// Initializer for the PaymentButton.
26
+ public init(
27
+ paymentSession: PaymentSession,
28
+ configuration: Configuration,
29
+ onCompletion: @escaping (PaymentSheetResult) -> Void,
30
+ @ViewBuilder content: () -> Content
31
+ ) {
32
+ self.paymentSession = paymentSession
33
+ self.configuration = configuration
34
+ self.completion = onCompletion
35
+ self.content = content()
36
+ }
37
+
38
+ /// The body of the PaymentButton view.
39
+ public var body: some View {
40
+ Button(action: {
41
+ if let vc = viewControllerHolder {
42
+ paymentSession.presentPaymentSheet(viewController: vc, configuration: configuration, completion: completion)
43
+ }
44
+ }) {
45
+ content
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,49 @@
1
+ //
2
+ // PaymentSheetView+UIKit.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 15/12/23.
6
+ //
7
+
8
+ import Foundation
9
+ import React
10
+
11
+ /// Extension on the PaymentSheet class to handle the presentation of the payment sheet view.
12
+ internal extension PaymentSheet {
13
+
14
+ /// Method to present the payment sheet view with a given root view and completion handler.
15
+ private func presentWithRootView(from presentingViewController: UIViewController, rootView: UIView?, completion: @escaping (PaymentSheetResult) -> ()) {
16
+
17
+ /// Set the completion closure for handling the payment sheet result.
18
+ self.completion = completion
19
+
20
+ /// Set the response handler for the RNViewManager to be the current PaymentSheet instance.
21
+ RNFabricManager.sharedInstance.responseHandler = self
22
+
23
+ /// Create a new UIViewController to present the payment sheet view.
24
+ let paymentSheetViewController = HyperUIViewController()
25
+
26
+ /// Set the modal presentation style to cover the entire screen.
27
+ paymentSheetViewController.modalPresentationStyle = .overFullScreen
28
+
29
+ /// Set the view of the payment sheet view controller to the provided root view.
30
+ paymentSheetViewController.view = rootView
31
+
32
+ /// Present the payment sheet view controller modally from the presenting view controller.
33
+ presentingViewController.present(paymentSheetViewController, animated: false)
34
+ }
35
+
36
+ /// Method to present the payment sheet view with the default configuration.
37
+ func present(from presentingViewController: UIViewController, completion: @escaping (PaymentSheetResult) -> ()) {
38
+
39
+ // Present the payment sheet view with the root view obtained from the getRootView() method.
40
+ self.presentWithRootView(from: presentingViewController, rootView: self.getRootView(), completion: completion)
41
+ }
42
+
43
+ /// Method to present the payment sheet view with custom parameters.
44
+ func presentWithParams(from presentingViewController: UIViewController, props: [String: Any], completion: @escaping ((PaymentSheetResult) -> ())) {
45
+
46
+ // Present the payment sheet view with the root view obtained from the getRootViewWithParams() method.
47
+ self.presentWithRootView(from: presentingViewController, rootView: self.getRootViewWithParams(props: props), completion: completion)
48
+ }
49
+ }