use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardWhenThereIsALookupError.
@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardWhenThereIsALookupError() throws InterruptedException {
BraintreeFragment fragment = getFragment();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
CardNonce cardNonce = (CardNonce) paymentMethodNonce;
assertEquals("77", cardNonce.getLastTwo());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShifted());
assertFalse(cardNonce.getThreeDSecureInfo().isLiabilityShiftPossible());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_LOOKUP_ERROR).expirationDate("12/20");
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder 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.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventOnFailure.
@Test
public void tokenize_sendGraphQLAnalyticsEventOnFailure() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).graphQLErrorResponse(ErrorWithResponse.fromGraphQLJson(stringFromFixture("errors/graphql/credit_card_error.json"))).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, new PaymentMethodNonceCallback() {
@Override
public void success(PaymentMethodNonce paymentMethodNonce) {
}
@Override
public void failure(Exception exception) {
}
});
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.failure");
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_includesSessionIdInRequest.
@Test
public void tokenize_includesSessionIdInRequest() throws JSONException {
BraintreeFragment fragment = new MockFragmentBuilder().build();
when(fragment.getSessionId()).thenReturn("session-id");
TokenizationClient.tokenize(fragment, new CardBuilder(), null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(fragment.getHttpClient()).post(anyString(), captor.capture(), any(HttpResponseCallback.class));
JSONObject data = new JSONObject(captor.getValue()).getJSONObject("_meta");
assertEquals("session-id", data.getString("sessionId"));
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_tokenizesCardsWithRestWhenGraphQLIsDisabled.
@Test
public void tokenize_tokenizesCardsWithRestWhenGraphQLIsDisabled() {
BraintreeFragment fragment = new MockFragmentBuilder().build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verifyZeroInteractions(fragment.getGraphQLHttpClient());
verify(fragment.getHttpClient()).post(anyString(), captor.capture(), any(HttpResponseCallback.class));
assertEquals(cardBuilder.build(), captor.getValue());
}
Aggregations