use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class GooglePaymentTest method setup.
@Before
public void setup() {
mLatch = new CountDownLatch(1);
mBaseConfiguration = new TestConfigurationBuilder().androidPay(new TestAndroidPayConfigurationBuilder().googleAuthorizationFingerprint("google-auth-fingerprint")).merchantId("android-pay-merchant-id");
}
use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class ThreeDSecureTest method onActivityResult_postsRecoverableErrorsToListener.
@Test(timeout = 2000)
public void onActivityResult_postsRecoverableErrorsToListener() throws InterruptedException {
BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("Failed to authenticate, please try a different form of payment", error.getMessage());
mCountDownLatch.countDown();
}
});
Intent data = new Intent().putExtra(ThreeDSecureWebViewActivity.EXTRA_THREE_D_SECURE_RESULT, ThreeDSecureAuthenticationResponse.fromJson(stringFromFixture("errors/three_d_secure_error.json")));
ThreeDSecure.onActivityResult(fragment, Activity.RESULT_OK, data);
mCountDownLatch.await();
}
use of com.braintreepayments.testutils.TestConfigurationBuilder 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.testutils.TestConfigurationBuilder 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