use of com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener 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.interfaces.PaymentMethodNonceCreatedListener 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.interfaces.PaymentMethodNonceCreatedListener 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();
}
use of com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener in project braintree_android by braintree.
the class UnionPayTest method tokenize_unionPayCredit_withExpirationMonthAndYear.
@Test(timeout = 30000)
public void tokenize_unionPayCredit_withExpirationMonthAndYear() throws InvalidArgumentException, InterruptedException {
final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationMonth("08").expirationYear("20").cvv("123").mobileCountryCode("62").mobilePhoneNumber("1111111111");
mBraintreeFragment.addListener(new UnionPayListener() {
@Override
public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
}
@Override
public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
assertTrue(smsCodeRequired);
cardBuilder.enrollmentId(enrollmentId);
cardBuilder.smsCode("12345");
UnionPay.tokenize(mBraintreeFragment, cardBuilder);
}
});
mBraintreeFragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("32", ((CardNonce) paymentMethodNonce).getLastTwo());
mCountDownLatch.countDown();
}
});
UnionPay.enroll(mBraintreeFragment, cardBuilder);
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener in project braintree_android by braintree.
the class UnionPayTest method tokenize_unionPayCredit_withExpirationDate.
@Test(timeout = 10000)
public void tokenize_unionPayCredit_withExpirationDate() throws InvalidArgumentException, InterruptedException {
final UnionPayCardBuilder cardBuilder = new UnionPayCardBuilder().cardNumber(CardNumber.UNIONPAY_CREDIT).expirationDate("08/20").cvv("123").mobileCountryCode("62").mobilePhoneNumber("1111111111");
mBraintreeFragment.addListener(new UnionPayListener() {
@Override
public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
}
@Override
public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
assertTrue(smsCodeRequired);
cardBuilder.enrollmentId(enrollmentId);
cardBuilder.smsCode("12345");
UnionPay.tokenize(mBraintreeFragment, cardBuilder);
}
});
mBraintreeFragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("32", ((CardNonce) paymentMethodNonce).getLastTwo());
mCountDownLatch.countDown();
}
});
UnionPay.enroll(mBraintreeFragment, cardBuilder);
mCountDownLatch.await();
}
Aggregations