Search in sources :

Example 26 with BraintreeErrorListener

use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.

the class ThreeDSecureVerificationTest method performVerification_returnsAnErrorWhenAuthenticationFails.

@Test(timeout = 30000)
public void performVerification_returnsAnErrorWhenAuthenticationFails() throws InterruptedException {
    BraintreeFragment fragment = getFragment();
    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();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_AUTHENTICATION_FAILED).expirationDate("12/30");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    waitForView(withId(android.R.id.widget_frame));
    clickWebViewText("Password:");
    onDevice().pressTab().typeText("1234");
    clickWebViewText("Submit");
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) BraintreeErrorListener(com.braintreepayments.api.interfaces.BraintreeErrorListener) AuthorizationException(com.braintreepayments.api.exceptions.AuthorizationException) InvalidArgumentException(com.braintreepayments.api.exceptions.InvalidArgumentException) Test(org.junit.Test)

Example 27 with BraintreeErrorListener

use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.

the class ThreeDSecureVerificationTest method performVerification_returnsAnUnexpectedErrorWhenIssuerIsDown.

@Test(timeout = 30000)
public void performVerification_returnsAnUnexpectedErrorWhenIssuerIsDown() throws InterruptedException {
    BraintreeFragment fragment = getFragment();
    fragment.addListener(new BraintreeErrorListener() {

        @Override
        public void onError(Exception error) {
            assertEquals("An unexpected error occurred", error.getMessage());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_ISSUER_DOWN).expirationDate("12/30");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    waitForView(withId(android.R.id.widget_frame));
    clickWebViewText("Password:");
    onDevice().pressTab().typeText("1234");
    clickWebViewText("Submit");
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) BraintreeErrorListener(com.braintreepayments.api.interfaces.BraintreeErrorListener) AuthorizationException(com.braintreepayments.api.exceptions.AuthorizationException) InvalidArgumentException(com.braintreepayments.api.exceptions.InvalidArgumentException) Test(org.junit.Test)

Aggregations

BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)27 Test (org.junit.Test)27 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)24 JSONException (org.json.JSONException)15 AuthorizationException (com.braintreepayments.api.exceptions.AuthorizationException)10 CardBuilder (com.braintreepayments.api.models.CardBuilder)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 CountDownLatch (java.util.concurrent.CountDownLatch)6 ErrorWithResponse (com.braintreepayments.api.exceptions.ErrorWithResponse)5 TestClientTokenBuilder (com.braintreepayments.api.test.TestClientTokenBuilder)5 Intent (android.content.Intent)4 BraintreePaymentResultListener (com.braintreepayments.api.interfaces.BraintreePaymentResultListener)3 PaymentMethodNoncesUpdatedListener (com.braintreepayments.api.interfaces.PaymentMethodNoncesUpdatedListener)3 UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)3 BraintreePaymentResult (com.braintreepayments.api.models.BraintreePaymentResult)3 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)3 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)3 IdealRequest (com.braintreepayments.api.models.IdealRequest)2 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)2 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)2