diff --git a/Examples/TossPayments.xcodeproj/project.pbxproj b/Examples/TossPayments.xcodeproj/project.pbxproj index 7534279..968459c 100644 --- a/Examples/TossPayments.xcodeproj/project.pbxproj +++ b/Examples/TossPayments.xcodeproj/project.pbxproj @@ -7,6 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 6A497D792B2C11B0004E5107 /* WidgetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A497D782B2C11B0004E5107 /* WidgetViewController.m */; }; + 6A497D7D2B2C11F9004E5107 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A497D7C2B2C11F9004E5107 /* BaseViewController.m */; }; + 6A497D812B2C1B16004E5107 /* DefaultWidgetPaymentInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A497D802B2C1B16004E5107 /* DefaultWidgetPaymentInfo.m */; }; + 6A637DAA2B2AA84C0058C7FC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A637DA92B2AA84C0058C7FC /* AppDelegate.m */; }; + 6A637DAD2B2AA84C0058C7FC /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A637DAC2B2AA84C0058C7FC /* SceneDelegate.m */; }; + 6A637DB02B2AA84C0058C7FC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A637DAF2B2AA84C0058C7FC /* ViewController.m */; }; + 6A637DB32B2AA84C0058C7FC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6A637DB12B2AA84C0058C7FC /* Main.storyboard */; }; + 6A637DB52B2AA84D0058C7FC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A637DB42B2AA84D0058C7FC /* Assets.xcassets */; }; + 6A637DB82B2AA84D0058C7FC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6A637DB62B2AA84D0058C7FC /* LaunchScreen.storyboard */; }; + 6A637DBB2B2AA84D0058C7FC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A637DBA2B2AA84D0058C7FC /* main.m */; }; 6A8EE10A2A7CA79600A9DD94 /* SwiftUI_ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8EE1092A7CA79600A9DD94 /* SwiftUI_ExampleApp.swift */; }; 6A8EE10C2A7CA79600A9DD94 /* TossPaymentsContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A8EE10B2A7CA79600A9DD94 /* TossPaymentsContentView.swift */; }; 6A8EE10E2A7CA79700A9DD94 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A8EE10D2A7CA79700A9DD94 /* Assets.xcassets */; }; @@ -95,6 +105,7 @@ 6AB1E3872A7799FC00D49332 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AB1E3792A7799FC00D49332 /* TextField.swift */; }; 6AB1E3882A7799FC00D49332 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AB1E37A2A7799FC00D49332 /* Button.swift */; }; 6ACD03AC2A778F9B00B6DAD1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6ACD03AB2A778F9B00B6DAD1 /* AppDelegate.swift */; }; + 6ADA37482B2AC99E005E688D /* TossPayments.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ACD03062A778F0A00B6DAD1 /* TossPayments.framework */; }; 6AFE43212AC12A05002CAE67 /* ChangePaymentMethodMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AFE43202AC12A05002CAE67 /* ChangePaymentMethodMessage.swift */; }; /* End PBXBuildFile section */ @@ -120,6 +131,13 @@ remoteGlobalIDString = 6ACD03052A778F0A00B6DAD1; remoteInfo = TossPayments; }; + 6ADA37462B2AC98B005E688D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E719D065FEA419CD729FCD6A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 6ACD03052A778F0A00B6DAD1; + remoteInfo = TossPayments; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -148,6 +166,24 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 6A497D782B2C11B0004E5107 /* WidgetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WidgetViewController.m; sourceTree = ""; }; + 6A497D7A2B2C11BD004E5107 /* WidgetViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WidgetViewController.h; sourceTree = ""; }; + 6A497D7C2B2C11F9004E5107 /* BaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseViewController.m; sourceTree = ""; }; + 6A497D7E2B2C120F004E5107 /* BaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = ""; }; + 6A497D7F2B2C1AFA004E5107 /* DefaultWidgetPaymentInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DefaultWidgetPaymentInfo.h; sourceTree = ""; }; + 6A497D802B2C1B16004E5107 /* DefaultWidgetPaymentInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DefaultWidgetPaymentInfo.m; sourceTree = ""; }; + 6A637DA62B2AA84C0058C7FC /* UIKit-Objc-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "UIKit-Objc-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6A637DA82B2AA84C0058C7FC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 6A637DA92B2AA84C0058C7FC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 6A637DAB2B2AA84C0058C7FC /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + 6A637DAC2B2AA84C0058C7FC /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; + 6A637DAE2B2AA84C0058C7FC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 6A637DAF2B2AA84C0058C7FC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 6A637DB22B2AA84C0058C7FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6A637DB42B2AA84D0058C7FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6A637DB72B2AA84D0058C7FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 6A637DB92B2AA84D0058C7FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6A637DBA2B2AA84D0058C7FC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 6A8EE1072A7CA79600A9DD94 /* SwiftUI-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUI-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 6A8EE1092A7CA79600A9DD94 /* SwiftUI_ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUI_ExampleApp.swift; sourceTree = ""; }; 6A8EE10B2A7CA79600A9DD94 /* TossPaymentsContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TossPaymentsContentView.swift; sourceTree = ""; }; @@ -241,6 +277,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 6A637DA32B2AA84C0058C7FC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6ADA37482B2AC99E005E688D /* TossPayments.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 6A8EE1042A7CA79600A9DD94 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -273,10 +317,51 @@ 6ACD03062A778F0A00B6DAD1 /* TossPayments.framework */, 6ACD03A92A778F9A00B6DAD1 /* UIKit-Example.app */, 6A8EE1072A7CA79600A9DD94 /* SwiftUI-Example.app */, + 6A637DA62B2AA84C0058C7FC /* UIKit-Objc-Example.app */, ); name = Products; sourceTree = ""; }; + 6A497D772B2C1182004E5107 /* Widget */ = { + isa = PBXGroup; + children = ( + 6A497D782B2C11B0004E5107 /* WidgetViewController.m */, + 6A497D7A2B2C11BD004E5107 /* WidgetViewController.h */, + 6A497D7F2B2C1AFA004E5107 /* DefaultWidgetPaymentInfo.h */, + 6A497D802B2C1B16004E5107 /* DefaultWidgetPaymentInfo.m */, + ); + path = Widget; + sourceTree = ""; + }; + 6A497D7B2B2C11EA004E5107 /* Base */ = { + isa = PBXGroup; + children = ( + 6A497D7C2B2C11F9004E5107 /* BaseViewController.m */, + 6A497D7E2B2C120F004E5107 /* BaseViewController.h */, + ); + path = Base; + sourceTree = ""; + }; + 6A637DA72B2AA84C0058C7FC /* UIKit-Objc-Example */ = { + isa = PBXGroup; + children = ( + 6A497D7B2B2C11EA004E5107 /* Base */, + 6A497D772B2C1182004E5107 /* Widget */, + 6A637DA82B2AA84C0058C7FC /* AppDelegate.h */, + 6A637DA92B2AA84C0058C7FC /* AppDelegate.m */, + 6A637DAB2B2AA84C0058C7FC /* SceneDelegate.h */, + 6A637DAC2B2AA84C0058C7FC /* SceneDelegate.m */, + 6A637DAE2B2AA84C0058C7FC /* ViewController.h */, + 6A637DAF2B2AA84C0058C7FC /* ViewController.m */, + 6A637DB12B2AA84C0058C7FC /* Main.storyboard */, + 6A637DB42B2AA84D0058C7FC /* Assets.xcassets */, + 6A637DB62B2AA84D0058C7FC /* LaunchScreen.storyboard */, + 6A637DB92B2AA84D0058C7FC /* Info.plist */, + 6A637DBA2B2AA84D0058C7FC /* main.m */, + ); + path = "UIKit-Objc-Example"; + sourceTree = ""; + }; 6A8EE1082A7CA79600A9DD94 /* SwiftUI-Example */ = { isa = PBXGroup; children = ( @@ -671,6 +756,7 @@ 6AB1E2A62A77976700D49332 /* TossPayments */, 6ACD03AA2A778F9A00B6DAD1 /* UIKit-Example */, 6A8EE1082A7CA79600A9DD94 /* SwiftUI-Example */, + 6A637DA72B2AA84C0058C7FC /* UIKit-Objc-Example */, 87F8BE6CD708A1BD538D9513 /* Frameworks */, 2E84ED8F29EF63DC8EE12764 /* Products */, ); @@ -689,6 +775,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 6A637DA52B2AA84C0058C7FC /* UIKit-Objc-Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6A637DBE2B2AA84D0058C7FC /* Build configuration list for PBXNativeTarget "UIKit-Objc-Example" */; + buildPhases = ( + 6A637DA22B2AA84C0058C7FC /* Sources */, + 6A637DA32B2AA84C0058C7FC /* Frameworks */, + 6A637DA42B2AA84C0058C7FC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 6ADA37472B2AC98B005E688D /* PBXTargetDependency */, + ); + name = "UIKit-Objc-Example"; + productName = "UIKit-Objc-Example"; + productReference = 6A637DA62B2AA84C0058C7FC /* UIKit-Objc-Example.app */; + productType = "com.apple.product-type.application"; + }; 6A8EE1062A7CA79600A9DD94 /* SwiftUI-Example */ = { isa = PBXNativeTarget; buildConfigurationList = 6A8EE1122A7CA79700A9DD94 /* Build configuration list for PBXNativeTarget "SwiftUI-Example" */; @@ -755,6 +859,9 @@ LastSwiftUpdateCheck = 1430; ORGANIZATIONNAME = "TossPayments, Inc"; TargetAttributes = { + 6A637DA52B2AA84C0058C7FC = { + CreatedOnToolsVersion = 15.0; + }; 6A8EE1062A7CA79600A9DD94 = { CreatedOnToolsVersion = 14.3.1; }; @@ -782,11 +889,22 @@ 6ACD03052A778F0A00B6DAD1 /* TossPayments */, 6ACD03A82A778F9A00B6DAD1 /* UIKit-Example */, 6A8EE1062A7CA79600A9DD94 /* SwiftUI-Example */, + 6A637DA52B2AA84C0058C7FC /* UIKit-Objc-Example */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 6A637DA42B2AA84C0058C7FC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6A637DB82B2AA84D0058C7FC /* LaunchScreen.storyboard in Resources */, + 6A637DB52B2AA84D0058C7FC /* Assets.xcassets in Resources */, + 6A637DB32B2AA84C0058C7FC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 6A8EE1052A7CA79600A9DD94 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -816,6 +934,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 6A637DA22B2AA84C0058C7FC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6A637DB02B2AA84C0058C7FC /* ViewController.m in Sources */, + 6A497D7D2B2C11F9004E5107 /* BaseViewController.m in Sources */, + 6A497D792B2C11B0004E5107 /* WidgetViewController.m in Sources */, + 6A637DAA2B2AA84C0058C7FC /* AppDelegate.m in Sources */, + 6A637DBB2B2AA84D0058C7FC /* main.m in Sources */, + 6A637DAD2B2AA84C0058C7FC /* SceneDelegate.m in Sources */, + 6A497D812B2C1B16004E5107 /* DefaultWidgetPaymentInfo.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 6A8EE1032A7CA79600A9DD94 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -935,9 +1067,30 @@ target = 6ACD03052A778F0A00B6DAD1 /* TossPayments */; targetProxy = 6AB1E3332A77990C00D49332 /* PBXContainerItemProxy */; }; + 6ADA37472B2AC98B005E688D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 6ACD03052A778F0A00B6DAD1 /* TossPayments */; + targetProxy = 6ADA37462B2AC98B005E688D /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + 6A637DB12B2AA84C0058C7FC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6A637DB22B2AA84C0058C7FC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 6A637DB62B2AA84D0058C7FC /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6A637DB72B2AA84D0058C7FC /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; 6AB1E3472A77993B00D49332 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -1016,6 +1169,77 @@ }; name = Debug; }; + 6A637DBC2B2AA84D0058C7FC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NXA4356DUW; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "UIKit-Objc-Example/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.tosspayments.UIKit-Objc-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6A637DBD2B2AA84D0058C7FC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = NXA4356DUW; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "UIKit-Objc-Example/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.tosspayments.UIKit-Objc-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 6A8EE1132A7CA79700A9DD94 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1295,6 +1519,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 6A637DBE2B2AA84D0058C7FC /* Build configuration list for PBXNativeTarget "UIKit-Objc-Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6A637DBC2B2AA84D0058C7FC /* Debug */, + 6A637DBD2B2AA84D0058C7FC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 6A8EE1122A7CA79700A9DD94 /* Build configuration list for PBXNativeTarget "SwiftUI-Example" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Examples/TossPayments.xcodeproj/xcshareddata/xcschemes/UIKit-Objc-Example.xcscheme b/Examples/TossPayments.xcodeproj/xcshareddata/xcschemes/UIKit-Objc-Example.xcscheme new file mode 100644 index 0000000..02c810b --- /dev/null +++ b/Examples/TossPayments.xcodeproj/xcshareddata/xcschemes/UIKit-Objc-Example.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/UIKit-Example/AppDelegate.swift b/Examples/UIKit-Example/AppDelegate.swift index 4045ceb..63bf85a 100644 --- a/Examples/UIKit-Example/AppDelegate.swift +++ b/Examples/UIKit-Example/AppDelegate.swift @@ -7,7 +7,6 @@ #if canImport(UIKit) import UIKit -import TossPayments @main class AppDelegate: UIResponder, UIApplicationDelegate { diff --git a/Examples/UIKit-Example/Sources/Environment/Environment.swift b/Examples/UIKit-Example/Sources/Environment/Environment.swift index cd2c094..abe7cc6 100644 --- a/Examples/UIKit-Example/Sources/Environment/Environment.swift +++ b/Examples/UIKit-Example/Sources/Environment/Environment.swift @@ -19,7 +19,7 @@ public final class Environment { } return scheme + "://" }() - static let defaultClientKey = "test_ck_P24xLea5zVA5mxMkelxVQAMYNwW6" + static let defaultClientKey = "test_ck_5GePWvyJnrKdzdyY29b8gLzN97Eo" static let defaultCustomerKey = "TOSSPAYMENTS" static let defaultBrandpayRedirectURL: String = { if let brandPayRedirectURL = Bundle.main.object(forInfoDictionaryKey: "BRANDPAY_REDIRECT_URL") as? String, diff --git a/Examples/UIKit-Example/Sources/Widget/PaymentWidgetViewController.swift b/Examples/UIKit-Example/Sources/Widget/PaymentWidgetViewController.swift index 4743f79..8bc3cd6 100644 --- a/Examples/UIKit-Example/Sources/Widget/PaymentWidgetViewController.swift +++ b/Examples/UIKit-Example/Sources/Widget/PaymentWidgetViewController.swift @@ -153,29 +153,29 @@ extension PaymentWidgetViewController: TossPaymentsDelegate { } extension PaymentWidgetViewController: TossPaymentsWidgetUIDelegate { - public func didReceivedCustomRequest(_ widget: PaymentMethodWidget, paymentMethodKey: String) { + public func didReceivedCustomRequest(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) { Logger.debug("PaymentMethodWidget didReceivedCustomRequest \(paymentMethodKey)") } - public func didReceivedCustomPaymentMethodSelected(_ widget: PaymentMethodWidget, paymentMethodKey: String) { + public func didReceivedCustomPaymentMethodSelected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) { Logger.debug("PaymentMethodWidget didReceivedCustomPaymentMethodSelected \(paymentMethodKey)") } - public func didReceivedCustomPaymentMethodUnselected(_ widget: PaymentMethodWidget, paymentMethodKey: String) { + public func didReceivedCustomPaymentMethodUnselected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) { Logger.debug("PaymentMethodWidget didReceivedCustomPaymentMethodUnselected \(paymentMethodKey)") } - public func didUpdateHeight(_ widget: PaymentMethodWidget, height: CGFloat) { + public func didUpdateHeight(_ methodWidget: PaymentMethodWidget, height: CGFloat) { Logger.debug("PaymentMethodWidget didUpdateHeight \(height)") } } extension PaymentWidgetViewController: TossPaymentsAgreementUIDelegate { - public func didUpdateHeight(_ widget: AgreementWidget, height: CGFloat) { + public func didUpdateAgreementWidgetHeight(_ agreementWidget: AgreementWidget, height: CGFloat) { Logger.debug("AgreementWidget didUpdateHeight \(height)") } - public func didUpdateAgreementStatus(_ widget: AgreementWidget, agreementStatus: AgreementStatus) { + public func didUpdateAgreementStatus(_ agreementWidget: AgreementWidget, agreementStatus: AgreementStatus) { Logger.debug("AgreemenetWidget didUpdateAgreementStatus \(agreementStatus)") button.backgroundColor = agreementStatus.agreedRequiredTerms ? .systemBlue : .systemRed button.isEnabled = agreementStatus.agreedRequiredTerms diff --git a/Examples/UIKit-Objc-Example/AppDelegate.h b/Examples/UIKit-Objc-Example/AppDelegate.h new file mode 100644 index 0000000..cdd2c4b --- /dev/null +++ b/Examples/UIKit-Objc-Example/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/Examples/UIKit-Objc-Example/AppDelegate.m b/Examples/UIKit-Objc-Example/AppDelegate.m new file mode 100644 index 0000000..e1cf5c9 --- /dev/null +++ b/Examples/UIKit-Objc-Example/AppDelegate.m @@ -0,0 +1,41 @@ +// +// AppDelegate.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +#pragma mark - UISceneSession lifecycle + + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. +} + + +@end diff --git a/Examples/UIKit-Objc-Example/Assets.xcassets/AccentColor.colorset/Contents.json b/Examples/UIKit-Objc-Example/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/UIKit-Objc-Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/UIKit-Objc-Example/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/UIKit-Objc-Example/Assets.xcassets/Contents.json b/Examples/UIKit-Objc-Example/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Examples/UIKit-Objc-Example/Base.lproj/LaunchScreen.storyboard b/Examples/UIKit-Objc-Example/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/UIKit-Objc-Example/Base.lproj/Main.storyboard b/Examples/UIKit-Objc-Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..ffb967c --- /dev/null +++ b/Examples/UIKit-Objc-Example/Base.lproj/Main.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/UIKit-Objc-Example/Base/BaseViewController.h b/Examples/UIKit-Objc-Example/Base/BaseViewController.h new file mode 100644 index 0000000..c654792 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Base/BaseViewController.h @@ -0,0 +1,18 @@ +// +// ViewController.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import + +@interface BaseViewController : UIViewController + +@property UIScrollView *scrollView; +@property UIStackView *stackView; +@property NSLayoutConstraint *scrollViewBottomAnchorConstraint; + +@end + diff --git a/Examples/UIKit-Objc-Example/Base/BaseViewController.m b/Examples/UIKit-Objc-Example/Base/BaseViewController.m new file mode 100644 index 0000000..d40adbb --- /dev/null +++ b/Examples/UIKit-Objc-Example/Base/BaseViewController.m @@ -0,0 +1,57 @@ +// +// BaseViewController.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import "BaseViewController.h" + +@interface BaseViewController () + +@end + +@implementation BaseViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; + [scrollView setAlwaysBounceVertical:true]; + [scrollView setKeyboardDismissMode:UIScrollViewKeyboardDismissModeOnDrag]; + + UIStackView *stackView = [[UIStackView alloc] initWithFrame:CGRectZero]; + [stackView setSpacing:24]; + [stackView setAxis:UILayoutConstraintAxisVertical]; + + [self.view addSubview:scrollView]; + [scrollView addSubview:stackView]; + + [scrollView setTranslatesAutoresizingMaskIntoConstraints:false]; + [stackView setTranslatesAutoresizingMaskIntoConstraints:false]; + + NSLayoutConstraint *scrollViewBottomAnchorConstraint = [scrollView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor]; + + [NSLayoutConstraint activateConstraints:@[ + [scrollView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], + [scrollView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor], + [scrollView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor], + [scrollView.widthAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.widthAnchor], + scrollViewBottomAnchorConstraint, + [stackView.topAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.topAnchor], + [stackView.leadingAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.leadingAnchor constant:24], + [stackView.trailingAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.trailingAnchor constant:-24], + [stackView.widthAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.widthAnchor constant:-48], + [stackView.bottomAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.bottomAnchor] + ]]; + + self.scrollView = scrollView; + self.stackView = stackView; + self.scrollViewBottomAnchorConstraint = scrollViewBottomAnchorConstraint; + +} + + +@end + diff --git a/Examples/UIKit-Objc-Example/Info.plist b/Examples/UIKit-Objc-Example/Info.plist new file mode 100644 index 0000000..81ed29b --- /dev/null +++ b/Examples/UIKit-Objc-Example/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Examples/UIKit-Objc-Example/SceneDelegate.h b/Examples/UIKit-Objc-Example/SceneDelegate.h new file mode 100644 index 0000000..8a17199 --- /dev/null +++ b/Examples/UIKit-Objc-Example/SceneDelegate.h @@ -0,0 +1,16 @@ +// +// SceneDelegate.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/Examples/UIKit-Objc-Example/SceneDelegate.m b/Examples/UIKit-Objc-Example/SceneDelegate.m new file mode 100644 index 0000000..d9eb4bb --- /dev/null +++ b/Examples/UIKit-Objc-Example/SceneDelegate.m @@ -0,0 +1,58 @@ +// +// SceneDelegate.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/Examples/UIKit-Objc-Example/ViewController.h b/Examples/UIKit-Objc-Example/ViewController.h new file mode 100644 index 0000000..ef8f41e --- /dev/null +++ b/Examples/UIKit-Objc-Example/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/Examples/UIKit-Objc-Example/ViewController.m b/Examples/UIKit-Objc-Example/ViewController.m new file mode 100644 index 0000000..e94dda4 --- /dev/null +++ b/Examples/UIKit-Objc-Example/ViewController.m @@ -0,0 +1,138 @@ +// +// ViewController.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import "ViewController.h" +#import "TossPayments/TossPayments-Swift.h" + +@interface ViewController () + +@property PaymentWidget *widget; + +@end +@interface ViewController (TossPaymentsDelegate) +@end + +@interface ViewController (TossPaymentsWidgetUIDelegate) +@end + +@interface ViewController (TossPaymentsAgreementUIDelegate) +@end + +@interface ViewController (TossPaymentsWidgetStatusDelegate) +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + BrandPay* brandPay = [[BrandPay alloc] initWithRedirectURL:@"https://tosspayments.com/redierct"]; + PaymentWidgetOptions* paymentWidgetOptions = [[PaymentWidgetOptions alloc] initWithBrandpay:brandPay]; + PaymentWidget* widget = [[PaymentWidget alloc] initWithClientKey:@"test_ck_5GePWvyJnrKdzdyY29b8gLzN97Eo" customerKey:@"TOSSPAYMENTS" options:paymentWidgetOptions]; + + Amount *amount = [[Amount alloc] initWithValue:1000 currency:@"KRW" country:@"KR"]; + PaymentMethodWidgetOptions *methodWidgetOptions = [[PaymentMethodWidgetOptions alloc] initWithVariantKey:@"DEFAULT"]; + PaymentMethodWidget* methodWidget = [widget renderPaymentMethodsWithAmount:amount options:methodWidgetOptions]; + AgreementWidget* agreementWidget = [widget renderAgreement]; + + UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; + [scrollView setAlwaysBounceVertical:true]; + [scrollView setKeyboardDismissMode:UIScrollViewKeyboardDismissModeOnDrag]; + + UIStackView *stackView = [[UIStackView alloc] initWithFrame:CGRectZero]; + [stackView setSpacing:24]; + [stackView setAxis:UILayoutConstraintAxisVertical]; + + [self.view addSubview:scrollView]; + [scrollView addSubview:stackView]; + [stackView addArrangedSubview:methodWidget]; + [stackView addArrangedSubview:agreementWidget]; + + [scrollView setTranslatesAutoresizingMaskIntoConstraints:false]; + [stackView setTranslatesAutoresizingMaskIntoConstraints:false]; + + [NSLayoutConstraint activateConstraints:@[ + [scrollView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], + [scrollView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor], + [scrollView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor], + [scrollView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], + [scrollView.widthAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.widthAnchor], + [stackView.topAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.topAnchor], + [stackView.leadingAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.leadingAnchor constant:24], + [stackView.trailingAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.trailingAnchor constant:-24], + [stackView.widthAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.widthAnchor constant:-48], + [stackView.bottomAnchor constraintEqualToAnchor:scrollView.safeAreaLayoutGuide.bottomAnchor] + ]]; + + [widget setDelegate:self]; + [[widget paymentMethodWidget] setWidgetUIDelegate:self]; + [[widget paymentMethodWidget] setWidgetStatusDelegate:self]; + [[widget agreementWidget] setAgreementUIDelegate:self]; + [[widget agreementWidget] setWidgetStatusDelegate:self]; + + self.widget = widget; +} + +@end + +@implementation ViewController (TossPaymentsDelegate) + +- (void)handleFailResult:(Fail * _Nonnull)fail { + NSLog(@"fail %@", fail); +} + +- (void)handleSuccessResult:(Success * _Nonnull)success { + NSLog(@"success %@", success); +} + +@end + +@implementation ViewController (TossPaymentsWidgetUIDelegate) + +- (void)didReceivedCustomPaymentMethodSelected:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didReceivedCustomPaymentMethodUnselected:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didReceivedCustomRequest:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didUpdateHeight:(PaymentMethodWidget * _Nonnull)widget height:(CGFloat)height { + +} + +@end + +@implementation ViewController (TossPaymentsAgreementUIDelegate) + +- (void)didUpdateAgreementStatus:(AgreementWidget * _Nonnull)widget agreementStatus:(AgreementStatus * _Nonnull)agreementStatus { + +} + +- (void)didUpdateAgreementWidgetHeight:(AgreementWidget * _Nonnull)agreementWidget height:(CGFloat)height { + +} + +@end + +@implementation ViewController (TossPaymentsWidgetStatusDelegate) + + +- (void)didReceiveFail:(NSString * _Nonnull)name fail:(Fail * _Nonnull)fail { + +} + +- (void)didReceivedLoad:(NSString * _Nonnull)name { + +} + +@end diff --git a/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.h b/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.h new file mode 100644 index 0000000..34b93eb --- /dev/null +++ b/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.h @@ -0,0 +1,43 @@ + +// +// DefaultWidgetPaymentInfo.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import +#import + +@interface DefaultWidgetPaymentInfo: NSObject + +@property (nonatomic, readonly, nonnull) NSString *orderId; +@property (nonatomic, readonly, nonnull) NSString *orderName; +@property (nonatomic, readonly, nullable) NSString *taxExemptionAmount; +@property (nonatomic, readonly, nullable) NSString *appScheme; +@property (nonatomic, readonly, nullable) NSString *customerName; +@property (nonatomic, readonly, nullable) NSString *customerEmail; +@property (nonatomic, readonly, nullable) NSNumber *taxFreeAmount; +@property (nonatomic, readonly) BOOL cultureExpense; +@property (nonatomic, readonly, nullable) NSString *customerMobilePhone; +@property (nonatomic, readonly, nullable) NSString *showCustomerMobilePhone; +@property (nonatomic, readonly, nullable) NSNumber *useEscrow; +@property (nonatomic, readonly, nullable) NSArray *escrowProducts; +@property (nonatomic, readonly, nullable) NSString *mobileCarrier; + +- (instancetype _Nonnull)initWithOrderId:(nonnull NSString *)orderId + orderName:(nonnull NSString *)orderName + taxExemptionAmount:(nullable NSString *)taxExemptionAmount + appScheme:(nullable NSString *)appScheme + customerName:(nullable NSString *)customerName + customerEmail:(nullable NSString *)customerEmail + taxFreeAmount:(nullable NSNumber *)taxFreeAmount + cultureExpense:(BOOL)cultureExpense + customerMobilePhone:(nullable NSString *)customerMobilePhone + showCustomerMobilePhone:(nullable NSString *)showCustomerMobilePhone + useEscrow:(nullable NSNumber *)useEscrow + escrowProducts:(nullable NSArray *)escrowProducts + mobileCarrier:(nullable NSString *)mobileCarrier; +@end + diff --git a/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.m b/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.m new file mode 100644 index 0000000..02d6c99 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Widget/DefaultWidgetPaymentInfo.m @@ -0,0 +1,50 @@ +// +// DefaultWidgetPaymentInfo.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/15. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import +#import "DefaultWidgetPaymentInfo.h" + +@interface DefaultWidgetPaymentInfo () + +@end + +@implementation DefaultWidgetPaymentInfo + +- (instancetype)initWithOrderId:(NSString *)orderId + orderName:(NSString *)orderName + taxExemptionAmount:(nullable NSString *)taxExemptionAmount + appScheme:(nullable NSString *)appScheme + customerName:(nullable NSString *)customerName + customerEmail:(nullable NSString *)customerEmail + taxFreeAmount:(nullable NSNumber *)taxFreeAmount + cultureExpense:(BOOL)cultureExpense + customerMobilePhone:(nullable NSString *)customerMobilePhone + showCustomerMobilePhone:(nullable NSString *)showCustomerMobilePhone + useEscrow:(nullable NSNumber *)useEscrow + escrowProducts:(nullable NSArray *)escrowProducts + mobileCarrier:(nullable NSString *)mobileCarrier { + self = [super init]; + if (self) { + _orderId = orderId; + _orderName = orderName; + _taxExemptionAmount = taxExemptionAmount; + _appScheme = appScheme; + _customerName = customerName; + _customerEmail = customerEmail; + _taxFreeAmount = taxFreeAmount; + _cultureExpense = cultureExpense; + _customerMobilePhone = customerMobilePhone; + _showCustomerMobilePhone = showCustomerMobilePhone; + _useEscrow = useEscrow; + _escrowProducts = escrowProducts; + _mobileCarrier = mobileCarrier; + } + return self; +} + +@end diff --git a/Examples/UIKit-Objc-Example/Widget/WidgetViewController.h b/Examples/UIKit-Objc-Example/Widget/WidgetViewController.h new file mode 100644 index 0000000..95f6e27 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Widget/WidgetViewController.h @@ -0,0 +1,17 @@ + +// +// ViewController.h +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import +#import "BaseViewController.h" + +@interface WidgetViewController : BaseViewController + + +@end + diff --git a/Examples/UIKit-Objc-Example/Widget/WidgetViewController.m b/Examples/UIKit-Objc-Example/Widget/WidgetViewController.m new file mode 100644 index 0000000..6d79ae1 --- /dev/null +++ b/Examples/UIKit-Objc-Example/Widget/WidgetViewController.m @@ -0,0 +1,136 @@ +// +// WidgetViewController.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import "WidgetViewController.h" +#import "TossPayments/TossPayments-Swift.h" +#import "DefaultWidgetPaymentInfo.h" + +@interface WidgetViewController () + +@property PaymentWidget *widget; +@property UIButton *button; + +@end +@interface WidgetViewController (TossPaymentsDelegate) +@end + +@interface WidgetViewController (TossPaymentsWidgetUIDelegate) +@end + +@interface WidgetViewController (TossPaymentsAgreementUIDelegate) +@end + +@interface WidgetViewController (TossPaymentsWidgetStatusDelegate) +@end + +@implementation WidgetViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + BrandPay* brandPay = [[BrandPay alloc] initWithRedirectURL:@"https://tosspayments.com/redierct"]; + PaymentWidgetOptions* paymentWidgetOptions = [[PaymentWidgetOptions alloc] initWithBrandpay:brandPay]; + PaymentWidget* widget = [[PaymentWidget alloc] initWithClientKey:@"test_ck_5GePWvyJnrKdzdyY29b8gLzN97Eo" customerKey:@"TOSSPAYMENTS" options:paymentWidgetOptions]; + UIButton *button = [[UIButton alloc] init]; + + Amount *amount = [[Amount alloc] initWithValue:1000 currency:@"KRW" country:@"KR"]; + PaymentMethodWidgetOptions *methodWidgetOptions = [[PaymentMethodWidgetOptions alloc] initWithVariantKey:@"DEFAULT"]; + PaymentMethodWidget* methodWidget = [widget renderPaymentMethodsWithAmount:amount options:methodWidgetOptions]; + AgreementWidget* agreementWidget = [widget renderAgreement]; + + [self.stackView addArrangedSubview:methodWidget]; + [self.stackView addArrangedSubview:agreementWidget]; + [self.view addSubview:button]; + + [button setTranslatesAutoresizingMaskIntoConstraints:false]; + + [self.scrollViewBottomAnchorConstraint setActive:false]; + [NSLayoutConstraint activateConstraints:@[ + [button.heightAnchor constraintEqualToConstant:60], + [button.topAnchor constraintEqualToAnchor:self.scrollView.bottomAnchor], + [button.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], + [button.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor], + [button.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor] + ]]; + + [button setBackgroundColor:UIColor.systemBlueColor]; + [button setTitle:@"결제하기" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(requestPayment) forControlEvents:UIControlEventTouchUpInside]; + + [widget setDelegate:self]; + [[widget paymentMethodWidget] setWidgetUIDelegate:self]; + [[widget paymentMethodWidget] setWidgetStatusDelegate:self]; + [[widget agreementWidget] setAgreementUIDelegate:self]; + [[widget agreementWidget] setWidgetStatusDelegate:self]; + + self.widget = widget; + self.button = button; +} + +- (void)requestPayment { + [self.widget requestPaymentWithInfo: [[DefaultWidgetPaymentInfo alloc] initWithOrderId:@"123" orderName:@"김토스" taxExemptionAmount:NULL appScheme:NULL customerName:NULL customerEmail:NULL taxFreeAmount:NULL cultureExpense:NULL customerMobilePhone:NULL showCustomerMobilePhone:NULL useEscrow:NULL escrowProducts:NULL mobileCarrier:NULL]]; +} + +@end + +@implementation WidgetViewController (TossPaymentsDelegate) + +- (void)handleFailResult:(Fail * _Nonnull)fail { + NSLog(@"fail %@", fail); +} + +- (void)handleSuccessResult:(Success * _Nonnull)success { + NSLog(@"success %@", success); +} + +@end + +@implementation WidgetViewController (TossPaymentsWidgetUIDelegate) + +- (void)didReceivedCustomPaymentMethodSelected:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didReceivedCustomPaymentMethodUnselected:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didReceivedCustomRequest:(PaymentMethodWidget * _Nonnull)widget paymentMethodKey:(NSString * _Nonnull)paymentMethodKey { + +} + +- (void)didUpdateHeight:(PaymentMethodWidget * _Nonnull)widget height:(CGFloat)height { + +} + +@end + +@implementation WidgetViewController (TossPaymentsAgreementUIDelegate) + +- (void)didUpdateAgreementStatus:(AgreementWidget * _Nonnull)widget agreementStatus:(AgreementStatus * _Nonnull)agreementStatus { + +} + +- (void)didUpdateAgreementWidgetHeight:(AgreementWidget * _Nonnull)agreementWidget height:(CGFloat)height { + +} + +@end + +@implementation WidgetViewController (TossPaymentsWidgetStatusDelegate) + + +- (void)didReceiveFail:(NSString * _Nonnull)name fail:(Fail * _Nonnull)fail { + +} + +- (void)didReceivedLoad:(NSString * _Nonnull)name { + +} + +@end diff --git a/Examples/UIKit-Objc-Example/main.m b/Examples/UIKit-Objc-Example/main.m new file mode 100644 index 0000000..49cacf3 --- /dev/null +++ b/Examples/UIKit-Objc-Example/main.m @@ -0,0 +1,19 @@ +// +// main.m +// UIKit-Objc-Example +// +// Created by 김진규 on 2023/12/14. +// Copyright © 2023 TossPayments, Inc. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/TossPayments/Sources/Model/TossPaymentsResult.swift b/TossPayments/Sources/Model/TossPaymentsResult.swift index dc542dc..c60d0de 100644 --- a/TossPayments/Sources/Model/TossPaymentsResult.swift +++ b/TossPayments/Sources/Model/TossPaymentsResult.swift @@ -8,7 +8,8 @@ import Foundation public enum TossPaymentsResult { - public struct Success: Equatable { + @objc + public class Success: NSObject { /// 결제 식별자 public let paymentKey: String @@ -21,9 +22,31 @@ public enum TossPaymentsResult { /// 추가 parameters public let additionalParameters: [String: String]? + + @objc + public init( + paymentKey: String, + orderId: String, + amount: Double, + additionalParameters: [String : String]? + ) { + self.paymentKey = paymentKey + self.orderId = orderId + self.amount = amount + self.additionalParameters = additionalParameters + } + + public override func isEqual(_ object: Any?) -> Bool { + guard let fail = object as? Success else { return false } + return self.paymentKey == fail.paymentKey + && self.orderId == fail.orderId + && self.amount == fail.amount + && self.additionalParameters == fail.additionalParameters + } } - public struct Fail: Equatable, Decodable { + @objc + public class Fail: NSObject, Decodable { /// 결제 실패코드 public let errorCode: String @@ -33,5 +56,19 @@ public enum TossPaymentsResult { /// 주문 식별자 public let orderId: String? + + @objc + public init(errorCode: String, errorMessage: String, orderId: String?) { + self.errorCode = errorCode + self.errorMessage = errorMessage + self.orderId = orderId + } + + public override func isEqual(_ object: Any?) -> Bool { + guard let fail = object as? Fail else { return false } + return self.errorCode == fail.errorCode + && self.errorMessage == fail.errorMessage + && self.orderId == fail.orderId + } } } diff --git a/TossPayments/Sources/Model/WidgetPaymentInfo/DefaultWidgetPaymentInfo.swift b/TossPayments/Sources/Model/WidgetPaymentInfo/DefaultWidgetPaymentInfo.swift index 6b44bf8..7692337 100644 --- a/TossPayments/Sources/Model/WidgetPaymentInfo/DefaultWidgetPaymentInfo.swift +++ b/TossPayments/Sources/Model/WidgetPaymentInfo/DefaultWidgetPaymentInfo.swift @@ -7,7 +7,7 @@ import Foundation -public struct DefaultWidgetPaymentInfo: WidgetPaymentInfo { +public class DefaultWidgetPaymentInfo: WidgetPaymentInfo { // 필수 public let orderId: String @@ -18,7 +18,7 @@ public struct DefaultWidgetPaymentInfo: WidgetPaymentInfo { // 선택 public let customerName: String? public let customerEmail: String? - public let taxFreeAmount: Double? + public let taxFreeAmount: NSNumber? public let cultureExpense: Bool // 추가 선택 @@ -35,7 +35,7 @@ public struct DefaultWidgetPaymentInfo: WidgetPaymentInfo { appScheme: String? = nil, customerName: String? = nil, customerEmail: String? = nil, - taxFreeAmount: Double? = nil, + taxFreeAmount: NSNumber? = nil, cultureExpense: Bool = false, customerMobilePhone: String? = nil, showCustomerMobilePhone: String? = nil, diff --git a/TossPayments/Sources/Model/WidgetPaymentInfo/WidgetPaymentInfo.swift b/TossPayments/Sources/Model/WidgetPaymentInfo/WidgetPaymentInfo.swift index b53a783..a20914d 100644 --- a/TossPayments/Sources/Model/WidgetPaymentInfo/WidgetPaymentInfo.swift +++ b/TossPayments/Sources/Model/WidgetPaymentInfo/WidgetPaymentInfo.swift @@ -1,13 +1,14 @@ // // WidgetPaymentInfo.swift -// +// // // Created by 김진규 on 2023/02/16. // import Foundation -public protocol WidgetPaymentInfo: Codable { +@objc +public protocol WidgetPaymentInfo: AnyObject { // 필수 var orderId: String { get } var orderName: String { get } @@ -15,19 +16,19 @@ public protocol WidgetPaymentInfo: Codable { // 선택 var customerName: String? { get } var customerEmail: String? { get } - var taxFreeAmount: Double? { get } + var taxFreeAmount: NSNumber? { get } } extension WidgetPaymentInfo { func convertToPaymentInfo(amount: Double) -> [String: Any]? { - do { - - let data = try JSONEncoder().encode(self) - var jsonObject = try JSONSerialization.jsonObject(with: data) as? [String: Any] - jsonObject?["amount"] = amount - return jsonObject - } catch { - fatalError() + let mirror = Mirror(reflecting: self) + var infoDict: [String: Any] = [:] + + for case let (label?, value) in mirror.children { + infoDict[label] = value } + + infoDict["amount"] = amount + return infoDict } } diff --git a/TossPayments/Sources/UIKit/Base/TossPaymentsDelegate.swift b/TossPayments/Sources/UIKit/Base/TossPaymentsDelegate.swift index 51cd2c1..4039e83 100644 --- a/TossPayments/Sources/UIKit/Base/TossPaymentsDelegate.swift +++ b/TossPayments/Sources/UIKit/Base/TossPaymentsDelegate.swift @@ -7,6 +7,7 @@ import Foundation +@objc public protocol TossPaymentsDelegate: AnyObject { func handleSuccessResult(_ success: TossPaymentsResult.Success) func handleFailResult(_ fail: TossPaymentsResult.Fail) diff --git a/TossPayments/Sources/UIKit/Base/TossPaymentsWidgetUIDelegate.swift b/TossPayments/Sources/UIKit/Base/TossPaymentsWidgetUIDelegate.swift index a2bd556..82069da 100644 --- a/TossPayments/Sources/UIKit/Base/TossPaymentsWidgetUIDelegate.swift +++ b/TossPayments/Sources/UIKit/Base/TossPaymentsWidgetUIDelegate.swift @@ -8,30 +8,33 @@ import Foundation import CoreGraphics +@objc public protocol TossPaymentsWidgetUIDelegate: AnyObject { - func didUpdateHeight(_ widget: PaymentMethodWidget, height: CGFloat) - func didReceivedCustomRequest(_ widget: PaymentMethodWidget, paymentMethodKey: String) - func didReceivedCustomPaymentMethodSelected(_ widget: PaymentMethodWidget, paymentMethodKey: String) - func didReceivedCustomPaymentMethodUnselected(_ widget: PaymentMethodWidget, paymentMethodKey: String) + func didUpdateHeight(_ methodWidget: PaymentMethodWidget, height: CGFloat) + func didReceivedCustomRequest(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) + func didReceivedCustomPaymentMethodSelected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) + func didReceivedCustomPaymentMethodUnselected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) } public extension TossPaymentsWidgetUIDelegate { - func didUpdateHeight(_ widget: PaymentMethodWidget, height: CGFloat) {} - func didReceivedCustomRequest(_ widget: PaymentMethodWidget, paymentMethodKey: String) {} - func didReceivedCustomPaymentMethodSelected(_ widget: PaymentMethodWidget, paymentMethodKey: String) {} - func didReceivedCustomPaymentMethodUnselected(_ widget: PaymentMethodWidget, paymentMethodKey: String) {} + func didUpdateHeight(_ methodWidget: PaymentMethodWidget, height: CGFloat) {} + func didReceivedCustomRequest(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) {} + func didReceivedCustomPaymentMethodSelected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) {} + func didReceivedCustomPaymentMethodUnselected(_ methodWidget: PaymentMethodWidget, paymentMethodKey: String) {} } +@objc public protocol TossPaymentsAgreementUIDelegate: AnyObject { - func didUpdateHeight(_ widget: AgreementWidget, height: CGFloat) - func didUpdateAgreementStatus(_ widget: AgreementWidget, agreementStatus: AgreementStatus) + func didUpdateAgreementWidgetHeight(_ agreementWidget: AgreementWidget, height: CGFloat) + func didUpdateAgreementStatus(_ agreementWidget: AgreementWidget, agreementStatus: AgreementStatus) } public extension TossPaymentsAgreementUIDelegate { - func didUpdateHeight(_ widget: AgreementWidget, height: CGFloat) {} - func didUpdateAgreementStatus(_ widget: AgreementWidget, agreementStatus: AgreementStatus) {} + func didUpdateAgreementWidgetHeight(_ agreementWidget: AgreementWidget, height: CGFloat) {} + func didUpdateAgreementStatus(_ agreementWidget: AgreementWidget, agreementStatus: AgreementStatus) {} } +@objc public protocol TossPaymentsWidgetStatusDelegate: AnyObject { func didReceivedLoad(_ name: String) func didReceiveFail(_ name: String, fail: TossPaymentsResult.Fail) diff --git a/TossPayments/Sources/UIKit/BrandPay/BrandPay.swift b/TossPayments/Sources/UIKit/BrandPay/BrandPay.swift index ea15354..4422d60 100644 --- a/TossPayments/Sources/UIKit/BrandPay/BrandPay.swift +++ b/TossPayments/Sources/UIKit/BrandPay/BrandPay.swift @@ -10,7 +10,9 @@ import UIKit extension PaymentWidget { /// 결제위젯에 추가적으로 들어갈 수 있는 기능 - public struct Options: Encodable { + @objc(PaymentWidgetOptions) + @objcMembers + public class Options: NSObject, Encodable { public let brandpay: BrandPay? let environment: Environment let service: String @@ -24,7 +26,9 @@ extension PaymentWidget { } /// 브랜드페이 - public struct BrandPay: Encodable { + @objc + @objcMembers + public class BrandPay: NSObject, Encodable { /// 가맹점의 서버에서 구현해줘야하는 auth URL 주소 public let redirectURL: String @@ -37,7 +41,8 @@ extension PaymentWidget { } } - public struct Environment: Encodable { + @objcMembers + public class Environment: NSObject, Encodable { public let platform: String = "ios" public let sdkVersion: String = "0.1.26" public let osVersion: String = UIDevice.current.systemVersion diff --git a/TossPayments/Sources/UIKit/Widget/Model/AgreementWidget.swift b/TossPayments/Sources/UIKit/Widget/Model/AgreementWidget.swift index 32738c0..603b89a 100644 --- a/TossPayments/Sources/UIKit/Widget/Model/AgreementWidget.swift +++ b/TossPayments/Sources/UIKit/Widget/Model/AgreementWidget.swift @@ -8,6 +8,7 @@ import Foundation import WebKit +@objcMembers public final class AgreementWidget: WKWebView, PaymentWidgetComponent { public weak var widgetStatusDelegate: TossPaymentsWidgetStatusDelegate? public weak var agreementUIDelegate: TossPaymentsAgreementUIDelegate? @@ -15,7 +16,7 @@ public final class AgreementWidget: WKWebView, PaymentWidgetComponent { public var updatedHeight: CGFloat = 92 { didSet { guard oldValue != updatedHeight else { return } - agreementUIDelegate?.didUpdateHeight(self, height: updatedHeight) + agreementUIDelegate?.didUpdateAgreementWidgetHeight(self, height: updatedHeight) invalidateIntrinsicContentSize() } } @@ -23,12 +24,19 @@ public final class AgreementWidget: WKWebView, PaymentWidgetComponent { init() { super.init(frame: .zero, configuration: WKWebViewConfiguration()) uiDelegate = self -#if DEBUG + if #available(iOS 16.4, *) { - isInspectable = true + setInspectable() + } else { + // Fallback on earlier versions } -#endif + } + @available(iOS 16.4, *) + func setInspectable() { +#if DEBUG + isInspectable = true +#endif } required init?(coder: NSCoder) { diff --git a/TossPayments/Sources/UIKit/Widget/Model/PaymentMethodWidget.swift b/TossPayments/Sources/UIKit/Widget/Model/PaymentMethodWidget.swift index 4609c03..3ea3239 100644 --- a/TossPayments/Sources/UIKit/Widget/Model/PaymentMethodWidget.swift +++ b/TossPayments/Sources/UIKit/Widget/Model/PaymentMethodWidget.swift @@ -8,6 +8,7 @@ import Foundation import WebKit +@objcMembers public final class PaymentMethodWidget: WKWebView, PaymentWidgetComponent { public weak var widgetStatusDelegate: TossPaymentsWidgetStatusDelegate? public weak var widgetUIDelegate: TossPaymentsWidgetUIDelegate? diff --git a/TossPayments/Sources/UIKit/Widget/PaymentMethodWidget+Extensions.swift b/TossPayments/Sources/UIKit/Widget/PaymentMethodWidget+Extensions.swift index beec601..42a3a9f 100644 --- a/TossPayments/Sources/UIKit/Widget/PaymentMethodWidget+Extensions.swift +++ b/TossPayments/Sources/UIKit/Widget/PaymentMethodWidget+Extensions.swift @@ -9,7 +9,9 @@ import Foundation extension PaymentMethodWidget { - public struct Amount: Encodable { + @objc + @objcMembers + public class Amount: NSObject, Encodable { public let value: Double public let currency: String? public let country: String? @@ -25,7 +27,9 @@ extension PaymentMethodWidget { } } - public struct Options: Encodable { + @objc(PaymentMethodWidgetOptions) + @objcMembers + public class Options: NSObject, Encodable { public let variantKey: String? public init( variantKey: String? diff --git a/TossPayments/Sources/UIKit/Widget/PaymentWidget.swift b/TossPayments/Sources/UIKit/Widget/PaymentWidget.swift index 94630d3..0602e0e 100644 --- a/TossPayments/Sources/UIKit/Widget/PaymentWidget.swift +++ b/TossPayments/Sources/UIKit/Widget/PaymentWidget.swift @@ -8,6 +8,7 @@ import Foundation import WebKit +@objcMembers public final class PaymentWidget: NSObject, HandleURLResult { // MARK: - Private properties private lazy var messageHandler = MessageHandler( @@ -72,6 +73,8 @@ public final class PaymentWidget: NSObject, HandleURLResult { public weak var delegate: TossPaymentsDelegate? public var paymentMethodWidget: PaymentMethodWidget? public var agreementWidget: AgreementWidget? + + @objc public init( clientKey: String, customerKey: String, @@ -95,6 +98,7 @@ public final class PaymentWidget: NSObject, HandleURLResult { } // MARK: Public methods + @objc public func renderPaymentMethods(amount: PaymentMethodWidget.Amount, options: PaymentMethodWidget.Options? = nil) -> PaymentMethodWidget { let paymentMethodWidget = PaymentMethodWidget() self.methodWidgetAmount = amount @@ -130,45 +134,45 @@ public final class PaymentWidget: NSObject, HandleURLResult { return paymentMethodWidget } - @available(*, deprecated, message: "use func renderPaymentMethods(amount: PaymentMethodWidget.Object, options: PaymentMethodWidget.Options? = nil)") - public func renderPaymentMethods( - amount: Double, - options: PaymentMethodWidget.Options? = nil - ) -> PaymentMethodWidget { - let paymentMethodWidget = PaymentMethodWidget() - self.amount = amount - self.methodWidgetOptions = options - - paymentMethodWidget.configuration.userContentController.addUserScript(legacyPaymentMethodScript) - - paymentMethodWidget.configuration.userContentController.add( - RequestPaymentsMessageHandler(self), - name: ScriptName.requestPayments.rawValue - ) - paymentMethodWidget.configuration.userContentController.add( - ErrorHandler({ [weak self] fail in - self?.paymentMethodWidget?.widgetStatusDelegate?.didReceiveFail("paymentMethodWidget", fail: fail) - }), - name: ScriptName.error.rawValue - ) - paymentMethodWidget.configuration.userContentController.add( - UpdateHeightMessageHandler(), - name: ScriptName.updateHeight.rawValue - ) - paymentMethodWidget.configuration.userContentController.add( - RequestHTMLMessageHandler(self), - name: ScriptName.requestHTML.rawValue - ) - paymentMethodWidget.configuration.userContentController.add( - MessageScriptHandler(self), - name: ScriptName.message.rawValue - ) - paymentMethodWidget.loadHTMLString(htmlString, baseURL: baseURL) - - self.paymentMethodWidget = paymentMethodWidget - return paymentMethodWidget - } - +// @available(*, deprecated, message: "use func renderPaymentMethods(amount: PaymentMethodWidget.Object, options: PaymentMethodWidget.Options? = nil)") +// public func renderPaymentMethods( +// amount: Double, +// options: PaymentMethodWidget.Options? = nil +// ) -> PaymentMethodWidget { +// let paymentMethodWidget = PaymentMethodWidget() +// self.amount = amount +// self.methodWidgetOptions = options +// +// paymentMethodWidget.configuration.userContentController.addUserScript(legacyPaymentMethodScript) +// +// paymentMethodWidget.configuration.userContentController.add( +// RequestPaymentsMessageHandler(self), +// name: ScriptName.requestPayments.rawValue +// ) +// paymentMethodWidget.configuration.userContentController.add( +// ErrorHandler({ [weak self] fail in +// self?.paymentMethodWidget?.widgetStatusDelegate?.didReceiveFail("paymentMethodWidget", fail: fail) +// }), +// name: ScriptName.error.rawValue +// ) +// paymentMethodWidget.configuration.userContentController.add( +// UpdateHeightMessageHandler(), +// name: ScriptName.updateHeight.rawValue +// ) +// paymentMethodWidget.configuration.userContentController.add( +// RequestHTMLMessageHandler(self), +// name: ScriptName.requestHTML.rawValue +// ) +// paymentMethodWidget.configuration.userContentController.add( +// MessageScriptHandler(self), +// name: ScriptName.message.rawValue +// ) +// paymentMethodWidget.loadHTMLString(htmlString, baseURL: baseURL) +// +// self.paymentMethodWidget = paymentMethodWidget +// return paymentMethodWidget +// } +// public func renderAgreement() -> AgreementWidget { let agreementWidget = AgreementWidget() agreementWidget.configuration.userContentController.addUserScript(agreementScript)