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

Open
wants to merge 3 commits into
base: shopper-insights-rp1-feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/BraintreePayPal/BTPayPalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ 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(
Expand Down
8 changes: 7 additions & 1 deletion Sources/BraintreeVenmo/BTVenmoClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 since this is public this would technically be a breaking change.

@scannillo I know on the original spec for this we had the app install checks in the Venmo and PayPal modules. Thinking more about it, does it make sense to move these into the shopper insights module? Since they are beta methods it could make more sense to keep them contained to that module vs being in the PayPal and Venmo feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just looking at this on the Android side and I think it makes more sense to keep these separated in the ShopperInsightsClient - otherwise we need to do refactoring with the current use of app installed methods in the PayPal module to make them public (or duplicate code).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, totally agree. We can have Sammy update the specs in our wiki pages once she's back. Sorry to change this from what was in the ticket @stechiu - but lets move both of the app installed methods and tests to the Shopper Insights module.

guard let appSwitchURL = BTVenmoAppSwitchRedirectURL.baseAppSwitchURL else {
return false
}
Expand Down
15 changes: 15 additions & 0 deletions UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1028,4 +1028,19 @@ 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())
}
}
19 changes: 17 additions & 2 deletions UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
Loading