/** * Create parameters necessary for converting a token into a source * * @param tokenId the id of the {@link Token} to be converted into a source. * @return a {@link SourceParams} object that can be used to create a source. */ @NonNull public static SourceParams createSourceFromTokenParams(String tokenId) { SourceParams sourceParams = SourceParams.createCustomParams(); sourceParams.setType(Source.CARD); sourceParams.setToken(tokenId); return sourceParams; }
/** * Create parameters needed to make a Visa Checkout source. * * @param callId The payment request ID (callId) from the Visa Checkout SDK. * @return a {@link SourceParams} object that can be used to create a Visa Checkout Card Source. * * @see <a href="https://stripe.com/docs/visa-checkout">https://stripe.com/docs/visa-checkout</a> * @see <a href="https://developer.visa.com/capabilities/visa_checkout/docs">https://developer.visa.com/capabilities/visa_checkout/docs</a> */ @NonNull public static SourceParams createVisaCheckoutParams(@NonNull String callId) { return new SourceParams() .setType(Source.CARD) .setApiParameterMap( createSimpleMap(VISA_CHECKOUT, createSimpleMap(CALL_ID, callId))); }
/** * Create parameters needed to make a Masterpass source * * @param transactionId The transaction ID from the Masterpass SDK. * @param cartID A unique string that you generate to identify the purchase when creating a cart * for checkout in the Masterpass SDK. * * @return a {@link SourceParams} object that can be used to create a Masterpass Card Source. * * @see <a href="https://stripe.com/docs/masterpass">https://stripe.com/docs/masterpass</a> * @see <a href="https://developer.mastercard.com/product/masterpass">https://developer.mastercard.com/product/masterpass</a> * @see <a href="https://developer.mastercard.com/page/masterpass-merchant-mobile-checkout-sdk-for-android-v2">https://developer.mastercard.com/page/masterpass-merchant-mobile-checkout-sdk-for-android-v2</a> */ @NonNull public static SourceParams createMasterpassParams( @NonNull String transactionId, @NonNull String cartID) { final Map<String, Object> map = createSimpleMap(TRANSACTION_ID, transactionId); map.put(CART_ID, cartID); return new SourceParams() .setType(Source.CARD) .setApiParameterMap(createSimpleMap(MASTERPASS, map)); }
@Nullable String bank) { final SourceParams params = new SourceParams() .setType(Source.IDEAL) .setCurrency(Source.EURO) .setAmount(amount)
/** * Create parameters necessary to create a 3D Secure source. * * @param amount A positive integer in the smallest currency unit representing the amount to * charge the customer (e.g., 1099 for a €10.99 payment). * @param currency The currency the payment is being created in (e.g., eur). * @param returnUrl The URL the customer should be redirected to after the verification process. * @param cardID The ID of the card source. * @return a {@link SourceParams} object that can be used to create a 3D Secure source * * @see <a href="https://stripe.com/docs/sources/three-d-secure">https://stripe.com/docs/sources/three-d-secure</a> */ @NonNull public static SourceParams createThreeDSecureParams( @IntRange(from = 0) long amount, @NonNull String currency, @NonNull String returnUrl, @NonNull String cardID) { final SourceParams params = new SourceParams() .setType(Source.THREE_D_SECURE) .setCurrency(currency) .setAmount(amount) .setRedirect(createSimpleMap(FIELD_RETURN_URL, returnUrl)); params.setApiParameterMap(createSimpleMap(FIELD_CARD, cardID)); return params; }
@Nullable String statementDescriptor) { final SourceParams params = new SourceParams() .setType(Source.SOFORT) .setCurrency(Source.EURO) .setAmount(amount)
@NonNull String returnUrl) { final SourceParams params = new SourceParams() .setType(Source.ALIPAY) .setCurrency(currency) .setRedirect(createSimpleMap(FIELD_RETURN_URL, returnUrl))
@Nullable @Size(2) String country) { final SourceParams params = new SourceParams() .setType(Source.SEPA_DEBIT) .setCurrency(Source.EURO);
final SourceParams params = new SourceParams() .setAmount(amount) .setType(Source.P24) .setCurrency(currency) .setRedirect(createSimpleMap(FIELD_RETURN_URL, returnUrl));
/** * Create parameters necessary to create a Multibanco source. * * @param amount A positive integer in the smallest currency unit representing the amount to * charge the customer (e.g., 1099 for a €10.99 payment). * @param returnUrl The URL the customer should be redirected to after the authorization * process. * @param email The full email address of the customer. * @return a {@link SourceParams} object that can be used to create a Multibanco source * * @see <a href="https://stripe.com/docs/sources/multibanco">https://stripe.com/docs/sources/multibanco</a> */ @NonNull public static SourceParams createMultibancoParams( @IntRange(from = 0) long amount, @NonNull String returnUrl, @NonNull String email) { return new SourceParams() .setType(Source.MULTIBANCO) .setCurrency(Source.EURO) .setAmount(amount) .setRedirect(createSimpleMap(FIELD_RETURN_URL, returnUrl)) .setOwner(createSimpleMap(FIELD_EMAIL, email)); }
@NonNull String returnUrl) { final SourceParams params = new SourceParams() .setType(Source.ALIPAY) .setCurrency(currency) .setAmount(amount)
final SourceParams params = new SourceParams().setType(Source.CARD);
@Nullable String statementDescriptor) { final SourceParams params = new SourceParams() .setType(Source.EPS) .setCurrency(Source.EURO) .setAmount(amount)
@Nullable String statementDescriptor) { final SourceParams params = new SourceParams() .setType(Source.GIROPAY) .setCurrency(Source.EURO) .setAmount(amount)
@Nullable String preferredLanguage) { final SourceParams params = new SourceParams() .setType(Source.BANCONTACT) .setCurrency(Source.EURO) .setAmount(amount)
@Test public void createToken_createSource_returnsSource() { try { Stripe stripe = new Stripe(mContext, FUNCTIONAL_PUBLISHABLE_KEY); TestLoggingListener listener = new TestLoggingListener(true); stripe.setLoggingResponseListener(listener); Token token = stripe.createTokenSynchronous(mCard); assertNotNull(token); SourceParams sourceParams = SourceParams.createCustomParams(); sourceParams.setType(Source.CARD); sourceParams.setToken(token.getId()); Source source = stripe.createSourceSynchronous(sourceParams, FUNCTIONAL_PUBLISHABLE_KEY); assertNotNull(source); assertAllLogsAreValid(listener, 4); } catch (AuthenticationException authEx) { fail("Unexpected error: " + authEx.getLocalizedMessage()); } catch (StripeException stripeEx) { fail("Unexpected error when connecting to Stripe API: " + stripeEx.getLocalizedMessage()); } }