@Test public void createAlipaySingleUseParams_withAllFields_hasExpectedFields() { final SourceParams params = SourceParams.createAlipaySingleUseParams( 1000L, "aud", "Jane Tester", "jane@test.com", "stripe://testactivity"); assertEquals(Source.ALIPAY, params.getType()); assertNotNull(params.getAmount()); assertEquals(1000L, params.getAmount().longValue()); assertEquals("aud", params.getCurrency()); assertNotNull(params.getOwner()); assertEquals("Jane Tester", params.getOwner().get("name")); assertEquals("jane@test.com", params.getOwner().get("email")); assertNotNull(params.getRedirect()); assertEquals("stripe://testactivity", params.getRedirect().get("return_url")); }
@Test public void createAlipaySingleUseParams_withoutOwner_hasNoOwnerFields() { final SourceParams params = SourceParams.createAlipaySingleUseParams( 555L, "eur", null, null, "stripe://testactivity2"); assertEquals(Source.ALIPAY, params.getType()); assertNotNull(params.getAmount()); assertEquals(555L, params.getAmount().longValue()); assertEquals("eur", params.getCurrency()); assertNull(params.getOwner()); assertNotNull(params.getRedirect()); assertEquals("stripe://testactivity2", params.getRedirect().get("return_url")); }
@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()); } }