@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,494 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSheetConfiguration.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Balaganesh on 09/12/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import PassKit
|
|
10
|
+
import UIKit
|
|
11
|
+
|
|
12
|
+
// MARK: - Configuration
|
|
13
|
+
extension PaymentSheet {
|
|
14
|
+
|
|
15
|
+
/// Style options for colors in PaymentSheet
|
|
16
|
+
public enum UserInterfaceStyle: Int, DictionaryConverter {
|
|
17
|
+
|
|
18
|
+
/// (default) PaymentSheet will automatically switch between standard and dark mode compatible colors based on device settings
|
|
19
|
+
case automatic = 0
|
|
20
|
+
|
|
21
|
+
/// PaymentSheet will always use colors appropriate for standard, i.e. non-dark mode UI
|
|
22
|
+
case alwaysLight
|
|
23
|
+
|
|
24
|
+
/// PaymentSheet will always use colors appropriate for dark mode UI
|
|
25
|
+
case alwaysDark
|
|
26
|
+
|
|
27
|
+
func configure(_ viewController: UIViewController) {
|
|
28
|
+
switch self {
|
|
29
|
+
case .automatic:
|
|
30
|
+
break // no-op
|
|
31
|
+
|
|
32
|
+
case .alwaysLight:
|
|
33
|
+
if #available(iOS 13.0, *) {
|
|
34
|
+
viewController.overrideUserInterfaceStyle = .light
|
|
35
|
+
}
|
|
36
|
+
case .alwaysDark:
|
|
37
|
+
if #available(iOS 13.0, *) {
|
|
38
|
+
viewController.overrideUserInterfaceStyle = .dark
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Options for the default state of save payment method controls
|
|
45
|
+
/// @note Some jurisdictions may have rules governing the ability to default to opt-out behaviors
|
|
46
|
+
public enum SavePaymentMethodOptInBehavior: DictionaryConverter {
|
|
47
|
+
|
|
48
|
+
/// (Default) The SDK will apply opt-out behavior for supported countries.
|
|
49
|
+
/// Currently, this behavior is supported in the US.
|
|
50
|
+
case automatic
|
|
51
|
+
|
|
52
|
+
/// The control will always default to unselected and users
|
|
53
|
+
/// will have to explicitly interact to save their payment method
|
|
54
|
+
case requiresOptIn
|
|
55
|
+
|
|
56
|
+
/// The control will always default to selected and users
|
|
57
|
+
/// will have to explicitly interact to not save their payment method
|
|
58
|
+
case requiresOptOut
|
|
59
|
+
|
|
60
|
+
var isSelectedByDefault: Bool {
|
|
61
|
+
switch self {
|
|
62
|
+
case .automatic:
|
|
63
|
+
// only enable the save checkbox by default for US
|
|
64
|
+
return Locale.current.regionCode == "US"
|
|
65
|
+
case .requiresOptIn:
|
|
66
|
+
return false
|
|
67
|
+
case .requiresOptOut:
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public struct PlaceHolder: Equatable, DictionaryConverter {
|
|
74
|
+
public init() {}
|
|
75
|
+
public var cardNumber: String?
|
|
76
|
+
public var expiryDate: String? // MM/YY
|
|
77
|
+
public var cvv: String?
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// Configuration for PaymentSheet
|
|
81
|
+
public struct Configuration: DictionaryConverter {
|
|
82
|
+
|
|
83
|
+
/// If true, allows payment methods that do not move money at the end of the checkout. Defaults to false.
|
|
84
|
+
/// - Description: Some payment methods can't guarantee you will receive funds from your customer at the end of the checkout because they take time to settle (eg. most bank debits, like SEPA or ACH) or require customer action to complete (e.g. OXXO, Konbini, Boleto). If this is set to true, make sure your integration listens to webhooks for notifications on whether a payment has succeeded or not.
|
|
85
|
+
/// - Seealso: https://docs.hyperswitch.io/payments/payment-methods#payment-notification
|
|
86
|
+
public var allowsDelayedPaymentMethods: Bool = false
|
|
87
|
+
|
|
88
|
+
/// If `true`, allows payment methods that require a shipping address, like Afterpay and Affirm. Defaults to `false`.
|
|
89
|
+
/// Set this to `true` if you collect shipping addresses and set `Configuration.shippingDetails` or set `shipping` details directly on the PaymentIntent.
|
|
90
|
+
/// - Note: PaymentSheet considers this property `true` and allows payment methods that require a shipping address if `shipping` details are present on the PaymentIntent when PaymentSheet loads.
|
|
91
|
+
public var allowsPaymentMethodsRequiringShippingAddress: Bool = false
|
|
92
|
+
|
|
93
|
+
/// The APIClient instance used to make requests to Hyperswitch
|
|
94
|
+
// internal var apiClient: APIClient = APIClient.shared
|
|
95
|
+
|
|
96
|
+
/// Configuration related to Apple Pay
|
|
97
|
+
/// If set, PaymentSheet displays Apple Pay as a payment option
|
|
98
|
+
public var applePay: ApplePayConfiguration?
|
|
99
|
+
|
|
100
|
+
/// The color of the Buy or Add button. Defaults to `.systemBlue` when `nil`.
|
|
101
|
+
public var primaryButtonColor: UIColor? {
|
|
102
|
+
get {
|
|
103
|
+
return appearance.primaryButton.backgroundColor
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
set {
|
|
107
|
+
appearance.primaryButton.backgroundColor = newValue
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// The label to use for the primary button.
|
|
112
|
+
///
|
|
113
|
+
/// If not set, Payment Sheet will display suitable default labels
|
|
114
|
+
/// for payment and setup intents.
|
|
115
|
+
public var primaryButtonLabel: String?
|
|
116
|
+
public var paymentSheetHeaderLabel: String?
|
|
117
|
+
public var savedPaymentSheetHeaderLabel: String?
|
|
118
|
+
|
|
119
|
+
private var styleRawValue: Int = 0 // SheetStyle.automatic.rawValue
|
|
120
|
+
/// The color styling to use for PaymentSheet UI
|
|
121
|
+
/// Default value is SheetStyle.automatic
|
|
122
|
+
/// @see SheetStyle
|
|
123
|
+
public var style: UserInterfaceStyle { // stored properties can't be marked @available which is why this uses the styleRawValue private var
|
|
124
|
+
get {
|
|
125
|
+
return UserInterfaceStyle(rawValue: styleRawValue)!
|
|
126
|
+
}
|
|
127
|
+
set {
|
|
128
|
+
styleRawValue = newValue.rawValue
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// Configuration related to the Hyperswitch Customer
|
|
133
|
+
/// If set, the customer can select a previously saved payment method within PaymentSheet
|
|
134
|
+
public var customer: CustomerConfiguration?
|
|
135
|
+
|
|
136
|
+
/// Your customer-facing business name.
|
|
137
|
+
/// The default value is the name of your app, using CFBundleDisplayName or CFBundleName
|
|
138
|
+
public var merchantDisplayName: String = Bundle.displayName ?? ""
|
|
139
|
+
|
|
140
|
+
///
|
|
141
|
+
/// toggle to disable SaveCard CheckBox
|
|
142
|
+
public var displaySavedPaymentMethodsCheckbox: Bool? = true
|
|
143
|
+
|
|
144
|
+
///
|
|
145
|
+
/// toggle to disable SavedCard Screen
|
|
146
|
+
public var displaySavedPaymentMethods: Bool? = true
|
|
147
|
+
|
|
148
|
+
///
|
|
149
|
+
/// toggle to disable Branding
|
|
150
|
+
public var disableBranding: Bool? = false
|
|
151
|
+
|
|
152
|
+
///
|
|
153
|
+
/// add custom placeholder text
|
|
154
|
+
public var placeholder: PlaceHolder = PlaceHolder()
|
|
155
|
+
|
|
156
|
+
///
|
|
157
|
+
/// toggle to disable Default Saved Payment Icon
|
|
158
|
+
public var displayDefaultSavedPaymentIcon: Bool? = true
|
|
159
|
+
|
|
160
|
+
/// A URL that redirects back to your app that PaymentSheet can use to auto-dismiss
|
|
161
|
+
/// web views used for additional authentication, e.g. 3DS2
|
|
162
|
+
public var returnURL: String?
|
|
163
|
+
|
|
164
|
+
/// PaymentSheet pre-populates fields with the values provided.
|
|
165
|
+
/// If `billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod` is `true`, these values will
|
|
166
|
+
/// be attached to the payment method even if they are not collected by the PaymentSheet UI.
|
|
167
|
+
public var defaultBillingDetails: BillingDetails = BillingDetails()
|
|
168
|
+
|
|
169
|
+
/// PaymentSheet offers users an option to save some payment methods for later use.
|
|
170
|
+
/// Default value is .automatic
|
|
171
|
+
/// @see SavePaymentMethodOptInBehavior
|
|
172
|
+
public var savePaymentMethodOptInBehavior: SavePaymentMethodOptInBehavior = .automatic
|
|
173
|
+
|
|
174
|
+
/// DefaultView = `true` launches PaymentSheet with cardForm, never shows the loading state.
|
|
175
|
+
/// Default value is `false`
|
|
176
|
+
public var defaultView: Bool? = false
|
|
177
|
+
|
|
178
|
+
/// Describes the appearance of PaymentSheet
|
|
179
|
+
public var appearance = PaymentSheet.Appearance.default
|
|
180
|
+
|
|
181
|
+
/// A closure that returns the customer's shipping details.
|
|
182
|
+
/// This is used to display a "Billing address is same as shipping" checkbox if `defaultBillingDetails` is not provided
|
|
183
|
+
/// If `name` and `line1` are populated, it's also [attached to the PaymentIntent](https://docs.hyperswitch.io/api/payment_intents/object#payment_intent_object-shipping) during payment.
|
|
184
|
+
// public var shippingDetails: () -> AddressViewController.AddressDetails? = { return nil }
|
|
185
|
+
public var shippingDetails: BillingDetails = BillingDetails()
|
|
186
|
+
|
|
187
|
+
/// The list of preferred networks that should be used to process payments made with a co-branded card.
|
|
188
|
+
/// This value will only be used if your user hasn't selected a network themselves.
|
|
189
|
+
// public var preferredNetworks: [CardBrand]? {
|
|
190
|
+
// didSet {
|
|
191
|
+
// guard let preferredNetworks = preferredNetworks else { return }
|
|
192
|
+
// assert(Set<CardBrand>(preferredNetworks).count == preferredNetworks.count,
|
|
193
|
+
// "preferredNetworks must not contain any duplicate card brands")
|
|
194
|
+
// }
|
|
195
|
+
// }
|
|
196
|
+
|
|
197
|
+
/// Initializes a Configuration with default values
|
|
198
|
+
public init() {}
|
|
199
|
+
|
|
200
|
+
// MARK: Internal
|
|
201
|
+
internal var linkPaymentMethodsOnly: Bool = false
|
|
202
|
+
|
|
203
|
+
/// Describes how billing details should be collected.
|
|
204
|
+
/// All values default to `automatic`.
|
|
205
|
+
/// If `never` is used for a required field for the Payment Method used during checkout,
|
|
206
|
+
/// you **must** provide an appropriate value as part of `defaultBillingDetails`.
|
|
207
|
+
public var billingDetailsCollectionConfiguration = BillingDetailsCollectionConfiguration()
|
|
208
|
+
|
|
209
|
+
/// Optional configuration to display a custom message when a saved payment method is removed.
|
|
210
|
+
public var removeSavedPaymentMethodMessage: String?
|
|
211
|
+
|
|
212
|
+
/// Configuration for external payment methods.
|
|
213
|
+
public var externalPaymentMethodConfiguration: ExternalPaymentMethodConfiguration?
|
|
214
|
+
|
|
215
|
+
/// By default, PaymentSheet will use a dynamic ordering that optimizes payment method display for the customer.
|
|
216
|
+
/// You can override the default order in which payment methods are displayed in PaymentSheet with a list of payment method types.
|
|
217
|
+
/// See https://docs.hyperswitch.io/api/payment_methods/object#payment_method_object-type for the list of valid types. You may also pass external payment methods.
|
|
218
|
+
/// - Example: ["card", "external_paypal", "klarna"]
|
|
219
|
+
/// - Note: If you omit payment methods from this list, they’ll be automatically ordered by Hyperswitch after the ones you provide. Invalid payment methods are ignored.
|
|
220
|
+
public var paymentMethodOrder: [String]?
|
|
221
|
+
|
|
222
|
+
/// Api key used to invoke netcetera sdk for redirection-less 3DS authentication.
|
|
223
|
+
public var netceteraSDKApiKey: String?
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// Configuration related to the Hyperswitch Customer
|
|
227
|
+
public struct CustomerConfiguration: DictionaryConverter {
|
|
228
|
+
/// The identifier of the Hyperswitch Customer object.
|
|
229
|
+
/// See https://docs.hyperswitch.io/api/customers/object#customer_object-id
|
|
230
|
+
public let id: String
|
|
231
|
+
|
|
232
|
+
/// A short-lived token that allows the SDK to access a Customer's payment methods
|
|
233
|
+
public let ephemeralKeySecret: String
|
|
234
|
+
|
|
235
|
+
/// Initializes a CustomerConfiguration
|
|
236
|
+
public init(id: String, ephemeralKeySecret: String) {
|
|
237
|
+
self.id = id
|
|
238
|
+
self.ephemeralKeySecret = ephemeralKeySecret
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/// Configuration related to Apple Pay
|
|
243
|
+
public struct ApplePayConfiguration {
|
|
244
|
+
/// The Apple Merchant Identifier to use during Apple Pay transactions.
|
|
245
|
+
/// To obtain one, see https://docs.hyperswitch.io/apple-pay#native
|
|
246
|
+
public let merchantId: String
|
|
247
|
+
|
|
248
|
+
/// The two-letter ISO 3166 code of the country of your business, e.g. "US"
|
|
249
|
+
/// See your account's country value here https://app.hyperswitch.io/settings/account
|
|
250
|
+
public let merchantCountryCode: String
|
|
251
|
+
|
|
252
|
+
/// Defines the label that will be displayed in the Apple Pay button.
|
|
253
|
+
/// See <https://developer.apple.com/design/human-interface-guidelines/technologies/apple-pay/buttons-and-marks/>
|
|
254
|
+
/// for all available options.
|
|
255
|
+
public let buttonType: PKPaymentButtonType
|
|
256
|
+
|
|
257
|
+
/// An array of payment summary item objects that summarize the amount of the payment. This property is identical to `PKPaymentRequest.paymentSummaryItems`.
|
|
258
|
+
/// If `nil`, we display a single line item with the amount on the PaymentIntent or "Amount pending" for SetupIntents.
|
|
259
|
+
/// If you're using a SetupIntent for a recurring payment, you should set this to display the amount you intend to charge, in accordance with https://developer.apple.com/design/human-interface-guidelines/technologies/apple-pay/subscriptions-and-donations
|
|
260
|
+
/// Follow Apple's documentation to set this property: https://developer.apple.com/documentation/passkit/pkpaymentrequest/1619231-paymentsummaryitems
|
|
261
|
+
public let paymentSummaryItems: [PKPaymentSummaryItem]?
|
|
262
|
+
|
|
263
|
+
/// Optional handler blocks for Apple Pay
|
|
264
|
+
public let customHandlers: Handlers?
|
|
265
|
+
|
|
266
|
+
/// Custom handler blocks for Apple Pay
|
|
267
|
+
public struct Handlers {
|
|
268
|
+
/// Optionally configure additional information on your PKPaymentRequest.
|
|
269
|
+
/// This closure will be called after the PKPaymentRequest is created, but before the Apple Pay sheet is presented.
|
|
270
|
+
/// In your implementation, you can configure the PKPaymentRequest to add custom fields, such as `recurringPaymentRequest`.
|
|
271
|
+
/// See https://developer.apple.com/documentation/passkit/pkpaymentrequest for all configuration options.
|
|
272
|
+
/// - Parameter: The PKPaymentRequest created by PaymentSheet.
|
|
273
|
+
/// - Return: The PKPaymentRequest after your modifications.
|
|
274
|
+
public let paymentRequestHandler: ((PKPaymentRequest) -> PKPaymentRequest)?
|
|
275
|
+
|
|
276
|
+
/// Optionally configure additional information on your PKPaymentAuthorizationResult.
|
|
277
|
+
/// This closure will be called after the PaymentIntent or SetupIntent is confirmed, but before
|
|
278
|
+
/// the Apple Pay sheet has been closed.
|
|
279
|
+
/// In your implementation, you can configure the PKPaymentAuthorizationResult to add custom fields, such as `orderDetails`.
|
|
280
|
+
/// See https://developer.apple.com/documentation/passkit/pkpaymentauthorizationresult for all configuration options.
|
|
281
|
+
/// - Parameter $0: The PKPaymentAuthorizationResult created by PaymentSheet.
|
|
282
|
+
/// - Parameter $1: A completion handler. You must call this handler with the PKPaymentAuthorizationResult on the main queue
|
|
283
|
+
/// after applying your modifications.
|
|
284
|
+
/// For example:
|
|
285
|
+
/// ```
|
|
286
|
+
/// .authorizationResultHandler = { result, completion in
|
|
287
|
+
/// result.orderDetails = PKPaymentOrderDetails(/* ... */)
|
|
288
|
+
/// completion(result)
|
|
289
|
+
/// }
|
|
290
|
+
/// ```
|
|
291
|
+
/// WARNING: If you do not call the completion handler, your app will hang until the Apple Pay sheet times out.
|
|
292
|
+
public let authorizationResultHandler:
|
|
293
|
+
((PKPaymentAuthorizationResult, @escaping ((PKPaymentAuthorizationResult) -> Void)) -> Void)?
|
|
294
|
+
|
|
295
|
+
/// Initializes the ApplePayConfiguration Handlers.
|
|
296
|
+
public init(
|
|
297
|
+
paymentRequestHandler: ((PKPaymentRequest) -> PKPaymentRequest)? = nil,
|
|
298
|
+
authorizationResultHandler: (
|
|
299
|
+
(PKPaymentAuthorizationResult, @escaping ((PKPaymentAuthorizationResult) -> Void)) -> Void
|
|
300
|
+
)? = nil
|
|
301
|
+
) {
|
|
302
|
+
self.paymentRequestHandler = paymentRequestHandler
|
|
303
|
+
self.authorizationResultHandler = authorizationResultHandler
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/// Initializes a ApplePayConfiguration
|
|
308
|
+
public init(
|
|
309
|
+
merchantId: String,
|
|
310
|
+
merchantCountryCode: String,
|
|
311
|
+
buttonType: PKPaymentButtonType = .plain,
|
|
312
|
+
paymentSummaryItems: [PKPaymentSummaryItem]? = nil,
|
|
313
|
+
customHandlers: Handlers? = nil
|
|
314
|
+
) {
|
|
315
|
+
self.merchantId = merchantId
|
|
316
|
+
self.merchantCountryCode = merchantCountryCode
|
|
317
|
+
self.buttonType = buttonType
|
|
318
|
+
self.paymentSummaryItems = paymentSummaryItems
|
|
319
|
+
self.customHandlers = customHandlers
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/// An address.
|
|
324
|
+
public struct Address: Equatable, DictionaryConverter {
|
|
325
|
+
/// City, district, suburb, town, or village.
|
|
326
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
327
|
+
public var city: String?
|
|
328
|
+
|
|
329
|
+
/// Two-letter country code (ISO 3166-1 alpha-2).
|
|
330
|
+
public var country: String?
|
|
331
|
+
|
|
332
|
+
/// Address line 1 (e.g., street, PO Box, or company name).
|
|
333
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
334
|
+
public var line1: String?
|
|
335
|
+
|
|
336
|
+
/// Address line 2 (e.g., apartment, suite, unit, or building).
|
|
337
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
338
|
+
public var line2: String?
|
|
339
|
+
|
|
340
|
+
/// ZIP or postal code.
|
|
341
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
342
|
+
public var postalCode: String?
|
|
343
|
+
|
|
344
|
+
/// State, county, province, or region.
|
|
345
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
346
|
+
public var state: String?
|
|
347
|
+
|
|
348
|
+
/// Initializes an Address
|
|
349
|
+
public init(
|
|
350
|
+
city: String? = nil,
|
|
351
|
+
country: String? = nil,
|
|
352
|
+
line1: String? = nil,
|
|
353
|
+
line2: String? = nil,
|
|
354
|
+
postalCode: String? = nil,
|
|
355
|
+
state: String? = nil
|
|
356
|
+
) {
|
|
357
|
+
self.city = city
|
|
358
|
+
self.country = country
|
|
359
|
+
self.line1 = line1
|
|
360
|
+
self.line2 = line2
|
|
361
|
+
self.postalCode = postalCode
|
|
362
|
+
self.state = state
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// Billing details of a customer
|
|
367
|
+
public struct BillingDetails: Equatable, DictionaryConverter {
|
|
368
|
+
/// The customer's billing address
|
|
369
|
+
public var address: Address = Address()
|
|
370
|
+
|
|
371
|
+
/// The customer's email
|
|
372
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
373
|
+
public var email: String?
|
|
374
|
+
|
|
375
|
+
/// The customer's full name
|
|
376
|
+
/// - Note: The value set is displayed in the payment sheet as-is. Depending on the payment method, the customer may be required to edit this value.
|
|
377
|
+
public var name: String?
|
|
378
|
+
|
|
379
|
+
/// The customer's phone number without formatting (e.g. 5551234567)
|
|
380
|
+
public var phone: String?
|
|
381
|
+
|
|
382
|
+
/// Initializes billing details
|
|
383
|
+
public init(address: PaymentSheet.Address = Address(), email: String? = nil, name: String? = nil, phone: String? = nil) {
|
|
384
|
+
self.address = address
|
|
385
|
+
self.email = email
|
|
386
|
+
self.name = name
|
|
387
|
+
self.phone = phone
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// Configuration for how billing details are collected during checkout.
|
|
392
|
+
public struct BillingDetailsCollectionConfiguration: Equatable {
|
|
393
|
+
/// Billing details fields collection options.
|
|
394
|
+
public enum CollectionMode: String, CaseIterable {
|
|
395
|
+
/// The field will be collected depending on the Payment Method's requirements.
|
|
396
|
+
case automatic
|
|
397
|
+
/// The field will never be collected.
|
|
398
|
+
/// If this field is required by the Payment Method, you must provide it as part of `defaultBillingDetails`.
|
|
399
|
+
case never
|
|
400
|
+
/// The field will always be collected, even if it isn't required for the Payment Method.
|
|
401
|
+
case always
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/// Billing address collection options.
|
|
405
|
+
public enum AddressCollectionMode: String, CaseIterable {
|
|
406
|
+
/// Only the fields required by the Payment Method will be collected, this may be none.
|
|
407
|
+
case automatic
|
|
408
|
+
/// Address will never be collected.
|
|
409
|
+
/// If the Payment Method requires a billing address, you must provide it as part of
|
|
410
|
+
/// `defaultBillingDetails`.
|
|
411
|
+
case never
|
|
412
|
+
/// Collect the full billing address, regardless of the Payment Method requirements.
|
|
413
|
+
case full
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/// How to collect the name field.
|
|
417
|
+
/// Defaults to `automatic`.
|
|
418
|
+
public var name: CollectionMode = .automatic
|
|
419
|
+
|
|
420
|
+
/// How to collect the phone field.
|
|
421
|
+
/// Defaults to `automatic`.
|
|
422
|
+
public var phone: CollectionMode = .automatic
|
|
423
|
+
|
|
424
|
+
/// How to collect the email field.
|
|
425
|
+
/// Defaults to `automatic`.
|
|
426
|
+
public var email: CollectionMode = .automatic
|
|
427
|
+
|
|
428
|
+
/// How to collect the billing address.
|
|
429
|
+
/// Defaults to `automatic`.
|
|
430
|
+
public var address: AddressCollectionMode = .automatic
|
|
431
|
+
|
|
432
|
+
/// Whether the values included in `Configuration.defaultBillingDetails` should be attached to the payment
|
|
433
|
+
/// method, this includes fields that aren't displayed in the form.
|
|
434
|
+
///
|
|
435
|
+
/// If `false` (the default), those values will only be used to prefill the corresponding fields in the form.
|
|
436
|
+
public var attachDefaultsToPaymentMethod = false
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/// Configuration for external payment methods
|
|
440
|
+
/// - Seealso: See the [integration guide](https://docs.hyperswitch.io/payments/external-payment-methods?platform=ios).
|
|
441
|
+
public struct ExternalPaymentMethodConfiguration {
|
|
442
|
+
|
|
443
|
+
/// Initializes an `ExternalPaymentMethodConfiguration`
|
|
444
|
+
/// - Parameter externalPaymentMethods: A list of external payment methods to display in PaymentSheet e.g., ["external_paypal"].
|
|
445
|
+
/// - Parameter externalPaymentMethodConfirmHandler: A handler called when the customer confirms the payment using an external payment method.
|
|
446
|
+
/// - Seealso: See the [integration guide](https://docs.hyperswitch.io/payments/external-payment-methods?platform=ios).
|
|
447
|
+
public init(externalPaymentMethods: [String], externalPaymentMethodConfirmHandler: @escaping PaymentSheet.ExternalPaymentMethodConfiguration.ExternalPaymentMethodConfirmHandler) {
|
|
448
|
+
self.externalPaymentMethods = externalPaymentMethods
|
|
449
|
+
self.externalPaymentMethodConfirmHandler = externalPaymentMethodConfirmHandler
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/// A list of external payment methods to display in PaymentSheet.
|
|
453
|
+
/// e.g. ["external_paypal"].
|
|
454
|
+
public var externalPaymentMethods: [String] = []
|
|
455
|
+
|
|
456
|
+
/// - Parameter externalPaymentMethodType: The external payment method to confirm payment with e.g., "external_paypal"
|
|
457
|
+
/// - Parameter billingDetails: An object containing any billing details you've configured PaymentSheet to collect.
|
|
458
|
+
/// - Parameter completion: Call this after payment has completed, passing the result of the payment.
|
|
459
|
+
/// - Returns: The result of the attempt to confirm payment using the given external payment method.
|
|
460
|
+
public typealias ExternalPaymentMethodConfirmHandler = (
|
|
461
|
+
_ externalPaymentMethodType: String,
|
|
462
|
+
_ billingDetails: BillingDetails,
|
|
463
|
+
_ completion: @escaping ((PaymentSheetResult) -> Void)
|
|
464
|
+
) -> Void
|
|
465
|
+
|
|
466
|
+
/// This handler is called when the customer confirms the payment using an external payment method.
|
|
467
|
+
/// Your implementation should complete the payment and call the `completion` parameter with the result.
|
|
468
|
+
/// - Note: This is always called on the main thread.
|
|
469
|
+
public var externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
extension Bundle {
|
|
474
|
+
public class func applicationName() -> String? {
|
|
475
|
+
return self.main.infoDictionary?[kCFBundleNameKey as String] as? String
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
public class func applicationVersion() -> String? {
|
|
479
|
+
return self.main.infoDictionary?["CFBundleShortVersionString"] as? String
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public class func applicationBundleId() -> String? {
|
|
483
|
+
return self.main.bundleIdentifier
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
public class func buildVersion() -> String? {
|
|
487
|
+
return self.main.infoDictionary?["CFBundleVersion"] as? String
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
public class var displayName: String? {
|
|
491
|
+
return self.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String ?? self.main
|
|
492
|
+
.object(forInfoDictionaryKey: "CFBundleName") as? String
|
|
493
|
+
}
|
|
494
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SwiftUIManager.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Shivam Shashank on 02/12/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
struct ViewControllerHolder {
|
|
11
|
+
weak var value: UIViewController?
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@available(iOS 13.0, *)
|
|
15
|
+
struct ViewControllerKey: EnvironmentKey {
|
|
16
|
+
static var defaultValue: ViewControllerHolder {
|
|
17
|
+
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
|
18
|
+
return ViewControllerHolder(value: windowScene?.windows.first?.rootViewController)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@available(iOS 13.0, *)
|
|
23
|
+
extension EnvironmentValues {
|
|
24
|
+
var viewController: UIViewController? {
|
|
25
|
+
get { return self[ViewControllerKey.self].value }
|
|
26
|
+
set { self[ViewControllerKey.self].value = newValue }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
rescript = 1
|
|
2
|
+
g_finger := /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/@rescript/react/lib/ocaml/install.stamp
|
|
3
|
+
g_finger := /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript-react-native/lib/ocaml/install.stamp
|
|
4
|
+
g_finger := /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/@rescript/core/lib/ocaml/install.stamp
|
|
5
|
+
rule astj
|
|
6
|
+
command = /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript/darwinarm64/bsc.exe -bs-v 11.1.4 -bs-jsx 4 -uncurried -open RescriptCore -absname -bs-ast -o $out $i
|
|
7
|
+
o src/modules/NativeHyperswitchSdk.ast : astj ../../src/modules/NativeHyperswitchSdk.res
|
|
8
|
+
rule deps
|
|
9
|
+
command = /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript/darwinarm64/bsb_helper.exe -hash 20066052cc03cf578e73f89389aaafc3 -bs-ns JuspayTechReactNativeHyperswitch $in
|
|
10
|
+
restat = 1
|
|
11
|
+
o src/modules/NativeHyperswitchSdk.d : deps src/modules/NativeHyperswitchSdk.ast
|
|
12
|
+
rule mij
|
|
13
|
+
command = /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript/darwinarm64/bsc.exe -bs-ns JuspayTechReactNativeHyperswitch -I . -I src/types -I src/context -I src/specs -I src/__tests__ -I src/shims -I src/hooks -I src/modules -I src -I /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/@rescript/react/lib/ocaml -I /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript-react-native/lib/ocaml -I /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/@rescript/core/lib/ocaml -open RescriptCore -bs-gentype -uncurried -bs-package-name @juspay-tech/react-native-hyperswitch -bs-package-output esmodule:$in_d:.res.js -bs-v $g_finger $i
|
|
14
|
+
dyndep = 1
|
|
15
|
+
restat = 1
|
|
16
|
+
o src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi ../../src/modules/NativeHyperswitchSdk.res.js : mij src/modules/NativeHyperswitchSdk.ast
|
|
17
|
+
o src/hooks/useHyper.ast : astj ../../src/hooks/useHyper.res
|
|
18
|
+
o src/hooks/useHyper.d : deps src/hooks/useHyper.ast
|
|
19
|
+
o src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi ../../src/hooks/useHyper.res.js : mij src/hooks/useHyper.ast
|
|
20
|
+
o src/context/HyperProvider.ast : astj ../../src/context/HyperProvider.res
|
|
21
|
+
o src/context/HyperProvider.d : deps src/context/HyperProvider.ast
|
|
22
|
+
o src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi ../../src/context/HyperProvider.res.js : mij src/context/HyperProvider.ast
|
|
23
|
+
o src/types/PaymentSheetConfiguration.ast : astj ../../src/types/PaymentSheetConfiguration.res
|
|
24
|
+
o src/types/PaymentSheetConfiguration.d : deps src/types/PaymentSheetConfiguration.ast
|
|
25
|
+
o src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi ../../src/types/PaymentSheetConfiguration.res.js : mij src/types/PaymentSheetConfiguration.ast
|
|
26
|
+
rule build_package
|
|
27
|
+
command = /Users/shivam.shashank/Documents/repositories/hyperswitch-react-native-libraries/packages/@juspay-tech/react-native-hyperswitch/node_modules/rescript/darwinarm64/bsc.exe -w -49 -color always -no-alias-deps $i
|
|
28
|
+
restat = 1
|
|
29
|
+
o JuspayTechReactNativeHyperswitch.cmi : build_package JuspayTechReactNativeHyperswitch.mlmap
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
rescript = 1
|
|
2
|
+
rule cp
|
|
3
|
+
command = cp $i $out
|
|
4
|
+
rule touch
|
|
5
|
+
command = touch $out
|
|
6
|
+
o NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi : cp ../bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi
|
|
7
|
+
o NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj : cp ../bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj
|
|
8
|
+
o NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt : cp ../bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt
|
|
9
|
+
o NativeHyperswitchSdk.res : cp ../../src/modules/NativeHyperswitchSdk.res
|
|
10
|
+
o useHyper-JuspayTechReactNativeHyperswitch.cmi : cp ../bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi
|
|
11
|
+
o useHyper-JuspayTechReactNativeHyperswitch.cmj : cp ../bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj
|
|
12
|
+
o useHyper-JuspayTechReactNativeHyperswitch.cmt : cp ../bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmt
|
|
13
|
+
o useHyper.res : cp ../../src/hooks/useHyper.res
|
|
14
|
+
o HyperProvider-JuspayTechReactNativeHyperswitch.cmi : cp ../bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi
|
|
15
|
+
o HyperProvider-JuspayTechReactNativeHyperswitch.cmj : cp ../bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj
|
|
16
|
+
o HyperProvider-JuspayTechReactNativeHyperswitch.cmt : cp ../bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt
|
|
17
|
+
o HyperProvider.res : cp ../../src/context/HyperProvider.res
|
|
18
|
+
o PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi : cp ../bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi
|
|
19
|
+
o PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj : cp ../bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj
|
|
20
|
+
o PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt : cp ../bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt
|
|
21
|
+
o PaymentSheetConfiguration.res : cp ../../src/types/PaymentSheetConfiguration.res
|
|
22
|
+
o JuspayTechReactNativeHyperswitch.cmi : cp ../bs/JuspayTechReactNativeHyperswitch.cmi
|
|
23
|
+
o JuspayTechReactNativeHyperswitch.cmj : cp ../bs/JuspayTechReactNativeHyperswitch.cmj
|
|
24
|
+
o JuspayTechReactNativeHyperswitch.cmt : cp ../bs/JuspayTechReactNativeHyperswitch.cmt
|
|
25
|
+
build install.stamp : touch NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj useHyper-JuspayTechReactNativeHyperswitch.cmi useHyper-JuspayTechReactNativeHyperswitch.cmj HyperProvider-JuspayTechReactNativeHyperswitch.cmi HyperProvider-JuspayTechReactNativeHyperswitch.cmj PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj JuspayTechReactNativeHyperswitch.cmi JuspayTechReactNativeHyperswitch.cmj
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj : JuspayTechReactNativeHyperswitch.cmi src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj : JuspayTechReactNativeHyperswitch.cmi src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj : JuspayTechReactNativeHyperswitch.cmi src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi
|