@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,21 @@
1
+ //
2
+ // APIClient.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 10/05/23.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ @objc internal class APIClient: NSObject {
11
+
12
+ @objc(sharedClient) public static let shared: APIClient = {
13
+ let client = APIClient()
14
+ return client
15
+ }()
16
+
17
+ @objc public var publishableKey: String?
18
+ @objc public var customBackendUrl: String?
19
+ @objc public var customParams: [String : Any]?
20
+ @objc public var customLogUrl: String?
21
+ }
@@ -0,0 +1,104 @@
1
+ //
2
+ // DictionaryConverter.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Balaganesh on 20/12/22.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ protocol DictionaryConverter {
12
+ func toDictionary() -> [String : Any]
13
+ }
14
+
15
+ extension DictionaryConverter {
16
+
17
+ /// Helper function to convert a UIColor to a hexadecimal string representation.
18
+ func hexStringFromColor(color: UIColor) -> String {
19
+ let cgColorInRGB = color.cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil)!
20
+ let colorRef = cgColorInRGB.components
21
+ let r = colorRef?[0] ?? 0
22
+ let g = colorRef?[1] ?? 0
23
+ let b = ((colorRef?.count ?? 0) > 2 ? colorRef?[2] : g) ?? 0
24
+ let a = color.cgColor.alpha
25
+
26
+ var color = String(
27
+ format: "#%02lX%02lX%02lX",
28
+ lroundf(Float(r * 255)),
29
+ lroundf(Float(g * 255)),
30
+ lroundf(Float(b * 255))
31
+ )
32
+
33
+ if a < 1 {
34
+ color += String(format: "%02lX", lroundf(Float(a * 255)))
35
+ }
36
+
37
+ return color
38
+ }
39
+
40
+ /// Function to convert the current instance to a dictionary.
41
+ func toDictionary() -> [String : Any] {
42
+ let reflect = Mirror(reflecting: self)
43
+ let children = reflect.children
44
+ let dictionary = toAnyHashable(elements: children)
45
+ return dictionary
46
+ }
47
+
48
+ /// Recursive helper function to convert the properties of an instance to a dictionary.
49
+ func toAnyHashable(elements: AnyCollection<Mirror.Child>) -> [String : Any] {
50
+ var dictionary: [String : Any] = [:]
51
+ for element in elements {
52
+ if let key = element.label {
53
+
54
+ if let value = element.value as? AnyHashable {
55
+ if "\(value)" == "nil" {
56
+ continue
57
+ }
58
+ }
59
+
60
+ let isEnumValue = Mirror(reflecting:element.value).displayStyle == .enum
61
+
62
+ if let collectionValidHashable = element.value as? [AnyHashable] {
63
+ dictionary[key] = collectionValidHashable
64
+ }
65
+
66
+ if let validHashable = element.value as? AnyHashable {
67
+ if (isEnumValue) {
68
+ dictionary[key] = "\(validHashable)"
69
+ } else {
70
+ dictionary[key] = validHashable
71
+ }
72
+ }
73
+
74
+ /// Handle Theme values
75
+ if let theme = element.value as? PaymentSheet.Appearance.Theme {
76
+ dictionary[key] = theme.themeLabel
77
+ }
78
+
79
+ /// Handle UIColor values
80
+ if let color = element.value as? UIColor {
81
+ dictionary[key] = self.hexStringFromColor(color: color)
82
+ }
83
+
84
+ /// Handle UIFont values
85
+ if let font = element.value as? UIFont {
86
+ dictionary[key] = font.fontName
87
+ }
88
+
89
+ if let convertor = element.value as? DictionaryConverter {
90
+ if (!isEnumValue) {
91
+ dictionary[key] = convertor.toDictionary()
92
+ }
93
+ }
94
+
95
+ if let convertorList = element.value as? [DictionaryConverter] {
96
+ dictionary[key] = convertorList.map({ e in
97
+ e.toDictionary()
98
+ })
99
+ }
100
+ }
101
+ }
102
+ return dictionary
103
+ }
104
+ }
@@ -0,0 +1,24 @@
1
+ //
2
+ // Environment.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Kuntimaddi Manideep on 24/01/25.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ enum SDKEnvironment {
11
+ case PROD, SANDBOX
12
+
13
+ static func getEnvironment(_ publishableKey: String) -> SDKEnvironment {
14
+ return publishableKey.contains("_snd_") ? .SANDBOX : .PROD
15
+ }
16
+
17
+ static func baseURL(for publishableKey: String) -> String {
18
+ return getEnvironment(publishableKey) == .PROD ? "https://api.hyperswitch.io" : "https://sandbox.hyperswitch.io"
19
+ }
20
+
21
+ static func loggingURL(for publishableKey: String) -> String {
22
+ return "\(baseURL(for: publishableKey))/logs/sdk"
23
+ }
24
+ }
@@ -0,0 +1,31 @@
1
+ //
2
+ // Extensions.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 05/09/24.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ internal extension UIColor {
12
+ static func dynamic(light: UIColor, dark: UIColor) -> UIColor {
13
+ return UIColor(dynamicProvider: { (traitCollection) in
14
+ switch traitCollection.userInterfaceStyle {
15
+ case .light, .unspecified:
16
+ return light
17
+ case .dark:
18
+ return dark
19
+ @unknown default:
20
+ return light
21
+ }
22
+ })
23
+ }
24
+ }
25
+
26
+ internal extension String {
27
+ func toJSON() -> Any? {
28
+ guard let data = self.data(using: .utf8, allowLossyConversion: false) else { return nil }
29
+ return try? JSONSerialization.jsonObject(with: data, options: .mutableContainers)
30
+ }
31
+ }
@@ -0,0 +1,16 @@
1
+ //
2
+ // Helper.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 22/10/24.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ internal func getInfoPlist(_ key: String) -> String? {
11
+ guard let infoDictionary = Bundle.main.infoDictionary,
12
+ let value = infoDictionary[key] as? String, !value.isEmpty else {
13
+ return nil
14
+ }
15
+ return value
16
+ }
@@ -0,0 +1,137 @@
1
+ //
2
+ // HyperswitchNetworking.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Kuntimaddi Manideep on 24/01/25.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ // MARK: HTTP Methods
11
+ enum HTTPMethod: String, Encodable {
12
+ case get = "GET"
13
+ case head = "HEAD"
14
+ case post = "POST"
15
+ case put = "PUT"
16
+ case delete = "DELETE"
17
+ case connect = "CONNECT"
18
+ case options = "OPTIONS"
19
+ case trace = "TRACE"
20
+ case patch = "PATCH"
21
+ }
22
+
23
+ // MARK: HTTPClient
24
+ /// The protocol used to define the specifications necessary for a `HTTPClient`.
25
+ protocol HTTPClient {
26
+ /// The host, conforming to RFC 1808.
27
+ var host: String { get }
28
+
29
+ /// The path, conforming to RFC 1808
30
+ var path: String { get }
31
+
32
+ /// API Endpoint
33
+ var endpoint: String { get }
34
+
35
+ /// The HTTP method used in the request.
36
+ var method: HTTPMethod { get }
37
+
38
+ /// The HTTP JSON request parameters.
39
+ var jsonParameters: [String: Any]? { get }
40
+
41
+ /// The HTTP Data request parameters.
42
+ var bodyData: Data? { get }
43
+
44
+ /// A dictionary containing all the HTTP header fields
45
+ var headers: [String: String]? { get }
46
+ }
47
+
48
+ /// HTTPClient Errors
49
+ enum HTTPClientError: Error {
50
+ case badURL
51
+ }
52
+
53
+ extension HTTPClient {
54
+ /// The URL of the receiver.
55
+ fileprivate var url: String {
56
+ return host + path + endpoint
57
+ }
58
+
59
+ func request<T: Codable>(type: T.Type, completionHandler: @escaping (Result<T, Error>, Int) -> Void) {
60
+ guard let url = URL(string: url) else {
61
+ completionHandler(.failure(HTTPClientError.badURL), 400)
62
+ return
63
+ }
64
+
65
+ var request = URLRequest(url: url)
66
+ request.httpMethod = method.rawValue
67
+ request.allHTTPHeaderFields = headers
68
+ request.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData
69
+
70
+ if let parameters = jsonParameters {
71
+ do {
72
+ request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: [])
73
+ } catch {
74
+ completionHandler(.failure(error), 400)
75
+ return
76
+ }
77
+ } else if let bodyData = bodyData {
78
+ request.httpBody = bodyData
79
+ }
80
+
81
+ let configuration = URLSessionConfiguration.default
82
+ configuration.timeoutIntervalForRequest = 10.0 // 10 seconds
83
+ configuration.timeoutIntervalForResource = 10.0 // 10 seconds
84
+ let session = URLSession(configuration: configuration)
85
+ let dataTask = session.dataTask(with: request, completionHandler: { (data, response, error) -> Void in
86
+ var responseCode = 400
87
+ if let httpResponse = response as? HTTPURLResponse {
88
+ responseCode = httpResponse.statusCode
89
+ }
90
+ if let error = error {
91
+ completionHandler(.failure(error), responseCode)
92
+ return
93
+ }
94
+
95
+ if let data = data {
96
+ do {
97
+ if T.self == Data.self {
98
+ completionHandler(.success(data as! T), responseCode)
99
+ } else {
100
+ completionHandler(.success(try JSONDecoder().decode(type, from: data)), responseCode)
101
+ }
102
+ } catch {
103
+ completionHandler(.failure(error), responseCode)
104
+ return
105
+ }
106
+ }
107
+ })
108
+
109
+ dataTask.resume()
110
+ }
111
+ }
112
+
113
+ class HTTPRequestService: HTTPClient {
114
+
115
+ let host: String
116
+ let path: String
117
+ let endpoint: String
118
+ let method: HTTPMethod
119
+
120
+ var jsonParameters: [String : Any]?
121
+ var bodyData: Data?
122
+ var headers: [String : String]?
123
+
124
+ init(host: String, path: String, endpoint: String, method: HTTPMethod, jsonParameters: [String : Any]? = nil, bodyData: Data? = nil, headers: [String : String]? = nil) {
125
+ self.host = host
126
+ self.path = path
127
+ self.endpoint = endpoint
128
+ self.method = method
129
+ self.jsonParameters = jsonParameters
130
+ self.bodyData = bodyData
131
+ self.headers = headers
132
+ }
133
+
134
+ func getDictionary() -> [String: Any] {
135
+ return ["host": host, "path": path, "endpoint": endpoint, "method": method.rawValue,"jsonParameters": jsonParameters ?? "nil", "headers": headers ?? "nil"]
136
+ }
137
+ }
@@ -0,0 +1,44 @@
1
+ //
2
+ // HyperParams.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Shivam Nan on 15/01/25.
6
+ //
7
+
8
+ import Foundation
9
+ import WebKit
10
+
11
+ class HyperParams {
12
+ static let appId: String? = Bundle.main.bundleIdentifier
13
+ static let sdkVersion: String = SDKVersion.current
14
+ static let country: String? = NSLocale.current.regionCode
15
+ static let userAgent: String? = WKWebView().value(forKey: "userAgent") as? String
16
+ static let deviceModel: String = UIDevice.current.model
17
+ static let osVersion: String = UIDevice.current.systemVersion
18
+
19
+ static func getSafeAreaInsets() -> UIEdgeInsets {
20
+ let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
21
+ return windowScene?.windows.first?.safeAreaInsets ?? UIEdgeInsets.zero
22
+ }
23
+
24
+ static func getHyperParams() -> [String: Any?] {
25
+
26
+ let safeAreaInset = getSafeAreaInsets()
27
+
28
+ let params: [String: Any?] = [
29
+ "appId": appId,
30
+ "sdkVersion": sdkVersion,
31
+ "country": country,
32
+ "user-agent": userAgent,
33
+ "device_model": deviceModel,
34
+ "os_version": osVersion,
35
+ "os_type": "ios",
36
+ "launchTime": Int(Date().timeIntervalSince1970 * 1000),
37
+ "topInset": safeAreaInset.top,
38
+ "bottomInset":safeAreaInset.bottom,
39
+ "leftInset":safeAreaInset.left,
40
+ "rightInset":safeAreaInset.right,
41
+ ]
42
+ return params
43
+ }
44
+ }
@@ -0,0 +1,25 @@
1
+ //
2
+ // HyperUIViewController.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 07/10/24.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ internal class HyperUIViewController: UIViewController {
12
+ internal override var shouldAutorotate: Bool {
13
+ return false
14
+ }
15
+ internal override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
16
+ return UIInterfaceOrientationMask.portrait
17
+ }
18
+ internal override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
19
+ return UIInterfaceOrientation.portrait
20
+ }
21
+ internal override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {}
22
+ internal override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {}
23
+ internal override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {}
24
+ internal override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {}
25
+ }
@@ -0,0 +1,43 @@
1
+ //
2
+ // PaymentSession.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 07/03/24.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ @frozen public enum PaymentResult {
11
+ case completed(data: String)
12
+ case canceled(data: String)
13
+ case failed(error: Error)
14
+ }
15
+
16
+ public class PaymentSession {
17
+
18
+ internal static var isPresented: Bool = false
19
+ internal static var paymentIntentClientSecret: String?
20
+ internal static var ephemeralKey: String?
21
+
22
+ public init(publishableKey: String, customBackendUrl: String? = nil, customParams: [String : Any]? = nil, customLogUrl: String? = nil){
23
+ APIClient.shared.publishableKey = publishableKey
24
+ APIClient.shared.customBackendUrl = customBackendUrl
25
+ APIClient.shared.customLogUrl = customLogUrl
26
+ APIClient.shared.customParams = customParams
27
+
28
+ #if canImport(HyperOTA)
29
+ OTAServices.shared.initialize(publishableKey: publishableKey)
30
+ LogManager.initialize(publishableKey: publishableKey)
31
+ RNFabricManager.sharedInstance.startReactNative()
32
+ #endif
33
+ }
34
+
35
+ public func initPaymentSession(paymentIntentClientSecret: String){
36
+ PaymentSession.paymentIntentClientSecret = paymentIntentClientSecret
37
+ }
38
+
39
+ public func initPaymentManagementSession(ephemeralKey: String, paymentIntentClientSecret: String? = nil){
40
+ PaymentSession.ephemeralKey = ephemeralKey
41
+ PaymentSession.paymentIntentClientSecret = paymentIntentClientSecret
42
+ }
43
+ }
@@ -0,0 +1,30 @@
1
+ //
2
+ // PaymentSheet.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Balaganesh on 09/12/22.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ /// PaymentSheetResult is an enum that represents the possible outcomes of a payment sheet operation.
11
+ @frozen public enum PaymentSheetResult {
12
+ case completed(data: String)
13
+ case canceled(data: String)
14
+ case failed(error: Error)
15
+ }
16
+
17
+ /// PaymentSheet is a class that handles the presentation and management of a payment sheet interface.
18
+ public class PaymentSheet {
19
+
20
+ /// The initializer method that sets up the payment sheet with the required parameters.
21
+ internal required init(paymentIntentClientSecret: String, configuration: Configuration) {
22
+ self.intentClientSecret = paymentIntentClientSecret
23
+ self.configuration = configuration
24
+ }
25
+
26
+ /// The configuration object that holds the settings for the payment sheet.
27
+ internal let configuration: Configuration?
28
+ internal let intentClientSecret: String
29
+ internal var completion: ((PaymentSheetResult) -> ())?
30
+ }