From 94a875e2bc3103da76c15fe3d2920f18c064a82c Mon Sep 17 00:00:00 2001 From: stechiu Date: Fri, 22 Nov 2024 10:40:27 -0800 Subject: [PATCH 01/10] Added `isPayPalAppInstalled`, `isVenmoAppInstalled` methods --- Sources/BraintreePayPal/BTPayPalClient.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/BraintreePayPal/BTPayPalClient.swift b/Sources/BraintreePayPal/BTPayPalClient.swift index 0362ed1597..4cbf51f340 100644 --- a/Sources/BraintreePayPal/BTPayPalClient.swift +++ b/Sources/BraintreePayPal/BTPayPalClient.swift @@ -184,6 +184,18 @@ import BraintreeDataCollector } } + /// Indicates whether the PayPal App is installed. + /// - Warning: This module is in beta. It's public API may change or be removed in future releases. + public func isPayPalAppInstalled() -> Bool { + application.isPayPalAppInstalled() + } + + /// Indicates whether the Venmo App is installed. + /// - Warning: This module is in beta. It's public API may change or be removed in future releases. + public func isVenmoAppInstalled() -> Bool { + application.isVenmoAppInstalled() + } + // MARK: - Internal Methods func handleReturn( From d424deeeb910243fad7c61e67a9542ac3d5d0ca6 Mon Sep 17 00:00:00 2001 From: stechiu Date: Fri, 22 Nov 2024 15:40:34 -0800 Subject: [PATCH 02/10] Added unit tests --- .../BTPayPalClient_Tests.swift | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift index 7fff4ad489..f5d30fdb13 100644 --- a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift +++ b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift @@ -1028,4 +1028,34 @@ class BTPayPalClient_Tests: XCTestCase { XCTAssertFalse(mockAPIClient.postedIsVaultRequest) } + + func test_payPalAppNotInstalled() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = false + + XCTAssertEqual(fakeApplication.isPayPalAppInstalled(), payPalClient.application.isPayPalAppInstalled()) + } + + func test_payPalAppInstalled() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + + XCTAssertEqual(fakeApplication.isPayPalAppInstalled(), payPalClient.application.isPayPalAppInstalled()) + } + + func test_venmoAppNotInstalled() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = false + + XCTAssertEqual(fakeApplication.isVenmoAppInstalled(), payPalClient.application.isVenmoAppInstalled()) + } + + func test_venmoAppInstalled() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + + XCTAssertEqual(fakeApplication.isVenmoAppInstalled(), payPalClient.application.isVenmoAppInstalled()) + } } From 36e3122c164967811db3c5da77b7a5ee42802bac Mon Sep 17 00:00:00 2001 From: stechiu Date: Mon, 2 Dec 2024 16:54:55 -0800 Subject: [PATCH 03/10] Addressed PR comments --- Sources/BraintreePayPal/BTPayPalClient.swift | 8 +------ Sources/BraintreeVenmo/BTVenmoClient.swift | 8 ++++++- .../BTPayPalClient_Tests.swift | 23 ++++--------------- .../BTVenmoClient_Tests.swift | 19 +++++++++++++-- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Sources/BraintreePayPal/BTPayPalClient.swift b/Sources/BraintreePayPal/BTPayPalClient.swift index 4cbf51f340..0462a7f8f9 100644 --- a/Sources/BraintreePayPal/BTPayPalClient.swift +++ b/Sources/BraintreePayPal/BTPayPalClient.swift @@ -185,17 +185,11 @@ import BraintreeDataCollector } /// Indicates whether the PayPal App is installed. - /// - Warning: This module is in beta. It's public API may change or be removed in future releases. + /// - Warning: This method is currently in beta and may change or be removed in future releases. public func isPayPalAppInstalled() -> Bool { application.isPayPalAppInstalled() } - /// Indicates whether the Venmo App is installed. - /// - Warning: This module is in beta. It's public API may change or be removed in future releases. - public func isVenmoAppInstalled() -> Bool { - application.isVenmoAppInstalled() - } - // MARK: - Internal Methods func handleReturn( diff --git a/Sources/BraintreeVenmo/BTVenmoClient.swift b/Sources/BraintreeVenmo/BTVenmoClient.swift index f5fa291508..53eb9345ed 100644 --- a/Sources/BraintreeVenmo/BTVenmoClient.swift +++ b/Sources/BraintreeVenmo/BTVenmoClient.swift @@ -201,9 +201,15 @@ import BraintreeCore } } } + + /// Indicates whether the Venmo App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isVenmoAppInstalled() -> Bool { + application.isVenmoAppInstalled() + } /// Returns true if the proper Venmo app is installed and configured correctly, returns false otherwise. - @objc public func isVenmoAppInstalled() -> Bool { + @objc public func isVenmoAppSwitchAvailable() -> Bool { guard let appSwitchURL = BTVenmoAppSwitchRedirectURL.baseAppSwitchURL else { return false } diff --git a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift index f5d30fdb13..a9ff8ce01f 100644 --- a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift +++ b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift @@ -1029,33 +1029,18 @@ class BTPayPalClient_Tests: XCTestCase { XCTAssertFalse(mockAPIClient.postedIsVaultRequest) } - func test_payPalAppNotInstalled() { + func testIsPayPalAppInstalled_whenPayPalAppNotInstalled_returnsFalse() { let fakeApplication = FakeApplication() payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = false - XCTAssertEqual(fakeApplication.isPayPalAppInstalled(), payPalClient.application.isPayPalAppInstalled()) + XCTAssertFalse(payPalClient.application.isPayPalAppInstalled()) } - func test_payPalAppInstalled() { + func testIsPayPalAppInstalled_whenPayPalAppIsInstalled_returnsTrue() { let fakeApplication = FakeApplication() payPalClient.application = fakeApplication - XCTAssertEqual(fakeApplication.isPayPalAppInstalled(), payPalClient.application.isPayPalAppInstalled()) - } - - func test_venmoAppNotInstalled() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - fakeApplication.cannedCanOpenURL = false - - XCTAssertEqual(fakeApplication.isVenmoAppInstalled(), payPalClient.application.isVenmoAppInstalled()) - } - - func test_venmoAppInstalled() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - - XCTAssertEqual(fakeApplication.isVenmoAppInstalled(), payPalClient.application.isVenmoAppInstalled()) + XCTAssertTrue(payPalClient.application.isPayPalAppInstalled()) } } diff --git a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift index e9101a4380..b9264beca9 100644 --- a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift +++ b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift @@ -829,7 +829,7 @@ class BTVenmoClient_Tests: XCTestCase { fakeApplication.canOpenURLWhitelist.append(URL(string: "com.venmo.touch.v2://x-callback-url/path")!) venmoClient.application = fakeApplication - XCTAssertTrue(venmoClient.isVenmoAppInstalled()) + XCTAssertTrue(venmoClient.isVenmoAppSwitchAvailable()) } func testIsiOSAppSwitchAvailable_whenApplicationCantOpenVenmoURL_returnsFalse() { @@ -839,7 +839,22 @@ class BTVenmoClient_Tests: XCTestCase { fakeApplication.cannedCanOpenURL = false venmoClient.application = fakeApplication - XCTAssertFalse(venmoClient.isVenmoAppInstalled()) + XCTAssertFalse(venmoClient.isVenmoAppSwitchAvailable()) + } + + func testIsVenmoAppInstalled_whenVenmoAppNotInstalled_returnsFalse() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = false + + XCTAssertFalse(payPalClient.application.isVenmoAppInstalled()) + } + + func testIsVenmoAppInstalled_whenVenmoAppIsInstalled_returnsTrue() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + + XCTAssertTrue(payPalClient.application.isVenmoAppInstalled()) } func testCanHandleReturnURL_withValidHost_andValidPath_returnsTrue() { From d846369164c9ce4c67d231acacdfd3de4bed84ce Mon Sep 17 00:00:00 2001 From: stechiu Date: Wed, 4 Dec 2024 14:05:50 -0800 Subject: [PATCH 04/10] Moved methods to Shopper Insights --- Podfile.lock | 2 +- Sources/BraintreePayPal/BTPayPalClient.swift | 6 ---- .../BTShopperInsightsClient.swift | 14 ++++++++ Sources/BraintreeVenmo/BTVenmoClient.swift | 8 +---- .../BTPayPalClient_Tests.swift | 15 -------- .../BTShopperInsightsClient_Tests.swift | 36 +++++++++++++++++++ .../BTVenmoClient_Tests.swift | 19 ++-------- 7 files changed, 54 insertions(+), 46 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 53baaccb08..086a065f08 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -37,4 +37,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 224cc2d6666b79d3d6adb45cccd6dfbc6fe74d18 -COCOAPODS: 1.15.2 +COCOAPODS: 1.14.3 diff --git a/Sources/BraintreePayPal/BTPayPalClient.swift b/Sources/BraintreePayPal/BTPayPalClient.swift index 0462a7f8f9..0362ed1597 100644 --- a/Sources/BraintreePayPal/BTPayPalClient.swift +++ b/Sources/BraintreePayPal/BTPayPalClient.swift @@ -184,12 +184,6 @@ import BraintreeDataCollector } } - /// Indicates whether the PayPal App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isPayPalAppInstalled() -> Bool { - application.isPayPalAppInstalled() - } - // MARK: - Internal Methods func handleReturn( diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index e5dc83a6cc..a7eec363f5 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -140,4 +140,18 @@ public class BTShopperInsightsClient { ) return error } + + // MARK: - Public Methods + + /// Indicates whether the PayPal App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isPayPalAppInstalled() -> Bool { + application.isPayPalAppInstalled() + } + + /// Indicates whether the Venmo App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isVenmoAppInstalled() -> Bool { + application.isVenmoAppInstalled() + } } diff --git a/Sources/BraintreeVenmo/BTVenmoClient.swift b/Sources/BraintreeVenmo/BTVenmoClient.swift index 53eb9345ed..f5fa291508 100644 --- a/Sources/BraintreeVenmo/BTVenmoClient.swift +++ b/Sources/BraintreeVenmo/BTVenmoClient.swift @@ -201,15 +201,9 @@ import BraintreeCore } } } - - /// Indicates whether the Venmo App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isVenmoAppInstalled() -> Bool { - application.isVenmoAppInstalled() - } /// Returns true if the proper Venmo app is installed and configured correctly, returns false otherwise. - @objc public func isVenmoAppSwitchAvailable() -> Bool { + @objc public func isVenmoAppInstalled() -> Bool { guard let appSwitchURL = BTVenmoAppSwitchRedirectURL.baseAppSwitchURL else { return false } diff --git a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift index a9ff8ce01f..7fff4ad489 100644 --- a/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift +++ b/UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift @@ -1028,19 +1028,4 @@ class BTPayPalClient_Tests: XCTestCase { XCTAssertFalse(mockAPIClient.postedIsVaultRequest) } - - func testIsPayPalAppInstalled_whenPayPalAppNotInstalled_returnsFalse() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - fakeApplication.cannedCanOpenURL = false - - XCTAssertFalse(payPalClient.application.isPayPalAppInstalled()) - } - - func testIsPayPalAppInstalled_whenPayPalAppIsInstalled_returnsTrue() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - - XCTAssertTrue(payPalClient.application.isPayPalAppInstalled()) - } } diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 168e282134..3652fff28d 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -3,11 +3,13 @@ import XCTest @testable import BraintreeTestShared @testable import BraintreeShopperInsights @testable import BraintreeCore +@testable import BraintreePayPal class BTShopperInsightsClient_Tests: XCTestCase { let clientToken = TestClientTokenFactory.token(withVersion: 3) var mockAPIClient: MockAPIClient! + var payPalClient: BTPayPalClient! var sut: BTShopperInsightsClient! let request = BTShopperInsightsRequest( @@ -227,4 +229,38 @@ class BTShopperInsightsClient_Tests: XCTestCase { sut.sendVenmoSelectedEvent() XCTAssertEqual(mockAPIClient.postedAnalyticsEvents.first, "shopper-insights:venmo-selected") } + + // MARK: - App Installed Methods + + func testIsPayPalAppInstalled_whenPayPalAppNotInstalled_returnsFalse() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = false + + XCTAssertFalse(payPalClient.application.isPayPalAppInstalled()) + } + + func testIsPayPalAppInstalled_whenPayPalAppIsInstalled_returnsTrue() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = true + + XCTAssertTrue(payPalClient.application.isPayPalAppInstalled()) + } + + func testIsVenmoAppInstalled_whenVenmoAppNotInstalled_returnsFalse() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = false + + XCTAssertFalse(payPalClient.application.isVenmoAppInstalled()) + } + + func testIsVenmoAppInstalled_whenVenmoAppIsInstalled_returnsTrue() { + let fakeApplication = FakeApplication() + payPalClient.application = fakeApplication + fakeApplication.cannedCanOpenURL = true + + XCTAssertTrue(payPalClient.application.isVenmoAppInstalled()) + } } diff --git a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift index b9264beca9..e9101a4380 100644 --- a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift +++ b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift @@ -829,7 +829,7 @@ class BTVenmoClient_Tests: XCTestCase { fakeApplication.canOpenURLWhitelist.append(URL(string: "com.venmo.touch.v2://x-callback-url/path")!) venmoClient.application = fakeApplication - XCTAssertTrue(venmoClient.isVenmoAppSwitchAvailable()) + XCTAssertTrue(venmoClient.isVenmoAppInstalled()) } func testIsiOSAppSwitchAvailable_whenApplicationCantOpenVenmoURL_returnsFalse() { @@ -839,22 +839,7 @@ class BTVenmoClient_Tests: XCTestCase { fakeApplication.cannedCanOpenURL = false venmoClient.application = fakeApplication - XCTAssertFalse(venmoClient.isVenmoAppSwitchAvailable()) - } - - func testIsVenmoAppInstalled_whenVenmoAppNotInstalled_returnsFalse() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - fakeApplication.cannedCanOpenURL = false - - XCTAssertFalse(payPalClient.application.isVenmoAppInstalled()) - } - - func testIsVenmoAppInstalled_whenVenmoAppIsInstalled_returnsTrue() { - let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication - - XCTAssertTrue(payPalClient.application.isVenmoAppInstalled()) + XCTAssertFalse(venmoClient.isVenmoAppInstalled()) } func testCanHandleReturnURL_withValidHost_andValidPath_returnsTrue() { From f167e6743f5bcf3a2f9da47d6949b5a8f60b93cc Mon Sep 17 00:00:00 2001 From: stechiu Date: Wed, 4 Dec 2024 14:19:46 -0800 Subject: [PATCH 05/10] Fixed failing unit tests. Added to CHANGELOG --- CHANGELOG.md | 2 ++ .../BTShopperInsightsClient_Tests.swift | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 156f060520..4ffda6028f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * Add `BTPayPalRequest.userPhoneNumber` optional property * BraintreeVenmo * Send `url` in `event_params` for App Switch events to PayPal's analytics service (FPTI) +* BraintreeShopperInsights (BETA) + * Add `isPayPalAppInstalled()` and/or `isVenmoAppInstalled()` ## 6.24.0 (2024-10-15) * BraintreePayPal diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 3652fff28d..97e34e2b38 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -11,6 +11,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { var mockAPIClient: MockAPIClient! var payPalClient: BTPayPalClient! var sut: BTShopperInsightsClient! + var mockWebAuthenticationSession: MockWebAuthenticationSession! let request = BTShopperInsightsRequest( email: "my-email", @@ -35,6 +36,9 @@ class BTShopperInsightsClient_Tests: XCTestCase { super.setUp() mockAPIClient = MockAPIClient(authorization: clientToken) sut = BTShopperInsightsClient(apiClient: mockAPIClient!) + payPalClient = BTPayPalClient(apiClient: mockAPIClient, universalLink: URL(string: "https://www.paypal.com")!) + mockWebAuthenticationSession = MockWebAuthenticationSession() + payPalClient.webAuthenticationSession = mockWebAuthenticationSession } // MARK: - getRecommendedPaymentMethods() From 1211a3a6f49ad25e49b84e1e9723c6f434c7ae88 Mon Sep 17 00:00:00 2001 From: stechiu Date: Wed, 4 Dec 2024 15:50:16 -0800 Subject: [PATCH 06/10] Unit test --- .../BTShopperInsightsClient_Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 97e34e2b38..f19dccc3ed 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -1,9 +1,9 @@ import Foundation import XCTest +@testable import BraintreePayPal @testable import BraintreeTestShared @testable import BraintreeShopperInsights @testable import BraintreeCore -@testable import BraintreePayPal class BTShopperInsightsClient_Tests: XCTestCase { From e6f694695559cc7476eb44e7d75585bac72b04b5 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 5 Dec 2024 10:11:13 -0800 Subject: [PATCH 07/10] Addressed PR comments --- Podfile.lock | 2 +- .../BTShopperInsightsClient.swift | 28 +++++++++---------- .../BTShopperInsightsClient_Tests.swift | 14 +++------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 086a065f08..53baaccb08 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -37,4 +37,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 224cc2d6666b79d3d6adb45cccd6dfbc6fe74d18 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index a7eec363f5..1fc6ca7bbd 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -8,6 +8,20 @@ import BraintreeCore /// By customizing each customer’s checkout experience, you can improve conversion, increase sales/repeat buys and boost user retention/loyalty. /// - Warning: This feature is in beta. It's public API may change or be removed in future releases. public class BTShopperInsightsClient { + + // MARK: - Public Methods + + /// Indicates whether the PayPal App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isPayPalAppInstalled() -> Bool { + application.isPayPalAppInstalled() + } + + /// Indicates whether the Venmo App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isVenmoAppInstalled() -> Bool { + application.isVenmoAppInstalled() + } // MARK: - Internal Properties @@ -140,18 +154,4 @@ public class BTShopperInsightsClient { ) return error } - - // MARK: - Public Methods - - /// Indicates whether the PayPal App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isPayPalAppInstalled() -> Bool { - application.isPayPalAppInstalled() - } - - /// Indicates whether the Venmo App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isVenmoAppInstalled() -> Bool { - application.isVenmoAppInstalled() - } } diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index f19dccc3ed..07f70f759e 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -1,6 +1,5 @@ import Foundation import XCTest -@testable import BraintreePayPal @testable import BraintreeTestShared @testable import BraintreeShopperInsights @testable import BraintreeCore @@ -9,9 +8,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { let clientToken = TestClientTokenFactory.token(withVersion: 3) var mockAPIClient: MockAPIClient! - var payPalClient: BTPayPalClient! var sut: BTShopperInsightsClient! - var mockWebAuthenticationSession: MockWebAuthenticationSession! let request = BTShopperInsightsRequest( email: "my-email", @@ -36,9 +33,6 @@ class BTShopperInsightsClient_Tests: XCTestCase { super.setUp() mockAPIClient = MockAPIClient(authorization: clientToken) sut = BTShopperInsightsClient(apiClient: mockAPIClient!) - payPalClient = BTPayPalClient(apiClient: mockAPIClient, universalLink: URL(string: "https://www.paypal.com")!) - mockWebAuthenticationSession = MockWebAuthenticationSession() - payPalClient.webAuthenticationSession = mockWebAuthenticationSession } // MARK: - getRecommendedPaymentMethods() @@ -241,7 +235,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = false - XCTAssertFalse(payPalClient.application.isPayPalAppInstalled()) + XCTAssertFalse(sut.isPayPalAppInstalled()) } func testIsPayPalAppInstalled_whenPayPalAppIsInstalled_returnsTrue() { @@ -249,7 +243,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = true - XCTAssertTrue(payPalClient.application.isPayPalAppInstalled()) + XCTAssertTrue(sut.isPayPalAppInstalled()) } func testIsVenmoAppInstalled_whenVenmoAppNotInstalled_returnsFalse() { @@ -257,7 +251,7 @@ class BTShopperInsightsClient_Tests: XCTestCase { payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = false - XCTAssertFalse(payPalClient.application.isVenmoAppInstalled()) + XCTAssertFalse(sut.isVenmoAppInstalled()) } func testIsVenmoAppInstalled_whenVenmoAppIsInstalled_returnsTrue() { @@ -265,6 +259,6 @@ class BTShopperInsightsClient_Tests: XCTestCase { payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = true - XCTAssertTrue(payPalClient.application.isVenmoAppInstalled()) + XCTAssertTrue(sut.isVenmoAppInstalled()) } } From 5fb58f9273894886097ad32bd7335fe325cd235f Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 5 Dec 2024 10:47:29 -0800 Subject: [PATCH 08/10] Fixed failing tests --- .../BTShopperInsightsClient_Tests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift index 07f70f759e..a8019bbdfa 100644 --- a/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift +++ b/UnitTests/BraintreeShopperInsightsTests/BTShopperInsightsClient_Tests.swift @@ -232,7 +232,6 @@ class BTShopperInsightsClient_Tests: XCTestCase { func testIsPayPalAppInstalled_whenPayPalAppNotInstalled_returnsFalse() { let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = false XCTAssertFalse(sut.isPayPalAppInstalled()) @@ -240,15 +239,15 @@ class BTShopperInsightsClient_Tests: XCTestCase { func testIsPayPalAppInstalled_whenPayPalAppIsInstalled_returnsTrue() { let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = true + fakeApplication.canOpenURLWhitelist.append(URL(string: "paypal-app-switch-checkout://x-callback-url/path")!) + sut.application = fakeApplication XCTAssertTrue(sut.isPayPalAppInstalled()) } func testIsVenmoAppInstalled_whenVenmoAppNotInstalled_returnsFalse() { let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = false XCTAssertFalse(sut.isVenmoAppInstalled()) @@ -256,8 +255,9 @@ class BTShopperInsightsClient_Tests: XCTestCase { func testIsVenmoAppInstalled_whenVenmoAppIsInstalled_returnsTrue() { let fakeApplication = FakeApplication() - payPalClient.application = fakeApplication fakeApplication.cannedCanOpenURL = true + fakeApplication.canOpenURLWhitelist.append(URL(string: "com.venmo.touch.v2://x-callback-url/path")!) + sut.application = fakeApplication XCTAssertTrue(sut.isVenmoAppInstalled()) } From 3f70f84ef04bedd4b7a68ac39c850f1fc8c677b0 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 5 Dec 2024 14:03:40 -0800 Subject: [PATCH 09/10] Addressed PR comment --- .../BTShopperInsightsClient.swift | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index 1fc6ca7bbd..5eceb05ddf 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -8,20 +8,6 @@ import BraintreeCore /// By customizing each customer’s checkout experience, you can improve conversion, increase sales/repeat buys and boost user retention/loyalty. /// - Warning: This feature is in beta. It's public API may change or be removed in future releases. public class BTShopperInsightsClient { - - // MARK: - Public Methods - - /// Indicates whether the PayPal App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isPayPalAppInstalled() -> Bool { - application.isPayPalAppInstalled() - } - - /// Indicates whether the Venmo App is installed. - /// - Warning: This method is currently in beta and may change or be removed in future releases. - public func isVenmoAppInstalled() -> Bool { - application.isVenmoAppInstalled() - } // MARK: - Internal Properties @@ -38,7 +24,10 @@ public class BTShopperInsightsClient { public init(apiClient: BTAPIClient) { self.apiClient = apiClient } + + // MARK: - Public Methods + /// This method confirms if the customer is a user of PayPal services using their email and phone number. /// - Parameters: /// - request: Required: A `BTShopperInsightsRequest` containing the buyer's user information. @@ -135,7 +124,19 @@ public class BTShopperInsightsClient { public func sendVenmoSelectedEvent() { apiClient.sendAnalyticsEvent(BTShopperInsightsAnalytics.venmoSelected) } - + + /// Indicates whether the PayPal App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isPayPalAppInstalled() -> Bool { + application.isPayPalAppInstalled() + } + + /// Indicates whether the Venmo App is installed. + /// - Warning: This method is currently in beta and may change or be removed in future releases. + public func isVenmoAppInstalled() -> Bool { + application.isVenmoAppInstalled() + } + // MARK: - Analytics Helper Methods private func notifySuccess(with result: BTShopperInsightsResult, for experiment: String?) -> BTShopperInsightsResult { From ffd78d8abc6cd7cc5aa22213e5fd1538f3146695 Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Fri, 6 Dec 2024 08:37:09 -0600 Subject: [PATCH 10/10] Update Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift --- Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift index 5eceb05ddf..c403682291 100644 --- a/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift +++ b/Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift @@ -24,7 +24,6 @@ public class BTShopperInsightsClient { public init(apiClient: BTAPIClient) { self.apiClient = apiClient } - // MARK: - Public Methods