use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addListener_flushesPaymentMethodNonceCreatedCallback.
@Test
public void addListener_flushesPaymentMethodNonceCreatedCallback() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.postCallback(new CardNonce());
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method removeListener_noPaymentMethodNonceCreatedReceived.
@Test
public void removeListener_noPaymentMethodNonceCreatedReceived() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
PaymentMethodNonceCreatedListener listener = new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
fail("Listener was called");
}
};
fragment.addListener(listener);
fragment.removeListener(listener);
fragment.postCallback(new CardNonce());
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method postCallback_addsPaymentMethodNonceToCache.
@Test
public void postCallback_addsPaymentMethodNonceToCache() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
assertEquals(0, fragment.getCachedPaymentMethodNonces().size());
fragment.postCallback(new CardNonce());
assertEquals(1, fragment.getCachedPaymentMethodNonces().size());
assertTrue(fragment.getCachedPaymentMethodNonces().get(0) instanceof CardNonce);
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method postCallback_addsPaymentMethodNonceToBeginningOfCache.
@Test
public void postCallback_addsPaymentMethodNonceToBeginningOfCache() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
assertEquals(0, fragment.getCachedPaymentMethodNonces().size());
fragment.postCallback(new CardNonce());
fragment.postCallback(new PayPalAccountNonce());
assertEquals(2, fragment.getCachedPaymentMethodNonces().size());
assertTrue(fragment.getCachedPaymentMethodNonces().get(0) instanceof PayPalAccountNonce);
}
use of com.braintreepayments.api.models.CardNonce 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();
}
Aggregations