use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureTest method performVerification_postsPaymentMethodNonceToListenersWhenLookupReturnsACard.
@Test(timeout = 10000)
public void performVerification_postsPaymentMethodNonceToListenersWhenLookupReturnsACard() throws InterruptedException, InvalidArgumentException {
String clientToken = new TestClientTokenBuilder().withThreeDSecure().build();
BraintreeFragment fragment = getFragmentWithAuthorization(mActivity, clientToken);
String nonce = tokenize(fragment, new CardBuilder().cardNumber("4000000000000051").expirationDate("12/20")).getNonce();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("51", ((CardNonce) paymentMethodNonce).getLastTwo());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
ThreeDSecure.performVerification(fragment, nonce, "5");
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardWhenAuthenticationIsUnavailable.
@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardWhenAuthenticationIsUnavailable() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("69", cardNonce.getLastTwo());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_AUTHENTICATION_UNAVAILABLE).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_requestsAuthenticationWhenRequired.
@Test(timeout = 30000)
public void performVerification_requestsAuthenticationWhenRequired() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("02", cardNonce.getLastTwo());
assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
assertTrue(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/30");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
waitForView(withId(android.R.id.widget_frame));
clickWebViewText("Password:");
onDevice().pressTab().typeText("1234");
clickWebViewText("Submit");
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_callsCancelListenerWhenUpIsPressed.
@Test(timeout = 30000)
public void performVerification_callsCancelListenerWhenUpIsPressed() throws InterruptedException {
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/30");
BraintreeFragment fragment = getFragment();
fragment.addListener(new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
assertEquals(BraintreeRequestCodes.THREE_D_SECURE, requestCode);
mCountDownLatch.countDown();
}
});
ThreeDSecure.performVerification(getFragment(), cardBuilder, TEST_AMOUNT);
waitForView(withId(android.R.id.widget_frame));
onView(withContentDescription("Navigate up")).perform(click());
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardAndANullACSUrlWhenAuthenticationIsNotRequired.
@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardAndANullACSUrlWhenAuthenticationIsNotRequired() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("51", cardNonce.getLastTwo());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON_NOT_REQUIRED).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
Aggregations