use of com.braintreepayments.api.models.ThreeDSecureRequest in project braintree_android by braintree.
the class ThreeDSecureTest method performVerification_acceptsAThreeDSecureRequest_postsPaymentMethodNonceToListenersWhenLookupReturnsACard.
@Test(timeout = 10000)
public void performVerification_acceptsAThreeDSecureRequest_postsPaymentMethodNonceToListenersWhenLookupReturnsACard() throws InterruptedException, InvalidArgumentException {
String clientToken = new TestClientTokenBuilder().withThreeDSecure().build();
BraintreeFragment fragment = getFragmentWithAuthorization(mActivity, clientToken);
String nonce = tokenize(fragment, new CardBuilder().cardNumber("4000000000000051").expirationDate("12/20")).getNonce();
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertIsANonce(paymentMethodNonce.getNonce());
assertEquals("51", ((CardNonce) paymentMethodNonce).getLastTwo());
ThreeDSecureInfo threeDSecureInfo = ((CardNonce) paymentMethodNonce).getThreeDSecureInfo();
assertFalse(threeDSecureInfo.isLiabilityShifted());
assertFalse(threeDSecureInfo.isLiabilityShiftPossible());
assertTrue(((CardNonce) paymentMethodNonce).getThreeDSecureInfo().wasVerified());
mCountDownLatch.countDown();
}
});
ThreeDSecureRequest request = new ThreeDSecureRequest().nonce(nonce).amount("5");
ThreeDSecure.performVerification(fragment, request);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.ThreeDSecureRequest in project braintree_android by braintree.
the class ThreeDSecureTest method performVerification_withInvalidThreeDSecureRequest_postsException.
@Test(timeout = 1000)
public void performVerification_withInvalidThreeDSecureRequest_postsException() throws InterruptedException, InvalidArgumentException {
String clientToken = new TestClientTokenBuilder().withThreeDSecure().build();
BraintreeFragment fragment = getFragmentWithAuthorization(mActivity, clientToken);
fragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
assertEquals("The ThreeDSecureRequest nonce and amount cannot be null", error.getMessage());
mCountDownLatch.countDown();
}
});
ThreeDSecureRequest request = new ThreeDSecureRequest().amount("5");
ThreeDSecure.performVerification(fragment, request);
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.ThreeDSecureRequest in project braintree_android by braintree.
the class ThreeDSecure method performVerification.
/**
* Verification is associated with a transaction amount and your merchant account. To specify a
* different merchant account (or, in turn, currency), you will need to specify the merchant
* account id when <a href="https://developers.braintreepayments.com/android/sdk/overview/generate-client-token">
* generating a client token</a>
*
* During lookup the original payment method nonce is consumed and a new one is returned,
* which points to the original payment method, as well as the 3D Secure verification.
* Transactions created with this nonce will be 3D Secure, and benefit from the appropriate
* liability shift if authentication is successful or fail with a 3D Secure failure.
*
* @param fragment the {@link BraintreeFragment} backing the http request. This fragment will
* also be responsible for handling callbacks to it's listeners
* @param nonce The nonce that represents a card to perform a 3D Secure verification against.
* @param amount The amount of the transaction in the current merchant account's currency.
*/
public static void performVerification(final BraintreeFragment fragment, final String nonce, final String amount) {
ThreeDSecureRequest request = new ThreeDSecureRequest().nonce(nonce).amount(amount);
performVerification(fragment, request);
}
Aggregations