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,470 @@
|
|
|
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
|
+
|
|
16
|
+
// Instance handle -> Hyperswitch created with publishable key only.
|
|
17
|
+
private var instances = [String: Hyperswitch]()
|
|
18
|
+
|
|
19
|
+
private var activeHyperswitch: Hyperswitch?
|
|
20
|
+
private var activePublishableKey: String?
|
|
21
|
+
private var activeProfileId: String?
|
|
22
|
+
private var activePaymentSession: PaymentSession?
|
|
23
|
+
private var activePaymentSessionHandler: PaymentSessionHandler?
|
|
24
|
+
@objc internal static var isCvcWidgetActive: Bool = false
|
|
25
|
+
|
|
26
|
+
/// View-registry reference injected by HyperswitchSdkReactNative.mm so this singleton
|
|
27
|
+
/// can resolve native widget views by reactTag.
|
|
28
|
+
@objc public var viewRegistry_DEPRECATED: RCTViewRegistry?
|
|
29
|
+
|
|
30
|
+
@objc(initialiseWithPublishableKey:customBackendUrl:customLogUrl:customParams:resolve:reject:)
|
|
31
|
+
public func initialise(
|
|
32
|
+
publishableKey: String,
|
|
33
|
+
customBackendUrl: String?,
|
|
34
|
+
customLogUrl: String?,
|
|
35
|
+
customParams: [String: Any]?,
|
|
36
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
37
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
38
|
+
) {
|
|
39
|
+
activePublishableKey = publishableKey
|
|
40
|
+
activeProfileId = customParams?["profileId"] as? String
|
|
41
|
+
|
|
42
|
+
let customEndpoints = CustomEndpointConfiguration.overrideEndpoints(
|
|
43
|
+
OverrideEndpointConfiguration(
|
|
44
|
+
customBackendEndpoint: customBackendUrl,
|
|
45
|
+
customLoggingEndpoint: customLogUrl
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
let hyperswitch = Hyperswitch(
|
|
49
|
+
configuration: HyperswitchConfiguration(
|
|
50
|
+
publishableKey: publishableKey,
|
|
51
|
+
profileId: activeProfileId,
|
|
52
|
+
customEndpoints: customEndpoints
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
let handle = UUID().uuidString
|
|
57
|
+
instances[handle] = hyperswitch
|
|
58
|
+
|
|
59
|
+
resolve(handle)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@objc(initPaymentSession:sdkAuthorization:resolve:reject:)
|
|
63
|
+
public func initPaymentSession(
|
|
64
|
+
instanceHandle: String,
|
|
65
|
+
sdkAuthorization: String,
|
|
66
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
67
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
68
|
+
) {
|
|
69
|
+
guard let hyperswitch = instances[instanceHandle] else {
|
|
70
|
+
reject("INIT_ERROR", "Hyperswitch instance not found for handle: \(instanceHandle)", NSError(domain: "HyperswitchModule", code: 0))
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
activeHyperswitch = nil
|
|
75
|
+
activePaymentSession = nil
|
|
76
|
+
activePaymentSessionHandler = nil
|
|
77
|
+
|
|
78
|
+
let session = hyperswitch.initPaymentSession(
|
|
79
|
+
configuration: PaymentSessionConfiguration(sdkAuthorization: sdkAuthorization)
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
activeHyperswitch = hyperswitch
|
|
83
|
+
activePaymentSession = session
|
|
84
|
+
activePaymentSessionHandler = nil
|
|
85
|
+
|
|
86
|
+
resolve("active")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
internal static func getActiveHyperswitch() -> Hyperswitch? {
|
|
90
|
+
return shared.activeHyperswitch
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
internal static func getActivePaymentSession() -> PaymentSession? {
|
|
94
|
+
return shared.activePaymentSession
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
internal static func getActivePublishableKey() -> String? {
|
|
98
|
+
return shared.activePublishableKey
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
internal static func getActiveProfileId() -> String? {
|
|
102
|
+
return shared.activeProfileId
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@objc(presentPaymentSheet:resolve:reject:)
|
|
106
|
+
public func presentPaymentSheet(
|
|
107
|
+
configuration: [String: Any],
|
|
108
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
109
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
110
|
+
) {
|
|
111
|
+
guard let session = activePaymentSession else {
|
|
112
|
+
reject("PRESENT_ERROR", "Payment session not initialized. Call initPaymentSession first.", NSError(domain: "HyperswitchModule", code: 0))
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
DispatchQueue.main.async {
|
|
117
|
+
guard let vc = RCTPresentedViewController() else {
|
|
118
|
+
reject("error", "Could not find presented view controller", NSError())
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
session.presentPaymentSheetWithParams(
|
|
122
|
+
viewController: vc,
|
|
123
|
+
params: configuration,
|
|
124
|
+
completion: { result in
|
|
125
|
+
switch result {
|
|
126
|
+
case .completed(let data):
|
|
127
|
+
resolve(["status": "completed", "message": data])
|
|
128
|
+
case .failed(let error as NSError):
|
|
129
|
+
resolve([
|
|
130
|
+
"status": "failed", "code": error.domain, "message": "Payment failed: \(error.userInfo["message"] ?? "Failed")",
|
|
131
|
+
])
|
|
132
|
+
case .canceled(let data):
|
|
133
|
+
resolve(["status": "cancelled", "message": data])
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// MARK: - Headless Payment Methods
|
|
141
|
+
|
|
142
|
+
@objc(getCustomerSavedPaymentMethods:resolve:reject:)
|
|
143
|
+
public func getCustomerSavedPaymentMethods(
|
|
144
|
+
options: [String: Any]?,
|
|
145
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
146
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
147
|
+
) {
|
|
148
|
+
guard let session = activePaymentSession else {
|
|
149
|
+
resolve([
|
|
150
|
+
"status": "error",
|
|
151
|
+
"code": "NO_SESSION",
|
|
152
|
+
"message": "Payment session not initialized. Call initPaymentSession first.",
|
|
153
|
+
])
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
session.getCustomerSavedPaymentMethods { [weak self] handler in
|
|
158
|
+
self?.activePaymentSessionHandler = handler
|
|
159
|
+
resolve(["status": "success", "message": "Payment methods initialized"])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@objc(getCustomerDefaultSavedPaymentMethodDataWithResolve:reject:)
|
|
164
|
+
public func getCustomerDefaultSavedPaymentMethodData(
|
|
165
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
166
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
167
|
+
) {
|
|
168
|
+
guard let handler = activePaymentSessionHandler else {
|
|
169
|
+
resolve([
|
|
170
|
+
"status": "error",
|
|
171
|
+
"message": "Payment session handler not initialized.",
|
|
172
|
+
])
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let result = handler.getCustomerDefaultSavedPaymentMethodData()
|
|
177
|
+
switch result {
|
|
178
|
+
case .success(let paymentMethod):
|
|
179
|
+
if let jsonData = try? JSONEncoder().encode(paymentMethod),
|
|
180
|
+
let jsonDict = try? JSONSerialization.jsonObject(with: jsonData) as? [String: Any]
|
|
181
|
+
{
|
|
182
|
+
resolve([
|
|
183
|
+
"status": "success",
|
|
184
|
+
"message": "Default payment method retrieved",
|
|
185
|
+
"data": jsonDict,
|
|
186
|
+
])
|
|
187
|
+
} else {
|
|
188
|
+
resolve([
|
|
189
|
+
"status": "error",
|
|
190
|
+
"code": "ENCODE_ERROR",
|
|
191
|
+
"message": "Failed to encode payment method data",
|
|
192
|
+
])
|
|
193
|
+
}
|
|
194
|
+
case .failure(let error):
|
|
195
|
+
resolve([
|
|
196
|
+
"status": "failed",
|
|
197
|
+
"code": error.code,
|
|
198
|
+
"message": error.message,
|
|
199
|
+
])
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@objc(getCustomerLastUsedPaymentMethodDataWithResolve:reject:)
|
|
204
|
+
public func getCustomerLastUsedPaymentMethodData(
|
|
205
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
206
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
207
|
+
) {
|
|
208
|
+
guard let handler = activePaymentSessionHandler else {
|
|
209
|
+
resolve([
|
|
210
|
+
"status": "error",
|
|
211
|
+
"message": "Payment session handler not initialized.",
|
|
212
|
+
])
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let result = handler.getCustomerLastUsedPaymentMethodData()
|
|
217
|
+
switch result {
|
|
218
|
+
case .success(let paymentMethod):
|
|
219
|
+
if let jsonData = try? JSONEncoder().encode(paymentMethod),
|
|
220
|
+
let jsonDict = try? JSONSerialization.jsonObject(with: jsonData) as? [String: Any]
|
|
221
|
+
{
|
|
222
|
+
resolve([
|
|
223
|
+
"status": "success",
|
|
224
|
+
"message": "Last used payment method retrieved",
|
|
225
|
+
"data": jsonDict,
|
|
226
|
+
])
|
|
227
|
+
} else {
|
|
228
|
+
resolve([
|
|
229
|
+
"status": "error",
|
|
230
|
+
"code": "ENCODE_ERROR",
|
|
231
|
+
"message": "Failed to encode payment method",
|
|
232
|
+
])
|
|
233
|
+
}
|
|
234
|
+
case .failure(let error):
|
|
235
|
+
resolve([
|
|
236
|
+
"status": "failed",
|
|
237
|
+
"code": error.code,
|
|
238
|
+
"message": error.message,
|
|
239
|
+
])
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@objc(confirmWithCustomerDefaultPaymentMethod:resolve:reject:)
|
|
244
|
+
public func confirmWithCustomerDefaultPaymentMethod(
|
|
245
|
+
cvcWidgetReactTag: String?,
|
|
246
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
247
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
248
|
+
) {
|
|
249
|
+
guard let handler = activePaymentSessionHandler else {
|
|
250
|
+
resolve([
|
|
251
|
+
"status": "error",
|
|
252
|
+
"message": "Payment session handler not initialized.",
|
|
253
|
+
])
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
let reactTag = Int(cvcWidgetReactTag ?? "") ?? 0
|
|
258
|
+
|
|
259
|
+
if reactTag > 0 {
|
|
260
|
+
// CvcWidget reactTag provided — route through the native widget view
|
|
261
|
+
// so we can use the inner RCTRootView tag (widgetReactTag).
|
|
262
|
+
let result = handler.getCustomerDefaultSavedPaymentMethodData()
|
|
263
|
+
switch result {
|
|
264
|
+
case .success(let paymentMethod):
|
|
265
|
+
if paymentMethod.requiresCvv && paymentMethod.paymentMethod == "card" {
|
|
266
|
+
self.withNativePaymentWidgetView(
|
|
267
|
+
NSNumber(value: reactTag),
|
|
268
|
+
onFound: { view in
|
|
269
|
+
view.confirmCVCPayment(
|
|
270
|
+
paymentToken: paymentMethod.paymentToken,
|
|
271
|
+
paymentMethodId: paymentMethod.paymentMethodId,
|
|
272
|
+
resolve: resolve
|
|
273
|
+
)
|
|
274
|
+
},
|
|
275
|
+
onMissing: {
|
|
276
|
+
resolve([
|
|
277
|
+
"status": "failed",
|
|
278
|
+
"code": "WIDGET_NOT_FOUND",
|
|
279
|
+
"message": "CVC widget view not found for reactTag \(reactTag)",
|
|
280
|
+
])
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
} else {
|
|
284
|
+
// Not a card or requiresCvv is false — bypass CvcWidget, confirm directly with cvc = nil
|
|
285
|
+
handler.confirmWithCustomerDefaultPaymentMethod { result in
|
|
286
|
+
resolve(HyperswitchModule.paymentResultToDict(result))
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
case .failure(let error):
|
|
290
|
+
resolve([
|
|
291
|
+
"status": "failed",
|
|
292
|
+
"code": error.code,
|
|
293
|
+
"message": error.message,
|
|
294
|
+
])
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
// No CvcWidget — confirm through HeadlessTask callback (cvc will be nil)
|
|
298
|
+
handler.confirmWithCustomerDefaultPaymentMethod { result in
|
|
299
|
+
resolve(HyperswitchModule.paymentResultToDict(result))
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@objc(confirmWithCustomerLastUsedPaymentMethod:resolve:reject:)
|
|
305
|
+
public func confirmWithCustomerLastUsedPaymentMethod(
|
|
306
|
+
cvcWidgetReactTag: String?,
|
|
307
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
308
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
309
|
+
) {
|
|
310
|
+
guard let handler = activePaymentSessionHandler else {
|
|
311
|
+
resolve([
|
|
312
|
+
"status": "error",
|
|
313
|
+
"message": "Payment session handler not initialized.",
|
|
314
|
+
])
|
|
315
|
+
return
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
let reactTag = Int(cvcWidgetReactTag ?? "") ?? 0
|
|
319
|
+
|
|
320
|
+
if reactTag > 0 {
|
|
321
|
+
// CvcWidget reactTag provided — route through the native widget view
|
|
322
|
+
// so we can use the inner RCTRootView tag (widgetReactTag).
|
|
323
|
+
let result = handler.getCustomerLastUsedPaymentMethodData()
|
|
324
|
+
switch result {
|
|
325
|
+
case .success(let paymentMethod):
|
|
326
|
+
if paymentMethod.requiresCvv && paymentMethod.paymentMethod == "card" {
|
|
327
|
+
self.withNativePaymentWidgetView(
|
|
328
|
+
NSNumber(value: reactTag),
|
|
329
|
+
onFound: { view in
|
|
330
|
+
guard let cvcWidget = view.cvcWidgetRef else {
|
|
331
|
+
resolve([
|
|
332
|
+
"status": "failed",
|
|
333
|
+
"code": "WIDGET_NOT_READY",
|
|
334
|
+
"message": "CVC widget is not ready",
|
|
335
|
+
])
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
handler.confirmWithCustomerLastUsedPaymentMethod(cvcWidget) { result in
|
|
339
|
+
resolve(HyperswitchModule.paymentResultToDict(result))
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
onMissing: {
|
|
343
|
+
resolve([
|
|
344
|
+
"status": "failed",
|
|
345
|
+
"code": "WIDGET_NOT_FOUND",
|
|
346
|
+
"message": "CVC widget view not found for reactTag \(reactTag)",
|
|
347
|
+
])
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
} else {
|
|
351
|
+
// Not a card or requiresCvv is false — bypass CvcWidget, confirm directly with cvc = nil
|
|
352
|
+
resolve([
|
|
353
|
+
"status": "failed",
|
|
354
|
+
"code": "CVC_WIDGET_REQUIRED",
|
|
355
|
+
"message": "CVC widget is required to confirm the last used card payment method",
|
|
356
|
+
])
|
|
357
|
+
}
|
|
358
|
+
case .failure(let error):
|
|
359
|
+
resolve([
|
|
360
|
+
"status": "failed",
|
|
361
|
+
"code": error.code,
|
|
362
|
+
"message": error.message,
|
|
363
|
+
])
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
resolve([
|
|
367
|
+
"status": "failed",
|
|
368
|
+
"code": "CVC_WIDGET_REQUIRED",
|
|
369
|
+
"message": "CVC widget is required to confirm the last used payment method",
|
|
370
|
+
])
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@objc(confirmWithCustomerPaymentToken:resolve:reject:)
|
|
375
|
+
public func confirmWithCustomerPaymentToken(
|
|
376
|
+
paymentToken: String,
|
|
377
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
378
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
379
|
+
) {
|
|
380
|
+
guard let handler = activePaymentSessionHandler else {
|
|
381
|
+
resolve([
|
|
382
|
+
"status": "error",
|
|
383
|
+
"message": "Payment session handler not initialized.",
|
|
384
|
+
])
|
|
385
|
+
return
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
handler.confirmWithCustomerPaymentToken(paymentToken: paymentToken) { result in
|
|
389
|
+
resolve(HyperswitchModule.paymentResultToDict(result))
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@objc(updateIntent:resolve:reject:)
|
|
394
|
+
public func updateIntent(
|
|
395
|
+
sdkAuthorization: String,
|
|
396
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
397
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
398
|
+
) {
|
|
399
|
+
guard let session = activePaymentSession else {
|
|
400
|
+
reject("UPDATE_INTENT_ERROR", "Payment session not initialized. Call initPaymentSession first.", NSError(domain: "HyperswitchModule", code: 0))
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
session.updateIntent(
|
|
405
|
+
authorizationProvider: { completion in
|
|
406
|
+
completion(sdkAuthorization)
|
|
407
|
+
},
|
|
408
|
+
completion: { result in
|
|
409
|
+
switch result {
|
|
410
|
+
case .success:
|
|
411
|
+
resolve(["status": "success", "message": "Payment intent updated"])
|
|
412
|
+
case .cancelled:
|
|
413
|
+
resolve(["status": "cancelled", "message": "Payment intent update cancelled"])
|
|
414
|
+
case .failure(let error as NSError):
|
|
415
|
+
reject(error.domain, error.userInfo[NSLocalizedDescriptionKey] as? String ?? "Payment intent update failed", error)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// MARK: - CvcWidget View Lookup
|
|
422
|
+
|
|
423
|
+
/// Looks up the NativePaymentWidgetView for the supplied React tag by walking up the view
|
|
424
|
+
/// hierarchy, mirroring the approach used in HyperModule. Calls `onFound` when the widget
|
|
425
|
+
/// wrapper is located, otherwise `onMissing`.
|
|
426
|
+
private func withNativePaymentWidgetView(
|
|
427
|
+
_ reactTag: NSNumber,
|
|
428
|
+
onFound: @escaping (NativePaymentWidgetView) -> Void,
|
|
429
|
+
onMissing: @escaping () -> Void
|
|
430
|
+
) {
|
|
431
|
+
guard let viewRegistry = self.viewRegistry_DEPRECATED else {
|
|
432
|
+
onMissing()
|
|
433
|
+
return
|
|
434
|
+
}
|
|
435
|
+
let view = viewRegistry.view(forReactTag: reactTag)
|
|
436
|
+
var current: UIView? = view
|
|
437
|
+
while let v = current {
|
|
438
|
+
if let nativeWidget = v as? NativePaymentWidgetView {
|
|
439
|
+
onFound(nativeWidget)
|
|
440
|
+
return
|
|
441
|
+
}
|
|
442
|
+
current = v.superview
|
|
443
|
+
}
|
|
444
|
+
onMissing()
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/// Convert a PaymentResult to a dictionary suitable for RCTPromiseResolveBlock.
|
|
448
|
+
private static func paymentResultToDict(_ result: PaymentResult) -> [String: Any] {
|
|
449
|
+
switch result {
|
|
450
|
+
case .completed(let data):
|
|
451
|
+
return [
|
|
452
|
+
"status": "success",
|
|
453
|
+
"message": "Payment confirmed successfully",
|
|
454
|
+
"data": data,
|
|
455
|
+
]
|
|
456
|
+
case .failed(let error as NSError):
|
|
457
|
+
return [
|
|
458
|
+
"status": "failed",
|
|
459
|
+
"code": error.domain,
|
|
460
|
+
"message": error.userInfo["message"] as? String ?? "Payment confirmation failed",
|
|
461
|
+
]
|
|
462
|
+
case .canceled(let data):
|
|
463
|
+
return [
|
|
464
|
+
"status": "cancelled",
|
|
465
|
+
"message": "Payment confirmation cancelled",
|
|
466
|
+
"data": data,
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#import "HyperswitchSdkReactNative.h"
|
|
2
|
+
#import <React/RCTComponent.h>
|
|
3
|
+
#import <memory>
|
|
4
|
+
#if __has_include("HyperswitchSdkReactNative-Swift.h")
|
|
5
|
+
#import "HyperswitchSdkReactNative-Swift.h"
|
|
6
|
+
#else
|
|
7
|
+
// When using use_frameworks! :linkage => :static in Podfile
|
|
8
|
+
#import <HyperswitchSdkReactNative/HyperswitchSdkReactNative-Swift.h>
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@implementation HyperswitchSdkReactNative
|
|
13
|
+
|
|
14
|
+
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_MODULE()
|
|
17
|
+
|
|
18
|
+
RCT_EXPORT_METHOD(initialise:(nonnull NSDictionary *)config
|
|
19
|
+
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
20
|
+
reject:(nonnull RCTPromiseRejectBlock)reject) {
|
|
21
|
+
NSString *publishableKey = [config[@"publishableKey"] isKindOfClass:NSString.class] ? config[@"publishableKey"] : nil;
|
|
22
|
+
NSString *profileId = [config[@"profileId"] isKindOfClass:NSString.class] ? config[@"profileId"] : nil;
|
|
23
|
+
NSDictionary *customEndpoints = [config[@"customEndpoints"] isKindOfClass:NSDictionary.class] ? config[@"customEndpoints"] : nil;
|
|
24
|
+
NSDictionary *overrideEndpoints = [customEndpoints[@"overrideEndpoints"] isKindOfClass:NSDictionary.class] ? customEndpoints[@"overrideEndpoints"] : nil;
|
|
25
|
+
NSString *customBackendUrl = [overrideEndpoints[@"customBackendEndpoint"] isKindOfClass:NSString.class] ? overrideEndpoints[@"customBackendEndpoint"] : nil;
|
|
26
|
+
NSString *customLogUrl = [overrideEndpoints[@"customLoggingEndpoint"] isKindOfClass:NSString.class] ? overrideEndpoints[@"customLoggingEndpoint"] : nil;
|
|
27
|
+
|
|
28
|
+
NSMutableDictionary *customParams = [NSMutableDictionary dictionary];
|
|
29
|
+
if (profileId != nil) {
|
|
30
|
+
customParams[@"profileId"] = profileId;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[[self hyperswitchModule] initialiseWithPublishableKey:publishableKey customBackendUrl:customBackendUrl customLogUrl:customLogUrl customParams:customParams resolve:resolve reject:reject];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RCT_EXPORT_METHOD(initPaymentSession:(nonnull NSString *)instanceHandle
|
|
37
|
+
sdkAuthorization:(nonnull NSString *)sdkAuthorization
|
|
38
|
+
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
39
|
+
reject:(nonnull RCTPromiseRejectBlock)reject) {
|
|
40
|
+
[[self hyperswitchModule] initPaymentSession:instanceHandle sdkAuthorization:sdkAuthorization resolve:resolve reject:reject];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
RCT_EXPORT_METHOD(presentPaymentSheet:(nonnull NSDictionary *)configuration
|
|
44
|
+
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
45
|
+
reject:(nonnull RCTPromiseRejectBlock)reject)
|
|
46
|
+
{
|
|
47
|
+
[[self hyperswitchModule] presentPaymentSheet:configuration resolve:resolve reject:reject];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#pragma mark - Headless Payment Methods
|
|
51
|
+
|
|
52
|
+
RCT_EXPORT_METHOD(getCustomerSavedPaymentMethods:(nullable NSDictionary *)options
|
|
53
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
55
|
+
{
|
|
56
|
+
[[self hyperswitchModule] getCustomerSavedPaymentMethods:options resolve:resolve reject:reject];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
RCT_EXPORT_METHOD(getCustomerDefaultSavedPaymentMethodData:(RCTPromiseResolveBlock)resolve
|
|
60
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
61
|
+
{
|
|
62
|
+
[[self hyperswitchModule] getCustomerDefaultSavedPaymentMethodDataWithResolve:resolve reject:reject];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RCT_EXPORT_METHOD(getCustomerLastUsedPaymentMethodData:(RCTPromiseResolveBlock)resolve
|
|
66
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
67
|
+
{
|
|
68
|
+
[[self hyperswitchModule] getCustomerLastUsedPaymentMethodDataWithResolve:resolve reject:reject];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
RCT_EXPORT_METHOD(confirmWithCustomerDefaultPaymentMethod:(nullable NSString *)cvcWidgetReactTag
|
|
72
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
73
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
74
|
+
{
|
|
75
|
+
[[self hyperswitchModule] confirmWithCustomerDefaultPaymentMethod:cvcWidgetReactTag resolve:resolve reject:reject];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
RCT_EXPORT_METHOD(confirmWithCustomerLastUsedPaymentMethod:(nullable NSString *)cvcWidgetReactTag
|
|
79
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
80
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
81
|
+
{
|
|
82
|
+
[[self hyperswitchModule] confirmWithCustomerLastUsedPaymentMethod:cvcWidgetReactTag resolve:resolve reject:reject];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
RCT_EXPORT_METHOD(confirmWithCustomerPaymentToken:(nonnull NSString *)paymentToken
|
|
86
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
87
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
88
|
+
{
|
|
89
|
+
[[self hyperswitchModule] confirmWithCustomerPaymentToken:paymentToken resolve:resolve reject:reject];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
RCT_EXPORT_METHOD(updateIntent:(nonnull NSString *)sdkAuthorization
|
|
93
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
94
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
95
|
+
{
|
|
96
|
+
[[self hyperswitchModule] updateIntent:sdkAuthorization resolve:resolve reject:reject];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
100
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
101
|
+
{
|
|
102
|
+
return std::make_shared<facebook::react::NativeHyperswitchSdkReactNativeSpecJSI>(params);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
+ (BOOL)requiresMainQueueSetup
|
|
106
|
+
{
|
|
107
|
+
return YES;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (dispatch_queue_t)methodQueue
|
|
111
|
+
{
|
|
112
|
+
return dispatch_get_main_queue();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (HyperswitchModule *)hyperswitchModule
|
|
116
|
+
{
|
|
117
|
+
HyperswitchModule.shared.viewRegistry_DEPRECATED = self.viewRegistry_DEPRECATED;
|
|
118
|
+
return HyperswitchModule.shared;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#import <HyperswitchSdkReactNativeSpec/HyperswitchSdkReactNativeSpec.h>
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* iOS TurboModule / legacy bridge implementation for the NativeHyperswitchModule spec.
|
|
5
|
+
*
|
|
6
|
+
* Matches the Android ReactNativeHyperswitchModule API exactly:
|
|
7
|
+
* • initialise(publishableKey, platformPublishableKey, profileId, environment, customEndpoints)
|
|
8
|
+
* • presentPaymentSheet(params)
|
|
9
|
+
* • getCustomerSavedPaymentMethods(params?)
|
|
10
|
+
* • getCustomerLastUsedPaymentMethodData()
|
|
11
|
+
* • getCustomerDefaultSavedPaymentMethodData()
|
|
12
|
+
* • getCustomerSavedPaymentMethodData() ← new
|
|
13
|
+
* • confirmWithCustomerLastUsedPaymentMethod() ← no cvcWidgetReactTag
|
|
14
|
+
* • confirmWithCustomerDefaultPaymentMethod() ← no cvcWidgetReactTag
|
|
15
|
+
*/
|
|
16
|
+
@interface NativeHyperswitchModule : NSObject <NativeHyperswitchModuleSpec>
|
|
17
|
+
|
|
18
|
+
@end
|