-
Notifications
You must be signed in to change notification settings - Fork 662
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
90 changes: 90 additions & 0 deletions
90
stripe/src/main/java/com/stripe/android/model/AccountParams.java
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,90 @@ | ||
package com.stripe.android.model; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static com.stripe.android.StripeNetworkUtils.removeNullAndEmptyParams; | ||
|
||
/** | ||
* Represents a grouping of parameters needed to create a Token for a Connect account on the server. | ||
*/ | ||
public class AccountParams { | ||
|
||
static final String API_PARAM_LEGAL_ENTITY = "legal_entity"; | ||
static final String API_TOS_SHOWN_AND_ACCEPTED = "tos_shown_and_accepted"; | ||
private Boolean mTosShownAndAccepted; | ||
private Map<String, Object> mLegalEntity; | ||
|
||
/** | ||
* @param tosShownAndAccepted indicates that the platform showed the user the appropriate text | ||
* 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 fields specified by legal_entity in the | ||
* API docs. | ||
* | ||
* See {@linktourl https://stripe.com/docs/api#account_object-legal_entity} | ||
* | ||
* The object in the map is expected to be a string or a list or map of | ||
* strings. All {@link StripeJsonModel} types have a toMap() function that | ||
* can be used to convert the {@link StripeJsonModel} to map representation | ||
* that can be passed in here. | ||
*/ | ||
public static AccountParams createAccountParams( | ||
boolean tosShownAndAccepted, | ||
Map<String, Object> legalEntity) { | ||
AccountParams accountParams = new AccountParams() | ||
.setTosShownAndAccepted(tosShownAndAccepted) | ||
.setLegalEntity(legalEntity); | ||
return accountParams; | ||
} | ||
|
||
/** | ||
* @param tosShownAndAccepted whether the platform showed the user the appropriate text | ||
* and links to Stripe's terms of service. Tokens will only generated | ||
* when this is true. | ||
* @return {@code this}, for chaining purposes | ||
*/ | ||
public AccountParams setTosShownAndAccepted(boolean tosShownAndAccepted) { | ||
mTosShownAndAccepted = tosShownAndAccepted; | ||
return this; | ||
} | ||
|
||
/** | ||
* @param legalEntity map that specifies the legal entity for which the connect account is being | ||
* created. Can contain any of the fields specified by legal_entity in the | ||
* API docs. | ||
* | ||
* See {@linktourl https://stripe.com/docs/api#account_object-legal_entity} | ||
* | ||
* The object in the map is expected to be a string or a list or map of | ||
* strings. All {@link StripeJsonModel} types have a toMap() function that | ||
* can be used to convert the {@link StripeJsonModel} to map representation | ||
* that can be passed in here. | ||
* @return {@code this}, for chaining purposes | ||
*/ | ||
public AccountParams setLegalEntity(Map<String, Object> legalEntity) { | ||
mLegalEntity = legalEntity; | ||
return this; | ||
} | ||
|
||
/** | ||
* Create a string-keyed map representing this object that is | ||
* ready to be sent over the network. | ||
* | ||
* @return a String-keyed map | ||
*/ | ||
@NonNull | ||
public Map<String, Object> toParamMap() { | ||
Map<String, Object> networkReadyMap = new HashMap<>(); | ||
Map<String, Object> tokenMap = new HashMap<>(); | ||
tokenMap.put(API_TOS_SHOWN_AND_ACCEPTED, mTosShownAndAccepted); | ||
tokenMap.put(API_PARAM_LEGAL_ENTITY, mLegalEntity); | ||
networkReadyMap.put("account", tokenMap); | ||
removeNullAndEmptyParams(networkReadyMap); | ||
return networkReadyMap; | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -12,16 +12,19 @@ | |
import java.util.Date; | ||
|
||
/** | ||
* The model of a Stripe card token. | ||
* Tokenization is the process Stripe uses to collect sensitive card, bank account details, Stripe | ||
* account details or personally identifiable information (PII), directly from your customers in a | ||
* secure manner. A Token representing this information is returned to you to use. | ||
*/ | ||
public class Token implements StripePaymentSource { | ||
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. The documentation of the |
||
|
||
@Retention(RetentionPolicy.SOURCE) | ||
@StringDef({TYPE_CARD, TYPE_BANK_ACCOUNT, TYPE_PII}) | ||
@StringDef({TYPE_CARD, TYPE_BANK_ACCOUNT, TYPE_PII, TYPE_ACCOUNT}) | ||
public @interface TokenType {} | ||
public static final String TYPE_CARD = "card"; | ||
public static final String TYPE_BANK_ACCOUNT = "bank_account"; | ||
public static final String TYPE_PII = "pii"; | ||
public static final String TYPE_ACCOUNT = "account"; | ||
|
||
// The key for these object fields is identical to their retrieved values | ||
// from the Type field. | ||
|
@@ -85,12 +88,13 @@ public Token( | |
*/ | ||
public Token( | ||
String id, | ||
String type, | ||
boolean livemode, | ||
Date created, | ||
Boolean used | ||
) { | ||
mId = id; | ||
mType = TYPE_PII; | ||
mType = type; | ||
mCreated = created; | ||
mCard = null; | ||
mBankAccount = null; | ||
|
@@ -192,10 +196,9 @@ public static Token fromJson(@Nullable JSONObject jsonObject) { | |
} | ||
Card card = Card.fromJson(cardObject); | ||
token = new Token(tokenId, liveMode, date, used, card); | ||
} else if (Token.TYPE_PII.equals(tokenType)) { | ||
token = new Token(tokenId, liveMode, date, used); | ||
} else if (Token.TYPE_PII.equals(tokenType) || Token.TYPE_ACCOUNT.equals(tokenType)) { | ||
token = new Token(tokenId, tokenType, liveMode, date, used); | ||
} | ||
|
||
return token; | ||
} | ||
|
||
|
@@ -219,6 +222,8 @@ static String asTokenType(@Nullable String possibleTokenType) { | |
return Token.TYPE_BANK_ACCOUNT; | ||
} else if (Token.TYPE_PII.equals(possibleTokenType)) { | ||
return Token.TYPE_PII; | ||
} else if (Token.TYPE_ACCOUNT.equals(possibleTokenType)) { | ||
return Token.TYPE_ACCOUNT; | ||
} | ||
|
||
return null; | ||
|
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.
You might document what this does if
publishableKey
isnull
.