/** * @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; }
@Test public void createTokenSynchronous_withValidAccount_passesIntegrationTest() { try { final Address exampleAddress = new Address .Builder() .setCity("SF") .setCountry("US") .setState("CA").build(); final Map<String, Object> exampleLegalEntity = new HashMap<String, Object>() {{ put("personal_address", exampleAddress.toMap()); put("type", "individual"); put("ssn_last_4", "1234"); put("first_name", "Kathy"); put("last_name", "Sun"); }}; Stripe stripe = new Stripe(mContext, FUNCTIONAL_PUBLISHABLE_KEY); TestLoggingListener listener = new TestLoggingListener(true); stripe.setLoggingResponseListener(listener); Token token = stripe.createAccountTokenSynchronous( AccountParams.createAccountParams(true, exampleLegalEntity)); assertNotNull(token); assertEquals(Token.TYPE_ACCOUNT, token.getType()); assertFalse(token.getLivemode()); assertFalse(token.getUsed()); assertNotNull(token.getId()); assertAllLogsAreValid(listener, 2); } catch (StripeException stripeEx) { fail(stripeEx.getMessage()); } }
return StripeApiHandler.createToken( mContext, accountParams.toParamMap(), requestOptions, Token.TYPE_ACCOUNT,
stripe.setLoggingResponseListener(listener); Token token = stripe.createAccountTokenSynchronous( AccountParams.createAccountParams(false, exampleLegalEntity)); assertNotNull(token); assertEquals(Token.TYPE_ACCOUNT, token.getType());