From 1d8cb0cd112b088dfef8857fb4ae7306058e1d74 Mon Sep 17 00:00:00 2001 From: GMALKHA Date: Tue, 26 Nov 2024 13:55:08 -0800 Subject: [PATCH] [DTPPMOBILE-143] Deprecate Delegation Methods in Paypal SDK (#304) * Deprecate delegate protocols and methods --- .github/workflows/build.yml | 1 + .github/workflows/swiftlint.yml | 2 ++ Sources/CardPayments/CardClient.swift | 2 ++ Sources/CardPayments/CardClientError.swift | 1 + Sources/CardPayments/CardDelegate.swift | 1 + Sources/CardPayments/CardVaultDelegate.swift | 1 + Sources/PayPalWebPayments/PayPalVaultDelegate.swift | 1 + Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift | 1 + Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift | 1 + Sources/PayPalWebPayments/PayPalWebCheckoutDelegate.swift | 1 + 10 files changed, 12 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e08eaf3f..400e55c26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,4 +34,5 @@ jobs: run: cd SampleApps/SPMTest && swift package resolve - name: Build & archive SPMTest run: xcodebuild -project 'SampleApps/SPMTest/SPMTest.xcodeproj' -scheme 'SPMTest' clean build archive CODE_SIGNING_ALLOWED=NO + run: pod lib lint --allow-warnings="deprecated" diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml index ac1f545aa..00cc8d86c 100644 --- a/.github/workflows/swiftlint.yml +++ b/.github/workflows/swiftlint.yml @@ -16,3 +16,5 @@ jobs: run: brew install swiftlint - name: Run SwiftLint run: swiftlint --strict +disabled_rules: + - deprecated_syntax diff --git a/Sources/CardPayments/CardClient.swift b/Sources/CardPayments/CardClient.swift index 8c77236d4..e1c022f70 100644 --- a/Sources/CardPayments/CardClient.swift +++ b/Sources/CardPayments/CardClient.swift @@ -43,6 +43,7 @@ public class CardClient: NSObject { /// If `didAttempt3DSecureVerification` is `true`, check verification status with `/v3/vault/setup-token/{id}` in your server. /// - Parameters: /// - vaultRequest: The request containing setupTokenID and card + @available(*, deprecated, message: "This method is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public func vault(_ vaultRequest: CardVaultRequest) { analyticsService = AnalyticsService(coreConfig: config, setupToken: vaultRequest.setupTokenID) analyticsService?.sendEvent("card-payments:vault-wo-purchase:started") @@ -75,6 +76,7 @@ public class CardClient: NSObject { /// - Parameters: /// - orderId: Order id for approval /// - request: The request containing the card + @available(*, deprecated, message: "This method is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public func approveOrder(request: CardRequest) { analyticsService = AnalyticsService(coreConfig: config, orderID: request.orderID) analyticsService?.sendEvent("card-payments:3ds:started") diff --git a/Sources/CardPayments/CardClientError.swift b/Sources/CardPayments/CardClientError.swift index 3a6522626..eeb826f06 100644 --- a/Sources/CardPayments/CardClientError.swift +++ b/Sources/CardPayments/CardClientError.swift @@ -3,6 +3,7 @@ import Foundation import CorePayments #endif +@available(*, deprecated, renamed: "CardError") enum CardClientError { static let domain = "CardClientErrorDomain" diff --git a/Sources/CardPayments/CardDelegate.swift b/Sources/CardPayments/CardDelegate.swift index 77c5cace6..7ec975682 100644 --- a/Sources/CardPayments/CardDelegate.swift +++ b/Sources/CardPayments/CardDelegate.swift @@ -4,6 +4,7 @@ import CorePayments #endif /// Card delegate to handle events from CardClient +@available(*, deprecated, message: "This protocol is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public protocol CardDelegate: AnyObject { /// Notify that the Card flow finished with a successful result diff --git a/Sources/CardPayments/CardVaultDelegate.swift b/Sources/CardPayments/CardVaultDelegate.swift index 4a85cb2aa..ebe5a516d 100644 --- a/Sources/CardPayments/CardVaultDelegate.swift +++ b/Sources/CardPayments/CardVaultDelegate.swift @@ -4,6 +4,7 @@ import CorePayments #endif /// CardVault delegate to handle events from CardClient +@available(*, deprecated, message: "This protocol is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public protocol CardVaultDelegate: AnyObject { /// Notify that the Card vault flow finished with a successful result diff --git a/Sources/PayPalWebPayments/PayPalVaultDelegate.swift b/Sources/PayPalWebPayments/PayPalVaultDelegate.swift index f189b31fa..367934a30 100644 --- a/Sources/PayPalWebPayments/PayPalVaultDelegate.swift +++ b/Sources/PayPalWebPayments/PayPalVaultDelegate.swift @@ -4,6 +4,7 @@ import CorePayments #endif /// PayPalVault delegate to vault results from PayPalWebCheckoutClient +@available(*, deprecated, message: "This protocol is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public protocol PayPalVaultDelegate: AnyObject { /// Notify that the PayPal vault flow finished with a successful result diff --git a/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift b/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift index 3ff509d55..c2d4b6a1f 100644 --- a/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift +++ b/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift @@ -32,6 +32,7 @@ public class PayPalWebCheckoutClient: NSObject { /// Launch the PayPal web flow /// - Parameters: /// - request: the PayPalRequest for the transaction + @available(*, deprecated, message: "This method is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public func start(request: PayPalWebCheckoutRequest) { analyticsService = AnalyticsService(coreConfig: config, orderID: request.orderID) analyticsService?.sendEvent("paypal-web-payments:started") diff --git a/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift b/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift index ccfd943fe..690578242 100644 --- a/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift +++ b/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift @@ -4,6 +4,7 @@ import Foundation import CorePayments #endif +@available(*, deprecated, renamed: "PayPalError") enum PayPalWebCheckoutClientError { static let domain = "PayPalClientErrorDomain" diff --git a/Sources/PayPalWebPayments/PayPalWebCheckoutDelegate.swift b/Sources/PayPalWebPayments/PayPalWebCheckoutDelegate.swift index 5fcfc8ecc..11a0a610c 100644 --- a/Sources/PayPalWebPayments/PayPalWebCheckoutDelegate.swift +++ b/Sources/PayPalWebPayments/PayPalWebCheckoutDelegate.swift @@ -4,6 +4,7 @@ import CorePayments #endif /// PayPal delegate to handle events from PayPalNativeCheckoutClient +@available(*, deprecated, message: "This protocol is deprecated and will be removed in version 2.0.0. Please use the new completion handler-based approach instead. For more details, visit the v2 migration guide: https://github.com/paypal/paypal-ios/") public protocol PayPalWebCheckoutDelegate: AnyObject { /// Notify that the PayPal flow finished with a successful result