@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,159 @@
|
|
|
1
|
+
package io.hyperswitch.logs
|
|
2
|
+
|
|
3
|
+
import org.json.JSONException
|
|
4
|
+
import org.json.JSONObject
|
|
5
|
+
|
|
6
|
+
enum class LogType {
|
|
7
|
+
DEBUG, INFO, ERROR, WARNING
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
enum class LogCategory {
|
|
11
|
+
API, USER_ERROR, USER_EVENT, MERCHANT_EVENT, OTA_LIFE_CYCLE
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
enum class EventName {
|
|
15
|
+
HYPER_OTA_INIT, HYPER_OTA_FINISH, HYPER_OTA_EVENT, CRASH_EVENT
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
data class HSLog(
|
|
19
|
+
val timestamp: String,
|
|
20
|
+
val logType: LogType,
|
|
21
|
+
val component: String = "MOBILE",
|
|
22
|
+
val category: LogCategory,
|
|
23
|
+
val version: String,
|
|
24
|
+
var codePushVersion: String,
|
|
25
|
+
var clientCoreVersion: String,
|
|
26
|
+
val value: String,
|
|
27
|
+
val internalMetadata: String,
|
|
28
|
+
val sessionId: String,
|
|
29
|
+
var merchantId: String,
|
|
30
|
+
val paymentId: String,
|
|
31
|
+
val appId: String? = null,
|
|
32
|
+
val platform: String = "ANDROID",
|
|
33
|
+
val userAgent: String,
|
|
34
|
+
val eventName: EventName,
|
|
35
|
+
val latency: String? = null,
|
|
36
|
+
val firstEvent: Boolean = false,
|
|
37
|
+
val paymentMethod: String? = null,
|
|
38
|
+
val paymentExperience: String? = null,
|
|
39
|
+
val source: String
|
|
40
|
+
) {
|
|
41
|
+
fun toJson(): String {
|
|
42
|
+
try {
|
|
43
|
+
|
|
44
|
+
val logData = JSONObject().apply {
|
|
45
|
+
put("timestamp", timestamp)
|
|
46
|
+
put("log_type", logType.name)
|
|
47
|
+
put("component", component)
|
|
48
|
+
put("category", category.toString())
|
|
49
|
+
put("version", version)
|
|
50
|
+
put("code_push_version", codePushVersion)
|
|
51
|
+
put("client_core_version", clientCoreVersion)
|
|
52
|
+
put("value", value)
|
|
53
|
+
put("internal_metadata", internalMetadata)
|
|
54
|
+
put("session_id", sessionId)
|
|
55
|
+
put("merchant_id", merchantId)
|
|
56
|
+
put("payment_id", paymentId)
|
|
57
|
+
put("app_id", appId ?: "")
|
|
58
|
+
put("platform", platform)
|
|
59
|
+
put("user_agent", userAgent)
|
|
60
|
+
put("event_name", eventName.name)
|
|
61
|
+
put("first_event", firstEvent.toString())
|
|
62
|
+
put("payment_method", paymentMethod ?: "")
|
|
63
|
+
put("payment_experience", paymentExperience ?: "")
|
|
64
|
+
put("latency", latency ?: "")
|
|
65
|
+
put("source", source)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val jsonString = logData.toString()
|
|
69
|
+
return jsonString
|
|
70
|
+
} catch (e: JSONException) {
|
|
71
|
+
return ""
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class LogBuilder {
|
|
77
|
+
private var timestamp: String = System.currentTimeMillis().toString()
|
|
78
|
+
private var logType: LogType = LogType.INFO
|
|
79
|
+
private var component: String = "MOBILE"
|
|
80
|
+
private lateinit var category: LogCategory
|
|
81
|
+
private var version: String = ""
|
|
82
|
+
private var codePushVersion: String = ""
|
|
83
|
+
private var clientCoreVersion: String = ""
|
|
84
|
+
private var value: String = ""
|
|
85
|
+
private var internalMetadata: String = ""
|
|
86
|
+
private var sessionId: String = ""
|
|
87
|
+
private var merchantId: String = ""
|
|
88
|
+
private var paymentId: String = ""
|
|
89
|
+
private var appId: String? = null
|
|
90
|
+
private var platform: String = "ANDROID"
|
|
91
|
+
private var userAgent: String = ""
|
|
92
|
+
private lateinit var eventName: EventName
|
|
93
|
+
private var latency: String? = null
|
|
94
|
+
private var firstEvent: Boolean = false
|
|
95
|
+
private var paymentMethod: String? = null
|
|
96
|
+
private var paymentExperience: String? = null
|
|
97
|
+
private var source: String = ""
|
|
98
|
+
|
|
99
|
+
fun timestamp(timestamp: String) = apply { this.timestamp = timestamp }
|
|
100
|
+
fun logType(logType: String) = apply {
|
|
101
|
+
this.logType =
|
|
102
|
+
LogType.entries.find { it.name == logType.uppercase() } ?: LogType.INFO
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fun component(component: String) = apply { this.component = component }
|
|
106
|
+
fun category(category: LogCategory) = apply { this.category = category }
|
|
107
|
+
fun version(version: String) = apply { this.version = version }
|
|
108
|
+
fun codePushVersion(codePushVersion: String) =
|
|
109
|
+
apply { this.codePushVersion = codePushVersion }
|
|
110
|
+
|
|
111
|
+
fun clientCoreVersion(clientCoreVersion: String) =
|
|
112
|
+
apply { this.clientCoreVersion = clientCoreVersion }
|
|
113
|
+
|
|
114
|
+
fun value(value: String) = apply { this.value = value }
|
|
115
|
+
fun internalMetadata(internalMetadata: String) =
|
|
116
|
+
apply { this.internalMetadata = internalMetadata }
|
|
117
|
+
|
|
118
|
+
fun sessionId(sessionId: String) = apply { this.sessionId = sessionId }
|
|
119
|
+
fun merchantId(merchantId: String) = apply { this.merchantId = merchantId }
|
|
120
|
+
fun paymentId(paymentId: String) = apply { this.paymentId = paymentId }
|
|
121
|
+
fun appId(appId: String?) = apply { this.appId = appId }
|
|
122
|
+
fun platform(platform: String) = apply { this.platform = platform }
|
|
123
|
+
fun userAgent(userAgent: String) = apply { this.userAgent = userAgent }
|
|
124
|
+
fun eventName(eventName: EventName) = apply { this.eventName = eventName }
|
|
125
|
+
fun latency(latency: String?) = apply { this.latency = latency }
|
|
126
|
+
fun firstEvent(firstEvent: Boolean) = apply { this.firstEvent = firstEvent }
|
|
127
|
+
fun paymentMethod(paymentMethod: String?) = apply { this.paymentMethod = paymentMethod }
|
|
128
|
+
fun paymentExperience(paymentExperience: String?) =
|
|
129
|
+
apply { this.paymentExperience = paymentExperience }
|
|
130
|
+
|
|
131
|
+
fun source(source: String) = apply { this.source = source }
|
|
132
|
+
|
|
133
|
+
fun build(): HSLog {
|
|
134
|
+
return HSLog(
|
|
135
|
+
timestamp,
|
|
136
|
+
logType,
|
|
137
|
+
component,
|
|
138
|
+
category,
|
|
139
|
+
version,
|
|
140
|
+
codePushVersion,
|
|
141
|
+
clientCoreVersion,
|
|
142
|
+
value,
|
|
143
|
+
internalMetadata,
|
|
144
|
+
sessionId,
|
|
145
|
+
merchantId,
|
|
146
|
+
paymentId,
|
|
147
|
+
appId,
|
|
148
|
+
platform,
|
|
149
|
+
userAgent,
|
|
150
|
+
eventName,
|
|
151
|
+
latency,
|
|
152
|
+
firstEvent,
|
|
153
|
+
paymentMethod,
|
|
154
|
+
paymentExperience,
|
|
155
|
+
source
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package io.hyperswitch.logs
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import org.json.JSONArray
|
|
5
|
+
import org.json.JSONException
|
|
6
|
+
import java.io.File
|
|
7
|
+
import java.io.IOException
|
|
8
|
+
|
|
9
|
+
class LogFileManager(private val context: Context) {
|
|
10
|
+
|
|
11
|
+
private val crashLogFileName = "crash_logs.json"
|
|
12
|
+
fun addLog(log: String) {
|
|
13
|
+
try {
|
|
14
|
+
val existingLogs = getAllLogs()
|
|
15
|
+
val newLogsArray = JSONArray(log)
|
|
16
|
+
for (i in 0 until newLogsArray.length()) {
|
|
17
|
+
existingLogs.put(newLogsArray.get(i))
|
|
18
|
+
}
|
|
19
|
+
writeLogsToFile(existingLogs)
|
|
20
|
+
} catch (e: JSONException) {
|
|
21
|
+
e.printStackTrace()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun getAllLogs(): JSONArray {
|
|
26
|
+
return try {
|
|
27
|
+
val file = File(context.filesDir, crashLogFileName)
|
|
28
|
+
if (file.exists()) {
|
|
29
|
+
val content = file.readText()
|
|
30
|
+
JSONArray(content)
|
|
31
|
+
} else {
|
|
32
|
+
JSONArray()
|
|
33
|
+
}
|
|
34
|
+
} catch (e: JSONException) {
|
|
35
|
+
JSONArray()
|
|
36
|
+
} catch (e: IOException) {
|
|
37
|
+
JSONArray()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fun writeLogsToFile(logs: JSONArray) {
|
|
42
|
+
try {
|
|
43
|
+
val file = File(context.filesDir, crashLogFileName)
|
|
44
|
+
file.writeText(logs.toString()) // Write the logs as a JSON string
|
|
45
|
+
} catch (e: IOException) {
|
|
46
|
+
e.printStackTrace()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun clearFile() {
|
|
51
|
+
try {
|
|
52
|
+
val file = File(context.filesDir, "crash_logs.json")
|
|
53
|
+
if (file.exists()) {
|
|
54
|
+
file.delete()
|
|
55
|
+
}
|
|
56
|
+
} catch (e: IOException) {
|
|
57
|
+
e.printStackTrace()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
package io.hyperswitch.networking
|
|
2
|
+
|
|
3
|
+
import okhttp3.*
|
|
4
|
+
import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
5
|
+
import okhttp3.MediaType.Companion.toMediaType
|
|
6
|
+
import okhttp3.RequestBody.Companion.toRequestBody
|
|
7
|
+
import java.io.IOException
|
|
8
|
+
|
|
9
|
+
object HyperNetworking {
|
|
10
|
+
private val client = OkHttpClient.Builder()
|
|
11
|
+
.connectTimeout(15, java.util.concurrent.TimeUnit.SECONDS)
|
|
12
|
+
.readTimeout(15, java.util.concurrent.TimeUnit.SECONDS)
|
|
13
|
+
.writeTimeout(15, java.util.concurrent.TimeUnit.SECONDS)
|
|
14
|
+
.build()
|
|
15
|
+
|
|
16
|
+
private fun makeHttpRequest(
|
|
17
|
+
urlString: String,
|
|
18
|
+
method: String,
|
|
19
|
+
headers: Map<String, String> = emptyMap(),
|
|
20
|
+
body: String? = null,
|
|
21
|
+
callback: (Result<String>) -> Unit
|
|
22
|
+
) {
|
|
23
|
+
try {
|
|
24
|
+
val mediaType = "application/json".toMediaType()
|
|
25
|
+
val requestBody = body?.takeIf { it.isNotBlank() }?.toRequestBody(mediaType)
|
|
26
|
+
|
|
27
|
+
val url = try {
|
|
28
|
+
urlString.toHttpUrl()
|
|
29
|
+
} catch (e: Exception) {
|
|
30
|
+
callback(Result.failure(IllegalArgumentException("Invalid URL: $urlString", e)))
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
val requestBuilder = Request.Builder()
|
|
35
|
+
.url(url)
|
|
36
|
+
.method(method, requestBody)
|
|
37
|
+
|
|
38
|
+
headers.forEach { (key, value) ->
|
|
39
|
+
requestBuilder.addHeader(key, value)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
val request = requestBuilder.build()
|
|
43
|
+
client.newCall(request).enqueue(object : Callback {
|
|
44
|
+
override fun onFailure(call: Call, e: IOException) {
|
|
45
|
+
callback(Result.failure(IOException("Network error: ${e.localizedMessage}", e)))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun onResponse(call: Call, response: Response) {
|
|
49
|
+
response.use {
|
|
50
|
+
when {
|
|
51
|
+
it.isSuccessful -> callback(Result.success(it.body?.string() ?: "success"))
|
|
52
|
+
it.code == 401 -> callback(Result.failure(Exception("Unauthorized (401) - Check API Key")))
|
|
53
|
+
it.code == 500 -> callback(Result.failure(Exception("Server Error (500) - Try again later")))
|
|
54
|
+
else -> callback(Result.failure(Exception("HTTP Error: ${it.code} - ${it.message}")))
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
} catch (e: Exception) {
|
|
60
|
+
callback(Result.failure(e))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fun makePostRequest(urlString: String, postData: Any, callback: (Result<String>) -> Unit) {
|
|
65
|
+
makeHttpRequest(
|
|
66
|
+
urlString = urlString,
|
|
67
|
+
method = "POST",
|
|
68
|
+
headers = mapOf("Content-Type" to "application/json"),
|
|
69
|
+
body = postData.toString().takeIf { it != "null" },
|
|
70
|
+
callback = callback
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package io.hyperswitch.react
|
|
2
|
+
|
|
3
|
+
import kotlin.text.isNotEmpty
|
|
4
|
+
import kotlin.text.startsWith
|
|
5
|
+
|
|
6
|
+
enum class SDKEnvironment { SANDBOX, PROD }
|
|
7
|
+
|
|
8
|
+
class Utils {
|
|
9
|
+
companion object {
|
|
10
|
+
fun checkEnvironment(publishableKey: String): SDKEnvironment {
|
|
11
|
+
return if (publishableKey.isNotEmpty() && publishableKey.startsWith("pk_prd_")) {
|
|
12
|
+
SDKEnvironment.PROD
|
|
13
|
+
} else {
|
|
14
|
+
SDKEnvironment.SANDBOX
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun getLoggingUrl(publishableKey: String): String {
|
|
19
|
+
return if (checkEnvironment(publishableKey) == SDKEnvironment.PROD) "https://api.hyperswitch.io/logs/sdk"
|
|
20
|
+
else "https://sandbox.hyperswitch.io/logs/sdk"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
|
|
4
|
+
<style name="HyperTransparentTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
|
5
|
+
<item name="android:windowIsTranslucent">true</item>
|
|
6
|
+
<item name="android:windowBackground">@android:color/transparent</item>
|
|
7
|
+
<item name="android:windowContentOverlay">@null</item>
|
|
8
|
+
<item name="android:windowNoTitle">true</item>
|
|
9
|
+
<item name="android:backgroundDimEnabled">true</item>
|
|
10
|
+
<item name="android:windowAnimationStyle">@null</item>
|
|
11
|
+
<item name="android:windowDisablePreview">true</item>
|
|
12
|
+
<item name="android:windowTranslucentStatus">true</item>
|
|
13
|
+
<item name="android:windowTranslucentNavigation">true</item>
|
|
14
|
+
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
15
|
+
</style>
|
|
16
|
+
</resources>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperswitchModule.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 12/09/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
|
|
11
|
+
@objc(HyperswitchModule)
|
|
12
|
+
public class HyperswitchModule: NSObject {
|
|
13
|
+
|
|
14
|
+
@objc public static let shared: HyperswitchModule = HyperswitchModule()
|
|
15
|
+
var paymentSession: PaymentSession?
|
|
16
|
+
|
|
17
|
+
@objc(initialiseWithPublishableKey:customBackendUrl:customLogUrl:customParams:resolve:reject:)
|
|
18
|
+
public func initialise(publishableKey: String,
|
|
19
|
+
customBackendUrl: String?,
|
|
20
|
+
customLogUrl: String?,
|
|
21
|
+
customParams: [String:Any],
|
|
22
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
23
|
+
reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
24
|
+
|
|
25
|
+
self.paymentSession = PaymentSession(publishableKey: publishableKey,
|
|
26
|
+
customBackendUrl: customBackendUrl,
|
|
27
|
+
customParams: customParams,
|
|
28
|
+
customLogUrl: customLogUrl)
|
|
29
|
+
resolve(NSNull())
|
|
30
|
+
}
|
|
31
|
+
@objc(initPaymentSessionWithpaymentIntentClientSecret:resolve:reject:)
|
|
32
|
+
public func initPaymentSession(paymentIntentClientSecret: String,
|
|
33
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
34
|
+
reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
35
|
+
|
|
36
|
+
self.paymentSession?.initPaymentSession(paymentIntentClientSecret: paymentIntentClientSecret)
|
|
37
|
+
resolve(NSNull())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc(presentPaymentSheetWithConfiguration:resolver:rejecter:)
|
|
41
|
+
public func presentPaymentSheet(configuration: [String:Any],
|
|
42
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
43
|
+
reject: @escaping RCTPromiseRejectBlock) -> Void{
|
|
44
|
+
DispatchQueue.main.async {
|
|
45
|
+
guard let vc = RCTPresentedViewController() else {
|
|
46
|
+
reject("error", "Could not find presented view controller", NSError())
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
self.paymentSession?.presentPaymentSheetWithParams(viewController: vc, params: configuration, completion: { result in
|
|
50
|
+
switch result {
|
|
51
|
+
case .completed(let data):
|
|
52
|
+
resolve(["status": "completed", "message": data])
|
|
53
|
+
case .failed(let error as NSError):
|
|
54
|
+
resolve(["status": "failed", "code": error.domain, "message": "\(error.userInfo["message"] ?? "Failed")"])
|
|
55
|
+
case .canceled(let data):
|
|
56
|
+
resolve(["status": "cancelled", "message": data])
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperswitchNativeModule.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 12/09/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
|
|
11
|
+
@objc(HyperswitchNativeModule)
|
|
12
|
+
public class HyperswitchNativeModule: NSObject {
|
|
13
|
+
|
|
14
|
+
@objc public static let shared: HyperswitchNativeModule = HyperswitchNativeModule()
|
|
15
|
+
private let applePayPaymentHandler = ApplePayHandler()
|
|
16
|
+
private var presentCallback: RCTResponseSenderBlock? = nil
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@objc
|
|
20
|
+
public func sendMessageToNative(_ rnMessage: String) {}
|
|
21
|
+
|
|
22
|
+
@objc(launchApplePayWithRnMessage:rnCallback:)
|
|
23
|
+
public func launchApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
24
|
+
applePayPaymentHandler.startPayment(rnMessage: rnMessage, rnCallback: rnCallback, presentCallback: self.presentCallback)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc(startApplePayWithRnMessage:rnCallback:)
|
|
28
|
+
public func startApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
29
|
+
rnCallback([])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc(presentApplePayWithRnMessage:rnCallback:)
|
|
33
|
+
public func presentApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
34
|
+
self.presentCallback = rnCallback
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@objc(exitPaymentsheetWithRootTag:result:reset:)
|
|
38
|
+
public func exitPaymentsheet(_ reactTag: Double, _ rnMessage: String, _ reset: Bool) {
|
|
39
|
+
exitSheet(rnMessage)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @objc
|
|
43
|
+
// private func exitWidgetPaymentsheet(_ reactTag: NSNumber, _ rnMessage: String, _ reset: Bool) {
|
|
44
|
+
// exitSheet(rnMessage)
|
|
45
|
+
// }
|
|
46
|
+
//
|
|
47
|
+
// @objc
|
|
48
|
+
// private func exitPaymentMethodManagement(_ reactTag: NSNumber, _ rnMessage: String, _ reset: Bool) {
|
|
49
|
+
// exitSheet(rnMessage)
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// @objc
|
|
53
|
+
// private func exitCardForm(_ rnMessage: String) {
|
|
54
|
+
// var response: String?
|
|
55
|
+
// var error: NSError?
|
|
56
|
+
//
|
|
57
|
+
// if let data = rnMessage.data(using: .utf8) {
|
|
58
|
+
// do {
|
|
59
|
+
// if let jsonDictionary = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
|
60
|
+
// let status = jsonDictionary["status"]
|
|
61
|
+
//
|
|
62
|
+
// if (status == "failed" || status == "requires_payment_method") {
|
|
63
|
+
// error = NSError(domain: (jsonDictionary["code"] ?? "") != "" ? jsonDictionary["code"]! : "UNKNOWN_ERROR", code: 0, userInfo: ["message" : jsonDictionary["message"] ?? "An error has occurred."])
|
|
64
|
+
// } else {
|
|
65
|
+
// response = status
|
|
66
|
+
// }
|
|
67
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: response, error: error)
|
|
68
|
+
// } else {
|
|
69
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
70
|
+
// }
|
|
71
|
+
// } catch {
|
|
72
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
73
|
+
// }
|
|
74
|
+
// } else {
|
|
75
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
78
|
+
|
|
79
|
+
@objc
|
|
80
|
+
private func exitSheet(_ rnMessage: String) {
|
|
81
|
+
var response: String?
|
|
82
|
+
var error: NSError?
|
|
83
|
+
|
|
84
|
+
if let data = rnMessage.data(using: .utf8) {
|
|
85
|
+
do {
|
|
86
|
+
if let jsonDictionary = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
|
87
|
+
let status = jsonDictionary["status"]
|
|
88
|
+
|
|
89
|
+
if (status == "failed" || status == "requires_payment_method") {
|
|
90
|
+
error = NSError(domain: (jsonDictionary["code"] ?? "") != "" ? jsonDictionary["code"]! : "UNKNOWN_ERROR", code: 0, userInfo: ["message" : jsonDictionary["message"] ?? "An error has occurred."])
|
|
91
|
+
} else {
|
|
92
|
+
response = status
|
|
93
|
+
}
|
|
94
|
+
RNFabricManager.sharedInstance.responseHandler?.didReceiveResponse(response: response, error: error)
|
|
95
|
+
} else {
|
|
96
|
+
RNFabricManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
RNFabricManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
RNFabricManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
103
|
+
}
|
|
104
|
+
DispatchQueue.main.async {
|
|
105
|
+
if let view = RNFabricManager.sharedInstance.rootView {
|
|
106
|
+
let reactNativeVC: UIViewController? = view.reactViewController()
|
|
107
|
+
reactNativeVC?.dismiss(animated: false, completion: nil)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#import "HyperswitchSdkNative.h"
|
|
2
|
+
#if __has_include("HyperswitchSdkReactNative-Swift.h")
|
|
3
|
+
#import "HyperswitchSdkReactNative-Swift.h"
|
|
4
|
+
#else
|
|
5
|
+
// When using use_frameworks! :linkage => :static in Podfile
|
|
6
|
+
#import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
@implementation HyperswitchSdkNative
|
|
10
|
+
RCT_EXPORT_MODULE(HyperModules)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
- (void)sendMessageToNative:(NSString *)message {
|
|
14
|
+
// RCTLogInfo(@"sendMessageToNative called with: %@", message);
|
|
15
|
+
// Forward to other modules if needed
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RCT_EXPORT_METHOD(launchApplePay:(NSString *)requestObj
|
|
19
|
+
callback:(RCTResponseSenderBlock)callback) {
|
|
20
|
+
[HyperswitchNativeModule.shared launchApplePayWithRnMessage:requestObj rnCallback:callback];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
RCT_EXPORT_METHOD(startApplePay:(NSString *)requestObj
|
|
24
|
+
callback:(RCTResponseSenderBlock)callback) {
|
|
25
|
+
// RCTLogInfo(@"startApplePay called with: %@", requestObj);
|
|
26
|
+
[HyperswitchNativeModule.shared startApplePayWithRnMessage:requestObj rnCallback:callback];
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
RCT_EXPORT_METHOD(presentApplePay:(NSString *)requestObj
|
|
31
|
+
callback:(RCTResponseSenderBlock)callback) {
|
|
32
|
+
[HyperswitchNativeModule.shared presentApplePayWithRnMessage:requestObj rnCallback:callback];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)launchGPay:(NSString *)requestObj
|
|
36
|
+
callback:(RCTResponseSenderBlock)callback {
|
|
37
|
+
// RCTLogInfo(@"launchGPay called");
|
|
38
|
+
// Google Pay is not available on iOS, but we can provide a callback
|
|
39
|
+
callback(@[@"Google Pay not available on iOS"]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)exitPaymentsheet:(double)rootTag
|
|
43
|
+
result:(NSString *)result
|
|
44
|
+
reset:(BOOL)reset {
|
|
45
|
+
[HyperswitchNativeModule.shared exitPaymentsheetWithRootTag:rootTag result:result reset:reset];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)exitPaymentMethodManagement:(double)rootTag
|
|
49
|
+
result:(NSString *)result
|
|
50
|
+
reset:(BOOL)reset {
|
|
51
|
+
// RCTLogInfo(@"exitPaymentMethodManagement called with rootTag: %f, result: %@, reset: %@",
|
|
52
|
+
// rootTag, result, reset ? @"YES" : @"NO");
|
|
53
|
+
// Implementation for exiting payment method management
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (void)exitWidget:(NSString *)result
|
|
57
|
+
widgetType:(NSString *)widgetType {
|
|
58
|
+
// RCTLogInfo(@"exitWidget called with result: %@, widgetType: %@", result, widgetType);
|
|
59
|
+
// Implementation for exiting widget
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)exitCardForm:(NSString *)result {
|
|
63
|
+
// RCTLogInfo(@"exitCardForm called with result: %@", result);
|
|
64
|
+
// Implementation for exiting card form
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)exitWidgetPaymentsheet:(double)rootTag
|
|
68
|
+
result:(NSString *)result
|
|
69
|
+
reset:(BOOL)reset {
|
|
70
|
+
// RCTLogInfo(@"exitWidgetPaymentsheet called with rootTag: %f, result: %@, reset: %@",
|
|
71
|
+
// rootTag, result, reset ? @"YES" : @"NO");
|
|
72
|
+
// Implementation for exiting widget payment sheet
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (void)launchWidgetPaymentSheet:(NSString *)requestObj
|
|
76
|
+
callback:(RCTResponseSenderBlock)callback {
|
|
77
|
+
// RCTLogInfo(@"launchWidgetPaymentSheet called");
|
|
78
|
+
// Implementation for launching widget payment sheet
|
|
79
|
+
callback(@[@"Widget payment sheet implementation needed"]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)updateWidgetHeight:(double)height {
|
|
83
|
+
// RCTLogInfo(@"updateWidgetHeight called with height: %f", height);
|
|
84
|
+
// Implementation for updating widget height
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)onAddPaymentMethod:(NSString *)data {
|
|
88
|
+
// RCTLogInfo(@"onAddPaymentMethod called with data: %@", data);
|
|
89
|
+
// Implementation for adding payment method
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
93
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
94
|
+
{
|
|
95
|
+
return std::make_shared<facebook::react::NativeHyperswitchSdkNativeSpecJSI>(params);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@end
|