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

Bindings to support Custom Connect onboarding in Europe #492

Merged
merged 3 commits into from
Dec 19, 2017

Conversation

ksun-stripe
Copy link

Add bindings to support custom connect onboarding in Europe. I opted against creating a custom object for legal entity because of longer term maintainability concerns.

r? @danj-stripe
cc: @basta-stripe @timpeacock-stripe @bg-stripe

@ksun-stripe ksun-stripe force-pushed the ksun-connect-bindings branch from 4622d37 to 0086c36 Compare December 15, 2017 00:15
@basta-stripe
Copy link

<3

Copy link
Contributor

@danj-stripe danj-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions, and suggested places to improve docs

throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
CardException,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature also says this throws CardException, but it's not covered by the documentation block. The createPii methods have the same problem. Maybe just a copy/paste error from createToken?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it deeper into the code, looks like this is because StripeAPIHandler.createToken() can throw CardException. For PII & Connect Account creation, I think you should probably "catch & swallow" CardException (only if it cannot happen, obviously). This prevents the underlying implementation (that you're sharing a method) from leaking to clients of the SDK. Otherwise I think it'd be good to document under what conditions it'd be thrown.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you might want to update variable names, etc, in StripeAPIHandler.createToken() - things like cardParams are now more general than just cards.

*/
public Token createAccountTokenSynchronous(
@NonNull final AccountParams accountParams,
@Nullable String publishableKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might document what this does if publishableKey is null.

validateKey(publishableKey);
RequestOptions requestOptions = RequestOptions.builder(
publishableKey,
null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other create token methods pass in mStripeAccount. Why don't we want to do that here? (also, looks like there're constructors for RequestOptions that just take the key and request type, which seems possibly better than null)

Copy link
Author

@ksun-stripe ksun-stripe Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that this is the function for creating a Stripe account so there should never be a pre-existing Stripe Account passed to it...since we're creating it with this function. In particular, I was concerned this would be cause unexpected server behavior since the token can be used for updates as well. Ex: somehow the user has an only StripeAccount string saved in the Stripe object and goes to create a new account with a new legal entity and accidentally changes their old legal entity.

EDIT: I checked and it doesn't cause issues.

On account updates:
https://docs.google.com/document/d/1mmDgLjhbV8AuR_Ulxu6KULF4kemz3SNoUHTxco8b0u8/edit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I like this method better:

public static RequestOptions.RequestOptionsBuilder builder(
@Nullable String publishableApiKey,
@NonNull @RequestType String requestType) {

@@ -17,11 +17,12 @@
public class Token implements StripePaymentSource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation of the Token class should be updated. It's no longer just a card. I'd also link to the docs for Token, which is probably a good place to borrow text from. https://stripe.com/docs/api#tokens

* and links to Stripe's terms of service. Tokens will only generated
* when this is true.
* @param legalEntity map that specifies the legal entity for which the connect account is being
* created. Can contain any of the field specified by legal_entity is the API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos: "any of the fields specified by legal_entity in the API"

Same typos below

* @return {@code this}, for chaining purposes
*/
public AccountParams setLegalEntity(Map<String, Object> legalEntity) {
mLegalEntity = legalEntity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concerns about validating that the user hasn't stuck something non-serializable into the legalEntity?

For example, I'm not sure what happens if they try to use com.stripe.android.model.Address objects instead of a Map<String, Object> for legal_entity.address.

I followed some of the code down, and it looked like the networking code was going to eventually call to flattenParamsValue(), which I don't think handles model objects.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm...yes...that is a good concern. we should check that.

Copy link
Contributor

@danj-stripe danj-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good otherwise!

@ksun-stripe ksun-stripe merged commit b8e3909 into master Dec 19, 2017
@mshafrir-stripe mshafrir-stripe deleted the ksun-connect-bindings branch January 24, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants