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,91 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LogPayload.swift
|
|
3
|
+
// hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Kuntimaddi Manideep on 24/01/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
struct LogPayload: Codable {
|
|
11
|
+
let timestamp: String
|
|
12
|
+
let log_type: LogType
|
|
13
|
+
let component: String
|
|
14
|
+
let category: LogCategory
|
|
15
|
+
let version: String
|
|
16
|
+
let code_push_version: String
|
|
17
|
+
let client_core_version: String
|
|
18
|
+
let value: String
|
|
19
|
+
let internal_metadata: String
|
|
20
|
+
let session_id: String
|
|
21
|
+
var merchant_id: String
|
|
22
|
+
let payment_id: String
|
|
23
|
+
let authentication_id: String
|
|
24
|
+
let app_id: String?
|
|
25
|
+
let platform: String
|
|
26
|
+
let user_agent: String
|
|
27
|
+
let event_name: EventName
|
|
28
|
+
let latency: String?
|
|
29
|
+
let first_event: String
|
|
30
|
+
let payment_method: String?
|
|
31
|
+
let payment_experience: String?
|
|
32
|
+
let source: String
|
|
33
|
+
|
|
34
|
+
func toJson() -> String? {
|
|
35
|
+
do {
|
|
36
|
+
let jsonData = try JSONEncoder().encode(self)
|
|
37
|
+
return String(data: jsonData, encoding: .utf8)
|
|
38
|
+
} catch {
|
|
39
|
+
return nil
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
enum LogType: String, Codable {
|
|
45
|
+
case DEBUG, INFO, ERROR, WARNING
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
enum LogCategory: String, Codable {
|
|
49
|
+
case API, USER_ERROR, USER_EVENT, MERCHANT_EVENT, OTA_LIFE_CYCLE
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
enum EventName: String, Codable {
|
|
53
|
+
case hyperOTAInit = "HYPER_OTA_INIT"
|
|
54
|
+
case hyperOTAFinish = "HYPER_OTA_FINISH"
|
|
55
|
+
case hyperOTAEvent = "HYPER_OTA_EVENT"
|
|
56
|
+
|
|
57
|
+
case authenticationSessionInit = "AUTHENTICATION_SESSION_INIT"
|
|
58
|
+
case authenticationSessionReturned = "AUTHENTICATION_SESSION_RETURNED"
|
|
59
|
+
case initClickToPaySessionInit = "INIT_CLICK_TO_PAY_SESSION_INIT"
|
|
60
|
+
case initClickToPaySessionReturned = "INIT_CLICK_TO_PAY_SESSION_RETURNED"
|
|
61
|
+
case initClickToPayDCTPSessionInit = "INIT_CLICK_TO_PAY_DCTP_SESSION_INIT"
|
|
62
|
+
case initClickToPayDCTPSessionReturned = "INIT_CLICK_TO_PAY_DCTP_SESSION_RETURNED"
|
|
63
|
+
case createWebViewInit = "CREATE_WEBVIEW_INIT"
|
|
64
|
+
case scriptLoadInit = "SCRIPT_LOAD_INIT"
|
|
65
|
+
case scriptLoadReturn = "SCRIPT_LOAD_RETURN"
|
|
66
|
+
case dctpScriptLoadInit = "DCTP_SCRIPT_LOAD_INIT"
|
|
67
|
+
case dctpScriptLoadReturn = "DCTP_SCRIPT_LOAD_RETURN"
|
|
68
|
+
case createWebViewReturned = "CREATE_WEBVIEW_RETURNED"
|
|
69
|
+
case getActiveClickToPaySessionInit = "GET_ACTIVE_CLICK_TO_PAY_SESSION_INIT"
|
|
70
|
+
case getActiveClickToPaySessionReturned = "GET_ACTIVE_CLICK_TO_PAY_SESSION_RETURNED"
|
|
71
|
+
case isCustomerPresentInit = "IS_CUSTOMER_PRESENT_INIT"
|
|
72
|
+
case isCustomerPresentReturned = "IS_CUSTOMER_PRESENT_RETURNED"
|
|
73
|
+
case getUserTypeInit = "GET_USER_TYPE_INIT"
|
|
74
|
+
case getUserTypeReturned = "GET_USER_TYPE_RETURNED"
|
|
75
|
+
case getRecognisedCardsInit = "GET_RECOGNISED_CARDS_INIT"
|
|
76
|
+
case getRecognisedCardsReturned = "GET_RECOGNISED_CARDS_RETURNED"
|
|
77
|
+
case validateCustomerAuthenticationInit = "VALIDATE_CUSTOMER_AUTHENTICATION_INIT"
|
|
78
|
+
case validateCustomerAuthenticationReturned = "VALIDATE_CUSTOMER_AUTHENTICATION_RETURNED"
|
|
79
|
+
case checkoutInit = "CHECKOUT_INIT"
|
|
80
|
+
case checkoutReturned = "CHECKOUT_RETURNED"
|
|
81
|
+
case createNewWebViewInit = "CREATE_NEW_WEBVIEW_INIT"
|
|
82
|
+
case createNewWebViewReturned = "CREATE_NEW_WEBVIEW_RETURNED"
|
|
83
|
+
case signOutInit = "SIGN_OUT_INIT"
|
|
84
|
+
case signOutReturned = "SIGN_OUT_RETURNED"
|
|
85
|
+
case closeInit = "CLOSE_INIT"
|
|
86
|
+
case closeReturned = "CLOSE_RETURNED"
|
|
87
|
+
case closeWebViewInit = "CLOSE_WEBVIEW_INIT"
|
|
88
|
+
case closeWebViewReturned = "CLOSE_WEBVIEW_RETURNED"
|
|
89
|
+
case checkSessionClosed = "CHECK_SESSION_CLOSED"
|
|
90
|
+
case userContentControllerReturned = "USER_CONTENT_CONTROLLER_RETURNED"
|
|
91
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentRequestData.swift
|
|
3
|
+
// hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 18/05/26.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
public struct PaymentRequestData: Codable {
|
|
9
|
+
public var paymentMethodType: PaymentMethodType
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public enum PaymentMethodType: String, Codable {
|
|
13
|
+
case applePay = "apple_pay"
|
|
14
|
+
case payPal = "paypal"
|
|
15
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSession.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 07/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Combine
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
@frozen public enum PaymentResult {
|
|
12
|
+
case completed(data: String)
|
|
13
|
+
case canceled(data: String)
|
|
14
|
+
case failed(error: Error)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public enum UpdateIntentResult {
|
|
18
|
+
case success
|
|
19
|
+
case cancelled
|
|
20
|
+
case failure(Error)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public class PaymentSession {
|
|
24
|
+
|
|
25
|
+
internal var paymentSessionConfiguration: PaymentSessionConfiguration
|
|
26
|
+
internal var hyperswitchConfiguration: HyperswitchConfiguration?
|
|
27
|
+
|
|
28
|
+
internal let updateIntentDidStart = PassthroughSubject<Void, Never>()
|
|
29
|
+
internal let updateIntentDidComplete = PassthroughSubject<String, Never>()
|
|
30
|
+
internal let updateIntentInitReturned = PassthroughSubject<String, Never>()
|
|
31
|
+
internal let updateIntentCompleteReturned = PassthroughSubject<String, Never>()
|
|
32
|
+
private var cancellables = Set<AnyCancellable>()
|
|
33
|
+
|
|
34
|
+
internal init(paymentSessionConfiguration: PaymentSessionConfiguration, hyperswitchConfiguration: HyperswitchConfiguration? = nil) {
|
|
35
|
+
self.paymentSessionConfiguration = paymentSessionConfiguration
|
|
36
|
+
self.hyperswitchConfiguration = hyperswitchConfiguration
|
|
37
|
+
|
|
38
|
+
if let hyperswitchConfiguration = hyperswitchConfiguration {
|
|
39
|
+
#if canImport(HyperOTA)
|
|
40
|
+
OTAServices.shared.initialize(publishableKey: hyperswitchConfiguration.publishableKey)
|
|
41
|
+
LogManager.initialize(publishableKey: hyperswitchConfiguration.publishableKey)
|
|
42
|
+
#endif
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public func updateIntent(
|
|
47
|
+
authorizationProvider: @escaping (@escaping (String) -> Void) -> Void,
|
|
48
|
+
completion: @escaping (UpdateIntentResult) -> Void
|
|
49
|
+
) {
|
|
50
|
+
// updateIntentInitReturned
|
|
51
|
+
// .first()
|
|
52
|
+
// .receive(on: DispatchQueue.main)
|
|
53
|
+
// .sink { [weak self] _ in
|
|
54
|
+
// guard let self = self else { return }
|
|
55
|
+
// authorizationProvider { [weak self] sdkAuthorization in
|
|
56
|
+
// guard let self = self else { return }
|
|
57
|
+
// self.updateIntentCompleteReturned
|
|
58
|
+
// .first()
|
|
59
|
+
// .receive(on: DispatchQueue.main)
|
|
60
|
+
// .sink { result in
|
|
61
|
+
// completion(self.parseUpdateIntentResult(result))
|
|
62
|
+
// }
|
|
63
|
+
// .store(in: &self.cancellables)
|
|
64
|
+
// self.sdkAuthorization = sdkAuthorization
|
|
65
|
+
// self.updateIntentDidComplete.send(sdkAuthorization)
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
// .store(in: &cancellables)
|
|
69
|
+
// updateIntentDidStart.send(())
|
|
70
|
+
|
|
71
|
+
// MARK: workaround
|
|
72
|
+
authorizationProvider { [weak self] sdkAuthorization in
|
|
73
|
+
self?.paymentSessionConfiguration = PaymentSessionConfiguration(sdkAuthorization: sdkAuthorization)
|
|
74
|
+
completion(UpdateIntentResult.success)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private func parseUpdateIntentResult(_ data: String) -> UpdateIntentResult {
|
|
79
|
+
guard
|
|
80
|
+
let bytes = data.data(using: .utf8),
|
|
81
|
+
let json = (try? JSONSerialization.jsonObject(with: bytes)) as? [String: String]
|
|
82
|
+
else {
|
|
83
|
+
return .failure(
|
|
84
|
+
NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: [NSLocalizedDescriptionKey: "Invalid update intent result"])
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
switch json["status"] {
|
|
88
|
+
case "cancelled":
|
|
89
|
+
return .cancelled
|
|
90
|
+
case "failed", "error":
|
|
91
|
+
let code = json["code"].flatMap { $0.isEmpty ? nil : $0 } ?? "UNKNOWN_ERROR"
|
|
92
|
+
let message = json["message"].flatMap { $0.isEmpty ? nil : $0 } ?? (json["status"] ?? "failed")
|
|
93
|
+
return .failure(NSError(domain: code, code: 0, userInfo: [NSLocalizedDescriptionKey: message]))
|
|
94
|
+
default:
|
|
95
|
+
return .success
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSessionConfiguration.swift
|
|
3
|
+
// HyperswitchCore
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 17/05/26.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
public struct PaymentSessionConfiguration: Codable {
|
|
9
|
+
public let sdkAuthorization: String
|
|
10
|
+
|
|
11
|
+
public init(sdkAuthorization: String) {
|
|
12
|
+
self.sdkAuthorization = sdkAuthorization
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSheet.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Balaganesh on 09/12/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
/// PaymentSheet is a class that handles the presentation and management of a payment sheet interface.
|
|
11
|
+
public class PaymentSheet {
|
|
12
|
+
|
|
13
|
+
/// The initializer method that sets up the payment sheet with the required parameters.
|
|
14
|
+
internal required init(
|
|
15
|
+
paymentSessionConfiguration: PaymentSessionConfiguration,
|
|
16
|
+
hyperswitchConfiguration: HyperswitchConfiguration? = nil,
|
|
17
|
+
configuration: Configuration? = nil
|
|
18
|
+
) {
|
|
19
|
+
self.paymentSessionConfiguration = paymentSessionConfiguration
|
|
20
|
+
self.hyperswitchConfiguration = hyperswitchConfiguration
|
|
21
|
+
self.configuration = configuration
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
internal let paymentSessionConfiguration: PaymentSessionConfiguration
|
|
25
|
+
internal var hyperswitchConfiguration: HyperswitchConfiguration?
|
|
26
|
+
|
|
27
|
+
/// The configuration object that holds the settings for the payment sheet.
|
|
28
|
+
internal let configuration: Configuration?
|
|
29
|
+
internal var completion: ((PaymentResult) -> Void)?
|
|
30
|
+
internal var subscribedEvents: [String]?
|
|
31
|
+
internal var paymentEventListener: PaymentEventListener?
|
|
32
|
+
internal var shouldProceedWithPaymentCallback: ((PaymentRequestData, @escaping (Bool) -> Void) -> Void)?
|
|
33
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSheetAppearance+Codable.swift
|
|
3
|
+
// hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 09/10/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// MARK: - Codable Conformance
|
|
9
|
+
import UIKit
|
|
10
|
+
|
|
11
|
+
extension PaymentSheet.Appearance.Colors: Codable {
|
|
12
|
+
enum CodingKeys: String, CodingKey {
|
|
13
|
+
case primary, background, componentBackground, componentBorder
|
|
14
|
+
case componentDivider, text, textSecondary, componentText
|
|
15
|
+
case componentPlaceholderText, icon, danger
|
|
16
|
+
case loaderBackground, loaderForeground
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public func encode(to encoder: Encoder) throws {
|
|
20
|
+
var c = encoder.container(keyedBy: CodingKeys.self)
|
|
21
|
+
try c.encodeIfPresent(primary.map { CodableColor($0) }, forKey: .primary)
|
|
22
|
+
try c.encodeIfPresent(background.map { CodableColor($0) }, forKey: .background)
|
|
23
|
+
try c.encodeIfPresent(componentBackground.map { CodableColor($0) }, forKey: .componentBackground)
|
|
24
|
+
try c.encodeIfPresent(componentBorder.map { CodableColor($0) }, forKey: .componentBorder)
|
|
25
|
+
try c.encodeIfPresent(componentDivider.map { CodableColor($0) }, forKey: .componentDivider)
|
|
26
|
+
try c.encodeIfPresent(text.map { CodableColor($0) }, forKey: .text)
|
|
27
|
+
try c.encodeIfPresent(textSecondary.map { CodableColor($0) }, forKey: .textSecondary)
|
|
28
|
+
try c.encodeIfPresent(componentText.map { CodableColor($0) }, forKey: .componentText)
|
|
29
|
+
try c.encodeIfPresent(componentPlaceholderText.map { CodableColor($0) }, forKey: .componentPlaceholderText)
|
|
30
|
+
try c.encodeIfPresent(icon.map { CodableColor($0) }, forKey: .icon)
|
|
31
|
+
try c.encodeIfPresent(danger.map { CodableColor($0) }, forKey: .danger)
|
|
32
|
+
try c.encodeIfPresent(loaderBackground.map { CodableColor($0) }, forKey: .loaderBackground)
|
|
33
|
+
try c.encodeIfPresent(loaderForeground.map { CodableColor($0) }, forKey: .loaderForeground)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public init(from decoder: Decoder) throws {
|
|
37
|
+
self.init()
|
|
38
|
+
let c = try decoder.container(keyedBy: CodingKeys.self)
|
|
39
|
+
primary = try c.decodeIfPresent(CodableColor.self, forKey: .primary)?.uiColor
|
|
40
|
+
background = try c.decodeIfPresent(CodableColor.self, forKey: .background)?.uiColor
|
|
41
|
+
componentBackground = try c.decodeIfPresent(CodableColor.self, forKey: .componentBackground)?.uiColor
|
|
42
|
+
componentBorder = try c.decodeIfPresent(CodableColor.self, forKey: .componentBorder)?.uiColor
|
|
43
|
+
componentDivider = try c.decodeIfPresent(CodableColor.self, forKey: .componentDivider)?.uiColor
|
|
44
|
+
text = try c.decodeIfPresent(CodableColor.self, forKey: .text)?.uiColor
|
|
45
|
+
textSecondary = try c.decodeIfPresent(CodableColor.self, forKey: .textSecondary)?.uiColor
|
|
46
|
+
componentText = try c.decodeIfPresent(CodableColor.self, forKey: .componentText)?.uiColor
|
|
47
|
+
componentPlaceholderText = try c.decodeIfPresent(CodableColor.self, forKey: .componentPlaceholderText)?.uiColor
|
|
48
|
+
icon = try c.decodeIfPresent(CodableColor.self, forKey: .icon)?.uiColor
|
|
49
|
+
danger = try c.decodeIfPresent(CodableColor.self, forKey: .danger)?.uiColor
|
|
50
|
+
loaderBackground = try c.decodeIfPresent(CodableColor.self, forKey: .loaderBackground)?.uiColor
|
|
51
|
+
loaderForeground = try c.decodeIfPresent(CodableColor.self, forKey: .loaderForeground)?.uiColor
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
extension PaymentSheet.Appearance.Font: Codable {
|
|
56
|
+
enum CodingKeys: String, CodingKey {
|
|
57
|
+
case sizeScaleFactor, base, headingTextSizeAdjust, subHeadingTextSizeAdjust
|
|
58
|
+
case placeholderTextSizeAdjust, buttonTextSizeAdjust, errorTextSizeAdjust
|
|
59
|
+
case linkTextSizeAdjust, modalTextSizeAdjust, cardTextSizeAdjust, family
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public func encode(to encoder: Encoder) throws {
|
|
63
|
+
var c = encoder.container(keyedBy: CodingKeys.self)
|
|
64
|
+
try c.encodeIfPresent(sizeScaleFactor, forKey: .sizeScaleFactor)
|
|
65
|
+
try c.encodeIfPresent(base.map { CodableFont($0) }, forKey: .base)
|
|
66
|
+
try c.encodeIfPresent(headingTextSizeAdjust, forKey: .headingTextSizeAdjust)
|
|
67
|
+
try c.encodeIfPresent(subHeadingTextSizeAdjust, forKey: .subHeadingTextSizeAdjust)
|
|
68
|
+
try c.encodeIfPresent(placeholderTextSizeAdjust, forKey: .placeholderTextSizeAdjust)
|
|
69
|
+
try c.encodeIfPresent(buttonTextSizeAdjust, forKey: .buttonTextSizeAdjust)
|
|
70
|
+
try c.encodeIfPresent(errorTextSizeAdjust, forKey: .errorTextSizeAdjust)
|
|
71
|
+
try c.encodeIfPresent(linkTextSizeAdjust, forKey: .linkTextSizeAdjust)
|
|
72
|
+
try c.encodeIfPresent(modalTextSizeAdjust, forKey: .modalTextSizeAdjust)
|
|
73
|
+
try c.encodeIfPresent(cardTextSizeAdjust, forKey: .cardTextSizeAdjust)
|
|
74
|
+
try c.encodeIfPresent(family, forKey: .family)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public init(from decoder: Decoder) throws {
|
|
78
|
+
self.init()
|
|
79
|
+
let c = try decoder.container(keyedBy: CodingKeys.self)
|
|
80
|
+
sizeScaleFactor = try c.decodeIfPresent(CGFloat.self, forKey: .sizeScaleFactor)
|
|
81
|
+
base = try c.decodeIfPresent(CodableFont.self, forKey: .base)?.uiFont
|
|
82
|
+
headingTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .headingTextSizeAdjust)
|
|
83
|
+
subHeadingTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .subHeadingTextSizeAdjust)
|
|
84
|
+
placeholderTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .placeholderTextSizeAdjust)
|
|
85
|
+
buttonTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .buttonTextSizeAdjust)
|
|
86
|
+
errorTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .errorTextSizeAdjust)
|
|
87
|
+
linkTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .linkTextSizeAdjust)
|
|
88
|
+
modalTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .modalTextSizeAdjust)
|
|
89
|
+
cardTextSizeAdjust = try c.decodeIfPresent(CGFloat.self, forKey: .cardTextSizeAdjust)
|
|
90
|
+
family = try c.decodeIfPresent(String.self, forKey: .family)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
extension PaymentSheet.Appearance.PrimaryButton: Codable {
|
|
95
|
+
enum CodingKeys: String, CodingKey {
|
|
96
|
+
case backgroundColor, textColor, successBackgroundColor, successTextColor
|
|
97
|
+
case cornerRadius, borderColor, borderWidth, font, shadow, height
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public func encode(to encoder: Encoder) throws {
|
|
101
|
+
var c = encoder.container(keyedBy: CodingKeys.self)
|
|
102
|
+
try c.encodeIfPresent(backgroundColor.map { CodableColor($0) }, forKey: .backgroundColor)
|
|
103
|
+
try c.encodeIfPresent(textColor.map { CodableColor($0) }, forKey: .textColor)
|
|
104
|
+
try c.encodeIfPresent(successBackgroundColor.map { CodableColor($0) }, forKey: .successBackgroundColor)
|
|
105
|
+
try c.encodeIfPresent(successTextColor.map { CodableColor($0) }, forKey: .successTextColor)
|
|
106
|
+
try c.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
|
107
|
+
try c.encodeIfPresent(borderColor.map { CodableColor($0) }, forKey: .borderColor)
|
|
108
|
+
try c.encodeIfPresent(borderWidth, forKey: .borderWidth)
|
|
109
|
+
try c.encodeIfPresent(font.map { CodableFont($0) }, forKey: .font)
|
|
110
|
+
try c.encodeIfPresent(shadow, forKey: .shadow)
|
|
111
|
+
try c.encodeIfPresent(height, forKey: .height)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public init(from decoder: Decoder) throws {
|
|
115
|
+
self.init()
|
|
116
|
+
let c = try decoder.container(keyedBy: CodingKeys.self)
|
|
117
|
+
backgroundColor = try c.decodeIfPresent(CodableColor.self, forKey: .backgroundColor)?.uiColor
|
|
118
|
+
textColor = try c.decodeIfPresent(CodableColor.self, forKey: .textColor)?.uiColor
|
|
119
|
+
successBackgroundColor = try c.decodeIfPresent(CodableColor.self, forKey: .successBackgroundColor)?.uiColor
|
|
120
|
+
successTextColor = try c.decodeIfPresent(CodableColor.self, forKey: .successTextColor)?.uiColor
|
|
121
|
+
cornerRadius = try c.decodeIfPresent(CGFloat.self, forKey: .cornerRadius)
|
|
122
|
+
borderColor = try c.decodeIfPresent(CodableColor.self, forKey: .borderColor)?.uiColor
|
|
123
|
+
borderWidth = try c.decodeIfPresent(CGFloat.self, forKey: .borderWidth)
|
|
124
|
+
font = try c.decodeIfPresent(CodableFont.self, forKey: .font)?.uiFont
|
|
125
|
+
shadow = try c.decodeIfPresent(PaymentSheet.Appearance.Shadow.self, forKey: .shadow)
|
|
126
|
+
height = try c.decodeIfPresent(CGFloat.self, forKey: .height)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
extension PaymentSheet.Appearance.Shadow: Codable {
|
|
131
|
+
enum CodingKeys: String, CodingKey {
|
|
132
|
+
case color, opacity, offset, radius, intensity
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public func encode(to encoder: Encoder) throws {
|
|
136
|
+
var c = encoder.container(keyedBy: CodingKeys.self)
|
|
137
|
+
try c.encodeIfPresent(color.map { CodableColor($0) }, forKey: .color)
|
|
138
|
+
try c.encodeIfPresent(opacity, forKey: .opacity)
|
|
139
|
+
try c.encodeIfPresent(offset, forKey: .offset)
|
|
140
|
+
try c.encodeIfPresent(radius, forKey: .radius)
|
|
141
|
+
try c.encodeIfPresent(intensity, forKey: .intensity)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public init(from decoder: Decoder) throws {
|
|
145
|
+
self.init()
|
|
146
|
+
let c = try decoder.container(keyedBy: CodingKeys.self)
|
|
147
|
+
color = try c.decodeIfPresent(CodableColor.self, forKey: .color)?.uiColor
|
|
148
|
+
opacity = try c.decodeIfPresent(CGFloat.self, forKey: .opacity)
|
|
149
|
+
offset = try c.decodeIfPresent(CGSize.self, forKey: .offset)
|
|
150
|
+
radius = try c.decodeIfPresent(CGFloat.self, forKey: .radius)
|
|
151
|
+
intensity = try c.decodeIfPresent(CGFloat.self, forKey: .intensity)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
extension PaymentSheet.Appearance: Codable {
|
|
156
|
+
enum CodingKeys: String, CodingKey {
|
|
157
|
+
case font, colors, primaryButton, cornerRadius, borderWidth, shadow, theme
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public func encode(to encoder: Encoder) throws {
|
|
161
|
+
var c = encoder.container(keyedBy: CodingKeys.self)
|
|
162
|
+
try c.encodeIfPresent(font, forKey: .font)
|
|
163
|
+
try c.encodeIfPresent(colors, forKey: .colors)
|
|
164
|
+
try c.encodeIfPresent(primaryButton, forKey: .primaryButton)
|
|
165
|
+
try c.encodeIfPresent(cornerRadius, forKey: .cornerRadius)
|
|
166
|
+
try c.encodeIfPresent(borderWidth, forKey: .borderWidth)
|
|
167
|
+
try c.encodeIfPresent(shadow, forKey: .shadow)
|
|
168
|
+
try c.encodeIfPresent(theme, forKey: .theme)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public init(from decoder: Decoder) throws {
|
|
172
|
+
self.init()
|
|
173
|
+
let c = try decoder.container(keyedBy: CodingKeys.self)
|
|
174
|
+
font = try c.decodeIfPresent(PaymentSheet.Appearance.Font.self, forKey: .font) ?? Font()
|
|
175
|
+
colors = try c.decodeIfPresent(PaymentSheet.Appearance.Colors.self, forKey: .colors) ?? Colors()
|
|
176
|
+
primaryButton = try c.decodeIfPresent(PaymentSheet.Appearance.PrimaryButton.self, forKey: .primaryButton) ?? PrimaryButton()
|
|
177
|
+
cornerRadius = try c.decodeIfPresent(CGFloat.self, forKey: .cornerRadius)
|
|
178
|
+
borderWidth = try c.decodeIfPresent(CGFloat.self, forKey: .borderWidth)
|
|
179
|
+
shadow = try c.decodeIfPresent(PaymentSheet.Appearance.Shadow.self, forKey: .shadow)
|
|
180
|
+
theme = try c.decodeIfPresent(PaymentSheet.Appearance.Theme.self, forKey: .theme)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentSheetApperance.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 09/11/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
|
|
10
|
+
public extension PaymentSheet {
|
|
11
|
+
|
|
12
|
+
/// Describes the appearance of PaymentSheet
|
|
13
|
+
struct Appearance {
|
|
14
|
+
|
|
15
|
+
/// Creates a `PaymentSheet.Appearance` with default values
|
|
16
|
+
public init() {}
|
|
17
|
+
|
|
18
|
+
/// Describes the appearance of fonts in PaymentSheet
|
|
19
|
+
public var font: Font = Font()
|
|
20
|
+
|
|
21
|
+
/// Describes the colors in PaymentSheet
|
|
22
|
+
public var colors: Colors = Colors()
|
|
23
|
+
|
|
24
|
+
/// Describes the appearance of the primary button (e.g., the "Pay" button)
|
|
25
|
+
public var primaryButton: PrimaryButton = PrimaryButton()
|
|
26
|
+
|
|
27
|
+
/// The corner radius used for buttons, inputs, tabs in PaymentSheet
|
|
28
|
+
/// - Note: The behavior of this property is consistent with the behavior of corner radius on `CALayer`
|
|
29
|
+
public var cornerRadius: CGFloat?
|
|
30
|
+
|
|
31
|
+
/// The border used for inputs and tabs in PaymentSheet
|
|
32
|
+
/// - Note: The behavior of this property is consistent with the behavior of border width on `CALayer`
|
|
33
|
+
public var borderWidth: CGFloat?
|
|
34
|
+
|
|
35
|
+
/// The shadow used for inputs and tabs in PaymentSheet
|
|
36
|
+
/// - Note: Set this to `.disabled` to disable shadows
|
|
37
|
+
public var shadow: Shadow?
|
|
38
|
+
|
|
39
|
+
public var theme: Theme?
|
|
40
|
+
|
|
41
|
+
public enum Theme: String, Codable {
|
|
42
|
+
case `default` = "Default"
|
|
43
|
+
case light = "Light"
|
|
44
|
+
case dark = "Dark"
|
|
45
|
+
case minimal = "Minimal"
|
|
46
|
+
case flatMinimal = "FlatMinimal"
|
|
47
|
+
|
|
48
|
+
var themeLabel: String {
|
|
49
|
+
return self.rawValue
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: Fonts
|
|
54
|
+
|
|
55
|
+
/// Describes the appearance of fonts in PaymentSheet
|
|
56
|
+
public struct Font {
|
|
57
|
+
|
|
58
|
+
/// Creates a `PaymentSheet.Appearance.Font` with default values
|
|
59
|
+
public init() {}
|
|
60
|
+
|
|
61
|
+
/// The scale factor for all font sizes in PaymentSheet.
|
|
62
|
+
/// Font sizes are multiplied by this value before being displayed. For example, setting this to 1.2 increases the size of all text by 20%.
|
|
63
|
+
/// - Note: This value must be greater than 0. The default value is 1.0.
|
|
64
|
+
/// - Note: This is used in conjunction with the Dynamic Type accessibility text size.
|
|
65
|
+
public var sizeScaleFactor: CGFloat?
|
|
66
|
+
|
|
67
|
+
/// The font family of this font is used throughout PaymentSheet. PaymentSheet uses this font at multiple weights (e.g., regular, medium, semibold) if they exist.
|
|
68
|
+
/// - Note: The size and weight of the font is ignored. To adjust font sizes, see `sizeScaleFactor`.
|
|
69
|
+
public var base: UIFont?
|
|
70
|
+
|
|
71
|
+
/// The size adjustment for all heading texts in PaymentSheet
|
|
72
|
+
/// Font sizes of all headings will be increased by this value from their respective default size
|
|
73
|
+
public var headingTextSizeAdjust: CGFloat?
|
|
74
|
+
|
|
75
|
+
/// The size for all sub heading texts in PaymentSheet
|
|
76
|
+
/// Font sizes of all sub headings will be increased by this value from their respective default size
|
|
77
|
+
public var subHeadingTextSizeAdjust: CGFloat?
|
|
78
|
+
|
|
79
|
+
/// The size for all placeholder texts in PaymentSheet
|
|
80
|
+
/// Font sizes of all placeholder texts will be increased by this value from their respective default size
|
|
81
|
+
public var placeholderTextSizeAdjust: CGFloat?
|
|
82
|
+
|
|
83
|
+
/// The size for all button texts in PaymentSheet
|
|
84
|
+
/// Font sizes of all button texts will be increased by this value from their respective default size
|
|
85
|
+
public var buttonTextSizeAdjust: CGFloat?
|
|
86
|
+
|
|
87
|
+
/// The size for all error texts in PaymentSheet
|
|
88
|
+
/// Font sizes of all error texts will be increased by this value from their respective default size
|
|
89
|
+
public var errorTextSizeAdjust: CGFloat?
|
|
90
|
+
|
|
91
|
+
/// The size for all link texts in PaymentSheet
|
|
92
|
+
/// Font sizes of all link texts will be increased by this value from their respective default size
|
|
93
|
+
public var linkTextSizeAdjust: CGFloat?
|
|
94
|
+
|
|
95
|
+
/// The size for all modal texts in PaymentSheet
|
|
96
|
+
/// Font sizes of all modal texts will be increased by this value from their respective default size
|
|
97
|
+
public var modalTextSizeAdjust: CGFloat?
|
|
98
|
+
|
|
99
|
+
/// The size for all card texts in PaymentSheet
|
|
100
|
+
/// Font sizes of all card texts will be increased by this value from their respective default size
|
|
101
|
+
public var cardTextSizeAdjust: CGFloat?
|
|
102
|
+
|
|
103
|
+
/// the font Attributes for PaymentSheetLite
|
|
104
|
+
public var family: String?
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// MARK: Colors
|
|
108
|
+
|
|
109
|
+
/// Describes the colors in PaymentSheet
|
|
110
|
+
public struct Colors {
|
|
111
|
+
|
|
112
|
+
/// Creates a `PaymentSheet.Appearance.Colors` with default values
|
|
113
|
+
public init() {}
|
|
114
|
+
|
|
115
|
+
/// The primary color used throughout PaymentSheet
|
|
116
|
+
public var primary: UIColor?
|
|
117
|
+
|
|
118
|
+
/// The color used for the background of PaymentSheet
|
|
119
|
+
public var background: UIColor?
|
|
120
|
+
|
|
121
|
+
/// The color used for the background of inputs, tabs, and other components
|
|
122
|
+
public var componentBackground: UIColor?
|
|
123
|
+
|
|
124
|
+
/// The border color used for inputs, tabs, and other components
|
|
125
|
+
public var componentBorder: UIColor?
|
|
126
|
+
|
|
127
|
+
/// The color of the divider lines used inside inputs, tabs, and other components
|
|
128
|
+
public var componentDivider: UIColor?
|
|
129
|
+
|
|
130
|
+
/// The default text color used in PaymentSheet, appearing over the background color
|
|
131
|
+
public var text: UIColor?
|
|
132
|
+
|
|
133
|
+
/// The color used for text of secondary importance. For example, this color is used for the label above input fields
|
|
134
|
+
public var textSecondary: UIColor?
|
|
135
|
+
|
|
136
|
+
/// The color of text appearing over `componentBackground`
|
|
137
|
+
public var componentText: UIColor?
|
|
138
|
+
|
|
139
|
+
/// The color used for input placeholder text
|
|
140
|
+
public var componentPlaceholderText: UIColor?
|
|
141
|
+
|
|
142
|
+
/// The color used for icons in PaymentSheet, such as the close or back icons
|
|
143
|
+
public var icon: UIColor?
|
|
144
|
+
|
|
145
|
+
/// The color used to indicate errors or destructive actions in PaymentSheet
|
|
146
|
+
public var danger: UIColor?
|
|
147
|
+
|
|
148
|
+
/// The color used to indicate Loader Background Color
|
|
149
|
+
public var loaderBackground: UIColor?
|
|
150
|
+
|
|
151
|
+
/// The color used to indicate Loader Foreground Color
|
|
152
|
+
public var loaderForeground: UIColor?
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// MARK: Shadow
|
|
156
|
+
|
|
157
|
+
/// Represents a shadow in PaymentSheet
|
|
158
|
+
public struct Shadow {
|
|
159
|
+
|
|
160
|
+
/// Creates a `PaymentSheet.Appearance.Shadow` with default values
|
|
161
|
+
public init() {}
|
|
162
|
+
|
|
163
|
+
/// A pre-configured `Shadow` in the disabled or off state
|
|
164
|
+
public static var disabled: Shadow?
|
|
165
|
+
|
|
166
|
+
/// Color of the shadow
|
|
167
|
+
/// - Note: The behavior of this property is consistent with `CALayer.shadowColor`
|
|
168
|
+
public var color: UIColor?
|
|
169
|
+
|
|
170
|
+
/// Opacity or alpha of the shadow
|
|
171
|
+
/// - Note: The behavior of this property is consistent with `CALayer.shadowOpacity`
|
|
172
|
+
public var opacity: CGFloat?
|
|
173
|
+
|
|
174
|
+
/// Offset of the shadow
|
|
175
|
+
/// - Note: The behavior of this property is consistent with `CALayer.shadowOffset`
|
|
176
|
+
public var offset: CGSize?
|
|
177
|
+
|
|
178
|
+
/// Radius of the shadow
|
|
179
|
+
/// - Note: The behavior of this property is consistent with `CALayer.shadowRadius`
|
|
180
|
+
public var radius: CGFloat?
|
|
181
|
+
|
|
182
|
+
/// intensity of the shadow
|
|
183
|
+
/// - Note: The behavior of this property is consistent with `CALayer.shadowIntensity`
|
|
184
|
+
public var intensity: CGFloat?
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// MARK: Primary Button
|
|
188
|
+
|
|
189
|
+
/// Describes the appearance of the primary button (e.g., the "Pay" button)
|
|
190
|
+
public struct PrimaryButton {
|
|
191
|
+
|
|
192
|
+
/// Creates a `PaymentSheet.Appearance.PrimaryButton` with default values
|
|
193
|
+
public init() {}
|
|
194
|
+
|
|
195
|
+
/// The background color of the primary button
|
|
196
|
+
/// - Note: If `nil`, `appearance.colors.primary` will be used as the primary button background color
|
|
197
|
+
public var backgroundColor: UIColor?
|
|
198
|
+
|
|
199
|
+
/// The text color of the primary button
|
|
200
|
+
/// - Note: If `nil`, defaults to either white or black depending on the color of the button
|
|
201
|
+
public var textColor: UIColor?
|
|
202
|
+
|
|
203
|
+
/// The background color of the primary button when in a success state.
|
|
204
|
+
/// - Note: Only applies to PaymentSheet. The primary button transitions to the success state when payment succeeds.
|
|
205
|
+
public var successBackgroundColor: UIColor?
|
|
206
|
+
|
|
207
|
+
/// The text color of the primary button when in a success state.
|
|
208
|
+
/// - Note: Only applies to PaymentSheet. The primary button transitions to the success state when payment succeeds.
|
|
209
|
+
/// - Note: If `nil`, defaults to `textColor`
|
|
210
|
+
public var successTextColor: UIColor?
|
|
211
|
+
|
|
212
|
+
/// The corner radius of the primary button
|
|
213
|
+
/// - Note: If `nil`, `appearance.cornerRadius` will be used as the primary button corner radius
|
|
214
|
+
/// - Note: The behavior of this property is consistent with the behavior of corner radius on `CALayer`
|
|
215
|
+
public var cornerRadius: CGFloat?
|
|
216
|
+
|
|
217
|
+
/// The border color of the primary button
|
|
218
|
+
/// - Note: The behavior of this property is consistent with the behavior of border color on `CALayer`
|
|
219
|
+
public var borderColor: UIColor?
|
|
220
|
+
|
|
221
|
+
/// The border width of the primary button
|
|
222
|
+
/// - Note: The behavior of this property is consistent with the behavior of border width on `CALayer`
|
|
223
|
+
public var borderWidth: CGFloat?
|
|
224
|
+
|
|
225
|
+
/// The font used for the text of the primary button
|
|
226
|
+
/// - Note: If `nil`, `appearance.font.base` will be used as the primary button font
|
|
227
|
+
/// - Note: `appearance.font.sizeScaleFactor` does not impact the size of this font
|
|
228
|
+
public var font: UIFont?
|
|
229
|
+
|
|
230
|
+
/// The shadow of the primary button
|
|
231
|
+
/// - Note: If `nil`, `appearance.shadow` will be used as the primary button shadow
|
|
232
|
+
public var shadow: Shadow?
|
|
233
|
+
|
|
234
|
+
/// The height of the primary button in points
|
|
235
|
+
public var height: CGFloat?
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|