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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 224cc2d6666b79d3d6adb45cccd6dfbc6fe74d18

COCOAPODS: 1.15.2
COCOAPODS: 1.14.3
stechiu marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions Sources/BraintreeShopperInsights/BTShopperInsightsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,18 @@ public class BTShopperInsightsClient {
)
return error
}

// MARK: - Public Methods
jaxdesmarais marked this conversation as resolved.
Show resolved Hide resolved

/// 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()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import XCTest
@testable import BraintreePayPal
stechiu marked this conversation as resolved.
Show resolved Hide resolved
@testable import BraintreeTestShared
@testable import BraintreeShopperInsights
@testable import BraintreeCore
Expand All @@ -8,7 +9,9 @@ class BTShopperInsightsClient_Tests: XCTestCase {

let clientToken = TestClientTokenFactory.token(withVersion: 3)
var mockAPIClient: MockAPIClient!
var payPalClient: BTPayPalClient!
var sut: BTShopperInsightsClient!
var mockWebAuthenticationSession: MockWebAuthenticationSession!
stechiu marked this conversation as resolved.
Show resolved Hide resolved

let request = BTShopperInsightsRequest(
email: "my-email",
Expand All @@ -33,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()
Expand Down Expand Up @@ -227,4 +233,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())
stechiu marked this conversation as resolved.
Show resolved Hide resolved
}

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())
}
}
Loading