use of com.braintreepayments.api.models.ThreeDSecureAuthenticationResponse in project braintree_android by braintree.
the class ThreeDSecureTest method onActivityResult_postsUnrecoverableErrorsToListeners.
@Test(timeout = 2000)
public void onActivityResult_postsUnrecoverableErrorsToListeners() throws InterruptedException {
BraintreeFragment fragment = getMockFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("Error!", error.getMessage());
mCountDownLatch.countDown();
}
});
ThreeDSecureAuthenticationResponse authResponse = ThreeDSecureAuthenticationResponse.fromException("Error!");
Intent data = new Intent().putExtra(ThreeDSecureWebViewActivity.EXTRA_THREE_D_SECURE_RESULT, authResponse);
ThreeDSecure.onActivityResult(fragment, Activity.RESULT_OK, data);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.ThreeDSecureAuthenticationResponse in project braintree_android by braintree.
the class ThreeDSecure method onActivityResult.
protected static void onActivityResult(BraintreeFragment fragment, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
ThreeDSecureAuthenticationResponse authenticationResponse;
Uri resultUri = data.getData();
if (resultUri != null) {
authenticationResponse = ThreeDSecureAuthenticationResponse.fromJson(resultUri.getQueryParameter("auth_response"));
} else {
authenticationResponse = data.getParcelableExtra(ThreeDSecureWebViewActivity.EXTRA_THREE_D_SECURE_RESULT);
}
if (authenticationResponse.isSuccess()) {
fragment.postCallback(authenticationResponse.getCardNonce());
} else if (authenticationResponse.getException() != null) {
fragment.postCallback(new BraintreeException(authenticationResponse.getException()));
} else {
fragment.postCallback(new ErrorWithResponse(422, authenticationResponse.getErrors()));
}
}
}
Aggregations