From d0a4d348c637c707d151dd37e384f42417845fcc Mon Sep 17 00:00:00 2001 From: Jef Mathiot Date: Tue, 10 Sep 2024 09:15:05 +0200 Subject: [PATCH] Fix usage of the library in extensions to reflect changes in XCode >= 13 --- .../Source/API Bindings/STPAPIClient+Payments.swift | 2 ++ .../Source/API Bindings/STPRedirectContext.swift | 4 ++++ StripePayments/StripePayments/Source/Captcha/HCaptcha.swift | 1 + .../StripePayments/Source/Captcha/HCaptchaConfig.swift | 3 ++- .../StripePayments/Source/Captcha/HCaptchaResult.swift | 1 + .../StripePayments/Source/Captcha/HCaptchaURLOpener.swift | 1 + .../HCaptchaWebViewManager+WKNavigationDelegate.swift | 1 + .../Source/Captcha/HCaptchaWebViewManager.swift | 2 ++ .../Source/Helpers/STPPaymentConfirmation+SwiftUI.swift | 3 +++ .../Source/Internal/API Bindings/STPSourcePoller.swift | 1 + .../STPAnalyticsClient+STPPaymentHandler.swift | 1 + .../Source/PaymentHandler/STPPaymentHandler.swift | 5 +++++ 12 files changed, 24 insertions(+), 1 deletion(-) diff --git a/StripePayments/StripePayments/Source/API Bindings/STPAPIClient+Payments.swift b/StripePayments/StripePayments/Source/API Bindings/STPAPIClient+Payments.swift index 1ad35d73d4d..e1c067175f4 100644 --- a/StripePayments/StripePayments/Source/API Bindings/STPAPIClient+Payments.swift +++ b/StripePayments/StripePayments/Source/API Bindings/STPAPIClient+Payments.swift @@ -327,6 +327,7 @@ extension STPAPIClient { /// - secret: The client secret of the source. Cannot be nil. /// - timeout: The timeout for the polling operation, in seconds. Timeouts are capped at 5 minutes. /// - completion: The callback to run with the returned Source object, or an error. + @available(iOSApplicationExtension, unavailable) @objc(startPollingSourceWithId:clientSecret:timeout:completion:) public func startPollingSource( withId identifier: String, @@ -350,6 +351,7 @@ extension STPAPIClient { /// Stops polling the Source object with the given ID. Note that the completion block passed to /// `startPolling` will not be fired when `stopPolling` is called. /// - Parameter identifier: The identifier of the source to be retrieved. Cannot be nil. + @available(iOSApplicationExtension, unavailable) @objc(stopPollingSourceWithId:) public func stopPollingSource(withId identifier: String) { sourcePollersQueue?.async(execute: { diff --git a/StripePayments/StripePayments/Source/API Bindings/STPRedirectContext.swift b/StripePayments/StripePayments/Source/API Bindings/STPRedirectContext.swift index a91e9a21f94..01a673865b4 100644 --- a/StripePayments/StripePayments/Source/API Bindings/STPRedirectContext.swift +++ b/StripePayments/StripePayments/Source/API Bindings/STPRedirectContext.swift @@ -74,6 +74,8 @@ public typealias STPRedirectContextPaymentIntentCompletionBlock = (String, Error /// @note You must retain this instance for the duration of the redirect flow. /// This class dismisses any presented view controller upon deallocation. /// See https://stripe.com/docs/sources/best-practices + +@available(iOSApplicationExtension, unavailable) public class STPRedirectContext: NSObject, UIViewControllerTransitioningDelegate, STPSafariViewControllerDismissalDelegate { @@ -515,6 +517,7 @@ public class STPRedirectContext: NSObject, } /// :nodoc: +@available(iOSApplicationExtension, unavailable) @_spi(STP) extension STPRedirectContext: STPURLCallbackListener { /// :nodoc: @_spi(STP) public func handleURLCallback(_ url: URL) -> Bool { @@ -562,6 +565,7 @@ extension UIApplication: UIApplicationProtocol { } #if !canImport(CompositorServices) +@available(iOSApplicationExtension, unavailable) extension STPRedirectContext: SFSafariViewControllerDelegate { // MARK: - SFSafariViewControllerDelegate - /// :nodoc: diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptcha.swift b/StripePayments/StripePayments/Source/Captcha/HCaptcha.swift index 90813fb856d..0719425ea60 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptcha.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptcha.swift @@ -13,6 +13,7 @@ import WebKit /** hCaptcha SDK facade (entry point) */ +@available(iOSApplicationExtension, unavailable) @objc class HCaptcha: NSObject { fileprivate struct Constants { diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptchaConfig.swift b/StripePayments/StripePayments/Source/Captcha/HCaptchaConfig.swift index 28db2262eb9..f84b68ba1bc 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptchaConfig.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptchaConfig.swift @@ -77,6 +77,7 @@ enum HCaptchaOrientation: Int, RawRepresentable { /** Internal data model to keep SDK init params */ +@available(iOSApplicationExtension, unavailable) struct HCaptchaConfig: CustomDebugStringConvertible { /// The raw unformated HTML file content let html: String @@ -280,7 +281,7 @@ struct HCaptchaConfig: CustomDebugStringConvertible { } // MARK: - Private Methods - +@available(iOSApplicationExtension, unavailable) private extension HCaptchaConfig { /** - parameter url: The URL to be fixed diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptchaResult.swift b/StripePayments/StripePayments/Source/Captcha/HCaptchaResult.swift index 1f053350173..b50b308562d 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptchaResult.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptchaResult.swift @@ -12,6 +12,7 @@ import Foundation This may contain the validation token on success, or an error that may have occurred. */ +@available(iOSApplicationExtension, unavailable) @objc class HCaptchaResult: NSObject { diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptchaURLOpener.swift b/StripePayments/StripePayments/Source/Captcha/HCaptchaURLOpener.swift index 6439e6b172e..eaa3f13b5ad 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptchaURLOpener.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptchaURLOpener.swift @@ -28,6 +28,7 @@ internal protocol HCaptchaURLOpener { /** * UIApplication based implementation */ +@available(iOSApplicationExtension, unavailable) internal class HCapchaAppURLOpener: HCaptchaURLOpener { func canOpenURL(_ url: URL) -> Bool { return UIApplication.shared.canOpenURL(url) diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager+WKNavigationDelegate.swift b/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager+WKNavigationDelegate.swift index 962577f6c66..28598107a64 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager+WKNavigationDelegate.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager+WKNavigationDelegate.swift @@ -8,6 +8,7 @@ import Foundation import WebKit +@available(iOSApplicationExtension, unavailable) extension HCaptchaWebViewManager: WKNavigationDelegate { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { if navigationAction.targetFrame == nil, let url = navigationAction.request.url, urlOpener.canOpenURL(url) { diff --git a/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager.swift b/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager.swift index 7d9d9e91d12..e324802730c 100644 --- a/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager.swift +++ b/StripePayments/StripePayments/Source/Captcha/HCaptchaWebViewManager.swift @@ -7,6 +7,7 @@ import WebKit /** Handles comunications with the webview containing the HCaptcha challenge. */ +@available(iOSApplicationExtension, unavailable) internal class HCaptchaWebViewManager: NSObject { enum JSCommand: String { case execute = "execute();" @@ -219,6 +220,7 @@ internal class HCaptchaWebViewManager: NSObject { /** Private methods for HCaptchaWebViewManager */ +@available(iOSApplicationExtension, unavailable) fileprivate extension HCaptchaWebViewManager { /** - returns: An instance of `WKWebViewConfiguration` diff --git a/StripePayments/StripePayments/Source/Helpers/STPPaymentConfirmation+SwiftUI.swift b/StripePayments/StripePayments/Source/Helpers/STPPaymentConfirmation+SwiftUI.swift index 3ab81761975..b69aa9d4982 100644 --- a/StripePayments/StripePayments/Source/Helpers/STPPaymentConfirmation+SwiftUI.swift +++ b/StripePayments/StripePayments/Source/Helpers/STPPaymentConfirmation+SwiftUI.swift @@ -9,6 +9,7 @@ import SafariServices import SwiftUI +@available(iOSApplicationExtension, unavailable) struct ConfirmPaymentPresenter: UIViewControllerRepresentable { @Binding var presented: Bool let intentParams: ParamsType @@ -91,6 +92,7 @@ struct ConfirmPaymentPresenter: UIViewControlle } } +@available(iOSApplicationExtension, unavailable) extension View { /// Confirm the payment, presenting a sheet for the user to confirm their payment if needed. /// - Parameter isConfirmingPayment: A binding to whether the payment is being confirmed. This will present a sheet if needed. It will be updated to `false` after performing the payment confirmation. @@ -129,6 +131,7 @@ extension View { } } +@available(iOSApplicationExtension, unavailable) struct ConfirmPaymentPresentationModifier: ViewModifier { @Binding var isPresented: Bool let intentParams: ParamsType diff --git a/StripePayments/StripePayments/Source/Internal/API Bindings/STPSourcePoller.swift b/StripePayments/StripePayments/Source/Internal/API Bindings/STPSourcePoller.swift index 13ffa9f738d..8909bea9f0b 100644 --- a/StripePayments/StripePayments/Source/Internal/API Bindings/STPSourcePoller.swift +++ b/StripePayments/StripePayments/Source/Internal/API Bindings/STPSourcePoller.swift @@ -10,6 +10,7 @@ import Foundation @_spi(STP) import StripeCore import UIKit +@available(iOSApplicationExtension, unavailable) class STPSourcePoller: NSObject { required init( apiClient: STPAPIClient, diff --git a/StripePayments/StripePayments/Source/PaymentHandler/STPAnalyticsClient+STPPaymentHandler.swift b/StripePayments/StripePayments/Source/PaymentHandler/STPAnalyticsClient+STPPaymentHandler.swift index 71668d6304c..ddd8115c786 100644 --- a/StripePayments/StripePayments/Source/PaymentHandler/STPAnalyticsClient+STPPaymentHandler.swift +++ b/StripePayments/StripePayments/Source/PaymentHandler/STPAnalyticsClient+STPPaymentHandler.swift @@ -20,6 +20,7 @@ extension STPPaymentHandlerActionStatus { } } +@available(iOSApplicationExtension, unavailable) extension STPPaymentHandler { struct Analytic: StripeCore.Analytic { let event: StripeCore.STPAnalyticEvent diff --git a/StripePayments/StripePayments/Source/PaymentHandler/STPPaymentHandler.swift b/StripePayments/StripePayments/Source/PaymentHandler/STPPaymentHandler.swift index 1ad153ef875..dbac5b63e03 100644 --- a/StripePayments/StripePayments/Source/PaymentHandler/STPPaymentHandler.swift +++ b/StripePayments/StripePayments/Source/PaymentHandler/STPPaymentHandler.swift @@ -97,6 +97,7 @@ let missingReturnURLErrorMessage = "The payment method requires a return URL and /// `STPPaymentHandler` is a utility class that confirms PaymentIntents/SetupIntents and handles any authentication required, such as 3DS1/3DS2 for Strong Customer Authentication. /// It can present authentication UI on top of your app or redirect users out of your app (to e.g. their banking app). /// - seealso: https://stripe.com/docs/payments/3d-secure +@available(iOSApplicationExtension, unavailable) public class STPPaymentHandler: NSObject { /// The error domain for errors in `STPPaymentHandler`. @objc public static let errorDomain = "STPPaymentHandlerErrorDomain" @@ -2180,6 +2181,7 @@ public class STPPaymentHandler: NSObject { /// STPPaymentHandler errors (i.e. errors that are created by the STPPaymentHandler class and have a corresponding STPPaymentHandlerErrorCode) used to be NSErrors. /// This struct exists so that these errors can be Swift errors to conform to AnalyticLoggableError, while still looking like the old NSErrors to users (i.e. same domain and code). +@available(iOSApplicationExtension, unavailable) struct STPPaymentHandlerError: Error, CustomNSError, AnalyticLoggableError { // AnalyticLoggableError properties let analyticsErrorType: String = errorDomain @@ -2201,6 +2203,7 @@ struct STPPaymentHandlerError: Error, CustomNSError, AnalyticLoggableError { } #if !canImport(CompositorServices) +@available(iOSApplicationExtension, unavailable) extension STPPaymentHandler: SFSafariViewControllerDelegate { // MARK: - SFSafariViewControllerDelegate /// :nodoc: @@ -2226,6 +2229,7 @@ extension STPPaymentHandler: SFSafariViewControllerDelegate { #endif /// :nodoc: +@available(iOSApplicationExtension, unavailable) @_spi(STP) extension STPPaymentHandler: STPURLCallbackListener { /// :nodoc: @_spi(STP) public func handleURLCallback(_ url: URL) -> Bool { @@ -2259,6 +2263,7 @@ extension STPPaymentHandler: SFSafariViewControllerDelegate { } } +@available(iOSApplicationExtension, unavailable) extension STPPaymentHandler { // MARK: - STPChallengeStatusReceiver /// :nodoc: