Search in sources :

Example 36 with PaymentMethodNonce

use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.

the class ThreeDSecureVerificationTest method performVerification_doesALookupAndReturnsACardWhenThereIsAMPILookupError.

@Test(timeout = 10000)
public void performVerification_doesALookupAndReturnsACardWhenThereIsAMPILookupError() throws InterruptedException {
    BraintreeFragment fragment = getFragment();
    fragment.addListener(new PaymentMethodNonceCreatedListener() {

        @Override
        public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
            assertIsANonce(paymentMethodNonce.getNonce());
            CardNonce cardNonce = (CardNonce) paymentMethodNonce;
            assertEquals("85", 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_MPI_LOOKUP_ERROR).expirationDate("12/20");
    ThreeDSecure.performVerification(fragment, cardBuilder, TEST_AMOUNT);
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) CardNonce(com.braintreepayments.api.models.CardNonce) PaymentMethodNonceCreatedListener(com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) Test(org.junit.Test)

Example 37 with PaymentMethodNonce

use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.

the class PayPal method onSuccess.

private static void onSuccess(final BraintreeFragment fragment, Intent data, Request request, Result result) {
    PayPalRequest paypalRequest = getPersistedPayPalRequest(fragment.getApplicationContext());
    TokenizationClient.tokenize(fragment, parseResponse(paypalRequest, request, result, data), new PaymentMethodNonceCallback() {

        @Override
        public void success(PaymentMethodNonce paymentMethodNonce) {
            if (paymentMethodNonce instanceof PayPalAccountNonce && ((PayPalAccountNonce) paymentMethodNonce).getCreditFinancing() != null) {
                fragment.sendAnalyticsEvent("paypal.credit.accepted");
            }
            fragment.postCallback(paymentMethodNonce);
        }

        @Override
        public void failure(Exception exception) {
            fragment.postCallback(exception);
        }
    });
}
Also used : PaymentMethodNonceCallback(com.braintreepayments.api.interfaces.PaymentMethodNonceCallback) PayPalAccountNonce(com.braintreepayments.api.models.PayPalAccountNonce) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) PayPalRequest(com.braintreepayments.api.models.PayPalRequest) BraintreeException(com.braintreepayments.api.exceptions.BraintreeException) JSONException(org.json.JSONException) BrowserSwitchException(com.braintreepayments.api.exceptions.BrowserSwitchException)

Example 38 with PaymentMethodNonce

use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.

the class Venmo method vault.

private static void vault(final BraintreeFragment fragment, String nonce) {
    VenmoAccountBuilder vaultBuilder = new VenmoAccountBuilder().nonce(nonce);
    TokenizationClient.tokenize(fragment, vaultBuilder, new PaymentMethodNonceCallback() {

        @Override
        public void success(PaymentMethodNonce paymentMethodNonce) {
            fragment.postCallback(paymentMethodNonce);
            fragment.sendAnalyticsEvent("pay-with-venmo.vault.success");
        }

        @Override
        public void failure(Exception exception) {
            fragment.postCallback(exception);
            fragment.sendAnalyticsEvent("pay-with-venmo.vault.failed");
        }
    });
}
Also used : VenmoAccountBuilder(com.braintreepayments.api.models.VenmoAccountBuilder) PaymentMethodNonceCallback(com.braintreepayments.api.interfaces.PaymentMethodNonceCallback) PaymentMethodNonce(com.braintreepayments.api.models.PaymentMethodNonce) AppSwitchNotAvailableException(com.braintreepayments.api.exceptions.AppSwitchNotAvailableException) JSONException(org.json.JSONException)

Aggregations

PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)38 Test (org.junit.Test)31 CardNonce (com.braintreepayments.api.models.CardNonce)22 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)21 CardBuilder (com.braintreepayments.api.models.CardBuilder)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 PaymentMethodNonceCallback (com.braintreepayments.api.interfaces.PaymentMethodNonceCallback)8 JSONException (org.json.JSONException)7 Intent (android.content.Intent)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 PaymentMethodNoncesUpdatedListener (com.braintreepayments.api.interfaces.PaymentMethodNoncesUpdatedListener)5 AndroidPayCardNonce (com.braintreepayments.api.models.AndroidPayCardNonce)5 PayPalAccountNonce (com.braintreepayments.api.models.PayPalAccountNonce)5 PayPalRequest (com.braintreepayments.api.models.PayPalRequest)4 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)4 TestClientTokenBuilder (com.braintreepayments.api.test.TestClientTokenBuilder)4 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)4 ArrayList (java.util.ArrayList)4 BraintreeException (com.braintreepayments.api.exceptions.BraintreeException)3 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)3