@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(); } }
@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()); } }
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue());
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue());
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(sofortSource); assertNotNull(sofortSource.getClientSecret()); assertNotNull(sofortSource.getId()); assertEquals(Source.SOFORT, sofortSource.getType());
assertEquals(50000L, threeDSource.getAmount().longValue()); assertEquals("brl", threeDSource.getCurrency()); assertNotNull(threeDSource.getClientSecret()); assertNotNull(threeDSource.getId()); assertNull(threeDSource.getSourceTypeModel());
@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()); } }
assertNotNull(bancontactSource); assertNotNull(bancontactSource.getId()); assertNotNull(bancontactSource.getClientSecret()); assertEquals(Source.BANCONTACT, bancontactSource.getType()); assertEquals(1000L, bancontactSource.getAmount().longValue());
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(idealSource); assertNotNull(idealSource.getClientSecret()); assertNotNull(idealSource.getId()); assertEquals(5500L, idealSource.getAmount().longValue());
String clientSecret = threeDSource.getClientSecret();
stripe.createSourceSynchronous(params); assertNotNull(giropaySource); assertNotNull(giropaySource.getClientSecret()); assertNotNull(giropaySource.getId()); assertEquals("eur", giropaySource.getCurrency());
@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()); } }
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType());
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType());
stripe.createSourceSynchronous(params, FUNCTIONAL_SOURCE_PUBLISHABLE_KEY); assertNotNull(sepaDebitSource); assertNotNull(sepaDebitSource.getClientSecret()); assertNotNull(sepaDebitSource.getId()); assertEquals(Source.SEPA_DEBIT, sepaDebitSource.getType());
stripe.createSourceSynchronous(params); assertNotNull(cardSource); assertNotNull(cardSource.getClientSecret()); assertNotNull(cardSource.getId()); assertEquals(Source.CARD, cardSource.getType());