Skip to content

Commit

Permalink
Add VenmoClient, VenmoCheckoutRequest and VenmoCheckoutResult (#…
Browse files Browse the repository at this point in the history
…287)

* create `VenmoCheckoutRequest` and `VenmoCheckoutResult` structs, add shell for client class and basic unit test setup

* add changelog entry

* address pr feedback

* cleanup and address pr feedback
  • Loading branch information
agedd authored Jul 24, 2024
1 parent c281aa9 commit 725139c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* Add deprecated warning message to all public classes and methods
* VenmoPayments
* Add `VenmoPayments` module

* Add `VenmoCheckoutRequest` and `VenmoCheckoutResult` type for interacting with `start` method
* Add `start(_:)` method to `VenmoClient`

## 1.3.2 (2024-05-23)
* PaymentButtons
* Add black boundary around white buttons
Expand Down
28 changes: 28 additions & 0 deletions PayPal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
53A2A4E228A182AC0093441C /* NativeCheckoutProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A2A4E128A182AC0093441C /* NativeCheckoutProvider.swift */; };
62D3FB292C3DB5130046563B /* CorePayments.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 80B9F85126B8750000D67843 /* CorePayments.framework */; platformFilter = ios; };
62D3FB4B2C3ED82D0046563B /* VenmoClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D3FB492C3ED82D0046563B /* VenmoClient.swift */; };
62EEC3EE2C471EAE00C350FD /* VenmoCheckoutRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EEC3ED2C471EAE00C350FD /* VenmoCheckoutRequest.swift */; };
62EEC3F02C471F6000C350FD /* VenmoCheckoutResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EEC3EF2C471F6000C350FD /* VenmoCheckoutResult.swift */; };
8008D2052A9E54FF0003CAF4 /* CheckoutOrdersAPI_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8008D2042A9E54FF0003CAF4 /* CheckoutOrdersAPI_Tests.swift */; };
80132D7229008C000088D30D /* TestShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 80E743F8270E40CE00BACECA /* TestShared.framework */; };
8021B69029144E6D000FBC54 /* PayPalCoreConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8021B68F29144E6D000FBC54 /* PayPalCoreConstants.swift */; };
Expand Down Expand Up @@ -273,6 +275,8 @@
62D3FB2F2C3DB5130046563B /* VenmoPayments.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VenmoPayments.framework; sourceTree = BUILT_PRODUCTS_DIR; };
62D3FB452C3DB5370046563B /* VenmoPaymentsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VenmoPaymentsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
62D3FB492C3ED82D0046563B /* VenmoClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VenmoClient.swift; sourceTree = "<group>"; };
62EEC3ED2C471EAE00C350FD /* VenmoCheckoutRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VenmoCheckoutRequest.swift; sourceTree = "<group>"; };
62EEC3EF2C471F6000C350FD /* VenmoCheckoutResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VenmoCheckoutResult.swift; sourceTree = "<group>"; };
8008D2042A9E54FF0003CAF4 /* CheckoutOrdersAPI_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckoutOrdersAPI_Tests.swift; sourceTree = "<group>"; };
8021B68F29144E6D000FBC54 /* PayPalCoreConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayPalCoreConstants.swift; sourceTree = "<group>"; };
802C4A732945670400896A5D /* MockHTTP.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockHTTP.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -583,6 +587,9 @@
children = (
45B063B92C40456F00E743F2 /* EligibilityAPI.swift */,
45B063B22C4035DB00E743F2 /* EligibilityClient.swift */,
45B063AE2C40349300E743F2 /* EligibilityRequest.swift */,
45B063B02C4034B700E743F2 /* EligibilityResult.swift */,
45B063B72C40440000E743F2 /* EligibilityVariables.swift */,
459633152C46BD63002008EF /* EligibilityIntent.swift */,
45B063AE2C40349300E743F2 /* EligibilityRequest.swift */,
459633172C46BD6F002008EF /* EligibilityResponse.swift */,
Expand Down Expand Up @@ -619,6 +626,25 @@
path = Sources/VenmoPayments;
sourceTree = "<group>";
};
62D3FB122C3DB4B30046563B /* VenmoPaymentsTests */ = {
isa = PBXGroup;
children = (
62D3FB132C3DB4D40046563B /* VenmoClient_Tests.swift */,
);
path = VenmoPaymentsTests;
sourceTree = "<group>";
};
62D3FB4A2C3ED82D0046563B /* VenmoPayments */ = {
isa = PBXGroup;
children = (
62D3FB492C3ED82D0046563B /* VenmoClient.swift */,
62EEC3ED2C471EAE00C350FD /* VenmoCheckoutRequest.swift */,
62EEC3EF2C471F6000C350FD /* VenmoCheckoutResult.swift */,
);
name = VenmoPayments;
path = Sources/VenmoPayments;
sourceTree = "<group>";
};
8036C1DE270F9BCF00C0F091 /* PaymentsCoreTests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1478,6 +1504,8 @@
buildActionMask = 2147483647;
files = (
62D3FB4B2C3ED82D0046563B /* VenmoClient.swift in Sources */,
62EEC3EE2C471EAE00C350FD /* VenmoCheckoutRequest.swift in Sources */,
62EEC3F02C471F6000C350FD /* VenmoCheckoutResult.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
8 changes: 8 additions & 0 deletions Sources/VenmoPayments/VenmoCheckoutRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

/// Used to configure options for approving a Venmo Checkout order
public struct VenmoCheckoutRequest {

/// The order ID associated with the request
public let orderID: String
}
8 changes: 8 additions & 0 deletions Sources/VenmoPayments/VenmoCheckoutResult.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

/// The result of the Venmo checkout payment flow.
public struct VenmoCheckoutResult {

/// The order ID associated with the transaction
public let orderID: String
}
38 changes: 37 additions & 1 deletion Sources/VenmoPayments/VenmoClient.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
import Foundation

#if canImport(CorePayments)
import CorePayments
#endif

public class VenmoClient {

// TODO: to be implemented in a future PR
// MARK: - Properties

private let config: CoreConfig
private let universalLink: URL
private let networkingClient: NetworkingClient

// MARK: - Initializers

/// Initialize a VenmoClient to process a Venmo payment
/// - Parameter config: The CoreConfig object
/// - Parameter universalLink: The URL to use for the Venmo app switch checkout flow.
public init(config: CoreConfig, universalLink: URL) {
self.config = config
self.universalLink = universalLink
self.networkingClient = NetworkingClient(coreConfig: config)
}

/// For internal use for testing/mocking purpose
init(config: CoreConfig, universalLink: URL, networkingClient: NetworkingClient) {
self.config = config
self.universalLink = universalLink
self.networkingClient = networkingClient
}

/// Launch the Venmo checkout flow
/// - Parameters:
/// - request: the `VenmoCheckoutRequest` for the transaction
/// - Returns: A `VenmoCheckoutResult`
/// - Throws: An `Error` describing the failure
public func start(_ request: VenmoCheckoutRequest) async throws -> VenmoCheckoutResult {
// TODO: - Add logic in a future PR
VenmoCheckoutResult(orderID: "test-order-id")
}
}
15 changes: 14 additions & 1 deletion UnitTests/VenmoPaymentsTests/VenmoClient_Tests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import XCTest
@testable import VenmoPayments
@testable import CorePayments
@testable import TestShared

public class VenmoClient_Tests: XCTestCase {

// TODO: to be implemented in a future PR
var config: CoreConfig!
var venmoClient: VenmoClient!
var mockNetworkingClient: MockNetworkingClient!

override func setUp() {
super.setUp()
config = CoreConfig(clientID: "test-client-id", environment: .sandbox)
mockNetworkingClient = MockNetworkClient(http: MockHTTP(coreConfig: config))
}

// TODO: Add other relevant unit tests in a future PR
}

0 comments on commit 725139c

Please sign in to comment.