use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class CardTest method tokenize_tokenizesACardWithACompleteBillingAddress.
@Test(timeout = 10000)
public void tokenize_tokenizesACardWithACompleteBillingAddress() throws Exception {
CardBuilder cardBuilder = new CardBuilder().cardNumber(VISA).expirationDate("08/20").cvv("123").cardholderName("Joe Smith").firstName("Joe").lastName("Smith").company("Company").streetAddress("1 Main St").extendedAddress("Unit 1").locality("Some Town").postalCode("12345").region("Some Region").countryName("United States").countryCodeAlpha2("US").countryCodeAlpha3("USA").countryCodeNumeric("840");
assertTokenizationSuccessful(new TestClientTokenBuilder().build(), cardBuilder);
}
use of com.braintreepayments.api.models.CardBuilder in project braintree_android by braintree.
the class TokenizationClient method tokenize.
/**
* Create a {@link PaymentMethodNonce} in the Braintree Gateway.
* <p/>
* On completion, returns the {@link PaymentMethodNonce} to {@link PaymentMethodNonceCallback}.
* <p/>
* If creation fails validation, {@link com.braintreepayments.api.interfaces.BraintreeErrorListener#onError(Exception)}
* will be called with the resulting {@link ErrorWithResponse}.
* <p/>
* If an error not due to validation (server error, network issue, etc.) occurs, {@link
* com.braintreepayments.api.interfaces.BraintreeErrorListener#onError(Exception)} (Throwable)}
* will be called with the {@link Exception} that occurred.
*
* @param paymentMethodBuilder {@link PaymentMethodBuilder} for the {@link PaymentMethodNonce}
* to be created.
*/
static void tokenize(final BraintreeFragment fragment, final PaymentMethodBuilder paymentMethodBuilder, final PaymentMethodNonceCallback callback) {
paymentMethodBuilder.setSessionId(fragment.getSessionId());
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
if (paymentMethodBuilder instanceof CardBuilder && configuration.getGraphQL().isFeatureEnabled(GraphQLConfiguration.TOKENIZE_CREDIT_CARDS_FEATURE)) {
tokenizeGraphQL(fragment, (CardBuilder) paymentMethodBuilder, callback);
} else {
tokenizeRest(fragment, paymentMethodBuilder, callback);
}
}
});
}
use of com.braintreepayments.api.models.CardBuilder 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.models.CardBuilder in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_callsCancelListenerWhenBackIsPressed.
@Test(timeout = 30000)
public void performVerification_callsCancelListenerWhenBackIsPressed() throws InterruptedException {
CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/30");
BraintreeFragment fragment = getFragment();
fragment.addListener(new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
assertEquals(BraintreeRequestCodes.THREE_D_SECURE, requestCode);
mCountDownLatch.countDown();
}
});
ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
waitForView(withId(android.R.id.widget_frame));
pressBack();
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.CardBuilder 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();
}
Aggregations