use of com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method postCallback_postsPaymentMethodNonceToListener.
@Test
public void postCallback_postsPaymentMethodNonceToListener() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
final AtomicBoolean wasCalled = new AtomicBoolean(false);
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertTrue(paymentMethodNonce instanceof CardNonce);
wasCalled.set(true);
}
});
fragment.postCallback(new CardNonce());
assertTrue(wasCalled.get());
}
use of com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener 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.interfaces.PaymentMethodNonceCreatedListener 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.interfaces.PaymentMethodNonceCreatedListener 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.interfaces.PaymentMethodNonceCreatedListener in project braintree_android by braintree.
the class CardTest method assertTokenizationSuccessful.
private void assertTokenizationSuccessful(String authorization, CardBuilder cardBuilder) throws Exception {
final CountDownLatch countDownLatch = new CountDownLatch(1);
BraintreeFragment fragment = setupBraintreeFragment(authorization);
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertNotNull(cardNonce.getNonce());
assertEquals("Visa", cardNonce.getCardType());
assertEquals("1111", cardNonce.getLastFour());
assertEquals("11", cardNonce.getLastTwo());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getPrepaid());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getHealthcare());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getDebit());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getDurbinRegulated());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getCommercial());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getPayroll());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getIssuingBank());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getCountryOfIssuance());
assertEquals(BinData.UNKNOWN, cardNonce.getBinData().getProductId());
assertFalse(cardNonce.getThreeDSecureInfo().wasVerified());
countDownLatch.countDown();
}
});
Card.tokenize(fragment, cardBuilder);
countDownLatch.await();
}
Aggregations