Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RP1][iOS] Expose PayPal and Venmo App Installed for Merchants #1473

Merged
merged 10 commits into from
Dec 6, 2024
12 changes: 12 additions & 0 deletions Sources/BraintreePayPal/BTPayPalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
stechiu marked this conversation as resolved.
Show resolved Hide resolved
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()
}
stechiu marked this conversation as resolved.
Show resolved Hide resolved

// MARK: - Internal Methods

func handleReturn(
Expand Down
30 changes: 30 additions & 0 deletions UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1028,4 +1028,34 @@ class BTPayPalClient_Tests: XCTestCase {

XCTAssertFalse(mockAPIClient.postedIsVaultRequest)
}

func test_payPalAppNotInstalled() {
stechiu marked this conversation as resolved.
Show resolved Hide resolved
let fakeApplication = FakeApplication()
payPalClient.application = fakeApplication
fakeApplication.cannedCanOpenURL = false

XCTAssertEqual(fakeApplication.isPayPalAppInstalled(), payPalClient.application.isPayPalAppInstalled())
stechiu marked this conversation as resolved.
Show resolved Hide resolved
}

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())
}
stechiu marked this conversation as resolved.
Show resolved Hide resolved
}