@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,112 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
5
|
+
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
|
|
6
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
7
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
8
|
+
import * as NativeHyperswitchSdk$JuspayTechReactNativeHyperswitch from "../modules/NativeHyperswitchSdk.res.js";
|
|
9
|
+
|
|
10
|
+
var defaultVal = {
|
|
11
|
+
publishableKey: "",
|
|
12
|
+
isInitialized: false
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var hyperProviderContext = React.createContext([
|
|
16
|
+
defaultVal,
|
|
17
|
+
(function (param) {
|
|
18
|
+
|
|
19
|
+
})
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
var make = hyperProviderContext.Provider;
|
|
23
|
+
|
|
24
|
+
var Provider = {
|
|
25
|
+
make: make
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function initHyperswitch(publishableKey, customBackendUrl, customLogUrl, customParams) {
|
|
29
|
+
return NativeHyperswitchSdk$JuspayTechReactNativeHyperswitch.nativeHyperswitchSdk.initialise(publishableKey, customBackendUrl, customLogUrl, customParams);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function HyperProvider(props) {
|
|
33
|
+
var customParams = props.customParams;
|
|
34
|
+
var customLogUrl = props.customLogUrl;
|
|
35
|
+
var customBackendUrl = props.customBackendUrl;
|
|
36
|
+
var __publishableKey = props.publishableKey;
|
|
37
|
+
var publishableKey = __publishableKey !== undefined ? __publishableKey : "";
|
|
38
|
+
var match = React.useState(function () {
|
|
39
|
+
return {
|
|
40
|
+
publishableKey: publishableKey,
|
|
41
|
+
customBackendUrl: customBackendUrl,
|
|
42
|
+
customLogUrl: customLogUrl,
|
|
43
|
+
customParams: customParams,
|
|
44
|
+
isInitialized: false
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
var setState = match[1];
|
|
48
|
+
var state = match[0];
|
|
49
|
+
var getError = function (errorOpt) {
|
|
50
|
+
var error = errorOpt !== undefined ? errorOpt : "Failed to initialize Hyperswitch";
|
|
51
|
+
var newrecord = Caml_obj.obj_dup(state);
|
|
52
|
+
newrecord.error = error;
|
|
53
|
+
return newrecord;
|
|
54
|
+
};
|
|
55
|
+
var initialise = async function () {
|
|
56
|
+
try {
|
|
57
|
+
await initHyperswitch(publishableKey, customBackendUrl, customLogUrl, customParams);
|
|
58
|
+
return setState(function (param) {
|
|
59
|
+
var newrecord = Caml_obj.obj_dup(state);
|
|
60
|
+
newrecord.isInitialized = true;
|
|
61
|
+
return newrecord;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (raw_obj){
|
|
65
|
+
var obj = Caml_js_exceptions.internalToOCamlException(raw_obj);
|
|
66
|
+
if (obj.RE_EXN_ID !== Js_exn.$$Error) {
|
|
67
|
+
return setState(function (param) {
|
|
68
|
+
return getError(undefined);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
var error = obj._1.message;
|
|
72
|
+
if (error !== undefined) {
|
|
73
|
+
return setState(function (param) {
|
|
74
|
+
return getError(error);
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
return setState(function (param) {
|
|
78
|
+
return getError(undefined);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
React.useEffect((function () {
|
|
84
|
+
if (publishableKey !== "") {
|
|
85
|
+
initialise();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}), [publishableKey]);
|
|
89
|
+
var setState$1 = React.useCallback((function (val) {
|
|
90
|
+
setState(function (param) {
|
|
91
|
+
return val;
|
|
92
|
+
});
|
|
93
|
+
}), [setState]);
|
|
94
|
+
return JsxRuntime.jsx(make, {
|
|
95
|
+
value: [
|
|
96
|
+
state,
|
|
97
|
+
setState$1
|
|
98
|
+
],
|
|
99
|
+
children: props.children
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var make$1 = HyperProvider;
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
defaultVal ,
|
|
107
|
+
hyperProviderContext ,
|
|
108
|
+
Provider ,
|
|
109
|
+
initHyperswitch ,
|
|
110
|
+
make$1 as make,
|
|
111
|
+
}
|
|
112
|
+
/* hyperProviderContext Not a pure module */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* TypeScript file generated from useHyper.res by genType. */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
|
|
6
|
+
import * as useHyperJS from './useHyper.res.js';
|
|
7
|
+
|
|
8
|
+
import type {initPaymentSessionParams as NativeHyperswitchSdk_initPaymentSessionParams} from '../../src/modules/NativeHyperswitchSdk.gen';
|
|
9
|
+
|
|
10
|
+
import type {initPaymentSessionResult as NativeHyperswitchSdk_initPaymentSessionResult} from '../../src/modules/NativeHyperswitchSdk.gen';
|
|
11
|
+
|
|
12
|
+
import type {presentPaymentSheetParams as NativeHyperswitchSdk_presentPaymentSheetParams} from '../../src/modules/NativeHyperswitchSdk.gen';
|
|
13
|
+
|
|
14
|
+
import type {presentPaymentSheetResult as NativeHyperswitchSdk_presentPaymentSheetResult} from '../../src/modules/NativeHyperswitchSdk.gen';
|
|
15
|
+
|
|
16
|
+
export type useHyper = { readonly initPaymentSession: (_1:NativeHyperswitchSdk_initPaymentSessionParams) => Promise<NativeHyperswitchSdk_initPaymentSessionResult>; readonly presentPaymentSheet: (_1:NativeHyperswitchSdk_presentPaymentSheetParams) => Promise<NativeHyperswitchSdk_presentPaymentSheetResult> };
|
|
17
|
+
|
|
18
|
+
export const useHyper: () => useHyper = useHyperJS.useHyper as any;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
open NativeHyperswitchSdk
|
|
2
|
+
|
|
3
|
+
let getError: (~error: string=?) => presentPaymentSheetResult = (
|
|
4
|
+
~error="Unknown error occurred while presenting payment sheet",
|
|
5
|
+
) => {
|
|
6
|
+
{
|
|
7
|
+
error: {
|
|
8
|
+
code: "failed",
|
|
9
|
+
message: error,
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let _initPaymentSession = async (params: initPaymentSessionParams): initPaymentSessionResult => {
|
|
15
|
+
try {
|
|
16
|
+
await nativeHyperswitchSdk.initPaymentSession(
|
|
17
|
+
~paymentIntentClientSecret=params.paymentIntentClientSecret->Option.getOr(""),
|
|
18
|
+
)
|
|
19
|
+
{}
|
|
20
|
+
} catch {
|
|
21
|
+
| Exn.Error(obj) =>
|
|
22
|
+
switch Exn.message(obj) {
|
|
23
|
+
| Some(msg) => {error: msg}
|
|
24
|
+
| None => {error: "Unknown error occurred while initializing payment sheet"}
|
|
25
|
+
}
|
|
26
|
+
| _ => {error: "Unexpected error occurred while initializing payment sheet"}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
let getData = (data, ~key : string, ~fallback : string)=>{
|
|
30
|
+
data
|
|
31
|
+
->Option.flatMap(obj =>
|
|
32
|
+
obj->Js.Dict.get(key)->Option.flatMap(json => json->Js.Json.decodeString)
|
|
33
|
+
)
|
|
34
|
+
->Option.getOr(fallback)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let parsePaymentSheetResult = (result: 'a): presentPaymentSheetResult => {
|
|
38
|
+
try {
|
|
39
|
+
let parsed = switch Js.typeof(result) {
|
|
40
|
+
| "string" => Js.Json.parseExn(result)
|
|
41
|
+
| _ => result->Obj.magic
|
|
42
|
+
}
|
|
43
|
+
let decodedObject = parsed->Js.Json.decodeObject
|
|
44
|
+
|
|
45
|
+
let status =
|
|
46
|
+
decodedObject->getData(~key="status", ~fallback="failed")
|
|
47
|
+
let errorMessage =
|
|
48
|
+
decodedObject->getData(~key="error", ~fallback="")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
let code =
|
|
52
|
+
decodedObject->getData(~key="code", ~fallback="")
|
|
53
|
+
|
|
54
|
+
let typeData =
|
|
55
|
+
decodedObject->getData(~key="type", ~fallback="")
|
|
56
|
+
|
|
57
|
+
let message =
|
|
58
|
+
decodedObject
|
|
59
|
+
->getData(~key="message", ~fallback="failed")
|
|
60
|
+
|
|
61
|
+
let paymentResult = {
|
|
62
|
+
status,
|
|
63
|
+
message,
|
|
64
|
+
error: errorMessage,
|
|
65
|
+
\"type": typeData,
|
|
66
|
+
}
|
|
67
|
+
let error = {
|
|
68
|
+
code,
|
|
69
|
+
message: errorMessage,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if errorMessage != "" {
|
|
73
|
+
{error, paymentResult}
|
|
74
|
+
} else {
|
|
75
|
+
{paymentResult: paymentResult}
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
| _ => getError(~error="Failed to parse payment sheet result")
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let _presentPaymentSheet = async (params: presentPaymentSheetParams): presentPaymentSheetResult => {
|
|
83
|
+
try {
|
|
84
|
+
let result = await nativeHyperswitchSdk.presentPaymentSheet(params)
|
|
85
|
+
result->parsePaymentSheetResult
|
|
86
|
+
} catch {
|
|
87
|
+
| Exn.Error(obj) =>
|
|
88
|
+
// Check if the error is an object error - if so, return the error
|
|
89
|
+
switch Js.typeof(obj) {
|
|
90
|
+
| "object" =>
|
|
91
|
+
// Try to parse the object error
|
|
92
|
+
try {
|
|
93
|
+
let errorObj = obj->Obj.magic
|
|
94
|
+
let parsedError = errorObj->parsePaymentSheetResult
|
|
95
|
+
parsedError
|
|
96
|
+
} catch {
|
|
97
|
+
| _ =>
|
|
98
|
+
switch Exn.message(obj) {
|
|
99
|
+
| Some(error) => getError(~error)
|
|
100
|
+
| None => getError()
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
| _ =>
|
|
104
|
+
switch Exn.message(obj) {
|
|
105
|
+
| Some(error) => getError(~error)
|
|
106
|
+
| None => getError()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
| _ => getError()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
type useHyper = {
|
|
114
|
+
initPaymentSession: initPaymentSessionParams => promise<initPaymentSessionResult>,
|
|
115
|
+
presentPaymentSheet: presentPaymentSheetParams => promise<presentPaymentSheetResult>,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@genType
|
|
119
|
+
let useHyper = () => {
|
|
120
|
+
let (contextData, _) = React.useContext(HyperProvider.hyperProviderContext)
|
|
121
|
+
let isReady = contextData.isInitialized && contextData.error->Belt.Option.isNone
|
|
122
|
+
|
|
123
|
+
let initPaymentSession = React.useCallback0((params: initPaymentSessionParams) => {
|
|
124
|
+
_initPaymentSession(params)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
let presentPaymentSheet = React.useCallback1((params: presentPaymentSheetParams) => {
|
|
128
|
+
if !isReady {
|
|
129
|
+
let a: promise<presentPaymentSheetResult> = Promise.resolve(
|
|
130
|
+
getError(~error="Hyperswitch is not initialized"),
|
|
131
|
+
)
|
|
132
|
+
a
|
|
133
|
+
} else {
|
|
134
|
+
_presentPaymentSheet(params)
|
|
135
|
+
}
|
|
136
|
+
}, [isReady])
|
|
137
|
+
|
|
138
|
+
{
|
|
139
|
+
initPaymentSession,
|
|
140
|
+
presentPaymentSheet,
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
5
|
+
import * as Js_dict from "rescript/lib/es6/js_dict.js";
|
|
6
|
+
import * as Js_json from "rescript/lib/es6/js_json.js";
|
|
7
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
8
|
+
import * as Core__Option from "@rescript/core/src/Core__Option.res.js";
|
|
9
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
10
|
+
import * as HyperProvider$JuspayTechReactNativeHyperswitch from "../context/HyperProvider.res.js";
|
|
11
|
+
import * as NativeHyperswitchSdk$JuspayTechReactNativeHyperswitch from "../modules/NativeHyperswitchSdk.res.js";
|
|
12
|
+
|
|
13
|
+
function getError(errorOpt) {
|
|
14
|
+
var error = errorOpt !== undefined ? errorOpt : "Unknown error occurred while presenting payment sheet";
|
|
15
|
+
return {
|
|
16
|
+
error: {
|
|
17
|
+
code: "failed",
|
|
18
|
+
message: error
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function _initPaymentSession(params) {
|
|
24
|
+
try {
|
|
25
|
+
await NativeHyperswitchSdk$JuspayTechReactNativeHyperswitch.nativeHyperswitchSdk.initPaymentSession(Core__Option.getOr(params.paymentIntentClientSecret, ""));
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
catch (raw_obj){
|
|
29
|
+
var obj = Caml_js_exceptions.internalToOCamlException(raw_obj);
|
|
30
|
+
if (obj.RE_EXN_ID !== Js_exn.$$Error) {
|
|
31
|
+
return {
|
|
32
|
+
error: "Unexpected error occurred while initializing payment sheet"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var msg = obj._1.message;
|
|
36
|
+
if (msg !== undefined) {
|
|
37
|
+
return {
|
|
38
|
+
error: msg
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
return {
|
|
42
|
+
error: "Unknown error occurred while initializing payment sheet"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getData(data, key, fallback) {
|
|
49
|
+
return Core__Option.getOr(Core__Option.flatMap(data, (function (obj) {
|
|
50
|
+
return Core__Option.flatMap(Js_dict.get(obj, key), Js_json.decodeString);
|
|
51
|
+
})), fallback);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function parsePaymentSheetResult(result) {
|
|
55
|
+
try {
|
|
56
|
+
var match = typeof result;
|
|
57
|
+
var parsed = match === "string" ? JSON.parse(result) : result;
|
|
58
|
+
var decodedObject = Js_json.decodeObject(parsed);
|
|
59
|
+
var status = getData(decodedObject, "status", "failed");
|
|
60
|
+
var errorMessage = getData(decodedObject, "error", "");
|
|
61
|
+
var code = getData(decodedObject, "code", "");
|
|
62
|
+
var typeData = getData(decodedObject, "type", "");
|
|
63
|
+
var message = getData(decodedObject, "message", "failed");
|
|
64
|
+
var paymentResult_error = errorMessage;
|
|
65
|
+
var paymentResult_type = typeData;
|
|
66
|
+
var paymentResult = {
|
|
67
|
+
status: status,
|
|
68
|
+
message: message,
|
|
69
|
+
error: paymentResult_error,
|
|
70
|
+
type: paymentResult_type
|
|
71
|
+
};
|
|
72
|
+
var error_code = code;
|
|
73
|
+
var error_message = errorMessage;
|
|
74
|
+
var error = {
|
|
75
|
+
code: error_code,
|
|
76
|
+
message: error_message
|
|
77
|
+
};
|
|
78
|
+
if (errorMessage !== "") {
|
|
79
|
+
return {
|
|
80
|
+
error: error,
|
|
81
|
+
paymentResult: paymentResult
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
return {
|
|
85
|
+
paymentResult: paymentResult
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (exn){
|
|
90
|
+
return getError("Failed to parse payment sheet result");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function _presentPaymentSheet(params) {
|
|
95
|
+
try {
|
|
96
|
+
var result = await NativeHyperswitchSdk$JuspayTechReactNativeHyperswitch.nativeHyperswitchSdk.presentPaymentSheet(params);
|
|
97
|
+
return parsePaymentSheetResult(result);
|
|
98
|
+
}
|
|
99
|
+
catch (raw_obj){
|
|
100
|
+
var obj = Caml_js_exceptions.internalToOCamlException(raw_obj);
|
|
101
|
+
if (obj.RE_EXN_ID !== Js_exn.$$Error) {
|
|
102
|
+
return getError(undefined);
|
|
103
|
+
}
|
|
104
|
+
var obj$1 = obj._1;
|
|
105
|
+
var match = typeof obj$1;
|
|
106
|
+
if (match === "object") {
|
|
107
|
+
try {
|
|
108
|
+
return parsePaymentSheetResult(obj$1);
|
|
109
|
+
}
|
|
110
|
+
catch (exn){
|
|
111
|
+
var error = obj$1.message;
|
|
112
|
+
if (error !== undefined) {
|
|
113
|
+
return getError(error);
|
|
114
|
+
} else {
|
|
115
|
+
return getError(undefined);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
var error$1 = obj$1.message;
|
|
120
|
+
if (error$1 !== undefined) {
|
|
121
|
+
return getError(error$1);
|
|
122
|
+
} else {
|
|
123
|
+
return getError(undefined);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function useHyper() {
|
|
130
|
+
var match = React.useContext(HyperProvider$JuspayTechReactNativeHyperswitch.hyperProviderContext);
|
|
131
|
+
var contextData = match[0];
|
|
132
|
+
var isReady = contextData.isInitialized && Belt_Option.isNone(contextData.error);
|
|
133
|
+
var initPaymentSession = React.useCallback((function (params) {
|
|
134
|
+
return _initPaymentSession(params);
|
|
135
|
+
}), []);
|
|
136
|
+
var presentPaymentSheet = React.useCallback((function (params) {
|
|
137
|
+
if (isReady) {
|
|
138
|
+
return _presentPaymentSheet(params);
|
|
139
|
+
} else {
|
|
140
|
+
return Promise.resolve(getError("Hyperswitch is not initialized"));
|
|
141
|
+
}
|
|
142
|
+
}), [isReady]);
|
|
143
|
+
return {
|
|
144
|
+
initPaymentSession: initPaymentSession,
|
|
145
|
+
presentPaymentSheet: presentPaymentSheet
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
getError ,
|
|
151
|
+
_initPaymentSession ,
|
|
152
|
+
getData ,
|
|
153
|
+
parsePaymentSheetResult ,
|
|
154
|
+
_presentPaymentSheet ,
|
|
155
|
+
useHyper ,
|
|
156
|
+
}
|
|
157
|
+
/* react Not a pure module */
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
initPaymentSessionParams as InitPaymentSessionParams,
|
|
3
|
+
initPaymentSessionResult as InitPaymentSessionResult,
|
|
4
|
+
presentPaymentSheetParams as PresentPaymentSheetParams,
|
|
5
|
+
presentPaymentSheetResult as PresentPaymentSheetResult,
|
|
6
|
+
} from './modules/NativeHyperswitchSdk.gen';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
make as HyperProvider,
|
|
10
|
+
initHyperswitch,
|
|
11
|
+
} from './context/HyperProvider.gen';
|
|
12
|
+
|
|
13
|
+
export { useHyper } from './hooks/useHyper.gen';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* TypeScript file generated from NativeHyperswitchSdk.res by genType. */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
|
|
6
|
+
import type {options as PaymentSheetConfiguration_options} from '../../src/types/PaymentSheetConfiguration.gen';
|
|
7
|
+
|
|
8
|
+
export type initPaymentSessionParams = { readonly paymentIntentClientSecret?: string };
|
|
9
|
+
|
|
10
|
+
export type initPaymentSessionResult = { readonly error?: string };
|
|
11
|
+
|
|
12
|
+
export type presentPaymentSheetParams = PaymentSheetConfiguration_options;
|
|
13
|
+
|
|
14
|
+
export type paymentResult = {
|
|
15
|
+
readonly status: string;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
readonly error?: string;
|
|
18
|
+
readonly type?: string
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type error = { readonly code?: string; readonly message?: string };
|
|
22
|
+
|
|
23
|
+
export type presentPaymentSheetResult = { readonly error?: error; readonly paymentResult?: paymentResult };
|
|
24
|
+
|
|
25
|
+
export type presentPaymentSheet = (_1:presentPaymentSheetParams) => Promise<string>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
type initialise = (
|
|
3
|
+
~publishableKey: string,
|
|
4
|
+
~customBackendUrl: string=?,
|
|
5
|
+
~customLogUrl: string=?,
|
|
6
|
+
~customParams: Js.Json.t=?,
|
|
7
|
+
) => promise<unit>
|
|
8
|
+
|
|
9
|
+
type initPaymentSession = (~paymentIntentClientSecret: string) => promise<unit>
|
|
10
|
+
|
|
11
|
+
@genType
|
|
12
|
+
type initPaymentSessionParams = {paymentIntentClientSecret?: string}
|
|
13
|
+
|
|
14
|
+
@genType
|
|
15
|
+
type initPaymentSessionResult = {error?: string}
|
|
16
|
+
|
|
17
|
+
@genType
|
|
18
|
+
type presentPaymentSheetParams = PaymentSheetConfiguration.options
|
|
19
|
+
|
|
20
|
+
type status =
|
|
21
|
+
| @as("succeeded") Completed
|
|
22
|
+
| @as("cancelled") Canceled
|
|
23
|
+
| @as("Failed") Failed
|
|
24
|
+
|
|
25
|
+
@genType
|
|
26
|
+
type paymentResult = {
|
|
27
|
+
status: string,
|
|
28
|
+
message: string,
|
|
29
|
+
error?: string,
|
|
30
|
+
\"type"?: string,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@genType
|
|
34
|
+
type error = {
|
|
35
|
+
code?: string,
|
|
36
|
+
message?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@genType
|
|
40
|
+
type presentPaymentSheetResult = {
|
|
41
|
+
error?: error,
|
|
42
|
+
paymentResult?: paymentResult
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@genType
|
|
46
|
+
type presentPaymentSheet = presentPaymentSheetParams => promise<string>
|
|
47
|
+
|
|
48
|
+
type nativeHyperswitchSdk = {
|
|
49
|
+
initialise: initialise,
|
|
50
|
+
initPaymentSession: initPaymentSession,
|
|
51
|
+
presentPaymentSheet: presentPaymentSheet,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@module("../specs/NativeHyperswitchSdkReactNative")
|
|
55
|
+
external nativeHyperswitchSdk: nativeHyperswitchSdk = "default"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import NativeHyperswitchSdkReactNative from "../specs/NativeHyperswitchSdkReactNative";
|
|
4
|
+
|
|
5
|
+
var nativeHyperswitchSdk = NativeHyperswitchSdkReactNative;
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
nativeHyperswitchSdk ,
|
|
9
|
+
}
|
|
10
|
+
/* nativeHyperswitchSdk Not a pure module */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
interface NativeProps extends ViewProps {
|
|
6
|
+
buttonType?: string;
|
|
7
|
+
buttonStyle?: string;
|
|
8
|
+
cornerRadius?: Double;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default codegenNativeComponent<NativeProps>('ApplePayView');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
interface NativeProps extends ViewProps {
|
|
6
|
+
buttonType?: string;
|
|
7
|
+
buttonStyle?: string;
|
|
8
|
+
borderRadius?: Double;
|
|
9
|
+
allowedPaymentMethods?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default codegenNativeComponent<NativeProps>('GooglePayButton');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
// import type { ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// interface NativeProps extends ViewProps {
|
|
5
|
+
// color?: string;
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
// export default codegenNativeComponent<NativeProps>(
|
|
9
|
+
// 'HyperswitchSdkReactNativeView'
|
|
10
|
+
// );
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
// Send message to native
|
|
6
|
+
sendMessageToNative(message: string): void;
|
|
7
|
+
|
|
8
|
+
// Apple Pay methods
|
|
9
|
+
launchApplePay(requestObj: string, callback: (result: Object) => void): void;
|
|
10
|
+
// Google Pay method
|
|
11
|
+
launchGPay(requestObj: string, callback: (result: Object) => void): void;
|
|
12
|
+
|
|
13
|
+
// Exit methods
|
|
14
|
+
exitPaymentsheet(rootTag: number, result: string, reset: boolean): void;
|
|
15
|
+
exitPaymentMethodManagement(
|
|
16
|
+
rootTag: number,
|
|
17
|
+
result: string,
|
|
18
|
+
reset: boolean
|
|
19
|
+
): void;
|
|
20
|
+
exitWidget(result: string, widgetType: string): void;
|
|
21
|
+
exitCardForm(result: string): void;
|
|
22
|
+
exitWidgetPaymentsheet(rootTag: number, result: string, reset: boolean): void;
|
|
23
|
+
|
|
24
|
+
// Widget methods
|
|
25
|
+
launchWidgetPaymentSheet(
|
|
26
|
+
requestObj: string,
|
|
27
|
+
callback: (result: Object) => void
|
|
28
|
+
): void;
|
|
29
|
+
updateWidgetHeight(height: number): void;
|
|
30
|
+
onAddPaymentMethod(data: string): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('HyperModules') as Spec;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
initialise(
|
|
6
|
+
publishableKey: string,
|
|
7
|
+
customBackendUrl: undefined | string,
|
|
8
|
+
customLogUrl: undefined | string,
|
|
9
|
+
customParams: undefined | Object
|
|
10
|
+
): Promise<void>;
|
|
11
|
+
initPaymentSession(paymentIntentClientSecret: string): Promise<string>;
|
|
12
|
+
presentPaymentSheet(configuration: Object): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
16
|
+
'HyperswitchSdkReactNative'
|
|
17
|
+
);
|