Search in sources :

Example 6 with TestClientTokenBuilder

use of com.braintreepayments.api.test.TestClientTokenBuilder in project braintree_android by braintree.

the class BraintreeFragmentTest method setUp.

@Before
public void setUp() {
    mActivity = mActivityTestRule.getActivity();
    mClientToken = new TestClientTokenBuilder().build();
    mCountDownLatch = new CountDownLatch(1);
}
Also used : TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 7 with TestClientTokenBuilder

use of com.braintreepayments.api.test.TestClientTokenBuilder in project braintree_android by braintree.

the class CardTest method tokenize_tokenizesACardWithACustomer.

@Test(timeout = 10000)
public void tokenize_tokenizesACardWithACustomer() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20");
    assertTokenizationSuccessful(new TestClientTokenBuilder().build(), cardBuilder);
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) Test(org.junit.Test)

Example 8 with TestClientTokenBuilder

use of com.braintreepayments.api.test.TestClientTokenBuilder in project braintree_android by braintree.

the class CardTest method tokenize_tokenizesACardWithPostalCode.

@Test(timeout = 10000)
public void tokenize_tokenizesACardWithPostalCode() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").cvv("123");
    assertTokenizationSuccessful(new TestClientTokenBuilder().withPostalCodeVerification().build(), cardBuilder);
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) Test(org.junit.Test)

Example 9 with TestClientTokenBuilder

use of com.braintreepayments.api.test.TestClientTokenBuilder in project braintree_android by braintree.

the class CardTest method tokenize_tokenizesACardWithValidateFalse.

@Test(timeout = 10000)
public void tokenize_tokenizesACardWithValidateFalse() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").validate(false);
    assertTokenizationSuccessful(new TestClientTokenBuilder().build(), cardBuilder);
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) Test(org.junit.Test)

Example 10 with TestClientTokenBuilder

use of com.braintreepayments.api.test.TestClientTokenBuilder in project braintree_android by braintree.

the class CardTest method tokenize_callsErrorCallbackForInvalidCvv.

@Test(timeout = 10000)
public void tokenize_callsErrorCallbackForInvalidCvv() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").cvv("200");
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    BraintreeFragment fragment = setupBraintreeFragment(new TestClientTokenBuilder().withCvvVerification().build());
    fragment.addListener(new BraintreeErrorListener() {

        @Override
        public void onError(Exception error) {
            assertEquals("CVV verification failed", ((ErrorWithResponse) error).errorFor("creditCard").getFieldErrors().get(0).getMessage());
            countDownLatch.countDown();
        }
    });
    Card.tokenize(fragment, cardBuilder);
    countDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) BraintreeErrorListener(com.braintreepayments.api.interfaces.BraintreeErrorListener) JSONException(org.json.JSONException) AuthorizationException(com.braintreepayments.api.exceptions.AuthorizationException) Test(org.junit.Test)

Aggregations

TestClientTokenBuilder (com.braintreepayments.api.test.TestClientTokenBuilder)19 Test (org.junit.Test)16 CardBuilder (com.braintreepayments.api.models.CardBuilder)14 CountDownLatch (java.util.concurrent.CountDownLatch)7 BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)5 AuthorizationException (com.braintreepayments.api.exceptions.AuthorizationException)4 CardNonce (com.braintreepayments.api.models.CardNonce)4 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)4 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)3 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)3 JSONException (org.json.JSONException)3 Before (org.junit.Before)3 ThreeDSecureRequest (com.braintreepayments.api.models.ThreeDSecureRequest)2 ErrorWithResponse (com.braintreepayments.api.exceptions.ErrorWithResponse)1 PaymentMethodNoncesUpdatedListener (com.braintreepayments.api.interfaces.PaymentMethodNoncesUpdatedListener)1 Configuration (com.braintreepayments.api.models.Configuration)1 ThreeDSecureInfo (com.braintreepayments.api.models.ThreeDSecureInfo)1 HttpURLConnection (java.net.HttpURLConnection)1