react-native-hyperswitch-dev-sdk 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HyperswitchSdkReactNative.podspec +42 -0
- package/LICENSE +201 -0
- package/android/build.gradle +161 -0
- package/android/gradle.properties +5 -0
- package/android/hyperswitch_autolinking.gradle +378 -0
- package/android/proguard-rules.pro +72 -0
- package/android/src/legacy/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +41 -0
- package/android/src/legacy/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +20 -0
- package/android/src/legacy/java/com/facebook/react/viewmanagers/NativePaymentWidgetManagerDelegate.java +38 -0
- package/android/src/legacy/java/com/facebook/react/viewmanagers/NativePaymentWidgetManagerInterface.java +21 -0
- package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativeHyperswitchSdkNativeSpec.java +106 -0
- package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativeHyperswitchSdkReactNativeSpec.java +77 -0
- package/android/src/legacy/java/com/hyperswitchsdkreactnative/NativePaymentWidgetNativeSpec.java +36 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/assets/hyperswitch.bundle +1535 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +47 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/NativePaymentWidgetModule.kt +173 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/ReactNativeHyperswitchModule.kt +396 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/PaymentElementViewManager.kt +99 -0
- package/android/src/main/java/io/hyperswitch/HyperswitchReactPackageProvider.kt +19 -0
- package/android/src/main/java/io/hyperswitch/PaymentEventType.kt +18 -0
- package/android/src/main/java/io/hyperswitch/model/ElementConfiguration.kt +58 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/ExitHeadlessCallBackManager.kt +47 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/GetPaymentSessionCallBackManager.kt +23 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentMethod.kt +167 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionHandler.kt +68 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionHandlerImpl.kt +179 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSessionReactLauncher.kt +226 -0
- package/android/src/main/java/io/hyperswitch/paymentsession/PaymentSheetCallbackManager.kt +40 -0
- package/android/src/main/java/io/hyperswitch/paymentsheet/PaymentResult.kt +63 -0
- package/android/src/main/java/io/hyperswitch/react/GooglePayButtonManager.kt +54 -0
- package/android/src/main/java/io/hyperswitch/react/HyperActivity.kt +73 -0
- package/android/src/main/java/io/hyperswitch/react/HyperEventEmitter.kt +144 -0
- package/android/src/main/java/io/hyperswitch/react/HyperFragment.kt +429 -0
- package/android/src/main/java/io/hyperswitch/react/HyperFragmentManager.kt +155 -0
- package/android/src/main/java/io/hyperswitch/react/HyperHeadlessModule.kt +43 -0
- package/android/src/main/java/io/hyperswitch/react/HyperModule.kt +405 -0
- package/android/src/main/java/io/hyperswitch/react/HyperPackage.kt +16 -0
- package/android/src/main/java/io/hyperswitch/react/ReactNativeController.kt +251 -0
- package/android/src/main/java/io/hyperswitch/utils/ConversionUtils.kt +256 -0
- package/android/src/main/java/io/hyperswitch/utils/StandardResult.kt +45 -0
- package/android/src/main/java/io/hyperswitch/view/GooglePayButtonView.kt +59 -0
- package/android/src/main/java/io/hyperswitch/view/PaymentWidgetView.kt +405 -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/ReactNative/HyperswitchModule.swift +470 -0
- package/ios/Modules/ReactNative/HyperswitchSdkReactNative.h +5 -0
- package/ios/Modules/ReactNative/HyperswitchSdkReactNative.mm +121 -0
- package/ios/Modules/ReactNative/NativeHyperswitchModule.h +18 -0
- package/ios/Modules/ReactNative/NativeHyperswitchModule.mm +165 -0
- package/ios/Modules/ReactNative/NativeHyperswitchModuleImpl.swift +290 -0
- package/ios/Modules/ReactNative/NativePaymentElementModule.mm +129 -0
- package/ios/Views/Fabric/ApplePayView.h +14 -0
- package/ios/Views/Fabric/ApplePayView.mm +89 -0
- package/ios/Views/Fabric/NativePaymentElementView.h +21 -0
- package/ios/Views/Fabric/NativePaymentElementView.mm +200 -0
- package/ios/Views/Fabric/NativePaymentWidgetViewRegistry.h +37 -0
- package/ios/Views/Fabric/NativePaymentWidgetViewRegistry.m +45 -0
- package/ios/Views/Native/NativePaymentWidget.m +26 -0
- package/ios/Views/Native/NativePaymentWidget.swift +420 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +261 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +126 -0
- package/ios/hyperswitchSDK/Core/DeviceDataCollection/HeadlessWebView.swift +144 -0
- package/ios/hyperswitchSDK/Core/HyperCVCWidget/CVCWidget.swift +136 -0
- package/ios/hyperswitchSDK/Core/HyperExpressCheckout/ExpressCheckoutLauncher.swift +116 -0
- package/ios/hyperswitchSDK/Core/HyperExpressCheckout/ExpressCheckoutWidget.swift +42 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentCardTextField+SwiftUI.swift +67 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentCardTextField.swift +44 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentHandler.swift +59 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentIntentParams.swift +31 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentCardTextField/PaymentMethodParams.swift +25 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentMethodManagement/PaymentManagementConfiguration.swift +213 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentMethodManagement/PaymentMethodManagementWidget.swift +92 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheet+Events.swift +36 -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 +68 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentWidget/PaymentWidget.swift +212 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +228 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +174 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +15 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +108 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +31 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +343 -0
- package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +117 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +47 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +55 -0
- package/ios/hyperswitchSDK/Core/NativeModule/WidgetAction.swift +30 -0
- package/ios/hyperswitchSDK/Core/NativeModule/WidgetResponseRegistry.swift +92 -0
- package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +12 -0
- package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1531 -0
- package/ios/hyperswitchSDK/CoreLite/ApplePayHandlerLite.swift +251 -0
- package/ios/hyperswitchSDK/CoreLite/PaymentSession+Lite.swift +25 -0
- package/ios/hyperswitchSDK/CoreLite/PaymentSheetView+Lite.swift +45 -0
- package/ios/hyperswitchSDK/CoreLite/SwiftUI+Lite.swift +48 -0
- package/ios/hyperswitchSDK/CoreLite/WebViewController.swift +278 -0
- package/ios/hyperswitchSDK/Shared/APIClient.swift +22 -0
- package/ios/hyperswitchSDK/Shared/Codable+UIKit.swift +75 -0
- package/ios/hyperswitchSDK/Shared/CustomEndpointConfiguration.swift +67 -0
- package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
- package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
- package/ios/hyperswitchSDK/Shared/Extensions.swift +101 -0
- package/ios/hyperswitchSDK/Shared/Helper.swift +40 -0
- package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventData.swift +125 -0
- package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventSubscriptionBuilder.swift +45 -0
- package/ios/hyperswitchSDK/Shared/HyperEvents/PaymentEventType.swift +30 -0
- package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +151 -0
- package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
- package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +27 -0
- package/ios/hyperswitchSDK/Shared/Hyperswitch.swift +20 -0
- package/ios/hyperswitchSDK/Shared/HyperswitchConfigurationSchema.swift +54 -0
- package/ios/hyperswitchSDK/Shared/HyperswitchEnvironment.swift +11 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/Debouncer.swift +37 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogBuilder.swift +113 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogFileManager.swift +76 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogManager.swift +113 -0
- package/ios/hyperswitchSDK/Shared/NativeLogger/LogPayload.swift +91 -0
- package/ios/hyperswitchSDK/Shared/PaymentMethodType.swift +15 -0
- package/ios/hyperswitchSDK/Shared/PaymentSession.swift +98 -0
- package/ios/hyperswitchSDK/Shared/PaymentSessionConfiguration.swift +14 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +33 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance+Codable.swift +182 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +238 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +161 -0
- package/ios/hyperswitchSDK/Shared/SDKParams.swift +43 -0
- package/ios/hyperswitchSDK/Shared/SavedPaymentMethodsConfiguration.swift +20 -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 +0 -0
- package/lib/bs/build.ninja +8 -0
- package/lib/bs/install.ninja +9 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/context/WidgetRegistry-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/core/Hyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/core/HyperElements-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/hooks/usePaymentSession-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/hooks/useWidget-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/HyperTypes-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/NativeModuleTypes-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/AppearanceTransformer-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/EventValidator-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/NewArchUtils-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/PaymentSheetEventManager-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/ReactNativeUtils-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/utils/ResponseHandler-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/views/CVCElement-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/views/NativePaymentWidget-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/views/NativePaymentWidgetImpl-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/views/PaymentElement-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/commonjs/index.bundle.js +2 -0
- package/lib/commonjs/index.bundle.js.map +1 -0
- package/lib/module/index.bundle.js +2 -0
- package/lib/module/index.bundle.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +10 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/eslint.config.d.mts +3 -0
- package/lib/typescript/eslint.config.d.mts.map +1 -0
- package/lib/typescript/rollup.config.d.ts +23 -0
- package/lib/typescript/rollup.config.d.ts.map +1 -0
- package/lib/typescript/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/src/context/Elements.d.ts +7 -0
- package/lib/typescript/src/context/Elements.d.ts.map +1 -0
- package/lib/typescript/src/context/HyperElements.d.ts +23 -0
- package/lib/typescript/src/context/HyperElements.d.ts.map +1 -0
- package/lib/typescript/src/context/PaymentSession.d.ts +15 -0
- package/lib/typescript/src/context/PaymentSession.d.ts.map +1 -0
- package/lib/typescript/src/context/SavedPaymentMethods.d.ts +5 -0
- package/lib/typescript/src/context/SavedPaymentMethods.d.ts.map +1 -0
- package/lib/typescript/src/context/WidgetRegistry.d.ts +8 -0
- package/lib/typescript/src/context/WidgetRegistry.d.ts.map +1 -0
- package/lib/typescript/src/context/hooks.d.ts +5 -0
- package/lib/typescript/src/context/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/modules/NativeHyperswitchSdk.d.ts +61 -0
- package/lib/typescript/src/modules/NativeHyperswitchSdk.d.ts.map +1 -0
- package/lib/typescript/src/specs/ApplePayViewNativeComponent.d.ts +10 -0
- package/lib/typescript/src/specs/ApplePayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeHyperHeadless.d.ts +14 -0
- package/lib/typescript/src/specs/NativeHyperHeadless.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeHyperswitchModule.d.ts +32 -0
- package/lib/typescript/src/specs/NativeHyperswitchModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeHyperswitchSdkNative.d.ts +33 -0
- package/lib/typescript/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativePaymentElementModule.d.ts +9 -0
- package/lib/typescript/src/specs/NativePaymentElementModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/PaymentElementNativeComponent.d.ts +19 -0
- package/lib/typescript/src/specs/PaymentElementNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/utils.d.ts +15 -0
- package/lib/typescript/src/specs/utils.d.ts.map +1 -0
- package/lib/typescript/src/types/NativeModuleTypes.d.ts +67 -0
- package/lib/typescript/src/types/NativeModuleTypes.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheetConfiguration.d.ts +255 -0
- package/lib/typescript/src/types/PaymentSheetConfiguration.d.ts.map +1 -0
- package/lib/typescript/src/types/definitions.d.ts +85 -0
- package/lib/typescript/src/types/definitions.d.ts.map +1 -0
- package/lib/typescript/src/types/elements/index.d.ts +23 -0
- package/lib/typescript/src/types/elements/index.d.ts.map +1 -0
- package/lib/typescript/src/types/paymentresult/index.d.ts +5 -0
- package/lib/typescript/src/types/paymentresult/index.d.ts.map +1 -0
- package/lib/typescript/src/types/savedPaymentMethods/index.d.ts +69 -0
- package/lib/typescript/src/types/savedPaymentMethods/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/EventValidator.d.ts +9 -0
- package/lib/typescript/src/utils/EventValidator.d.ts.map +1 -0
- package/lib/typescript/src/utils/InitializationState.d.ts +13 -0
- package/lib/typescript/src/utils/InitializationState.d.ts.map +1 -0
- package/lib/typescript/src/utils/LaunchOptions.d.ts +7 -0
- package/lib/typescript/src/utils/LaunchOptions.d.ts.map +1 -0
- package/lib/typescript/src/utils/NewArchUtils.d.ts +7 -0
- package/lib/typescript/src/utils/NewArchUtils.d.ts.map +1 -0
- package/lib/typescript/src/utils/ReactNativeUtils.d.ts +3 -0
- package/lib/typescript/src/utils/ReactNativeUtils.d.ts.map +1 -0
- package/lib/typescript/src/views/CVCElement.d.ts +15 -0
- package/lib/typescript/src/views/CVCElement.d.ts.map +1 -0
- package/lib/typescript/src/views/NativePaymentWidget.d.ts +3 -0
- package/lib/typescript/src/views/NativePaymentWidget.d.ts.map +1 -0
- package/lib/typescript/src/views/NativePaymentWidgetImpl.d.ts +5 -0
- package/lib/typescript/src/views/NativePaymentWidgetImpl.d.ts.map +1 -0
- package/lib/typescript/src/views/PaymentElement.d.ts +18 -0
- package/lib/typescript/src/views/PaymentElement.d.ts.map +1 -0
- package/package.json +184 -0
- package/src/context/Elements.ts +80 -0
- package/src/context/HyperElements.tsx +81 -0
- package/src/context/PaymentSession.ts +121 -0
- package/src/context/SavedPaymentMethods.ts +80 -0
- package/src/context/WidgetRegistry.ts +74 -0
- package/src/context/hooks.ts +79 -0
- package/src/index.ts +53 -0
- package/src/modules/NativeHyperswitchSdk.ts +155 -0
- package/src/specs/ApplePayViewNativeComponent.ts +11 -0
- package/src/specs/NativeHyperHeadless.ts +22 -0
- package/src/specs/NativeHyperswitchModule.ts +51 -0
- package/src/specs/NativeHyperswitchSdkNative.ts +62 -0
- package/src/specs/NativePaymentElementModule.ts +25 -0
- package/src/specs/PaymentElementNativeComponent.ts +21 -0
- package/src/specs/utils.ts +15 -0
- package/src/types/NativeModuleTypes.ts +73 -0
- package/src/types/PaymentSheetConfiguration.ts +360 -0
- package/src/types/definitions.ts +109 -0
- package/src/types/elements/index.ts +33 -0
- package/src/types/paymentresult/index.ts +4 -0
- package/src/types/savedPaymentMethods/index.ts +74 -0
- package/src/utils/EventValidator.ts +39 -0
- package/src/utils/InitializationState.ts +28 -0
- package/src/utils/LaunchOptions.ts +41 -0
- package/src/utils/NewArchUtils.ts +18 -0
- package/src/utils/ReactNativeUtils.ts +13 -0
- package/src/views/CVCElement.tsx +122 -0
- package/src/views/NativePaymentWidget.ts +2 -0
- package/src/views/NativePaymentWidgetImpl.ts +16 -0
- package/src/views/PaymentElement.tsx +189 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
package io.hyperswitch.view
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import android.util.AttributeSet
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.MotionEvent
|
|
9
|
+
import android.view.View
|
|
10
|
+
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|
11
|
+
import android.widget.FrameLayout
|
|
12
|
+
import androidx.fragment.app.Fragment
|
|
13
|
+
import androidx.fragment.app.FragmentActivity
|
|
14
|
+
import com.facebook.react.bridge.Arguments
|
|
15
|
+
import com.facebook.react.bridge.Callback
|
|
16
|
+
import com.facebook.react.bridge.ReadableMap
|
|
17
|
+
import com.hyperswitchsdkreactnative.BuildConfig
|
|
18
|
+
import io.hyperswitch.PaymentEventListener
|
|
19
|
+
import io.hyperswitch.model.HyperswitchBaseConfiguration
|
|
20
|
+
import io.hyperswitch.model.PaymentSessionConfiguration
|
|
21
|
+
import io.hyperswitch.paymentsession.LaunchOptions
|
|
22
|
+
import io.hyperswitch.react.HyperFragment
|
|
23
|
+
import io.hyperswitch.react.HyperFragmentManager
|
|
24
|
+
import io.hyperswitch.react.ReactNativeController
|
|
25
|
+
import io.hyperswitch.utils.ConversionUtils
|
|
26
|
+
import kotlin.collections.orEmpty
|
|
27
|
+
|
|
28
|
+
import kotlin.math.abs
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Sealed interface representing the configuration source for the payment widget.
|
|
32
|
+
* Supports both native Android (PaymentSheet.Configuration) and React Native (ReadableMap) paths.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Functional interface for listening to payment results.
|
|
36
|
+
* Unified interface used by both native and React Native callers.
|
|
37
|
+
*/
|
|
38
|
+
fun interface PaymentResultListener {
|
|
39
|
+
fun onPaymentResult(result: String)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun interface ConfirmPaymentClickListener {
|
|
43
|
+
fun onConfirmPaymentCallback(data: String, onConfirmPaymentCallback: (Boolean) -> Unit)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
open class PaymentWidgetView : FrameLayout {
|
|
47
|
+
private var widgetConfig: ReadableMap? = null
|
|
48
|
+
private lateinit var launchOptions: LaunchOptions
|
|
49
|
+
private var fragment: HyperFragment? = null
|
|
50
|
+
private lateinit var mContext: Context
|
|
51
|
+
private var sdkAuthorization: String = ""
|
|
52
|
+
private var hsConfig: HyperswitchBaseConfiguration? = null
|
|
53
|
+
|
|
54
|
+
private var resultListener: PaymentResultListener? = null
|
|
55
|
+
|
|
56
|
+
private var confirmPaymentClickListener: ConfirmPaymentClickListener? = null
|
|
57
|
+
private var subscribedEvents: List<String> = emptyList()
|
|
58
|
+
|
|
59
|
+
private var onEventCallback: PaymentEventListener? = null
|
|
60
|
+
private var activeLayoutChangeListener: OnLayoutChangeListener? = null
|
|
61
|
+
private var widgetShown = false
|
|
62
|
+
|
|
63
|
+
constructor(context: Context) : super(context) {
|
|
64
|
+
init(context)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
|
|
68
|
+
init(context)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
constructor(
|
|
72
|
+
context: Context, attrs: AttributeSet?, defStyleAttr: Int
|
|
73
|
+
) : super(context, attrs, defStyleAttr) {
|
|
74
|
+
init(context)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun onAttachedToWindow() {
|
|
78
|
+
super.onAttachedToWindow()
|
|
79
|
+
if (!isSdkAuthorizationEmpty()) {
|
|
80
|
+
post { showWidgetInternal() }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private fun init(context: Context) {
|
|
85
|
+
if (id == NO_ID) {
|
|
86
|
+
id = generateViewId()
|
|
87
|
+
}
|
|
88
|
+
this.mContext = context
|
|
89
|
+
launchOptions = LaunchOptions(context.applicationContext, BuildConfig.VERSION_NAME, hsConfig)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fun setFragment(fragment: HyperFragment) {
|
|
93
|
+
this.fragment = fragment
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fun getFragment(): HyperFragment? {
|
|
97
|
+
return this.fragment
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private var widgetType: String? = null
|
|
101
|
+
|
|
102
|
+
fun initWidget(config: HyperswitchBaseConfiguration) {
|
|
103
|
+
this.hsConfig = config
|
|
104
|
+
this.widgetType = this.widgetType ?: "widgetPaymentSheet"
|
|
105
|
+
launchOptions = LaunchOptions(mContext.applicationContext, BuildConfig.VERSION_NAME, config)
|
|
106
|
+
ReactNativeController.initialize(mContext.applicationContext as Application)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fun isSdkAuthorizationEmpty(): Boolean {
|
|
110
|
+
return this.sdkAuthorization.isEmpty()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fun setWidgetType(widgetType: String?) {
|
|
114
|
+
this.widgetType = widgetType
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
fun setConfiguration(options: ReadableMap) {
|
|
118
|
+
widgetConfig =options
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
fun onPaymentResult(listener: PaymentResultListener) {
|
|
123
|
+
resultListener = listener
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fun onPaymentResult(callback: Callback) {
|
|
127
|
+
resultListener = PaymentResultListener { result ->
|
|
128
|
+
callback.invoke(result)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Dispatches the result to the registered listener */
|
|
133
|
+
private fun dispatchResult(result: String) {
|
|
134
|
+
resultListener?.onPaymentResult(result)
|
|
135
|
+
}
|
|
136
|
+
// fun onPaymentConfirmButtonClick(
|
|
137
|
+
// callback: (
|
|
138
|
+
// data: PaymentRequestData?,
|
|
139
|
+
// onConfirmPaymentCallback: (Boolean) -> Unit
|
|
140
|
+
// ) -> Unit
|
|
141
|
+
// ) {
|
|
142
|
+
// confirmPaymentClickListener = ConfirmPaymentClickListener { data, onConfirmPaymentCallback ->
|
|
143
|
+
// callback(PaymentRequestData.parse(data), onConfirmPaymentCallback)
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
fun onPaymentConfirmButtonClickWithMap(
|
|
148
|
+
callback: (
|
|
149
|
+
data: Map<String, Any?>,
|
|
150
|
+
onConfirmPaymentCallback: (Boolean) -> Unit
|
|
151
|
+
) -> Unit
|
|
152
|
+
) {
|
|
153
|
+
confirmPaymentClickListener = ConfirmPaymentClickListener { data, onConfirmPaymentCallback ->
|
|
154
|
+
// callback(PaymentRequestData.toMap(data), onConfirmPaymentCallback)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
fun onPaymentConfirmButtonClick(listener: ConfirmPaymentClickListener) {
|
|
159
|
+
confirmPaymentClickListener = listener
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private fun dispatchConfirmTriggered(
|
|
163
|
+
data: String,
|
|
164
|
+
onConfirmPaymentCallback: (Boolean) -> Unit
|
|
165
|
+
) {
|
|
166
|
+
if (confirmPaymentClickListener == null) {
|
|
167
|
+
onConfirmPaymentCallback(true)
|
|
168
|
+
} else {
|
|
169
|
+
confirmPaymentClickListener?.onConfirmPaymentCallback(data, onConfirmPaymentCallback)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fun onEvent(listener: PaymentEventListener) {
|
|
174
|
+
this.onEventCallback = listener
|
|
175
|
+
this.fragment?.setOnEventCallback(listener)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
fun setSubscribedEvents(events: List<String>) {
|
|
179
|
+
this.subscribedEvents = events
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fun getLaunchOptions(): Bundle {
|
|
183
|
+
val props = mutableMapOf<String, Any?>().apply {
|
|
184
|
+
putAll(widgetConfig?.toHashMap().orEmpty())
|
|
185
|
+
put("type", widgetType)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
val map: Map<String, Any?> = mapOf(
|
|
189
|
+
"props" to props
|
|
190
|
+
)
|
|
191
|
+
val bundle = launchOptions.toBundle(map)
|
|
192
|
+
return bundle
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fun confirmPayment(callback: (String) -> Unit) {
|
|
196
|
+
this.fragment?.confirmPayment(callback)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
fun updatePaymentIntentInit(callback: () -> Unit) {
|
|
201
|
+
if (isEligibleForUpdateIntent()) {
|
|
202
|
+
this.fragment?.updatePaymentIntentInit(callback)
|
|
203
|
+
} else {
|
|
204
|
+
callback()
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// fun updatePaymentIntentComplete(
|
|
209
|
+
// sdkAuthorization: String,
|
|
210
|
+
// callback: (ElementUpdateIntentResult) -> Unit
|
|
211
|
+
// ) {
|
|
212
|
+
// if (isEligibleForUpdateIntent()) {
|
|
213
|
+
// sdkAuthorization?.takeIf { it.isNotEmpty() }?.let {
|
|
214
|
+
// this.sdkAuthorization = it
|
|
215
|
+
// }
|
|
216
|
+
// this.fragment?.updatePaymentIntentComplete(sdkAuthorization, callback)
|
|
217
|
+
// ?: callback(
|
|
218
|
+
// ElementUpdateIntentResult.Failure(
|
|
219
|
+
// Throwable("Fragment not attached").apply {
|
|
220
|
+
// initCause(Throwable("FRAGMENT_NOT_ATTACHED"))
|
|
221
|
+
// }
|
|
222
|
+
// ))
|
|
223
|
+
// } else {
|
|
224
|
+
// callback(ElementUpdateIntentResult.Success)
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
|
|
228
|
+
private fun isEligibleForUpdateIntent(): Boolean {
|
|
229
|
+
when (widgetType) {
|
|
230
|
+
"payment",
|
|
231
|
+
"tabSheet",
|
|
232
|
+
"buttonSheet",
|
|
233
|
+
"widgetPaymentSheet",
|
|
234
|
+
"widgetTabSheet",
|
|
235
|
+
"widgetButtonSheet",
|
|
236
|
+
"hostedCheckout",
|
|
237
|
+
"google_pay",
|
|
238
|
+
"paypal",
|
|
239
|
+
"card",
|
|
240
|
+
"paymentMethodsManagement",
|
|
241
|
+
"headless",
|
|
242
|
+
"expressCheckout" -> return true
|
|
243
|
+
|
|
244
|
+
"cvcWidget" -> return false
|
|
245
|
+
else -> return false
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
fun confirmCvcPayment(
|
|
250
|
+
paymentToken: String,
|
|
251
|
+
billing: String?,
|
|
252
|
+
callback: (String) -> Unit
|
|
253
|
+
) {
|
|
254
|
+
this.fragment?.confirmCvcPayment(sdkAuthorization, paymentToken, billing, callback)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fun setSdkAuthorization(sdkAuthorization: String) {
|
|
258
|
+
this.sdkAuthorization = sdkAuthorization
|
|
259
|
+
if (isAttachedToWindow && !isSdkAuthorizationEmpty()) {
|
|
260
|
+
post { showWidgetInternal() }
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fun showWidgetInternal() {
|
|
265
|
+
if (this.isSdkAuthorizationEmpty()) return // callers already guard; no need to retry
|
|
266
|
+
if (widgetShown) return
|
|
267
|
+
widgetShown = true
|
|
268
|
+
val activity = context as? FragmentActivity ?: return
|
|
269
|
+
|
|
270
|
+
if (activity.isFinishing || activity.isDestroyed) return
|
|
271
|
+
|
|
272
|
+
val tag = "HyperPaymentSheet_${this.id}"
|
|
273
|
+
HyperFragmentManager.cancelPending(tag)
|
|
274
|
+
this.setFragment(
|
|
275
|
+
HyperFragment.Builder().setComponentName("hyperSwitch")
|
|
276
|
+
.setLaunchOptions(this.getLaunchOptions()).build()
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
val frameLayout = FrameLayout(activity).apply {
|
|
280
|
+
layoutParams = LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
|
281
|
+
}
|
|
282
|
+
this.addView(frameLayout, FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT))
|
|
283
|
+
val containerWidth = this.width
|
|
284
|
+
val containerHeight = this.height
|
|
285
|
+
frameLayout.post {
|
|
286
|
+
frameLayout.measure(
|
|
287
|
+
MeasureSpec.makeMeasureSpec(containerWidth, MeasureSpec.EXACTLY),
|
|
288
|
+
MeasureSpec.makeMeasureSpec(containerHeight, MeasureSpec.EXACTLY)
|
|
289
|
+
)
|
|
290
|
+
frameLayout.layout(0, 0, frameLayout.measuredWidth, frameLayout.measuredHeight)
|
|
291
|
+
setupLayout(frameLayout, containerWidth, containerHeight)
|
|
292
|
+
HyperFragmentManager.addOrReplace(
|
|
293
|
+
activity = activity,
|
|
294
|
+
container = frameLayout,
|
|
295
|
+
fragment = this.getFragment() as Fragment,
|
|
296
|
+
tag = tag,
|
|
297
|
+
addToBackStack = false
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
frameLayout.post { this.getFragment()?.view?.requestLayout() }
|
|
301
|
+
}
|
|
302
|
+
this.fragment?.setOnPaymentResult(::dispatchResult)
|
|
303
|
+
this.fragment?.setOnPaymentConfirmButtonClick(::dispatchConfirmTriggered)
|
|
304
|
+
onEventCallback?.let { this.fragment?.setOnEventCallback(it) }
|
|
305
|
+
this.fragment?.setOnExit {
|
|
306
|
+
removeWidget()
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private fun setupLayout(view: View, width: Int, height: Int) {
|
|
311
|
+
// Do an initial one-shot layout pass.
|
|
312
|
+
manuallyLayoutChildren(view, width, height)
|
|
313
|
+
|
|
314
|
+
// Re-layout only when the view's dimensions actually change, not every frame.
|
|
315
|
+
// This prevents the continuous forced layout() calls that destabilise focus
|
|
316
|
+
// in the embedded React Native TextInput (e.g. CVCWidget).
|
|
317
|
+
val listener =
|
|
318
|
+
View.OnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom ->
|
|
319
|
+
val newW = right - left
|
|
320
|
+
val newH = bottom - top
|
|
321
|
+
val oldW = oldRight - oldLeft
|
|
322
|
+
val oldH = oldBottom - oldTop
|
|
323
|
+
if (newW != oldW || newH != oldH) {
|
|
324
|
+
manuallyLayoutChildren(v, newW, newH)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
view.addOnLayoutChangeListener(listener)
|
|
328
|
+
activeLayoutChangeListener = listener
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
fun stopLayout() {
|
|
332
|
+
activeLayoutChangeListener?.let { listener ->
|
|
333
|
+
// We don't hold a reference to the view here, so we rely on removeWidget()
|
|
334
|
+
// calling removeAllViews() which detaches the listener automatically.
|
|
335
|
+
// Nulling the reference is sufficient to prevent leaks.
|
|
336
|
+
activeLayoutChangeListener = null
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
fun removeWidget() {
|
|
341
|
+
try {
|
|
342
|
+
this.cancelPendingInputEvents()
|
|
343
|
+
stopLayout()
|
|
344
|
+
val activity = context as? FragmentActivity ?: return
|
|
345
|
+
val tag = "HyperPaymentSheet_${this.id}"
|
|
346
|
+
HyperFragmentManager.remove(activity, tag)
|
|
347
|
+
post {
|
|
348
|
+
removeAllViews()
|
|
349
|
+
}
|
|
350
|
+
widgetShown = false
|
|
351
|
+
} catch (_: Exception) {
|
|
352
|
+
// Handle the errors
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private fun manuallyLayoutChildren(view: View, width: Int, height: Int) {
|
|
357
|
+
view.measure(
|
|
358
|
+
View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
359
|
+
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY)
|
|
360
|
+
)
|
|
361
|
+
view.layout(0, 0, width, height)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private var startY = 0f
|
|
365
|
+
private var startX = 0f
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Never intercept touch events - let the fragment's ReactRootView handle them.
|
|
369
|
+
* This prevents the parent RN ScrollView from stealing touches before the
|
|
370
|
+
* inner ReactFragment's ReactRootView gets a chance to process them.
|
|
371
|
+
*/
|
|
372
|
+
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
|
373
|
+
return false
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Dispatch touch events and coordinate with parent ScrollView.
|
|
378
|
+
* For vertical scrolling, we request the parent to not intercept touches,
|
|
379
|
+
* allowing the inner ReactScrollView (inside the fragment) to handle them.
|
|
380
|
+
*/
|
|
381
|
+
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
|
382
|
+
when (ev.action) {
|
|
383
|
+
MotionEvent.ACTION_DOWN -> {
|
|
384
|
+
startY = ev.y
|
|
385
|
+
startX = ev.x
|
|
386
|
+
// Do not disallow parent interception on DOWN — this was originally written
|
|
387
|
+
// for a parent RN ScrollView, but in native embedding (e.g. WidgetActivity)
|
|
388
|
+
// it prevents the outer Android ScrollView from ever scrolling.
|
|
389
|
+
// Direction-based gating on MOVE below is sufficient.
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
MotionEvent.ACTION_MOVE -> {
|
|
393
|
+
val dy = abs(ev.y - startY)
|
|
394
|
+
val dx = abs(ev.x - startX)
|
|
395
|
+
parent?.requestDisallowInterceptTouchEvent(dy > dx)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
MotionEvent.ACTION_UP,
|
|
399
|
+
MotionEvent.ACTION_CANCEL -> {
|
|
400
|
+
parent?.requestDisallowInterceptTouchEvent(false)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return super.dispatchTouchEvent(ev)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
@@ -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>
|