-
Notifications
You must be signed in to change notification settings - Fork 295
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 BTPayPalEditRequest and Tokenize for Edit FI #1358
Changes from 3 commits
7be938a
f14bf73
4489e37
f557bc7
6b65727
a0b81ed
8c3c33a
cef99d7
10c6b8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,6 +183,46 @@ import BraintreeDataCollector | |
} | ||
} | ||
|
||
/// Tokenize a PayPal request to be used with the Edit FI flow. | ||
/// | ||
/// On success, you will receive an instance of `BTPayPalAccountNonce`; on failure or user cancelation you will receive an error. | ||
/// If the user cancels out of the flow, the error code will be `.canceled`. | ||
/// | ||
/// - Parameters: | ||
/// - request: A `BTPayPalEditRequest` | ||
/// - completion: This completion will be invoked exactly once when tokenization is complete or an error occurs. | ||
/// - Warning: This feature is currently in beta and may change or be removed in future releases. | ||
@objc(tokenizeWithEditRequest:completion:) | ||
public func tokenize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to Jax's comment re: only supporting new features in Swift, what do folks think about only supporting new features in the async-await method syntax? We could hold on the completion style syntax and add it later based on merchant feedback? Is now a good time to trial this? Would love folks thoughts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People I've talked to are working with async-await syntax in their code bases, but that's just a small sampling. I'm sure there are a lot of companies with legacy repos. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a great point - i wonder how many merchants are transitioning to or already using the async/await style over the completion style syntax. imo i like that having both signatures gives merchants the choice to choose what works best for them but i also feel the asyn/await reads more clearly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! I like the brevity of the async-await style lately too I think V7 will be a good chance to yank the completion syntax 👀 |
||
_ request: BTPayPalEditRequest, | ||
completion: @escaping (BTPayPalAccountNonce?, Error?) -> Void | ||
) { | ||
// TODO: call API to get FI URL and return a BTPayPalNonce or Error | ||
completion(nil, nil) | ||
} | ||
|
||
/// Tokenize a PayPal request to be used with the Edit FI flow. | ||
/// | ||
/// On success, you will receive an instance of `BTPayPalAccountNonce`; on failure or user cancelation you will receive an error. | ||
/// If the user cancels out of the flow, the error code will be `.canceled`. | ||
/// | ||
/// - Parameter request: A `BTPayPalEditRequest` | ||
/// - Returns: A `BTPayPalAccountNonce` if successful | ||
/// - Throws: An `Error` describing the failure | ||
/// - Warning: This feature is currently in beta and may change or be removed in future releases. | ||
public func tokenize(_ request: BTPayPalEditRequest) async throws -> BTPayPalAccountNonce { | ||
try await withCheckedThrowingContinuation { continuation in | ||
tokenize(request) { nonce, error in | ||
if let error { | ||
continuation.resume(throwing: error) | ||
} else if let nonce { | ||
continuation.resume(returning: nonce) | ||
} | ||
} | ||
} | ||
} | ||
|
||
KunJeongPark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// MARK: - Internal Methods | ||
|
||
func handleReturn( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Foundation | ||
|
||
#if canImport(BraintreeCore) | ||
import BraintreeCore | ||
#endif | ||
|
||
/// Options for the PayPal Edit FI flow | ||
/// - Warning: This feature is currently in beta and may change or be removed in future releases. | ||
@objcMembers open class BTPayPalEditRequest: NSObject { | ||
KunJeongPark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public let token: String | ||
KunJeongPark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Initializes a PayPal Edit Request for the Edit FI flow | ||
/// - Parameters: | ||
/// - token: Required: Used to initiate tokenize call to edit funding instrument in customer's PayPal account. | ||
KunJeongPark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public init(token: String) { | ||
self.token = token | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure these files are alphabetized?