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

Add VenmoClient, VenmoCheckoutRequest and VenmoCheckoutResult #287

Merged
merged 5 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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(_ request: VenmoCheckoutRequest)` method to `VenmoClient`
agedd marked this conversation as resolved.
Show resolved Hide resolved

## 1.3.2 (2024-05-23)
* PaymentButtons
* Add black boundary around white buttons
Expand Down
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
}
agedd marked this conversation as resolved.
Show resolved Hide resolved
}
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)
agedd marked this conversation as resolved.
Show resolved Hide resolved
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
agedd marked this conversation as resolved.
Show resolved Hide resolved
init(config: CoreConfig, universalLink: URL) {
self.config = config
self.universalLink = universalLink
self.networkingClient = NetworkingClient(coreConfig: config)
}
agedd marked this conversation as resolved.
Show resolved Hide resolved

/// 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
agedd marked this conversation as resolved.
Show resolved Hide resolved
public func start(_ request: VenmoCheckoutRequest) async throws -> VenmoCheckoutResult {
// TODO: - Add logic in a future PR
.init(orderID: "test-order-id")
agedd marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
agedd marked this conversation as resolved.
Show resolved Hide resolved
@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
}
Loading