use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class IdealTest method fetchIssuingBanks_returnsIssuingBanks.
@Test(timeout = 10000)
public void fetchIssuingBanks_returnsIssuingBanks() throws InterruptedException {
Ideal.fetchIssuingBanks(mBraintreeFragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
assertFalse(idealBanks.isEmpty());
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getId()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getName()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getImageUri()));
mCountDownLatch.countDown();
}
});
mBraintreeFragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class IdealTest method startPayment_returnsError_whenOrderId_isAbsent.
@Test(timeout = 10000)
public void startPayment_returnsError_whenOrderId_isAbsent() throws InterruptedException {
IdealRequest builder = new IdealRequest().currency("EUR").amount("10").issuerId("INGBNL2A");
Ideal.startPayment(mBraintreeFragment, builder, null);
mBraintreeFragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof BraintreeApiErrorResponse);
mCountDownLatch.countDown();
}
});
mBraintreeFragment.addListener(new BraintreePaymentResultListener() {
@Override
public void onBraintreePaymentResult(BraintreePaymentResult result) {
fail("BraintreeApiErrorResponse expected");
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class PaymentMethodTest method getPaymentMethodNonces_getsPaymentMethodsFromServer.
@Test(timeout = 10000)
public void getPaymentMethodNonces_getsPaymentMethodsFromServer() throws InterruptedException, InvalidArgumentException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().build();
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, clientToken);
getInstrumentation().waitForIdleSync();
fragment.addListener(new PaymentMethodNoncesUpdatedListener() {
@Override
public void onPaymentMethodNoncesUpdated(List<PaymentMethodNonce> paymentMethodNonces) {
assertEquals(1, paymentMethodNonces.size());
assertIsANonce(paymentMethodNonces.get(0).getNonce());
assertEquals("11", ((CardNonce) paymentMethodNonces.get(0)).getLastTwo());
latch.countDown();
}
});
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
tokenize(fragment, new CardBuilder().cardNumber(VISA).expirationMonth("04").expirationYear(validExpirationYear()));
PaymentMethod.getPaymentMethodNonces(fragment);
latch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class PaymentMethodTest method getPaymentMethodNonces_failsWithATokenizationKey.
@Test(timeout = 10000)
public void getPaymentMethodNonces_failsWithATokenizationKey() throws InterruptedException, InvalidArgumentException {
final CountDownLatch latch = new CountDownLatch(1);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
getInstrumentation().waitForIdleSync();
fragment.addListener(new PaymentMethodNoncesUpdatedListener() {
@Override
public void onPaymentMethodNoncesUpdated(List<PaymentMethodNonce> paymentMethodNonces) {
fail("getPaymentMethodNonces succeeded");
}
});
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof AuthorizationException);
assertEquals("Tokenization key authorization not allowed for this endpoint. Please use an authentication method with upgraded permissions", error.getMessage());
latch.countDown();
}
});
tokenize(fragment, new CardBuilder().cardNumber(VISA).expirationMonth("04").expirationYear(validExpirationYear()));
PaymentMethod.getPaymentMethodNonces(fragment);
latch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class ThreeDSecureTest method onActivityResult_postsRecoverableErrorsToListener.
@Test(timeout = 2000)
public void onActivityResult_postsRecoverableErrorsToListener() throws InterruptedException {
BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("Failed to authenticate, please try a different form of payment", error.getMessage());
mCountDownLatch.countDown();
}
});
Intent data = new Intent().putExtra(ThreeDSecureWebViewActivity.EXTRA_THREE_D_SECURE_RESULT, ThreeDSecureAuthenticationResponse.fromJson(stringFromFixture("errors/three_d_secure_error.json")));
ThreeDSecure.onActivityResult(fragment, Activity.RESULT_OK, data);
mCountDownLatch.await();
}
Aggregations