private void addToList(@Nullable Source source) { if (source == null || !Source.CARD.equals(source.getType())) { return; } SourceCardData sourceCardData = (SourceCardData) source.getSourceTypeModel(); String endingIn = getString(R.string.endingIn); Map<String, String> map = new HashMap<>(); map.put("last4", endingIn + " " + sourceCardData.getLast4()); map.put("tokenId", source.getId()); mCardSources.add(map); mSimpleAdapter.notifyDataSetChanged(); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.getData() != null && intent.getData().getQuery() != null) { // The client secret and source ID found here is identical to // that of the source used to get the redirect URL. String clientSecret = intent.getData().getQueryParameter(QUERY_CLIENT_SECRET); String sourceId = intent.getData().getQueryParameter(QUERY_SOURCE_ID); if (clientSecret != null && sourceId != null && clientSecret.equals(mRedirectSource.getClientSecret()) && sourceId.equals(mRedirectSource.getId())) { updateSourceList(mRedirectSource); mRedirectSource = null; } mRedirectDialogController.dismissDialog(); } }
private void proceedWithPurchaseIf3DSCheckIsNotNecessary(Source source, String customerId) { if (source == null || !Source.CARD.equals(source.getType())) { displayError("Something went wrong - this should be rare"); return; } SourceCardData cardData = (SourceCardData) source.getSourceTypeModel(); if (SourceCardData.REQUIRED.equals(cardData.getThreeDSecureStatus())) { // In this case, you would need to ask the user to verify the purchase. // You can see an example of how to do this in the 3DS example application. // In stripe-android/example. } else { // If 3DS is not required, you can charge the source. completePurchase(source.getId(), customerId); } }
private void updateSourceList(@Nullable Source source) { if (source == null) { mRedirectAdapter.addItem( "No source found", "Stopped", "Error", "None"); return; } mRedirectAdapter.addItem( source.getStatus(), "complete", source.getId(), source.getType()); }
assertNotNull(cardSource.getId()); SourceParams threeDParams = SourceParams.createThreeDSecureParams( 5000L, "brl", "example://return", cardSource.getId()); stripe.createSourceSynchronous(threeDParams, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); String sourceId = threeDSource.getId(); String clientSecret = threeDSource.getClientSecret();
assertNotNull(cardSource.getId()); SourceParams threeDParams = SourceParams.createThreeDSecureParams( 50000L, "brl", "example://return", cardSource.getId()); Map<String, String> metamap = new HashMap<String, String>() {{ put("dimensions", "three"); assertEquals("brl", threeDSource.getCurrency()); assertNotNull(threeDSource.getClientSecret()); assertNotNull(threeDSource.getId()); assertNull(threeDSource.getSourceTypeModel()); assertEquals(Source.THREE_D_SECURE, threeDSource.getType());
@Test public void createSourceSynchronous_withSepaDebitParamsWithMinimalValues_passesIntegrationTest() { Stripe stripe = getNonLoggingStripe(mContext); String validIban = "DE89370400440532013000"; SourceParams params = SourceParams.createSepaDebitParams( "Sepa Account Holder", validIban, null, null, null, null, null); Map<String, String> metamap = new HashMap<String, String>() {{ put("water source", "well"); put("type", "brackish"); put("value", "100000"); }}; params.setMetaData(metamap); try { Source sepaDebitSource = stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType()); JsonTestUtils.assertMapEquals(metamap ,sepaDebitSource.getMetaData()); } catch (StripeException stripeEx) { fail("Unexpected error: " + stripeEx.getLocalizedMessage()); } }
assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue()); assertEquals(Source.IDEAL, idealSource.getType());
assertNotNull(sofortSource); assertNotNull(sofortSource.getClientSecret()); assertNotNull(sofortSource.getId()); assertEquals(Source.SOFORT, sofortSource.getType()); assertEquals("eur", sofortSource.getCurrency());
assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue()); assertEquals(Source.IDEAL, idealSource.getType());
@Test public void createSourceSynchronous_withAlipaySingleUseParams_passesIntegrationTest() { Stripe stripe = getNonLoggingStripe(mContext); SourceParams alipayParams = SourceParams.createAlipaySingleUseParams( 1000L, "usd", "Example Payer", "abc@def.com", "stripe://start"); try { Source alipaySource = stripe.createSourceSynchronous(alipayParams, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(alipaySource); assertNotNull(alipaySource.getId()); assertNotNull(alipaySource.getClientSecret()); assertNotNull(alipaySource.getAmount()); assertEquals(1000L, alipaySource.getAmount().longValue()); assertEquals(Source.ALIPAY, alipaySource.getType()); assertEquals("redirect", alipaySource.getFlow()); assertNotNull(alipaySource.getOwner()); assertEquals("Example Payer", alipaySource.getOwner().getName()); assertEquals("abc@def.com", alipaySource.getOwner().getEmail()); assertEquals("usd", alipaySource.getCurrency()); assertEquals(Source.SINGLE_USE, alipaySource.getUsage()); assertNotNull(alipaySource.getRedirect()); assertEquals("stripe://start", alipaySource.getRedirect().getReturnUrl()); } catch (StripeException stripeEx) { fail("Unexpected error: " + stripeEx.getLocalizedMessage()); } }
stripe.createSourceSynchronous(bancontactParams, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(bancontactSource); assertNotNull(bancontactSource.getId()); assertNotNull(bancontactSource.getClientSecret()); assertEquals(Source.BANCONTACT, bancontactSource.getType());
assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue()); assertEquals(Source.IDEAL, idealSource.getType());
assertNotNull(giropaySource); assertNotNull(giropaySource.getClientSecret()); assertNotNull(giropaySource.getId()); assertEquals("eur", giropaySource.getCurrency()); assertEquals(2000L, giropaySource.getAmount().longValue());
@Test public void createSourceSynchronous_withAlipayReusableParams_passesIntegrationTest() { Stripe stripe = getNonLoggingStripe(mContext); SourceParams alipayParams = SourceParams.createAlipayReusableParams( "usd", "Example Payer", "abc@def.com", "stripe://start"); try { Source alipaySource = stripe.createSourceSynchronous(alipayParams, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(alipaySource); assertNotNull(alipaySource.getId()); assertNotNull(alipaySource.getClientSecret()); assertEquals(Source.ALIPAY, alipaySource.getType()); assertEquals("redirect", alipaySource.getFlow()); assertNotNull(alipaySource.getOwner()); assertEquals("Example Payer", alipaySource.getOwner().getName()); assertEquals("abc@def.com", alipaySource.getOwner().getEmail()); assertEquals("usd", alipaySource.getCurrency()); assertEquals(Source.REUSABLE, alipaySource.getUsage()); assertNotNull(alipaySource.getRedirect()); assertEquals("stripe://start", alipaySource.getRedirect().getReturnUrl()); } catch (StripeException stripeEx) { fail("Unexpected error: " + stripeEx.getLocalizedMessage()); } }
@Test public void createSourceSynchronous_withP24Params_passesIntegrationTest() { Stripe stripe = getNonLoggingStripe(mContext); SourceParams p24Params = SourceParams.createP24Params( 100, "eur", "Example Payer", "abc@def.com", "stripe://start"); try { Source p24Source = stripe.createSourceSynchronous(p24Params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(p24Source); assertNotNull(p24Source.getId()); assertNotNull(p24Source.getClientSecret()); assertEquals(Source.P24, p24Source.getType()); assertEquals("redirect", p24Source.getFlow()); assertNotNull(p24Source.getOwner()); assertEquals("Example Payer", p24Source.getOwner().getName()); assertEquals("abc@def.com", p24Source.getOwner().getEmail()); assertEquals("eur", p24Source.getCurrency()); assertEquals(Source.SINGLE_USE, p24Source.getUsage()); assertNotNull(p24Source.getRedirect()); assertEquals("stripe://start", p24Source.getRedirect().getReturnUrl()); } catch (StripeException stripeEx) { fail("Unexpected error: " + stripeEx.getLocalizedMessage()); } }
assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType()); assertNotNull(sepaDebitSource.getSourceTypeData());
assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType()); assertNotNull(sepaDebitSource.getSourceTypeData());
assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType()); assertNotNull(sepaDebitSource.getSourceTypeData());
assertNotNull(cardSource); assertNotNull(cardSource.getClientSecret()); assertNotNull(cardSource.getId()); assertEquals(Source.CARD, cardSource.getType()); assertNotNull(cardSource.getSourceTypeData());