use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_withFailedVaultCall_sendsAnalyticsEvent.
@Test
public void onActivityResult_withFailedVaultCall_sendsAnalyticsEvent() throws InvalidArgumentException {
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").errorResponse(new AuthorizationException("Bad fingerprint")).build();
Venmo.authorizeAccount(fragment, true);
Intent responseIntent = new Intent().putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "nonce");
Venmo.onActivityResult(fragment, Activity.RESULT_OK, responseIntent);
verify(fragment).sendAnalyticsEvent(endsWith("pay-with-venmo.vault.failed"));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_whenProfileIdIsSpecified_appSwitchesWithProfileIdAndAccessToken.
@Test
public void performAppSwitch_whenProfileIdIsSpecified_appSwitchesWithProfileIdAndAccessToken() throws InvalidArgumentException, JSONException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).authorization(clientToken).configuration(configuration).build();
when(fragment.getSessionId()).thenReturn("a-session-id");
when(fragment.getIntegrationType()).thenReturn("custom");
Venmo.authorizeAccount(fragment, false, "second-pwv-profile-id");
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.VENMO));
assertEquals("com.venmo/com.venmo.controller.SetupMerchantActivity", captor.getValue().getComponent().flattenToString());
Bundle extras = captor.getValue().getExtras();
assertEquals("second-pwv-profile-id", extras.getString(Venmo.EXTRA_MERCHANT_ID));
assertEquals("access-token", extras.getString(Venmo.EXTRA_ACCESS_TOKEN));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method authorizeAccount_postsExceptionWhenNotInstalled.
@Test
public void authorizeAccount_postsExceptionWhenNotInstalled() {
Configuration configuration = getConfigurationFromFixture();
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 installed", captor.getValue().getMessage());
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentTest method fetchConfiguration_worksWithATokenizationKey.
@Test(timeout = 10000)
public void fetchConfiguration_worksWithATokenizationKey() throws InterruptedException {
final BraintreeFragment fragment = getFragmentWithAuthorization(mActivity, TOKENIZATION_KEY);
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertNotNull(configuration);
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class GooglePaymentTest method getTokenizationParameters_returnsCorrectParameters.
@Test(timeout = 5000)
public void getTokenizationParameters_returnsCorrectParameters() throws Exception {
String config = mBaseConfiguration.withAnalytics().build();
final BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, config);
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
Bundle tokenizationParameters = GooglePayment.getTokenizationParameters(fragment).getParameters();
assertEquals("braintree", tokenizationParameters.getString("gateway"));
assertEquals(configuration.getMerchantId(), tokenizationParameters.getString("braintree:merchantId"));
assertEquals(configuration.getAndroidPay().getGoogleAuthorizationFingerprint(), tokenizationParameters.getString("braintree:authorizationFingerprint"));
assertEquals("v1", tokenizationParameters.getString("braintree:apiVersion"));
assertEquals(BuildConfig.VERSION_NAME, tokenizationParameters.getString("braintree:sdkVersion"));
mLatch.countDown();
}
});
mLatch.await();
}
Aggregations