Skip to content

Commit

Permalink
Move email & phone details to BTPaymentInsightsRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo committed Dec 4, 2023
1 parent 3c7221b commit fb09a79
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Braintree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
8064F38F2B1E492F0059C4CB /* BTPaymentInsightsClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8064F38E2B1E492F0059C4CB /* BTPaymentInsightsClient.swift */; };
8064F3912B1E49E10059C4CB /* BTPaymentInsightsResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8064F3902B1E49E10059C4CB /* BTPaymentInsightsResult.swift */; };
8064F3952B1E4FEB0059C4CB /* BTPaymentInsightsClient_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8064F3942B1E4FEB0059C4CB /* BTPaymentInsightsClient_Tests.swift */; };
8064F3972B1E63800059C4CB /* BTPaymentInsightsRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8064F3962B1E63800059C4CB /* BTPaymentInsightsRequest.swift */; };
80BA64AC29D788E000E15264 /* BTLocalPaymentResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80BA64AB29D788E000E15264 /* BTLocalPaymentResult.swift */; };
80BA64B229D7937E00E15264 /* BTLocalPaymentRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80BA64B129D7937E00E15264 /* BTLocalPaymentRequest.swift */; };
80BA64B429D795D000E15264 /* BTLocalPaymentRequestDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80BA64B329D795D000E15264 /* BTLocalPaymentRequestDelegate.swift */; };
Expand Down Expand Up @@ -705,6 +706,7 @@
8064F38E2B1E492F0059C4CB /* BTPaymentInsightsClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPaymentInsightsClient.swift; sourceTree = "<group>"; };
8064F3902B1E49E10059C4CB /* BTPaymentInsightsResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPaymentInsightsResult.swift; sourceTree = "<group>"; };
8064F3942B1E4FEB0059C4CB /* BTPaymentInsightsClient_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPaymentInsightsClient_Tests.swift; sourceTree = "<group>"; };
8064F3962B1E63800059C4CB /* BTPaymentInsightsRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPaymentInsightsRequest.swift; sourceTree = "<group>"; };
80A1EE3D2236AAC600F6218B /* BTThreeDSecureAdditionalInformation_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTThreeDSecureAdditionalInformation_Tests.swift; sourceTree = "<group>"; };
80B6190C28C9535F00FB5022 /* PayPalCheckout.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = PayPalCheckout.xcframework; path = Frameworks/XCFrameworks/PayPalCheckout.xcframework; sourceTree = "<group>"; };
80BA64AB29D788E000E15264 /* BTLocalPaymentResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTLocalPaymentResult.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1191,6 +1193,7 @@
570B93D82853C6180041BAFE /* BTLogLevel.swift */,
570B93D62853C29A0041BAFE /* BTLogLevelDescription.swift */,
8064F38E2B1E492F0059C4CB /* BTPaymentInsightsClient.swift */,
8064F3962B1E63800059C4CB /* BTPaymentInsightsRequest.swift */,
8064F3902B1E49E10059C4CB /* BTPaymentInsightsResult.swift */,
BE9FB82A2898324C00D6FE2F /* BTPaymentMethodNonce.swift */,
BE9FB82C28984ADE00D6FE2F /* BTPaymentMethodNonceParser.swift */,
Expand Down Expand Up @@ -2764,6 +2767,7 @@
BE698EA028AA8DCB001D9B10 /* BTHTTP.swift in Sources */,
BC17F9B428D23C5C004B18CC /* BTGraphQLMultiErrorNode.swift in Sources */,
5708E0A828809BC6007946B9 /* BTJSONError.swift in Sources */,
8064F3972B1E63800059C4CB /* BTPaymentInsightsRequest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions Sources/BraintreeCore/BTPaymentInsightsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import Foundation
self.apiClient = apiClient
}

/// This method confirmes if the customer is a user of PayPal services using their email and phone number.
/// This method confirms if the customer is a user of PayPal services using their email and phone number.
/// - Parameters:
/// - email: The buyer's email address
/// - phone: The buyer's phone number
/// - Returns: A `BTPaymentInsightsResult` instance
/// - Note: This feature is in beta. It's public API may change in future releases.
public func getRecommendedPaymentMethods(email: String, phone: String) async throws -> BTPaymentInsightsResult {
public func getRecommendedPaymentMethods(request: BTPaymentInsightsRequest) async throws -> BTPaymentInsightsResult {
// TODO: - Add isAppInstalled checks for PP & Venmo. DTBTSDK-3176
// TODO: - Make API call to PaymentReadyAPI. DTBTSDK-3176
return BTPaymentInsightsResult()
Expand Down
26 changes: 26 additions & 0 deletions Sources/BraintreeCore/BTPaymentInsightsRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation

/// Buyer data required to use the Payment Insights feature.
/// - Note: This feature is in beta. It's public API may change in future releases.
@objcMembers public class BTPaymentInsightsRequest: NSObject {

/// The buyer's email address.
public let email: String

/// The buyer's country code prefix to the national telephone number. An identifier for a specific country.
public let phoneCountryCode: String

/// The buyer's national phone number.
public let phoneNationalNumber: String

/// Initialize a `BTPaymentInsightsRequest`
/// - Parameters:
/// - email: The buyer's email address.
/// - phoneCountryCode: The buyer's country code prefix to the national telephone number. An identifier for a specific country.
/// - phoneNationalNumber: The buyer's national phone number.
init(email: String, phoneCountryCode: String, phoneNationalNumber: String) {
self.email = email
self.phoneCountryCode = phoneCountryCode
self.phoneNationalNumber = phoneNationalNumber
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class BTPaymentInsightsClient_Tests: XCTestCase {
}

func testGetRecommendedPaymentMethods_returnsDefaultRecommendations() async {
let result = try? await sut.getRecommendedPaymentMethods(email: "fake-email", phone: "fake-phone")
let request = BTPaymentInsightsRequest(
email: "fake-email",
phoneCountryCode: "fake-country-code",
phoneNationalNumber: "fake-national-phone"
)
let result = try? await sut.getRecommendedPaymentMethods(request: request)

XCTAssertNotNil(result!.isPayPalRecommended)
XCTAssertNotNil(result!.isPayPalRecommended)
Expand Down

0 comments on commit fb09a79

Please sign in to comment.