Search in sources :

Example 21 with CardNonce

use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.

the class UnionPayTest method tokenize_unionPayCredit_withExpirationMonthAndYear.

@Test(timeout = 30000)
public void tokenize_unionPayCredit_withExpirationMonthAndYear() throws InvalidArgumentException, InterruptedException {
    final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationMonth("08").expirationYear("20").cvv("123").mobileCountryCode("62").mobilePhoneNumber("1111111111");
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            assertTrue(smsCodeRequired);
            cardBuilder.enrollmentId(enrollmentId);
            cardBuilder.smsCode("12345");
            UnionPay.tokenize(mBraintreeFragment, cardBuilder);
        }
    });
    mBraintreeFragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            assertEquals("32", ((CardNonce) paymentMethodNonce).getLastTwo());
            mCountDownLatch.countDown();
        }
    });
    UnionPay.enroll(mBraintreeFragment, cardBuilder);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 22 with CardNonce

use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.

the class UnionPayTest method tokenize_unionPayCredit_withExpirationDate.

@Test(timeout = 10000)
public void tokenize_unionPayCredit_withExpirationDate() throws InvalidArgumentException, InterruptedException {
    final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationDate("08/20").cvv("123").mobileCountryCode("62").mobilePhoneNumber("1111111111");
    mBraintreeFragment.addListener(new UnionPayListener() {

        @Override
        public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
        }

        @Override
        public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
            assertTrue(smsCodeRequired);
            cardBuilder.enrollmentId(enrollmentId);
            cardBuilder.smsCode("12345");
            UnionPay.tokenize(mBraintreeFragment, cardBuilder);
        }
    });
    mBraintreeFragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            assertEquals("32", ((CardNonce) paymentMethodNonce).getLastTwo());
            mCountDownLatch.countDown();
        }
    });
    UnionPay.enroll(mBraintreeFragment, cardBuilder);
    mCountDownLatch.await();
}
Also used : UnionPayListener(com.braintreepayments.api.interfaces.UnionPayListener) UnionPayCardBuilder(com.braintreepayments.api.models.UnionPayCardBuilder) UnionPayCapabilities(com.braintreepayments.api.models.UnionPayCapabilities) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 23 with CardNonce

use of com.braintreepayments.api.models.CardNonce 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 24 with CardNonce

use of com.braintreepayments.api.models.CardNonce 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 25 with CardNonce

use of com.braintreepayments.api.models.CardNonce 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)

Aggregations

CardNonce (com.braintreepayments.api.models.CardNonce)29 Test (org.junit.Test)24 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)22 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)20 CardBuilder (com.braintreepayments.api.models.CardBuilder)12 AndroidPayCardNonce (com.braintreepayments.api.models.AndroidPayCardNonce)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 TestClientTokenBuilder (com.braintreepayments.api.test.TestClientTokenBuilder)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Intent (android.content.Intent)3 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)3 PaymentMethodNonceCallback (com.braintreepayments.api.interfaces.PaymentMethodNonceCallback)2 UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)2 PayPalAccountNonce (com.braintreepayments.api.models.PayPalAccountNonce)2 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)2 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)2 JSONObject (org.json.JSONObject)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 PowerMockito.doAnswer (org.powermock.api.mockito.PowerMockito.doAnswer)2