-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…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
Showing
6 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |