use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardAfterATimeout.
@Test(timeout = 30000)
public void performVerification_doesALookupAndReturnsACardAfterATimeout() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("44", 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_LOOKUP_TIMEOUT).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_returnsASuccessfulAuthenticationWhenIssuerDoesNotParticipate.
@Test(timeout = 30000)
public void performVerification_returnsASuccessfulAuthenticationWhenIssuerDoesNotParticipate() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("01", 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_ISSUER_DOES_NOT_PARTICIPATE).expirationDate("12/30");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardWhenThereIsAMPILookupError.
@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardWhenThereIsAMPILookupError() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("85", 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_MPI_LOOKUP_ERROR).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class CardActivity method onPaymentMethodNonceCreated.
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
super.onPaymentMethodNonceCreated(paymentMethodNonce);
if (!mThreeDSecureRequested && paymentMethodNonce instanceof CardNonce && Settings.isThreeDSecureEnabled(this)) {
mThreeDSecureRequested = true;
mLoading = ProgressDialog.show(this, getString(R.string.loading), getString(R.string.loading), true, false);
ThreeDSecure.performVerification(mBraintreeFragment, paymentMethodNonce.getNonce(), "1");
} else if (paymentMethodNonce instanceof CardNonce && Settings.isAmexRewardsBalanceEnabled(this)) {
mLoading = ProgressDialog.show(this, getString(R.string.loading), getString(R.string.loading), true, false);
AmericanExpress.getRewardsBalance(mBraintreeFragment, paymentMethodNonce.getNonce(), "USD");
} else {
Intent intent = new Intent().putExtra(MainActivity.EXTRA_PAYMENT_RESULT, paymentMethodNonce).putExtra(MainActivity.EXTRA_DEVICE_DATA, mDeviceData);
setResult(RESULT_OK, intent);
finish();
}
}
Aggregations