use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class CardTest method tokenize_failsWithTokenizationKeyAndValidateTrue.
@Test(timeout = 10000)
public void tokenize_failsWithTokenizationKeyAndValidateTrue() throws Exception {
CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").validate(true);
final CountDownLatch countDownLatch = new CountDownLatch(1);
BraintreeFragment fragment = setupBraintreeFragment(TOKENIZATION_KEY);
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof AuthorizationException);
if (mRequestProtocol.equals(GRAPHQL)) {
assertEquals("Validation is not supported for requests authorized with a tokenization key.", error.getMessage());
} else {
assertEquals("Tokenization key authorization not allowed for this endpoint. Please use an " + "authentication method with upgraded permissions", error.getMessage());
}
countDownLatch.countDown();
}
});
Card.tokenize(fragment, cardBuilder);
countDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder 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);
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class CardTest method tokenize_tokenizesACardWithATokenizationKey.
@Test(timeout = 10000)
public void tokenize_tokenizesACardWithATokenizationKey() throws Exception {
CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20");
assertTokenizationSuccessful(TOKENIZATION_KEY, cardBuilder);
}
use of com.braintreepayments.api.models.CardBuilder 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();
}
use of com.braintreepayments.api.models.CardBuilder 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);
}
Aggregations