use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventWhenEnabled.
@Test
public void tokenize_sendGraphQLAnalyticsEventWhenEnabled() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, null);
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.started");
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventOnSuccess.
@Test
public void tokenize_sendGraphQLAnalyticsEventOnSuccess() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).graphQLSuccessResponse(stringFromFixture("response/graphql/credit_card.json")).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, new PaymentMethodNonceCallback() {
@Override
public void success(PaymentMethodNonce paymentMethodNonce) {
}
@Override
public void failure(Exception exception) {
}
});
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.success");
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_tokenizesCardsWithGraphQLWhenEnabled.
@Test
public void tokenize_tokenizesCardsWithGraphQLWhenEnabled() throws BraintreeException {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verifyZeroInteractions(fragment.getHttpClient());
verify(fragment.getGraphQLHttpClient()).post(captor.capture(), any(HttpResponseCallback.class));
assertEquals(cardBuilder.buildGraphQL(fragment.getApplicationContext(), fragment.getAuthorization()), captor.getValue());
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class CardTest method tokenize_tokenizesCvvOnly.
@Test(timeout = 10000)
public void tokenize_tokenizesCvvOnly() throws Exception {
final CountDownLatch countDownLatch = new CountDownLatch(1);
BraintreeFragment fragment = setupBraintreeFragment(TOKENIZATION_KEY);
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertNotNull(cardNonce.getBinData());
assertEquals("Unknown", cardNonce.getCardType());
assertEquals("", cardNonce.getLastFour());
assertEquals("", cardNonce.getLastTwo());
assertNotNull(cardNonce.getThreeDSecureInfo());
assertFalse(cardNonce.isDefault());
assertEquals("", cardNonce.getDescription());
assertNotNull(cardNonce.getNonce());
countDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cvv("123");
Card.tokenize(fragment, cardBuilder);
countDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder 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);
}
Aggregations