Search in sources :

Example 11 with TestClientTokenBuilder

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

the class CardTest method tokenize_tokenizesACardWithoutACustomer.

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

Example 12 with TestClientTokenBuilder

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

the class CardTest method tokenize_tokenizesACardWithACompleteBillingAddress.

@Test(timeout = 10000)
public void tokenize_tokenizesACardWithACompleteBillingAddress() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").cvv("123").cardholderName("Joe Smith").firstName("Joe").lastName("Smith").company("Company").streetAddress("1 Main St").extendedAddress("Unit 1").locality("Some Town").postalCode("12345").region("Some Region").countryName("United States").countryCodeAlpha2("US").countryCodeAlpha3("USA").countryCodeNumeric("840");
    assertTokenizationSuccessful(new TestClientTokenBuilder().build(), cardBuilder);
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) Test(org.junit.Test)

Example 13 with TestClientTokenBuilder

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

the class IdealTest method setUp.

@Before
public void setUp() throws InvalidArgumentException {
    mCountDownLatch = new CountDownLatch(1);
    mBraintreeFragment = getFragmentWithAuthorization(mActivityTestRule.getActivity(), new TestClientTokenBuilder().withIdeal().withoutCustomer().build());
}
Also used : TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 14 with TestClientTokenBuilder

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

the class ThreeDSecureVerificationTest method performVerification_failsWithATokenizationKey.

@Test(timeout = 10000)
public void performVerification_failsWithATokenizationKey() throws InterruptedException {
    String clientToken = new TestClientTokenBuilder().withThreeDSecure().build();
    BraintreeFragment fragment = getFragment(TOKENIZATION_KEY, clientToken);
    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());
            mCountDownLatch.countDown();
        }
    });
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/20");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) AuthorizationException(com.braintreepayments.api.exceptions.AuthorizationException) BraintreeErrorListener(com.braintreepayments.api.interfaces.BraintreeErrorListener) AuthorizationException(com.braintreepayments.api.exceptions.AuthorizationException) InvalidArgumentException(com.braintreepayments.api.exceptions.InvalidArgumentException) Test(org.junit.Test)

Example 15 with TestClientTokenBuilder

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

the class CardTest method tokenize_tokenizesACardWithValidateTrue.

@Test(timeout = 10000)
public void tokenize_tokenizesACardWithValidateTrue() throws Exception {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").validate(true);
    assertTokenizationSuccessful(new TestClientTokenBuilder().build(), cardBuilder);
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) TestClientTokenBuilder(com.braintreepayments.api.test.TestClientTokenBuilder) 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