use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class IdealTest method startPayment_returnsPendingPayment.
@Test(timeout = 10000)
public void startPayment_returnsPendingPayment() throws InterruptedException {
IdealRequest builder = new IdealRequest().currency("EUR").amount("10").issuerId("INGBNL2A").orderId(UUID.randomUUID().toString().substring(0, 15));
Ideal.startPayment(mBraintreeFragment, builder, null);
String savedId;
do {
savedId = BraintreeSharedPreferences.getString(mBraintreeFragment.getApplicationContext(), Ideal.IDEAL_RESULT_ID);
SystemClock.sleep(500);
} while (savedId.equals(""));
Ideal.onActivityResult(mBraintreeFragment, Activity.RESULT_OK);
mBraintreeFragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
mBraintreeFragment.addListener(new BraintreePaymentResultListener() {
@Override
public void onBraintreePaymentResult(BraintreePaymentResult result) {
assertTrue(result instanceof IdealResult);
IdealResult idealResult = (IdealResult) result;
assertFalse(TextUtils.isEmpty(idealResult.getId()));
assertFalse(TextUtils.isEmpty(idealResult.getShortId()));
assertFalse(TextUtils.isEmpty(idealResult.getStatus()));
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_returnsAFailedAuthenticationWhenSignatureVerificationFails.
@Test(timeout = 30000)
public void performVerification_returnsAFailedAuthenticationWhenSignatureVerificationFails() throws InterruptedException {
BraintreeFragment fragment = getFragment();
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();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_SIGNATURE_VERIFICATION_FAILURE).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.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_failsWithATokenizationKey.
@Test(timeout = 10000)
public void performVerification_failsWithATokenizationKey() throws InterruptedException {
String clientToken = new TestClientTokenBuilder().withThreeDSecure().build();
BraintreeFragment fragment = getFragment(TOKENIZATION_KEY, clientToken);
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof AuthorizationException);
assertEquals("Tokenization key authorization not allowed for this endpoint. Please use an authentication method with upgraded permissions", error.getMessage());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_returnsAnErrorWhenCardinalReturnsError.
@Test(timeout = 30000)
public void performVerification_returnsAnErrorWhenCardinalReturnsError() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("An unexpected error occurred", error.getMessage());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_MPI_SERVICE_ERROR).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.interfaces.BraintreeErrorListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addListener_flushesErrorWithResponseCallback.
@Test
public void addListener_flushesErrorWithResponseCallback() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.postCallback(new ErrorWithResponse(422, ""));
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertTrue(error instanceof ErrorWithResponse);
assertEquals(422, ((ErrorWithResponse) error).getStatusCode());
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
Aggregations