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,75 @@
1
+ //
2
+ // Codable+UIKit.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 09/10/25.
6
+ //
7
+
8
+ import UIKit
9
+
10
+ // MARK: - CodableColor Wrapper
11
+ public struct CodableColor: Codable, Equatable {
12
+ private let wrapped: UIColor
13
+
14
+ public init(_ color: UIColor) {
15
+ self.wrapped = color
16
+ }
17
+
18
+ // Accessor for UIKit API compatibility
19
+ public var uiColor: UIColor { wrapped }
20
+
21
+ public func encode(to encoder: Encoder) throws {
22
+ var container = encoder.singleValueContainer()
23
+ guard let hex = wrapped.hexString else {
24
+ throw EncodingError.invalidValue(
25
+ wrapped,
26
+ EncodingError.Context(
27
+ codingPath: container.codingPath,
28
+ debugDescription: "Failed to encode UIColor to hex"
29
+ )
30
+ )
31
+ }
32
+ try container.encode(hex)
33
+ }
34
+
35
+ public init(from decoder: Decoder) throws {
36
+ let container = try decoder.singleValueContainer()
37
+ let hex = try container.decode(String.self)
38
+ guard let decoded = UIColor(hexString: hex) else {
39
+ throw DecodingError.dataCorruptedError(
40
+ in: container,
41
+ debugDescription: "Invalid hex string: \(hex)"
42
+ )
43
+ }
44
+ self.wrapped = decoded
45
+ }
46
+ }
47
+
48
+ // MARK: - CodableFont Wrapper
49
+ public struct CodableFont: Codable, Equatable {
50
+ private let wrapped: UIFont
51
+
52
+ public init(_ font: UIFont) {
53
+ self.wrapped = font
54
+ }
55
+
56
+ // Accessor for UIKit API compatibility
57
+ public var uiFont: UIFont { wrapped }
58
+
59
+ public func encode(to encoder: Encoder) throws {
60
+ var container = encoder.singleValueContainer()
61
+ try container.encode(wrapped.fontName)
62
+ }
63
+
64
+ public init(from decoder: Decoder) throws {
65
+ let container = try decoder.singleValueContainer()
66
+ let name = try container.decode(String.self)
67
+ guard let decodedFont = UIFont(name: name, size: .zero) else {
68
+ throw DecodingError.dataCorruptedError(
69
+ in: container,
70
+ debugDescription: "Invalid font name: \(name)"
71
+ )
72
+ }
73
+ self.wrapped = decodedFont
74
+ }
75
+ }
@@ -0,0 +1,67 @@
1
+ //
2
+ // CustomEndpointConfiguration.swift
3
+ // HyperswitchCore
4
+ //
5
+ // Created by Harshit Srivastava on 17/05/26.
6
+ //
7
+
8
+ public enum CustomEndpointConfiguration: Codable {
9
+ case commonEndpoint(String)
10
+ case overrideEndpoints(OverrideEndpointConfiguration)
11
+
12
+ private enum CodingKeys: String, CodingKey {
13
+ case commonEndpoint
14
+ case overrideEndpoints
15
+ }
16
+
17
+ public func encode(to encoder: Encoder) throws {
18
+ var container = encoder.container(keyedBy: CodingKeys.self)
19
+ switch self {
20
+ case .commonEndpoint(let value):
21
+ try container.encode(value, forKey: .commonEndpoint)
22
+ case .overrideEndpoints(let config):
23
+ try container.encode(config, forKey: .overrideEndpoints)
24
+ }
25
+ }
26
+
27
+ public init(from decoder: Decoder) throws {
28
+ let container = try decoder.container(keyedBy: CodingKeys.self)
29
+ if let value = try container.decodeIfPresent(String.self, forKey: .commonEndpoint) {
30
+ self = .commonEndpoint(value)
31
+ } else if let config = try container.decodeIfPresent(OverrideEndpointConfiguration.self, forKey: .overrideEndpoints) {
32
+ self = .overrideEndpoints(config)
33
+ } else {
34
+ throw DecodingError.dataCorrupted(
35
+ DecodingError.Context(
36
+ codingPath: decoder.codingPath,
37
+ debugDescription: ""
38
+ )
39
+ )
40
+ }
41
+ }
42
+ }
43
+
44
+ public struct OverrideEndpointConfiguration: Codable {
45
+ let customBackendEndpoint: String?
46
+ let customAssetEndpoint: String?
47
+ let customSDKConfigEndpoint: String?
48
+ let customConfirmEndpoint: String?
49
+ let customAirborneEndpoint: String?
50
+ let customLoggingEndpoint: String?
51
+
52
+ public init(
53
+ customBackendEndpoint: String? = nil,
54
+ customAssetEndpoint: String? = nil,
55
+ customSDKConfigEndpoint: String? = nil,
56
+ customConfirmEndpoint: String? = nil,
57
+ customAirborneEndpoint: String? = nil,
58
+ customLoggingEndpoint: String? = nil
59
+ ) {
60
+ self.customBackendEndpoint = customBackendEndpoint
61
+ self.customAssetEndpoint = customAssetEndpoint
62
+ self.customSDKConfigEndpoint = customSDKConfigEndpoint
63
+ self.customConfirmEndpoint = customConfirmEndpoint
64
+ self.customAirborneEndpoint = customAirborneEndpoint
65
+ self.customLoggingEndpoint = customLoggingEndpoint
66
+ }
67
+ }
@@ -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,101 @@
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
+ }
32
+
33
+ internal extension Encodable {
34
+ func toDictionary() throws -> [String: Any] {
35
+ let data = try JSONEncoder().encode(self)
36
+ guard let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any] else {
37
+ throw NSError(domain: "Encoding", code: 0)
38
+ }
39
+ return dict
40
+ }
41
+ }
42
+
43
+ internal extension UIColor {
44
+ /// Convert UIColor to hex string (#RRGGBB or #RRGGBBAA if alpha < 1)
45
+ var hexString: String? {
46
+ guard let sRGB = CGColorSpace(name: CGColorSpace.sRGB),
47
+ let cgColorInRGB = cgColor.converted(
48
+ to: sRGB,
49
+ intent: .defaultIntent,
50
+ options: nil
51
+ ),
52
+ let comps = cgColorInRGB.components
53
+ else {
54
+ return nil
55
+ }
56
+
57
+ let r = comps.count > 0 ? comps[0] : 0
58
+ let g = comps.count > 1 ? comps[1] : 0
59
+ let b = comps.count > 2 ? comps[2] : 0
60
+ let a = cgColor.alpha
61
+
62
+ var hex = String(
63
+ format: "#%02lX%02lX%02lX",
64
+ lroundf(Float(r * 255)),
65
+ lroundf(Float(g * 255)),
66
+ lroundf(Float(b * 255))
67
+ )
68
+ if a < 1 {
69
+ hex += String(format: "%02lX", lroundf(Float(a * 255)))
70
+ }
71
+ return hex
72
+ }
73
+
74
+ /// Initialize UIColor from hex string (#RRGGBB or #RRGGBBAA)
75
+ convenience init?(hexString: String) {
76
+ var hex = hexString.trimmingCharacters(in: .whitespacesAndNewlines)
77
+ hex = hex.replacingOccurrences(of: "#", with: "")
78
+
79
+ var rgb: UInt64 = 0
80
+ guard Scanner(string: hex).scanHexInt64(&rgb) else { return nil }
81
+
82
+ switch hex.count {
83
+ case 6:
84
+ self.init(
85
+ red: CGFloat((rgb & 0xFF0000) >> 16) / 255,
86
+ green: CGFloat((rgb & 0x00FF00) >> 8) / 255,
87
+ blue: CGFloat(rgb & 0x0000FF) / 255,
88
+ alpha: 1.0
89
+ )
90
+ case 8:
91
+ self.init(
92
+ red: CGFloat((rgb & 0xFF000000) >> 24) / 255,
93
+ green: CGFloat((rgb & 0x00FF0000) >> 16) / 255,
94
+ blue: CGFloat((rgb & 0x0000FF00) >> 8) / 255,
95
+ alpha: CGFloat(rgb & 0x000000FF) / 255
96
+ )
97
+ default:
98
+ return nil
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,40 @@
1
+ //
2
+ // Helper.swift
3
+ // hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 22/10/24.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ enum Helper {
11
+
12
+ static func getInfoPlist(_ key: String) -> String? {
13
+ guard let infoDictionary = Bundle.main.infoDictionary,
14
+ let value = infoDictionary[key] as? String, !value.isEmpty
15
+ else {
16
+ return nil
17
+ }
18
+ return value
19
+ }
20
+
21
+ /// Dedicated serial queue protecting the read-then-write block
22
+ private static let uuidQueue = DispatchQueue(label: "io.hyperswitch.helper.uuid")
23
+
24
+ static func persistentUUID(for flow: String) -> String {
25
+ uuidQueue.sync {
26
+ /// never call this using another uuidQueue.sync (deadlock)
27
+ let safeFlow = flow.lowercased().replacingOccurrences(of: " ", with: "_")
28
+ let key = "uuid_\(safeFlow)"
29
+ let defaults = UserDefaults.standard
30
+
31
+ if let existing = defaults.string(forKey: key) {
32
+ return existing
33
+ }
34
+
35
+ let newUUID = UUID().uuidString
36
+ defaults.set(newUUID, forKey: key)
37
+ return newUUID
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,125 @@
1
+ //
2
+ // PaymentEventData.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 21/04/26.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ public enum PaymentEventData {
11
+
12
+ case cardInfo(CardInfo)
13
+ case paymentMethodStatus(PaymentMethodStatus)
14
+ case formStatus(FormStatusEvent)
15
+ case paymentMethodInfoAddress(PaymentMethodInfoAddress)
16
+ case cvcStatus(CvcStatus)
17
+
18
+ public struct CardInfo: Sendable {
19
+ public let bin: String?
20
+ public let last4: String?
21
+ public let brand: String?
22
+ public let expiryMonth: String?
23
+ public let expiryYear: String?
24
+ public let formattedExpiry: String?
25
+ public let isCardNumberComplete: Bool
26
+ public let isCvcComplete: Bool
27
+ public let isExpiryComplete: Bool
28
+ public let isCardNumberValid: Bool
29
+ public let isExpiryValid: Bool
30
+
31
+ static func from(_ map: [String: Any]) -> CardInfo {
32
+ CardInfo(
33
+ bin: map["bin"] as? String,
34
+ last4: map["last4"] as? String,
35
+ brand: map["brand"] as? String,
36
+ expiryMonth: map["expiryMonth"] as? String,
37
+ expiryYear: map["expiryYear"] as? String,
38
+ formattedExpiry: map["formattedExpiry"] as? String,
39
+ isCardNumberComplete: map["isCardNumberComplete"] as? Bool ?? false,
40
+ isCvcComplete: map["isCvcComplete"] as? Bool ?? false,
41
+ isExpiryComplete: map["isExpiryComplete"] as? Bool ?? false,
42
+ isCardNumberValid: map["isCardNumberValid"] as? Bool ?? false,
43
+ isExpiryValid: map["isExpiryValid"] as? Bool ?? false
44
+ )
45
+ }
46
+ }
47
+
48
+ public struct PaymentMethodStatus: Sendable {
49
+ public let paymentMethod: String
50
+ public let paymentMethodType: String
51
+ public let isSavedPaymentMethod: Bool
52
+ public let isOneClickWallet: Bool
53
+
54
+ static func from(_ map: [String: Any]) -> PaymentMethodStatus {
55
+ PaymentMethodStatus(
56
+ paymentMethod: map["paymentMethod"] as? String ?? "",
57
+ paymentMethodType: map["paymentMethodType"] as? String ?? "",
58
+ isSavedPaymentMethod: map["isSavedPaymentMethod"] as? Bool ?? false,
59
+ isOneClickWallet: map["isOneClickWallet"] as? Bool ?? false
60
+ )
61
+ }
62
+ }
63
+
64
+ public enum FormStatusValue: String, Sendable {
65
+ case empty = "EMPTY"
66
+ case filling = "FILLING"
67
+ case complete = "COMPLETE"
68
+ }
69
+
70
+ public struct FormStatusEvent: Sendable {
71
+ public let status: FormStatusValue?
72
+
73
+ static func from(_ map: [String: Any]) -> FormStatusEvent {
74
+ FormStatusEvent(status: (map["status"] as? String).flatMap(FormStatusValue.init(rawValue:)))
75
+ }
76
+ }
77
+
78
+ public struct PaymentMethodInfoAddress: Sendable {
79
+ public let country: String
80
+ public let state: String
81
+ public let postalCode: String
82
+
83
+ static func from(_ map: [String: Any]) -> PaymentMethodInfoAddress {
84
+ PaymentMethodInfoAddress(
85
+ country: map["country"] as? String ?? "",
86
+ state: map["state"] as? String ?? "",
87
+ postalCode: map["postalCode"] as? String ?? ""
88
+ )
89
+ }
90
+ }
91
+
92
+ public struct CvcStatus: Sendable {
93
+ public let isCvcFocused: Bool
94
+ public let isCvcBlur: Bool
95
+ public let isCvcEmpty: Bool
96
+ public let isCvcComplete: Bool
97
+
98
+ static func from(_ map: [String: Any]) -> CvcStatus {
99
+ let source = (map["cvcStatus"] as? [String: Any]) ?? map
100
+ return CvcStatus(
101
+ isCvcFocused: source["isCvcFocused"] as? Bool ?? false,
102
+ isCvcBlur: source["isCvcBlur"] as? Bool ?? false,
103
+ isCvcEmpty: source["isCvcEmpty"] as? Bool ?? true,
104
+ isCvcComplete: source["isCvcComplete"] as? Bool ?? false
105
+ )
106
+ }
107
+ }
108
+
109
+ public static func from(type: String, payload: [String: Any]) -> PaymentEventData? {
110
+ switch type {
111
+ case PaymentEventType.paymentMethodInfoCard.rawValue:
112
+ return .cardInfo(.from(payload))
113
+ case PaymentEventType.paymentMethodStatus.rawValue:
114
+ return .paymentMethodStatus(.from(payload))
115
+ case PaymentEventType.formStatus.rawValue:
116
+ return .formStatus(.from(payload))
117
+ case PaymentEventType.paymentMethodInfoBillingAddress.rawValue:
118
+ return .paymentMethodInfoAddress(.from(payload))
119
+ case PaymentEventType.cvcStatus.rawValue:
120
+ return .cvcStatus(.from(payload))
121
+ default:
122
+ return nil
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,45 @@
1
+ //
2
+ // PaymentEventSubscriptionBuilder.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 21/04/26.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ public final class PaymentEventSubscriptionBuilder {
11
+ private var handlers: [PaymentEventType: (PaymentEvent) -> Void] = [:]
12
+
13
+ public init() {}
14
+
15
+ public func on(_ eventType: PaymentEventType, _ handler: @escaping (PaymentEvent) -> Void) {
16
+ handlers[eventType] = handler
17
+ }
18
+
19
+ internal func build() -> (subscription: PaymentEventSubscription, listener: PaymentEventListener) {
20
+ let dispatch: [String: (PaymentEvent) -> Void] = Dictionary(
21
+ uniqueKeysWithValues: handlers.map { ($0.key.rawValue, $0.value) }
22
+ )
23
+ let subscription = PaymentEventSubscription(eventTypes: Array(handlers.keys))
24
+ let listener = PaymentEventListener { event in
25
+ dispatch[event.type]?(event)
26
+ }
27
+ return (subscription, listener)
28
+ }
29
+ }
30
+
31
+ public struct PaymentEventSubscription: Sendable {
32
+ public let eventTypes: [PaymentEventType]
33
+
34
+ public func isSubscribed(_ rawType: String) -> Bool {
35
+ eventTypes.contains { $0.rawValue == rawType }
36
+ }
37
+
38
+ public func subscribedEventStrings() -> [String] {
39
+ eventTypes.map(\.rawValue)
40
+ }
41
+ }
42
+
43
+ internal struct PaymentEventListener {
44
+ let onPaymentEvent: (PaymentEvent) -> Void
45
+ }
@@ -0,0 +1,30 @@
1
+ //
2
+ // PaymentEventType.swift
3
+ // Hyperswitch
4
+ //
5
+ // Created by Harshit Srivastava on 21/04/26.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ public enum PaymentEventType: String, CaseIterable, Sendable {
11
+ case paymentMethodInfoCard = "PAYMENT_METHOD_INFO_CARD"
12
+ case paymentMethodStatus = "PAYMENT_METHOD_STATUS"
13
+ case formStatus = "FORM_STATUS"
14
+ case paymentMethodInfoBillingAddress = "PAYMENT_METHOD_INFO_BILLING_ADDRESS"
15
+ case cvcStatus = "CVC_STATUS"
16
+ }
17
+
18
+ public struct PaymentEvent {
19
+ public let type: String
20
+ public let payload: [String: Any]
21
+
22
+ public var data: PaymentEventData? {
23
+ PaymentEventData.from(type: type, payload: payload)
24
+ }
25
+
26
+ public init(type: String, payload: [String: Any]) {
27
+ self.type = type
28
+ self.payload = payload
29
+ }
30
+ }