-
Notifications
You must be signed in to change notification settings - Fork 709
StripeCryptoOnramp: API Review Feedback Part 3 #12296
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
Merged
+324
−172
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d54d56a
Turns OnrampConfiguration into a builder pattern
Twigz 707fff9
Update OnrampCoordinator.kt
Twigz b624d5b
Made OnrampCallbacks use a builder
Twigz af51c8d
mark constructors as internal
Twigz f1f2c38
Restrict State types
Twigz db5a43a
Move subtypes to builder pattern as well
Twigz e9e3dea
Fix fixtures in paymentsheet
Twigz c0ce85b
Adds some docs to OnrampConfiguration
Twigz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,7 +1,6 @@ | ||
| package com.stripe.android.crypto.onramp.model | ||
|
|
||
| import androidx.annotation.RestrictTo | ||
| import dev.drewhamilton.poko.Poko | ||
|
|
||
| /** | ||
| * Container for all callbacks required by the Onramp coordinator. | ||
|
|
@@ -12,37 +11,88 @@ import dev.drewhamilton.poko.Poko | |
| * Each callback represents a distinct stage in the onramp process and is | ||
| * invoked by the coordinator at the appropriate time. | ||
| */ | ||
| @Poko | ||
| @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
| class OnrampCallbacks( | ||
| class OnrampCallbacks { | ||
|
|
||
| private var authenticateUserCallback: OnrampAuthenticateUserCallback? = null | ||
| private var verifyIdentityCallback: OnrampVerifyIdentityCallback? = null | ||
| private var verifyKycCallback: OnrampVerifyKycCallback? = null | ||
| private var collectPaymentCallback: OnrampCollectPaymentMethodCallback? = null | ||
| private var authorizeCallback: OnrampAuthorizeCallback? = null | ||
| private var checkoutCallback: OnrampCheckoutCallback? = null | ||
|
|
||
| /** | ||
| * Callback invoked to authenticate the user before starting the onramp flow. | ||
| */ | ||
| internal val authenticateUserCallback: OnrampAuthenticateUserCallback, | ||
| fun authenticateUserCallback(callback: OnrampAuthenticateUserCallback) = apply { | ||
| this.authenticateUserCallback = callback | ||
| } | ||
|
|
||
| /** | ||
| * Callback invoked when signaling the result of verifying the user's identity. | ||
| */ | ||
| internal val verifyIdentityCallback: OnrampVerifyIdentityCallback, | ||
| fun verifyIdentityCallback(callback: OnrampVerifyIdentityCallback) = apply { | ||
| this.verifyIdentityCallback = callback | ||
| } | ||
|
|
||
| /** | ||
| * Callback invoked when KYC verification was attempted to be completed. | ||
| */ | ||
| internal val verifyKycCallback: OnrampVerifyKycCallback, | ||
| fun verifyKycCallback(callback: OnrampVerifyKycCallback) = apply { | ||
| this.verifyKycCallback = callback | ||
| } | ||
|
|
||
| /** | ||
| * Callback invoked when a payment method was attempted to be collected. | ||
| */ | ||
| internal val collectPaymentCallback: OnrampCollectPaymentMethodCallback, | ||
| fun collectPaymentCallback(callback: OnrampCollectPaymentMethodCallback) = apply { | ||
| this.collectPaymentCallback = callback | ||
| } | ||
|
|
||
| /** | ||
| * Callback invoked when gaining user authorization was attempted. | ||
| */ | ||
| internal val authorizeCallback: OnrampAuthorizeCallback, | ||
| fun authorizeCallback(callback: OnrampAuthorizeCallback) = apply { | ||
| this.authorizeCallback = callback | ||
| } | ||
|
|
||
| /** | ||
| * Callback invoked to when the checkout process has completed. | ||
| * Callback invoked when the checkout process has completed. | ||
| */ | ||
| internal val checkoutCallback: OnrampCheckoutCallback | ||
| ) | ||
| fun checkoutCallback(callback: OnrampCheckoutCallback) = apply { | ||
| this.checkoutCallback = callback | ||
| } | ||
|
|
||
| @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
| class State internal constructor( | ||
| internal val authenticateUserCallback: OnrampAuthenticateUserCallback, | ||
| internal val verifyIdentityCallback: OnrampVerifyIdentityCallback, | ||
| internal val verifyKycCallback: OnrampVerifyKycCallback, | ||
| internal val collectPaymentCallback: OnrampCollectPaymentMethodCallback, | ||
| internal val authorizeCallback: OnrampAuthorizeCallback, | ||
| internal val checkoutCallback: OnrampCheckoutCallback, | ||
| ) | ||
|
|
||
| fun build(): State { | ||
| return State( | ||
| authenticateUserCallback = requireNotNull(authenticateUserCallback) { | ||
| "authenticateUserCallback must not be null" | ||
|
Collaborator
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. Are all of these truly required? Is there zero use case for a merchant not to supply them?
Collaborator
Author
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. A merchant should supply all of them, yes. |
||
| }, | ||
| verifyIdentityCallback = requireNotNull(verifyIdentityCallback) { | ||
| "verifyIdentityCallback must not be null" | ||
| }, | ||
| verifyKycCallback = requireNotNull(verifyKycCallback) { | ||
| "verifyKycCallback must not be null" | ||
| }, | ||
| collectPaymentCallback = requireNotNull(collectPaymentCallback) { | ||
| "collectPaymentCallback must not be null" | ||
| }, | ||
| authorizeCallback = requireNotNull(authorizeCallback) { | ||
| "authorizeCallback must not be null" | ||
| }, | ||
| checkoutCallback = requireNotNull(checkoutCallback) { | ||
| "checkoutCallback must not be null" | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(not for this PR) Given the view model is the one that owns the coordinator, and is the implementor of all of these callbacks, I think it does shine a light on the fact that these should likely just move to the coordinator constructor.