use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_performsVaultRequestIfRequestPersisted.
@Test
public void onActivityResult_performsVaultRequestIfRequestPersisted() throws InvalidArgumentException, NoSuchAlgorithmException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).sessionId("session-id").build();
Venmo.authorizeAccount(fragment, true);
mockStatic(TokenizationClient.class);
Venmo.onActivityResult(fragment, Activity.RESULT_OK, new Intent());
verifyStatic();
TokenizationClient.tokenize(eq(fragment), any(VenmoAccountBuilder.class), any(PaymentMethodNonceCallback.class));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method getLaunchIntent_containsCorrectVenmoExtras.
@Test
public void getLaunchIntent_containsCorrectVenmoExtras() throws JSONException, InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
BraintreeFragment fragment = new MockFragmentBuilder().authorization(Authorization.fromString(stringFromFixture("client_token.json"))).configuration(configuration).sessionId("session-id").build();
when(fragment.getIntegrationType()).thenReturn("custom");
Intent intent = Venmo.getLaunchIntent(configuration.getPayWithVenmo(), configuration.getPayWithVenmo().getMerchantId(), fragment);
assertEquals(new ComponentName("com.venmo", "com.venmo.controller.SetupMerchantActivity"), intent.getComponent());
assertEquals("merchant-id", intent.getStringExtra(Venmo.EXTRA_MERCHANT_ID));
assertEquals("access-token", intent.getStringExtra(Venmo.EXTRA_ACCESS_TOKEN));
assertEquals("environment", intent.getStringExtra(Venmo.EXTRA_ENVIRONMENT));
JSONObject braintreeData = new JSONObject(intent.getStringExtra(Venmo.EXTRA_BRAINTREE_DATA));
JSONObject meta = braintreeData.getJSONObject("_meta");
assertNotNull(meta);
assertEquals("session-id", meta.getString("sessionId"));
assertEquals("custom", meta.getString("integration"));
assertEquals(BuildConfig.VERSION_NAME, meta.getString("version"));
assertEquals("android", meta.getString("platform"));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_doesNotPerformRequestIfTokenizationKeyUsed.
@Test
public void onActivityResult_doesNotPerformRequestIfTokenizationKeyUsed() throws NoSuchAlgorithmException, InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
mockStatic(TokenizationClient.class);
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(Authorization.fromString("sandbox_tk_abcd")).sessionId("another-session-id").build();
Venmo.authorizeAccount(fragment, true);
Venmo.onActivityResult(fragment, Activity.RESULT_OK, new Intent());
verifyStatic(times(0));
TokenizationClient.tokenize(eq(fragment), any(VenmoAccountBuilder.class), any(PaymentMethodNonceCallback.class));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_sendsAnalyticsEventWhenUnavailableAndPostException.
@Test
public void performAppSwitch_sendsAnalyticsEventWhenUnavailableAndPostException() {
Configuration configuration = getConfigurationFromFixture();
BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
Venmo.authorizeAccount(fragment, false);
ArgumentCaptor<AppSwitchNotAvailableException> captor = ArgumentCaptor.forClass(AppSwitchNotAvailableException.class);
InOrder order = inOrder(fragment);
order.verify(fragment).sendAnalyticsEvent("pay-with-venmo.selected");
order.verify(fragment).sendAnalyticsEvent("pay-with-venmo.app-switch.failed");
verify(fragment).postCallback(captor.capture());
assertEquals("Venmo is not installed", captor.getValue().getMessage());
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method authorizeAccount_postsExceptionWhenNotEnabled.
@Test
public void authorizeAccount_postsExceptionWhenNotEnabled() throws JSONException {
Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
Venmo.authorizeAccount(fragment, false);
ArgumentCaptor<AppSwitchNotAvailableException> captor = ArgumentCaptor.forClass(AppSwitchNotAvailableException.class);
verify(fragment).postCallback(captor.capture());
assertEquals("Venmo is not enabled", captor.getValue().getMessage());
}
Aggregations