use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeGraphQLHttpClientTest method getRequestSslCertificateSuccessfulInProduction.
@Test(timeout = 5000)
public void getRequestSslCertificateSuccessfulInProduction() throws InterruptedException, InvalidArgumentException {
BraintreeGraphQLHttpClient httpClient = new BraintreeGraphQLHttpClient("https://payments.braintree-api.com/graphql", TOKENIZATION_KEY);
httpClient.get("/", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
mCountDownLatch.countDown();
}
@Override
public void failure(Exception exception) {
assertFalse(exception instanceof SSLException);
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeHttpClientTest method getRequestBadCertificateCheck.
@Test(timeout = 5000)
public void getRequestBadCertificateCheck() throws InterruptedException, InvalidArgumentException {
if (!BuildConfig.RUN_ALL_TESTS) {
return;
}
BraintreeHttpClient httpClient = new BraintreeHttpClient(TokenizationKey.fromString(TOKENIZATION_KEY));
httpClient.setBaseUrl("https://" + EnvironmentHelper.getLocalhostIp() + ":9443");
httpClient.get("/", new HttpResponseCallback() {
@Override
public void success(String responseBody) {
fail("Request was successful");
}
@Override
public void failure(Exception exception) {
assertEquals("java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.", exception.getMessage());
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class IdealActivity method onBraintreePaymentResult.
@Override
public void onBraintreePaymentResult(BraintreePaymentResult result) {
super.onBraintreePaymentResult(result);
IdealResult idealResult = (IdealResult) result;
if (!mIsPolling && !("COMPLETE".equals(idealResult.getStatus()))) {
try {
Ideal.pollForCompletion(mBraintreeFragment, idealResult.getId(), 1, 1000);
mIsPolling = true;
} catch (InvalidArgumentException e) {
onError(e);
}
} else {
Intent intent = new Intent().putExtra(MainActivity.EXTRA_PAYMENT_RESULT, result);
setResult(Activity.RESULT_OK, intent);
finish();
}
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class IdealUnitTest method fetchIssuingBanks_postsConfigurationExceptionWhenIdealNotEnabled.
@Test
public void fetchIssuingBanks_postsConfigurationExceptionWhenIdealNotEnabled() throws InvalidArgumentException {
Configuration configuration = new TestConfigurationBuilder().braintreeApi(new TestBraintreeApiConfigurationBuilder().accessToken("access-token").url("http://api.braintree.com")).buildConfiguration();
BraintreeFragment fragment = getMockFragment(stringFromFixture("client_token.json"), configuration);
Ideal.fetchIssuingBanks(fragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
fail("Success listener called");
}
});
ArgumentCaptor<Exception> captor = ArgumentCaptor.forClass(Exception.class);
verify(fragment).postCallback(captor.capture());
Exception e = captor.getValue();
assertEquals("iDEAL is not enabled for this merchant.", e.getMessage());
}
use of com.braintreepayments.api.exceptions.InvalidArgumentException in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addListener_flushesErrorWithResponseCallback.
@Test
public void addListener_flushesErrorWithResponseCallback() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.postCallback(new ErrorWithResponse(422, ""));
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof ErrorWithResponse);
assertEquals(422, ((ErrorWithResponse) error).getStatusCode());
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
Aggregations