@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.
- package/HyperswitchSdkReactNative.podspec +31 -0
- package/android/build.gradle +119 -0
- package/android/gradle.properties +5 -0
- package/android/hyperswitch_autolinking.gradle +378 -0
- package/android/proguard-rules.pro +72 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/assets/hyperswitch.bundle +1677 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +36 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/activity/RedirectActivity.kt +39 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactHost.kt +314 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactNativeHost.kt +131 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactDelegate.kt +423 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactFragment.kt +335 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkNativeModule.kt +143 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkReactNativeModule.kt +92 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/provider/HyperProvider.kt +269 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonView.kt +60 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonViewManager.kt +76 -0
- package/android/src/main/java/io/hyperswitch/hyperota/HyperOtaLogger.kt +122 -0
- package/android/src/main/java/io/hyperswitch/logs/CrashHandler.kt +29 -0
- package/android/src/main/java/io/hyperswitch/logs/Debouncer.kt +20 -0
- package/android/src/main/java/io/hyperswitch/logs/HyperLogManager.kt +113 -0
- package/android/src/main/java/io/hyperswitch/logs/LogData.kt +159 -0
- package/android/src/main/java/io/hyperswitch/logs/LogFileManager.kt +60 -0
- package/android/src/main/java/io/hyperswitch/networking/HyperNetworking.kt +73 -0
- package/android/src/main/java/io/hyperswitch/react/Utils.kt +23 -0
- package/android/src/main/res/values/attrs.xml +6 -0
- package/android/src/main/res/values/strings.xml +5 -0
- package/android/src/main/res/values/theme.xml +16 -0
- package/ios/Modules/HyperswitchModule.swift +61 -0
- package/ios/Modules/HyperswitchNativeModule.swift +113 -0
- package/ios/Modules/HyperswitchSdkNative.h +5 -0
- package/ios/Modules/HyperswitchSdkNative.mm +98 -0
- package/ios/Modules/HyperswitchSdkReactNative.h +5 -0
- package/ios/Modules/HyperswitchSdkReactNative.mm +53 -0
- package/ios/Views/ApplePayView.h +14 -0
- package/ios/Views/ApplePayView.mm +89 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +249 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +123 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+SwiftUI.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +80 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +176 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +121 -0
- package/ios/hyperswitchSDK/Core/Models/LogPayload.swift +53 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/Debouncer.swift +37 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogBuilder.swift +91 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogFileManager.swift +75 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogManager.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +16 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +74 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +28 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +168 -0
- package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +45 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +90 -0
- package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +9 -0
- package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1673 -0
- package/ios/hyperswitchSDK/Shared/APIClient.swift +21 -0
- package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
- package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
- package/ios/hyperswitchSDK/Shared/Extensions.swift +31 -0
- package/ios/hyperswitchSDK/Shared/Helper.swift +16 -0
- package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +137 -0
- package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
- package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +25 -0
- package/ios/hyperswitchSDK/Shared/PaymentSession.swift +43 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +30 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +264 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +494 -0
- package/ios/hyperswitchSDK/Shared/SwiftUIManager.swift +28 -0
- package/ios/hyperswitchSDK/Shared/Version.swift +12 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.mlmap +5 -0
- package/lib/bs/build.ninja +29 -0
- package/lib/bs/install.ninja +25 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/context/HyperProvider.ast +0 -0
- package/lib/bs/src/context/HyperProvider.d +1 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/hooks/useHyper.ast +0 -0
- package/lib/bs/src/hooks/useHyper.d +1 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.ast +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.d +1 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.ast +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.d +1 -0
- package/lib/commonjs/context/HyperProvider.gen.js +16 -0
- package/lib/commonjs/context/HyperProvider.gen.js.map +1 -0
- package/lib/commonjs/context/HyperProvider.res +78 -0
- package/lib/commonjs/context/HyperProvider.res.js +98 -0
- package/lib/commonjs/context/HyperProvider.res.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.gen.js +15 -0
- package/lib/commonjs/hooks/useHyper.gen.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.res +142 -0
- package/lib/commonjs/hooks/useHyper.res.js +152 -0
- package/lib/commonjs/hooks/useHyper.res.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js +6 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js +14 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/shims/Js.shim.js +2 -0
- package/lib/commonjs/shims/Js.shim.js.map +1 -0
- package/lib/commonjs/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js +10 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/commonjs/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res +215 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/module/context/HyperProvider.gen.js +11 -0
- package/lib/module/context/HyperProvider.gen.js.map +1 -0
- package/lib/module/context/HyperProvider.res +78 -0
- package/lib/module/context/HyperProvider.res.js +91 -0
- package/lib/module/context/HyperProvider.res.js.map +1 -0
- package/lib/module/hooks/useHyper.gen.js +10 -0
- package/lib/module/hooks/useHyper.gen.js.map +1 -0
- package/lib/module/hooks/useHyper.res +142 -0
- package/lib/module/hooks/useHyper.res.js +142 -0
- package/lib/module/hooks/useHyper.res.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js +4 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js +9 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/shims/Js.shim.js +2 -0
- package/lib/module/shims/Js.shim.js.map +1 -0
- package/lib/module/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js +5 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/module/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.res +215 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/typescript/commonjs/babel.config.d.ts +10 -0
- package/lib/typescript/commonjs/babel.config.d.ts.map +1 -0
- package/lib/typescript/commonjs/eslint.config.d.mts +3 -0
- package/lib/typescript/commonjs/eslint.config.d.mts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/lib/typescript/module/babel.config.d.ts +10 -0
- package/lib/typescript/module/babel.config.d.ts.map +1 -0
- package/lib/typescript/module/eslint.config.d.mts +3 -0
- package/lib/typescript/module/eslint.config.d.mts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/package.json +196 -0
- package/src/context/HyperProvider.gen.tsx +26 -0
- package/src/context/HyperProvider.res +78 -0
- package/src/context/HyperProvider.res.js +112 -0
- package/src/hooks/useHyper.gen.tsx +18 -0
- package/src/hooks/useHyper.res +142 -0
- package/src/hooks/useHyper.res.js +157 -0
- package/src/index.tsx +13 -0
- package/src/modules/NativeHyperswitchSdk.gen.tsx +25 -0
- package/src/modules/NativeHyperswitchSdk.res +55 -0
- package/src/modules/NativeHyperswitchSdk.res.js +10 -0
- package/src/shims/Js.shim.ts +5 -0
- package/src/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/src/specs/GooglePayButtonNativeComponent.android.ts +12 -0
- package/src/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/src/specs/NativeHyperswitchSdkNative.ts +33 -0
- package/src/specs/NativeHyperswitchSdkReactNative.ts +17 -0
- package/src/types/PaymentSheetConfiguration.gen.tsx +202 -0
- package/src/types/PaymentSheetConfiguration.res +215 -0
- 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
|
+
}
|