Search in sources :

Example 16 with PaymentMethodNonceCreatedListener

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

the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardWhenAuthenticationIsUnavailable.

@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardWhenAuthenticationIsUnavailable() throws InterruptedException {
    BraintreeFragment fragment = getFragment();
    fragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("69", cardNonce.getLastTwo());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
            assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_AUTHENTICATION_UNAVAILABLE).expirationDate("12/20");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 17 with PaymentMethodNonceCreatedListener

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

the class ThreeDSecureVerificationTest method performVerification_requestsAuthenticationWhenRequired.

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

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("02", cardNonce.getLastTwo());
            assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
            assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
            assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).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) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 18 with PaymentMethodNonceCreatedListener

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

the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardAndANullACSUrlWhenAuthenticationIsNotRequired.

@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardAndANullACSUrlWhenAuthenticationIsNotRequired() throws InterruptedException {
    BraintreeFragment fragment = getFragment();
    fragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("51", cardNonce.getLastTwo());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
            assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON_NOT_REQUIRED).expirationDate("12/20");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 19 with PaymentMethodNonceCreatedListener

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

the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardAfterATimeout.

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

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("44", cardNonce.getLastTwo());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
            assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
            assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_LOOKUP_TIMEOUT).expirationDate("12/20");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 20 with PaymentMethodNonceCreatedListener

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

the class ThreeDSecureVerificationTest method performVerification_returnsASuccessfulAuthenticationWhenIssuerDoesNotParticipate.

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

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("01", cardNonce.getLastTwo());
            assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
            assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
            assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_ISSUER_DOES_NOT_PARTICIPATE).expirationDate("12/30");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Aggregations

PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)21 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)21 CardNonce (com.braintreepayments.api.models.CardNonce)20 Test (org.junit.Test)19 CardBuilder (com.braintreepayments.api.models.CardBuilder)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)3 AndroidPayCardNonce (com.braintreepayments.api.models.AndroidPayCardNonce)3 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)3 TestClientTokenBuilder (com.braintreepayments.api.test.TestClientTokenBuilder)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Intent (android.content.Intent)2 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)2 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)2 Uri (android.net.Uri)1 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)1 AmericanExpressListener (com.braintreepayments.api.interfaces.AmericanExpressListener)1 BraintreeCancelListener (com.braintreepayments.api.interfaces.BraintreeCancelListener)1 BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)1 BraintreePaymentResultListener (com.braintreepayments.api.interfaces.BraintreePaymentResultListener)1