Skip to content

Commit

Permalink
create VenmoCheckoutRequest and VenmoCheckoutResult structs, add …
Browse files Browse the repository at this point in the history
…shell for client class and basic unit test setup
  • Loading branch information
agedd committed Jul 16, 2024
1 parent 2cced79 commit 6f0a13a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 19 deletions.
42 changes: 25 additions & 17 deletions PayPal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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 @@ -265,6 +267,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 @@ -570,23 +574,6 @@
path = Models;
sourceTree = "<group>";
};
62D3FB122C3DB4B30046563B /* VenmoPaymentsTests */ = {
isa = PBXGroup;
children = (
62D3FB132C3DB4D40046563B /* VenmoClient_Tests.swift */,
);
path = VenmoPaymentsTests;
sourceTree = "<group>";
};
62D3FB4A2C3ED82D0046563B /* VenmoPayments */ = {
isa = PBXGroup;
children = (
62D3FB492C3ED82D0046563B /* VenmoClient.swift */,
);
name = VenmoPayments;
path = Sources/VenmoPayments;
sourceTree = "<group>";
};
45B063AD2C40346500E743F2 /* Eligibility */ = {
isa = PBXGroup;
children = (
Expand All @@ -608,6 +595,25 @@
path = Eligibility;
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 @@ -1466,6 +1472,8 @@
buildActionMask = 2147483647;
files = (
62D3FB4B2C3ED82D0046563B /* VenmoClient.swift in Sources */,
62EEC3EE2C471EAE00C350FD /* VenmoCheckoutRequest.swift in Sources */,
62EEC3F02C471F6000C350FD /* VenmoCheckoutResult.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
14 changes: 14 additions & 0 deletions Sources/VenmoPayments/VenmoCheckoutRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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

/// Creates an instance of VenmoCheckoutRequest
/// - Parameter orderID: The ID of an order to be approved
public init(orderID: String) {
self.orderID = orderID
}
}
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
}
34 changes: 33 additions & 1 deletion Sources/VenmoPayments/VenmoClient.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
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
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
public func start(_ request: VenmoCheckoutRequest) async throws -> VenmoCheckoutResult {
// TODO: - Add logic in a future PR
.init(orderID: "test-order-id")
}
}
16 changes: 15 additions & 1 deletion UnitTests/VenmoPaymentsTests/VenmoClient_Tests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import XCTest
import AuthenticationServices
@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 6f0a13a

Please sign in to comment.