use of com.braintreepayments.api.interfaces.ConfigurationListener in project braintree_android by braintree.
the class MockFragmentBuilder method build.
public BraintreeFragment build() {
BraintreeFragment fragment = mock(BraintreeFragment.class);
when(fragment.getApplicationContext()).thenReturn(mContext);
when(fragment.getAuthorization()).thenReturn(mAuthorization);
when(fragment.getSessionId()).thenReturn(mSessionId);
when(fragment.getReturnUrlScheme()).thenReturn("com.braintreepayments.api.braintree");
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ConfigurationListener) invocation.getArguments()[0]).onConfigurationFetched(mConfiguration);
return null;
}
}).when(fragment).waitForConfiguration(any(ConfigurationListener.class));
when(fragment.getConfiguration()).thenReturn(mConfiguration);
BraintreeHttpClient httpClient = mock(BraintreeHttpClient.class);
if (mSuccessResponse != null) {
setupSuccessResponses(httpClient);
} else if (mErrorResponse != null) {
setupErrorResponses(httpClient);
}
when(fragment.getHttpClient()).thenReturn(httpClient);
BraintreeGraphQLHttpClient graphQLHttpClient = mock(BraintreeGraphQLHttpClient.class);
if (mGraphQLSuccessResponse != null) {
setupGraphQLSuccessResponses(graphQLHttpClient);
} else if (mGraphQLErrorResponse != null) {
setupGraphQLErrorResponses(graphQLHttpClient);
}
when(fragment.getGraphQLHttpClient()).thenReturn(graphQLHttpClient);
return fragment;
}
use of com.braintreepayments.api.interfaces.ConfigurationListener 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.interfaces.ConfigurationListener 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();
}
use of com.braintreepayments.api.interfaces.ConfigurationListener in project braintree_android by braintree.
the class GooglePaymentTest method getTokenizationParameters_doesNotIncludeATokenizationKeyWhenNotPresent.
@Test(timeout = 5000)
public void getTokenizationParameters_doesNotIncludeATokenizationKeyWhenNotPresent() throws Exception {
final BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), stringFromFixture("client_token.json"), mBaseConfiguration.build());
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
Bundle tokenizationParameters = GooglePayment.getTokenizationParameters(fragment).getParameters();
assertNull(tokenizationParameters.getString("braintree:clientKey"));
mLatch.countDown();
}
});
mLatch.countDown();
}
use of com.braintreepayments.api.interfaces.ConfigurationListener in project braintree_android by braintree.
the class DataCollector method startDeviceCollector.
private static void startDeviceCollector(final BraintreeFragment fragment, final String merchantId, final String deviceSessionId, @Nullable final BraintreeResponseListener<String> listener) throws ClassNotFoundException, NumberFormatException {
fragment.sendAnalyticsEvent("data-collector.kount.started");
Class.forName(com.kount.api.DataCollector.class.getName());
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
final com.kount.api.DataCollector dataCollector = com.kount.api.DataCollector.getInstance();
dataCollector.setContext(fragment.getApplicationContext());
dataCollector.setMerchantID(Integer.parseInt(merchantId));
dataCollector.setLocationCollectorConfig(com.kount.api.DataCollector.LocationConfig.COLLECT);
dataCollector.setEnvironment(getDeviceCollectorEnvironment(configuration.getEnvironment()));
dataCollector.collectForSession(deviceSessionId, new com.kount.api.DataCollector.CompletionHandler() {
@Override
public void completed(String sessionID) {
fragment.sendAnalyticsEvent("data-collector.kount.succeeded");
if (listener != null) {
listener.onResponse(sessionID);
}
}
@Override
public void failed(String sessionID, final com.kount.api.DataCollector.Error error) {
fragment.sendAnalyticsEvent("data-collector.kount.failed");
if (listener != null) {
listener.onResponse(sessionID);
}
}
});
}
});
}
Aggregations