use of com.braintreepayments.api.models.CardNonce 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();
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class PaymentMethodTest method getPaymentMethodNonces_getsPaymentMethodsFromServer.
@Test(timeout = 10000)
public void getPaymentMethodNonces_getsPaymentMethodsFromServer() throws InterruptedException, InvalidArgumentException {
final CountDownLatch latch = new CountDownLatch(1);
final String clientToken = new TestClientTokenBuilder().build();
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, clientToken);
getInstrumentation().waitForIdleSync();
fragment.addListener(new PaymentMethodNoncesUpdatedListener() {
@Override
public void onPaymentMethodNoncesUpdated(List<PaymentMethodNonce> paymentMethodNonces) {
assertEquals(1, paymentMethodNonces.size());
assertIsANonce(paymentMethodNonces.get(0).getNonce());
assertEquals("11", ((CardNonce) paymentMethodNonces.get(0)).getLastTwo());
latch.countDown();
}
});
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
tokenize(fragment, new CardBuilder().cardNumber(VISA).expirationMonth("04").expirationYear(validExpirationYear()));
PaymentMethod.getPaymentMethodNonces(fragment);
latch.await();
}
use of com.braintreepayments.api.models.CardNonce in project braintree_android by braintree.
the class ThreeDSecureTest method onActivityResult_postsPaymentMethodNonceToListener.
@Test(timeout = 2000)
public void onActivityResult_postsPaymentMethodNonceToListener() throws JSONException, InterruptedException {
BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("11", ((CardNonce) paymentMethodNonce).getLastTwo());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
JSONObject authResponse = new JSONObject(stringFromFixture("three_d_secure/authentication_response.json"));
Intent data = new Intent().putExtra(ThreeDSecureWebViewActivity.EXTRA_THREE_D_SECURE_RESULT, ThreeDSecureAuthenticationResponse.fromJson(authResponse.toString()));
ThreeDSecure.onActivityResult(fragment, Activity.RESULT_OK, data);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardNonce 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.CardNonce in project braintree_android by braintree.
the class ThreeDSecureTest method onActivityResult_postsPaymentMethodNonceToListener_fromUri.
@Test(timeout = 1000)
public void onActivityResult_postsPaymentMethodNonceToListener_fromUri() throws JSONException, InterruptedException {
BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("11", ((CardNonce) paymentMethodNonce).getLastTwo());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
Uri responseUri = Uri.parse("http://demo-app.com").buildUpon().appendQueryParameter("auth_response", stringFromFixture("three_d_secure/authentication_response.json")).build();
Intent data = new Intent().setData(responseUri);
ThreeDSecure.onActivityResult(fragment, Activity.RESULT_OK, data);
mCountDownLatch.await();
}
Aggregations