-
Notifications
You must be signed in to change notification settings - Fork 659
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
Allow stripe account to be configured on a per-request basis #2379
Conversation
Update createToken Add missing JvmOverloads
@@ -258,11 +272,15 @@ class Stripe internal constructor( | |||
* Should be called via `Activity#onActivityResult(int, int, Intent)}}` to handle the | |||
* result of a PaymentIntent automatic confirmation (see [confirmPayment]) or | |||
* manual confirmation (see [handleNextActionForPayment]}) | |||
* | |||
* TODO(smaskell): figure out if we can get account id from the intent |
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.
@mshafrir-stripe any thoughts here? It looks like the account is added as an extra on the intent in some cases, but it doesn't seem consistent
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.
You can skip adding it here. We should be passing it through the Intent.
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.
We should be but we aren't. Is that going to be a problem? If we don't add it here then doesn't that mean we have to also not add it in confirmPayment? Otherwise you could do something like this
val stripe = new Stripe(acct_1)
stripe.confirmPayment(this, params, acct_2)
...
stripe.onPaymentResult(requestCode, intent, callback) // uses acc_1 even though payment was for acct_2
Should we avoid adding support here (and other places that use onActivityResult) and follow up on that later?
@@ -1256,6 +1363,7 @@ class Stripe internal constructor( | |||
|
|||
private fun createToken( | |||
tokenParams: TokenParams, | |||
stripeAccountId: String?, |
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.
you can set this to this.stripeAccountId
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 stripeAccountId
come after idempotencyKey
in the args?
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.
👍 on args order. imo, since this is a private method, stripeAccountId should be required so that we don't accidentally forget to supply it somewhere. Let the compiler catch anywhere that might need to be updated, instead of just letting a bunch of places silently continue using the default when they shouldn't be. Don't feel too strongly about that though.
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.
oh I had it in this order because I feel like we typically put required params before optional ones (except for the callback which should be last)
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.
that makes sense
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.
@mshafrir-stripe @smaskell-stripe
This just for discussion sake, do you think it is better or recommended to put idempotencyKey
stripeAccount
Or is there any reason we could not re-use something like
internal data class Options internal constructor( |
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.
Either way seems fine to me. We're creating the request options in this function anyway but we could make them a parameter.
@@ -258,11 +272,15 @@ class Stripe internal constructor( | |||
* Should be called via `Activity#onActivityResult(int, int, Intent)}}` to handle the | |||
* result of a PaymentIntent automatic confirmation (see [confirmPayment]) or | |||
* manual confirmation (see [handleNextActionForPayment]}) | |||
* | |||
* TODO(smaskell): figure out if we can get account id from the intent |
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.
You can skip adding it here. We should be passing it through the Intent.
@aliriaz-stripe - Would you mind doing a quick pass on this to make sure it aligns with ANDROID-247? |
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.
LGTM
Summary
Adds a stripeAccountId parameter to most methods in Stripe.kt
Note: This does not update
These will be updated later as they require passing the stripe account id through the intent
Motivation
ANDROID-247
Testing
Unit tests still pass